A TypeScript library for reading, parsing, and compressing .chm
files, providing both CLI tools and API interfaces.
English | 中文
CHMKit is a TypeScript library for reading, parsing, and compressing .chm
files, providing both CLI tools and API interfaces.
# Using npm
npm install -g chmkit
# Using pnpm
pnpm add -g chmkit
# Using yarn
yarn global add chmkit
# Show help
chmkit --help
# Extract CHM file contents
chmkit extract input.chm -o output/
chmkit extract input.chm --output ./docs --filter "*.html" --preserve-structure --verbose
# Pack directory to CHM file
chmkit pack ./docs -o help.chm
chmkit pack ./src --output manual.chm --title "User Manual" --compression --verbose
# Show CHM file information
chmkit info input.chm
chmkit info input.chm --json --verbose
import { CHMKit } from 'chmkit';
// Parse CHM file
const chmData = await CHMKit.parse('input.chm');
// Extract file contents
await CHMKit.extract('input.chm', './output');
// Pack directory
await CHMKit.pack('./docs', 'help.chm');
// Get file information
const info = await CHMKit.getInfo('input.chm');
CHMKit supports customization through a chmkit.config.json
configuration file in your project root. If no configuration file is found, default settings will be used.
Create a chmkit.config.json
file in your project root:
{
"default": {
"logLevel": "info",
"tempDir": "./temp",
"maxMemory": 104857600
},
"cli": {
"showProgress": true,
"maxConcurrency": 4,
"colorOutput": true
},
"performance": {
"chunkSize": 32768,
"bufferSize": 65536
}
}
default
- Basic CHMKit settings (log level, temp directory, memory limits)lzx
- LZX compression parameters (window size, compression level)format
- CHM file format settings (signatures, versions, supported extensions)cli
- CLI tool behavior (output settings, concurrency, progress display)performance
- Performance tuning (chunk sizes, buffers, thresholds)validation
- File validation settings (header checks, checksums, strict mode)
import { getConfig, getCliConfig } from 'chmkit/config';
// Get complete configuration
const config = getConfig();
// Get specific configuration section
const cliConfig = getCliConfig();
// Reload configuration
const newConfig = getConfig(true);
For detailed configuration options, see CONFIG.md and check the example configuration file.
- Node.js >= 20.10.0
# Clone the project
git clone <repository-url>
cd chmkit
# Install dependencies
pnpm install
# Development build
pnpm build
# Lint code
pnpm lint
# Format code
pnpm format
MIT License - see the LICENSE file for details.