@emailens/engine 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { E as EmailClient, F as Framework, T as TransformResult, C as CSSWarning, a as CodeFix, D as DiffResult, b as ExportPromptOptions, A as AiProvider, c as AiFixResult, S as SupportLevel, d as SpamAnalysisOptions, e as SpamReport, L as LinkReport, f as AccessibilityReport, I as ImageReport, g as InboxPreview, h as SizeReport, i as TemplateReport, j as DeliverabilityReport } from './types-4P9AtKm_.cjs';
2
- export { k as AccessibilityIssue, l as ClientTruncation, m as DeliverabilityCheck, n as DeliverabilityIssue, o as EstimateOptions, p as ExportScope, q as FixType, r as ImageInfo, s as ImageIssue, t as InboxPreviewIssue, u as InputFormat, v as LinkIssue, P as PreviewResult, w as SizeIssue, x as SpamIssue, y as TemplateIssue, z as TokenEstimate, B as TokenEstimateWithWarnings, G as estimateAiFixTokens, H as generateFixPrompt, J as heuristicTokenCount } from './types-4P9AtKm_.cjs';
3
- export { C as CompileError, a as CompileReactEmailOptions, S as SandboxStrategy } from './react-email-C-p8ZL37.cjs';
1
+ import { E as EmailClient, F as Framework, T as TransformResult, C as CSSWarning, a as CodeFix, D as DiffResult, b as ExportPromptOptions, A as AiProvider, c as AiFixResult, S as SupportLevel, d as SpamAnalysisOptions, e as SpamReport, L as LinkReport, f as AccessibilityReport, I as ImageReport, g as InboxPreview, h as SizeReport, i as TemplateReport, j as DeliverabilityReport } from './types-Duj14jTL.cjs';
2
+ export { k as AccessibilityIssue, l as ClientTruncation, m as DeliverabilityCheck, n as DeliverabilityIssue, o as EstimateOptions, p as ExportScope, q as FixType, r as ImageInfo, s as ImageIssue, t as InboxPreviewIssue, u as InputFormat, v as LinkIssue, P as PreviewResult, w as SizeIssue, x as SpamIssue, y as TemplateIssue, z as TokenEstimate, B as TokenEstimateWithWarnings, G as estimateAiFixTokens, H as generateFixPrompt, J as heuristicTokenCount } from './types-Duj14jTL.cjs';
3
+ export { C as CompileError, a as CompileReactEmailOptions, S as SandboxStrategy } from './react-email-BFwlVmzZ.cjs';
4
4
 
5
5
  declare const EMAIL_CLIENTS: EmailClient[];
6
6
  declare function getClient(id: string): EmailClient | undefined;
@@ -162,7 +162,7 @@ declare const AI_FIX_SYSTEM_PROMPT = "You are an expert email developer speciali
162
162
  * Last synced: 2026-03-04
163
163
  * caniemail last updated: 2026-02-16 15:39:06 +0000
164
164
  *
165
- * 251 features across 12 email clients.
165
+ * 251 features across 13 email clients.
166
166
  *
167
167
  * Support levels:
168
168
  * - "supported": fully supported
