Overview
TheRefractorEngine class orchestrates the full compile → obfuscate → compile pipeline. It’s a pure engine-layer class that depends on abstract Compiler and KernelIO interfaces, allowing you to provide custom IO-layer implementations.
Constructor
Implementation of the
Compiler interface for compiling Dart source to kernel and to target formatsImplementation of the
KernelIO interface for loading and writing kernel .dill filesOptional Mason logger for detailed build progress messages
Methods
run()
Executes the complete obfuscation pipeline: compile source to kernel, run obfuscation passes, write obfuscated kernel, and compile to target format.Configuration object specifying which passes to enable and their options
Build parameters including input/output paths, target format, and work directory
Returns
Ok(BuildResult) on success, containing output path, symbol table, and list of passes runSupporting Classes
BuildRequest
Bundles the IO parameters for aRefractorEngine.run() invocation.
Path to the Dart entry point file (e.g.,
lib/main.dart)Path where the final compiled output should be written
Compilation target:
Target.exe, Target.aot, Target.jit, or Target.kernelDirectory for intermediate build artifacts (e.g.,
.dart_tool/refractor)BuildResult
Result of a successfulRefractorEngine.run() invocation.
The final output path where the compiled artifact was written
Symbol table containing mappings from original to obfuscated identifiers
Names of all obfuscation passes that were executed
Target
Enum representing valid compilation targets.Usage Example
The engine handles the complete pipeline automatically:
- Compiles source to kernel
.dill - Loads kernel and runs obfuscation passes
- Writes obfuscated kernel
- Compiles to final target format (or outputs
.dillfor kernel target)
Related
PassRunner
Orchestrates obfuscation passes over kernel components
SymbolTable
Tracks identifier mappings for deobfuscation