TypeScript implementation of the AdGuard filter rules compiler using Deno.
- Compiles AdGuard filter rules from multiple sources
- Supports JSON, YAML, and TOML configuration formats
- SHA-384 hashing for output verification
- Interactive and CLI modes
- Comprehensive error handling and logging
- Deno 2.x or later
deno task interactivedeno task compile# Show help
deno task start -- --help
# Compile with specific config
deno task start -- -c config.yaml
# Compile with validation disabled
deno task start -- -c config.yaml --no-validate-config
# Fail on validation warnings
deno task start -- -c config.yaml --fail-on-warnings
# Validate configuration only
deno task start -- --validate -c config.yaml
# Show version information
deno task start -- --version| Option | Description |
|---|---|
-c, --config PATH |
Path to configuration file |
-o, --output PATH |
Path to output file |
-r, --copy-to-rules |
Copy output to rules directory |
--rules-dir PATH |
Custom rules directory path |
-f, --format FORMAT |
Force configuration format (json, yaml, toml) |
-v, --version |
Show version information |
-h, --help |
Show help message |
-d, --debug |
Enable debug output |
--show-config |
Show parsed configuration (don't compile) |
--validate-config |
Enable configuration validation before compilation (default: true) |
--no-validate-config |
Disable configuration validation before compilation |
--fail-on-warnings |
Fail compilation if configuration has validation warnings |
-i, --interactive |
Run in interactive menu mode |
--compile |
Run in CLI mode (compile and exit) |
--validate |
Validate configuration only |
--enable-chunking |
Enable chunked parallel compilation for large rule lists |
--chunk-size N |
Number of sources per chunk (when using source-based chunking) |
--max-parallel N |
Maximum number of chunks to compile in parallel (default: CPU count) |
For large rule lists (e.g., 10+ million entries), chunking splits compilation into parallel chunks for improved performance:
Command-line usage:
# Enable chunking with default settings (CPU count parallel workers)
deno task start -- --enable-chunking
# Custom parallel workers and chunk settings
deno task start -- --enable-chunking --max-parallel 8
# Fine-tune chunk size (sources per chunk)
deno task start -- --enable-chunking --chunk-size 50000 --max-parallel 4Configuration file:
{
"name": "My Filter List",
"chunking": {
"enabled": true,
"strategy": "source",
"maxParallel": 4
},
"sources": [
{ "source": "https://example.com/list1.txt" },
{ "source": "https://example.com/list2.txt" }
]
}How it works:
- Splits sources into N chunks (based on
maxParallel) - Compiles each chunk in parallel using Promise.all batching
- Merges and deduplicates results
- Preserves SHA-384 hash consistency
When to use:
- Large number of sources (10+)
- Very large individual sources (1M+ rules)
- Multi-core systems with available CPU resources
To generate TypeScript declaration files (.d.ts):
deno task generate:typesThis will create .d.ts files in the dist/ directory that re-export types from the source files. These files provide type information for consumers of this library.
Note: The .d.ts files are automatically generated and should not be edited manually. They are excluded from version control (see .gitignore).
deno task start- Run the compilerdeno task interactive- Run in interactive modedeno task compile- Compile from default configdeno task test- Run testsdeno task check- Type check the codedeno task lint- Lint the codedeno task fmt- Format the codedeno task generate:types- Generate.d.tstype definition files
This project uses Deno, which works with TypeScript natively. For compatibility with other tools or for publishing, type definition files (.d.ts) can be generated using:
deno task generate:typesThe generated files are placed in the dist/ directory and re-export all types from the source files.
- Make changes to the TypeScript source files in
src/ - Run tests:
deno task test - Type check:
deno task check - Generate type definitions:
deno task generate:types