@@ -299,6 +299,12 @@ interface AuditReport {
299
299
  */
300
300
  declare function auditEmail(html: string, options?: AuditOptions): AuditReport;
301
301
 
302
+ /**
303
+ * Convert HTML email to plain text suitable for multipart/alternative emails.
304
+ * Uses cheerio for parsing (already a dependency — no new deps needed).
305
+ */
306
+ declare function toPlainText(html: string): string;
307
+
302
308
  interface CreateSessionOptions {
303
309
  /** Framework for fix snippets (applies to analyze/audit/transform). */
304
310
  framework?: Framework;
@@ -360,7 +366,7 @@ interface EmailSession {
360
366
  */
361
367
  transformForClient(clientId: string): TransformResult;
362
368
  /**
363
- * Transform HTML for all 12 email clients.
369
+ * Transform HTML for all 13 email clients.
364
370
  *
365
371
  * Creates an isolated DOM copy per client (transforms mutate the DOM).
366
372
  */
@@ -418,8 +424,9 @@ declare const EMPTY_DELIVERABILITY: DeliverabilityReport;
418
424
  /**
419
425
  * WCAG 2.1 color parsing, luminance, and contrast utilities.
420
426
  *
421
- * Handles hex (#fff, #ffffff, #rrggbbaa), rgb()/rgba(), 148 named CSS colors,
422
- * and `transparent`. Returns null for unresolvable values like var(), inherit,
427
+ * Handles hex (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb()/rgba() (comma and
428
+ * space syntax), hsl()/hsla(), hwb(), oklch(), 148 named CSS colors, and
429
+ * `transparent`. Returns null for unresolvable values like var(), inherit,
423
430
  * currentColor.
424
431
  */
425
432
  interface RGBA {
@@ -433,6 +440,11 @@ type WcagGrade = "AAA" | "AA" | "AA Large" | "Fail";
433
440
  * Parse a CSS color value to RGBA. Returns null for unresolvable values.
434
441
  */
435
442
  declare function parseColor(value: string): RGBA | null;
443
+ /**
444
+ * Format an RGBA value as an rgb() or rgba() CSS string.
445
+ * Returns `rgba(r, g, b, a)` when alpha < 1, otherwise `rgb(r, g, b)`.
446
+ */
447
+ declare function formatRgb(rgba: RGBA): string;
436
448
  /**
437
449
  * Compute WCAG 2.1 relative luminance for an sRGB color.
438
450
  * Input values 0-255.
@@ -452,4 +464,30 @@ declare function wcagGrade(ratio: number): WcagGrade;
452
464
  */
453
465
  declare function alphaBlend(fg: RGBA, bgR: number, bgG: number, bgB: number): [number, number, number];
454
466
 
455
- export { AI_FIX_SYSTEM_PROMPT, AT_RULE_FEATURES, AccessibilityReport, AiFixResult, AiProvider, type AuditOptions, type AuditReport, COMPOUND_VALUE_FEATURES, CSSWarning, CSS_FUNCTION_FEATURES, CSS_SUPPORT, CodeFix, type CreateSessionOptions, DeliverabilityReport, DiffResult, EMAIL_CLIENTS, EMPTY_DELIVERABILITY, EmailClient, type EmailSession, ExportPromptOptions, Framework, GENERIC_LINK_TEXT, type GenerateAiFixOptions, HTML_ELEMENT_FEATURES, ImageReport, InboxPreview, LinkReport, MAX_HTML_SIZE, type RGBA, STRUCTURAL_FIX_PROPERTIES, SizeReport, SpamAnalysisOptions, SpamReport, SupportLevel, TemplateReport, TransformResult, type WcagGrade, alphaBlend, analyzeEmail, analyzeImages, analyzeSpam, auditEmail, checkAccessibility, checkSize, checkTemplateVariables, contrastRatio, createSession, diffResults, errorWarnings, extractInboxPreview, generateAiFix, generateCompatibilityScore, getClient, getCodeFix, getSuggestion, parseColor, relativeLuminance, simulateDarkMode, structuralWarnings, transformForAllClients, transformForClient, validateLinks, warningsForClient, wcagGrade };
467
+ /**
468
+ * Downlevel modern CSS in HTML emails to maximize email client compatibility.
469
+ *
470
+ * Transforms modern CSS features into widely-supported equivalents:
471
+ * - Modern color functions (oklch, hsl, hwb) to rgb()
472
+ * - Space-based rgb() to comma-based rgb()
473
+ * - CSS logical properties to physical properties
474
+ * - calc(infinity * 1px) to 9999px
475
+ * - CSS nesting to flat rules
476
+ * - Range media queries to legacy min/max syntax
477
+ * - CSS variables (var()) resolved within same stylesheet
478
+ */
479
+ /**
480
+ * Downlevel modern CSS in an HTML email to maximize email client compatibility.
481
+ *
482
+ * Transformations:
483
+ * 1. Convert modern color functions (oklch, hsl, hwb) to rgb()
484
+ * 2. Convert space-based rgb() to comma-based rgb()
485
+ * 3. Convert CSS logical properties to physical properties
486
+ * 4. Resolve calc(infinity * 1px) to 9999px
487
+ * 5. Unnest CSS nesting to flat rules
488
+ * 6. Convert range media queries to legacy min/max syntax
489
+ * 7. Resolve CSS variables (var()) within same stylesheet
490
+ */
491
+ declare function downlevelCSS(html: string): string;
492
+
493
+ export { AI_FIX_SYSTEM_PROMPT, AT_RULE_FEATURES, AccessibilityReport, AiFixResult, AiProvider, type AuditOptions, type AuditReport, COMPOUND_VALUE_FEATURES, CSSWarning, CSS_FUNCTION_FEATURES, CSS_SUPPORT, CodeFix, type CreateSessionOptions, DeliverabilityReport, DiffResult, EMAIL_CLIENTS, EMPTY_DELIVERABILITY, EmailClient, type EmailSession, ExportPromptOptions, Framework, GENERIC_LINK_TEXT, type GenerateAiFixOptions, HTML_ELEMENT_FEATURES, ImageReport, InboxPreview, LinkReport, MAX_HTML_SIZE, type RGBA, STRUCTURAL_FIX_PROPERTIES, SizeReport, SpamAnalysisOptions, SpamReport, SupportLevel, TemplateReport, TransformResult, type WcagGrade, alphaBlend, analyzeEmail, analyzeImages, analyzeSpam, auditEmail, checkAccessibility, checkSize, checkTemplateVariables, contrastRatio, createSession, diffResults, downlevelCSS, errorWarnings, extractInboxPreview, formatRgb, generateAiFix, generateCompatibilityScore, getClient, getCodeFix, getSuggestion, parseColor, relativeLuminance, simulateDarkMode, structuralWarnings, toPlainText, transformForAllClients, transformForClient, validateLinks, warningsForClient, wcagGrade };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { E as EmailClient, F as Framework, T as TransformResult, C as CSSWarning, a as CodeFix, D as DiffResult, b as ExportPromptOptions, A as AiProvider, c as AiFixResult, S as SupportLevel, d as SpamAnalysisOptions, e as SpamReport, L as LinkReport, f as AccessibilityReport, I as ImageReport, g as InboxPreview, h as SizeReport, i as TemplateReport, j as DeliverabilityReport } from './types-4P9AtKm_.js';
2
- export { k as AccessibilityIssue, l as ClientTruncation, m as DeliverabilityCheck, n as DeliverabilityIssue, o as EstimateOptions, p as ExportScope, q as FixType, r as ImageInfo, s as ImageIssue, t as InboxPreviewIssue, u as InputFormat, v as LinkIssue, P as PreviewResult, w as SizeIssue, x as SpamIssue, y as TemplateIssue, z as TokenEstimate, B as TokenEstimateWithWarnings, G as estimateAiFixTokens, H as generateFixPrompt, J as heuristicTokenCount } from './types-4P9AtKm_.js';
3
- export { C as CompileError, a as CompileReactEmailOptions, S as SandboxStrategy } from './react-email-DcseUoOu.js';
1
+ import { E as EmailClient, F as Framework, T as TransformResult, C as CSSWarning, a as CodeFix, D as DiffResult, b as ExportPromptOptions, A as AiProvider, c as AiFixResult, S as SupportLevel, d as SpamAnalysisOptions, e as SpamReport, L as LinkReport, f as AccessibilityReport, I as ImageReport, g as InboxPreview, h as SizeReport, i as TemplateReport, j as DeliverabilityReport } from './types-Duj14jTL.js';
2
+ export { k as AccessibilityIssue, l as ClientTruncation, m as DeliverabilityCheck, n as DeliverabilityIssue, o as EstimateOptions, p as ExportScope, q as FixType, r as ImageInfo, s as ImageIssue, t as InboxPreviewIssue, u as InputFormat, v as LinkIssue, P as PreviewResult, w as SizeIssue, x as SpamIssue, y as TemplateIssue, z as TokenEstimate, B as TokenEstimateWithWarnings, G as estimateAiFixTokens, H as generateFixPrompt, J as heuristicTokenCount } from './types-Duj14jTL.js';
3
+ export { C as CompileError, a as CompileReactEmailOptions, S as SandboxStrategy } from './react-email-BENS7LIn.js';
4
4
 
5
5
  declare const EMAIL_CLIENTS: EmailClient[];
6
6
  declare function getClient(id: string): EmailClient | undefined;
@@ -162,7 +162,7 @@ declare const AI_FIX_SYSTEM_PROMPT = "You are an expert email developer speciali
162
162
  * Last synced: 2026-03-04
163
163
  * caniemail last updated: 2026-02-16 15:39:06 +0000
164
164
  *
165
- * 251 features across 12 email clients.
165
+ * 251 features across 13 email clients.
166
166
  *
167
167
  * Support levels:
168
168
  * - "supported": fully supported
@@ -299,6 +299,12 @@ interface AuditReport {
299
299
  */
300
300
  declare function auditEmail(html: string, options?: AuditOptions): AuditReport;
301
301
 
302
+ /**
303
+ * Convert HTML email to plain text suitable for multipart/alternative emails.
304
+ * Uses cheerio for parsing (already a dependency — no new deps needed).
305
+ */
306
+ declare function toPlainText(html: string): string;
307
+
302
308
  interface CreateSessionOptions {
303
309
  /** Framework for fix snippets (applies to analyze/audit/transform). */
304
310
  framework?: Framework;
@@ -360,7 +366,7 @@ interface EmailSession {
360
366
  */
361
367
  transformForClient(clientId: string): TransformResult;
362
368
  /**
363
- * Transform HTML for all 12 email clients.
369
+ * Transform HTML for all 13 email clients.
364
370
  *
365
371
  * Creates an isolated DOM copy per client (transforms mutate the DOM).
366
372
  */
@@ -418,8 +424,9 @@ declare const EMPTY_DELIVERABILITY: DeliverabilityReport;
418
424
  /**
419
425
  * WCAG 2.1 color parsing, luminance, and contrast utilities.
420
426
  *
421
- * Handles hex (#fff, #ffffff, #rrggbbaa), rgb()/rgba(), 148 named CSS colors,
422
- * and `transparent`. Returns null for unresolvable values like var(), inherit,
427
+ * Handles hex (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb()/rgba() (comma and
428
+ * space syntax), hsl()/hsla(), hwb(), oklch(), 148 named CSS colors, and
429
+ * `transparent`. Returns null for unresolvable values like var(), inherit,
423
430
  * currentColor.
424
431
  */
425
432
  interface RGBA {
@@ -433,6 +440,11 @@ type WcagGrade = "AAA" | "AA" | "AA Large" | "Fail";
433
440
  * Parse a CSS color value to RGBA. Returns null for unresolvable values.
434
441
  */
435
442
  declare function parseColor(value: string): RGBA | null;
443
+ /**
444
+ * Format an RGBA value as an rgb() or rgba() CSS string.
445
+ * Returns `rgba(r, g, b, a)` when alpha < 1, otherwise `rgb(r, g, b)`.
446
+ */
447
+ declare function formatRgb(rgba: RGBA): string;
436
448
  /**
437
449
  * Compute WCAG 2.1 relative luminance for an sRGB color.
438
450
  * Input values 0-255.
@@ -452,4 +464,30 @@ declare function wcagGrade(ratio: number): WcagGrade;
452
464
  */
453
465
  declare function alphaBlend(fg: RGBA, bgR: number, bgG: number, bgB: number): [number, number, number];
454
466
 
455
- export { AI_FIX_SYSTEM_PROMPT, AT_RULE_FEATURES, AccessibilityReport, AiFixResult, AiProvider, type AuditOptions, type AuditReport, COMPOUND_VALUE_FEATURES, CSSWarning, CSS_FUNCTION_FEATURES, CSS_SUPPORT, CodeFix, type CreateSessionOptions, DeliverabilityReport, DiffResult, EMAIL_CLIENTS, EMPTY_DELIVERABILITY, EmailClient, type EmailSession, ExportPromptOptions, Framework, GENERIC_LINK_TEXT, type GenerateAiFixOptions, HTML_ELEMENT_FEATURES, ImageReport, InboxPreview, LinkReport, MAX_HTML_SIZE, type RGBA, STRUCTURAL_FIX_PROPERTIES, SizeReport, SpamAnalysisOptions, SpamReport, SupportLevel, TemplateReport, TransformResult, type WcagGrade, alphaBlend, analyzeEmail, analyzeImages, analyzeSpam, auditEmail, checkAccessibility, checkSize, checkTemplateVariables, contrastRatio, createSession, diffResults, errorWarnings, extractInboxPreview, generateAiFix, generateCompatibilityScore, getClient, getCodeFix, getSuggestion, parseColor, relativeLuminance, simulateDarkMode, structuralWarnings, transformForAllClients, transformForClient, validateLinks, warningsForClient, wcagGrade };
467
+ /**
468
+ * Downlevel modern CSS in HTML emails to maximize email client compatibility.
469
+ *
470
+ * Transforms modern CSS features into widely-supported equivalents:
471
+ * - Modern color functions (oklch, hsl, hwb) to rgb()
472
+ * - Space-based rgb() to comma-based rgb()
473
+ * - CSS logical properties to physical properties
474
+ * - calc(infinity * 1px) to 9999px
475
+ * - CSS nesting to flat rules
476
+ * - Range media queries to legacy min/max syntax
477
+ * - CSS variables (var()) resolved within same stylesheet
478
+ */
479
+ /**
480
+ * Downlevel modern CSS in an HTML email to maximize email client compatibility.
481
+ *
482
+ * Transformations:
483
+ * 1. Convert modern color functions (oklch, hsl, hwb) to rgb()
484
+ * 2. Convert space-based rgb() to comma-based rgb()
485
+ * 3. Convert CSS logical properties to physical properties
486
+ * 4. Resolve calc(infinity * 1px) to 9999px
487
+ * 5. Unnest CSS nesting to flat rules
488
+ * 6. Convert range media queries to legacy min/max syntax
489
+ * 7. Resolve CSS variables (var()) within same stylesheet
490
+ */
491
+ declare function downlevelCSS(html: string): string;
492
+
493
+ export { AI_FIX_SYSTEM_PROMPT, AT_RULE_FEATURES, AccessibilityReport, AiFixResult, AiProvider, type AuditOptions, type AuditReport, COMPOUND_VALUE_FEATURES, CSSWarning, CSS_FUNCTION_FEATURES, CSS_SUPPORT, CodeFix, type CreateSessionOptions, DeliverabilityReport, DiffResult, EMAIL_CLIENTS, EMPTY_DELIVERABILITY, EmailClient, type EmailSession, ExportPromptOptions, Framework, GENERIC_LINK_TEXT, type GenerateAiFixOptions, HTML_ELEMENT_FEATURES, ImageReport, InboxPreview, LinkReport, MAX_HTML_SIZE, type RGBA, STRUCTURAL_FIX_PROPERTIES, SizeReport, SpamAnalysisOptions, SpamReport, SupportLevel, TemplateReport, TransformResult, type WcagGrade, alphaBlend, analyzeEmail, analyzeImages, analyzeSpam, auditEmail, checkAccessibility, checkSize, checkTemplateVariables, contrastRatio, createSession, diffResults, downlevelCSS, errorWarnings, extractInboxPreview, formatRgb, generateAiFix, generateCompatibilityScore, getClient, getCodeFix, getSuggestion, parseColor, relativeLuminance, simulateDarkMode, structuralWarnings, toPlainText, transformForAllClients, transformForClient, validateLinks, warningsForClient, wcagGrade };