Emailens
Engine Package

Engine Package

@emailens/engine is the core library for email transformation, analysis, scoring, dark mode simulation, and framework-aware code fixes.

@emailens/engine is a standalone TypeScript package with no framework dependencies. It works in Node.js, Bun, Deno, and edge runtimes.

Installation

bun add @emailens/engine

Dependencies

Only two runtime dependencies:

  • cheerio — HTML parsing and manipulation
  • css-tree — CSS parsing and serialization

Exports

import {
  // Transformation
  transformForClient,
  transformForAllClients,

  // Analysis
  analyzeEmail,
  generateCompatibilityScore,

  // Dark mode
  simulateDarkMode,

  // Code fixes
  getCodeFix,

  // Diffing
  diffResults,

  // LLM export
  generateFixPrompt,

  // Client data
  EMAIL_CLIENTS,
  getClient,
} from "@emailens/engine";

Type exports

import type {
  EmailClient,
  CSSWarning,
  CodeFix,
  Framework,
  InputFormat,
  TransformResult,
  PreviewResult,
  DiffResult,
  SupportLevel,
  ExportPromptOptions,
  ExportScope,
} from "@emailens/engine";

Quick example

import {
  transformForAllClients,
  analyzeEmail,
  generateCompatibilityScore,
} from "@emailens/engine";

const html = `<html><body>
  <div style="border-radius: 8px; display: flex;">Hello</div>
</body></html>`;

// Get per-client HTML transforms
const transforms = transformForAllClients(html);

// Get CSS compatibility warnings (with React Email fix snippets)
const warnings = analyzeEmail(html, "jsx");

// Get 0-100 scores per client
const scores = generateCompatibilityScore(warnings);

console.log(scores["outlook-windows-legacy"]);
// { score: 65, errors: 2, warnings: 0, info: 0 }

Framework-aware fix snippets

Pass a framework parameter to analyzeEmail() or getCodeFix() to get fix suggestions in your framework's native patterns:

FrameworkValueFix style
Raw HTML/CSS(omit)Generic HTML tables, VML, inline CSS
React Email"jsx"Row/Column/Font/Img components
MJML"mjml"mj-section/mj-column/mj-font elements
Maizzle"maizzle"Tailwind classes, MSO conditionals, config guidance

See Code Fixes for the full resolution cascade and snippet catalog.

On this page