@emailens/engine 0.12.0 → 0.12.1

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.
@@ -0,0 +1,11 @@
1
+ import {
2
+ compileMaizzle,
3
+ isMaizzle6
4
+ } from "./chunk-OA6VNA5L.js";
5
+ import "./chunk-Z22AD2IU.js";
6
+ import "./chunk-2NMEKWO5.js";
7
+ export {
8
+ compileMaizzle,
9
+ isMaizzle6
10
+ };
11
+ //# sourceMappingURL=maizzle-R5KU3HHZ.js.map
@@ -1,4 +1,4 @@
1
- import { Z as InputFormat } from './types-edFeUest.js';
1
+ import { _ as InputFormat } from './types-hQYXbiqj.js';
2
2
 
3
3
  /**
4
4
  * Unified error class for all email compilation failures.
@@ -1,4 +1,4 @@
1
- import { Z as InputFormat } from './types-edFeUest.cjs';
1
+ import { _ as InputFormat } from './types-hQYXbiqj.cjs';
2
2
 
3
3
  /**
4
4
  * Unified error class for all email compilation failures.
package/dist/server.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'node:dns';
2
- import { l as DeliverabilityReport } from './types-edFeUest.cjs';
2
+ import { m as DeliverabilityReport } from './types-hQYXbiqj.cjs';
3
3
 
4
4
  /**
5
5
  * DNS-based email deliverability checker.
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'node:dns';
2
- import { l as DeliverabilityReport } from './types-edFeUest.js';
2
+ import { m as DeliverabilityReport } from './types-hQYXbiqj.js';
3
3
 
4
4
  /**
5
5
  * DNS-based email deliverability checker.
@@ -426,10 +426,31 @@ interface SizeIssue extends BaseIssue {
426
426
  }
427
427
  interface SizeReport {
428
428
  htmlBytes: number;
429
+ /** Bytes of CSS inside `<style>` elements, summed across all of them. */
430
+ styleBytes: number;
429
431
  humanSize: string;
430
432
  clipped: boolean;
431
433
  issues: SizeIssue[];
432
434
  }
435
+ interface StyleSurvivalIssue extends BaseIssue {
436
+ /**
437
+ * The clients that discard the CSS. Required, not optional: the consuming
438
+ * app groups findings per client, and an issue that cannot name its clients
439
+ * does not surface at all.
440
+ */
441
+ clients: string[];
442
+ detail?: string;
443
+ /**
444
+ * Where in the framework's source the offending CSS came from. Present only
445
+ * when the caller named a framework: the stylesheet that ships is assembled
446
+ * by the compiler, so "edit your <style> block" is the wrong instruction for
447
+ * someone whose source has no <style> block.
448
+ */
449
+ frameworkNote?: string;
450
+ }
451
+ interface StyleSurvivalReport {
452
+ issues: StyleSurvivalIssue[];
453
+ }
433
454
  interface OverflowIssue extends BaseIssue {
434
455
  detail?: string;
435
456
  }
@@ -495,4 +516,4 @@ interface DesignReport {
495
516
  };
496
517
  }
497
518
 
498
- export { type LinkIssue as $, type AiProvider as A, type BaseIssue as B, type CSSWarning as C, type DiffResult as D, type EmailClient as E, type Framework as F, type FeatureKey as G, type FixType as H, type ImageReport as I, GRACEFUL_FEATURES as J, HTML_ATTRIBUTE_FEATURES as K, type LinkReport as L, HTML_ELEMENT_FEATURES as M, HTML_MISC_FEATURES as N, type OverflowReport as O, IMAGE_FORMATS as P, IMAGE_SUPPORT as Q, IMAGE_SUPPORT_NOTES as R, type SpamAnalysisOptions as S, type TransformResult as T, type ImageFormat as U, type VmlReport as V, type ImageInfo as W, type ImageIssue as X, type InboxPreviewIssue as Y, type InputFormat as Z, type LinkInfo as _, type CodeFix as a, type OverflowIssue as a0, type PreviewResult as a1, SELECTOR_FEATURES as a2, STRUCTURAL_FIX_PROPERTIES as a3, SUPPORT_CLIENTS as a4, type Severity as a5, type SizeIssue as a6, type SourceLocation as a7, type SpamIssue as a8, type SupportLevel as a9, type TemplateIssue as aa, type TokenEstimate as ab, type TokenEstimateWithWarnings as ac, type VisualIssue as ad, type VmlIssue as ae, estimateAiFixTokens as af, generateFixPrompt as ag, heuristicTokenCount as ah, type ExportPromptOptions as b, type AiFixResult as c, type SpamReport as d, type AccessibilityReport as e, type AccessibilityIssue as f, type InboxPreview as g, type SizeReport as h, type TemplateReport as i, type VisualReport as j, type DesignReport as k, type DeliverabilityReport as l, AT_RULE_FEATURES as m, COMPOUND_VALUE_FEATURES as n, CSS_FUNCTION_FEATURES as o, CSS_PROPERTY_FEATURES as p, CSS_SUPPORT as q, CSS_SUPPORT_NOTES as r, type ClientId as s, type ClientTruncation as t, type DeliverabilityCheck as u, type DeliverabilityIssue as v, type DesignIssue as w, type EstimateOptions as x, type ExportScope as y, FEATURE_LAST_TESTED as z };
519
+ export { type LinkInfo as $, type AiProvider as A, type BaseIssue as B, type CSSWarning as C, type DiffResult as D, type EmailClient as E, type Framework as F, FEATURE_LAST_TESTED as G, type FeatureKey as H, type ImageReport as I, type FixType as J, GRACEFUL_FEATURES as K, type LinkReport as L, HTML_ATTRIBUTE_FEATURES as M, HTML_ELEMENT_FEATURES as N, type OverflowReport as O, HTML_MISC_FEATURES as P, IMAGE_FORMATS as Q, IMAGE_SUPPORT as R, type StyleSurvivalReport as S, type TransformResult as T, IMAGE_SUPPORT_NOTES as U, type VmlReport as V, type ImageFormat as W, type ImageInfo as X, type ImageIssue as Y, type InboxPreviewIssue as Z, type InputFormat as _, type CodeFix as a, type LinkIssue as a0, type OverflowIssue as a1, type PreviewResult as a2, SELECTOR_FEATURES as a3, STRUCTURAL_FIX_PROPERTIES as a4, SUPPORT_CLIENTS as a5, type Severity as a6, type SizeIssue as a7, type SourceLocation as a8, type SpamIssue as a9, type SupportLevel as aa, type TemplateIssue as ab, type TokenEstimate as ac, type TokenEstimateWithWarnings as ad, type VisualIssue as ae, type VmlIssue as af, estimateAiFixTokens as ag, generateFixPrompt as ah, heuristicTokenCount as ai, type ExportPromptOptions as b, type AiFixResult as c, type SpamAnalysisOptions as d, type SpamReport as e, type AccessibilityReport as f, type AccessibilityIssue as g, type InboxPreview as h, type SizeReport as i, type TemplateReport as j, type VisualReport as k, type DesignReport as l, type DeliverabilityReport as m, AT_RULE_FEATURES as n, COMPOUND_VALUE_FEATURES as o, CSS_FUNCTION_FEATURES as p, CSS_PROPERTY_FEATURES as q, CSS_SUPPORT as r, CSS_SUPPORT_NOTES as s, type ClientId as t, type ClientTruncation as u, type DeliverabilityCheck as v, type DeliverabilityIssue as w, type DesignIssue as x, type EstimateOptions as y, type ExportScope as z };
@@ -426,10 +426,31 @@ interface SizeIssue extends BaseIssue {
426
426
  }
427
427
  interface SizeReport {
428
428
  htmlBytes: number;
429
+ /** Bytes of CSS inside `<style>` elements, summed across all of them. */
430
+ styleBytes: number;
429
431
  humanSize: string;
430
432
  clipped: boolean;
431
433
  issues: SizeIssue[];
432
434
  }
435
+ interface StyleSurvivalIssue extends BaseIssue {
436
+ /**
437
+ * The clients that discard the CSS. Required, not optional: the consuming
438
+ * app groups findings per client, and an issue that cannot name its clients
439
+ * does not surface at all.
440
+ */
441
+ clients: string[];
442
+ detail?: string;
443
+ /**
444
+ * Where in the framework's source the offending CSS came from. Present only
445
+ * when the caller named a framework: the stylesheet that ships is assembled
446
+ * by the compiler, so "edit your <style> block" is the wrong instruction for
447
+ * someone whose source has no <style> block.
448
+ */
449
+ frameworkNote?: string;
450
+ }
451
+ interface StyleSurvivalReport {
452
+ issues: StyleSurvivalIssue[];
453
+ }
433
454
  interface OverflowIssue extends BaseIssue {
434
455
  detail?: string;
435
456
  }
@@ -495,4 +516,4 @@ interface DesignReport {
495
516
  };
496
517
  }
497
518
 
498
- export { type LinkIssue as $, type AiProvider as A, type BaseIssue as B, type CSSWarning as C, type DiffResult as D, type EmailClient as E, type Framework as F, type FeatureKey as G, type FixType as H, type ImageReport as I, GRACEFUL_FEATURES as J, HTML_ATTRIBUTE_FEATURES as K, type LinkReport as L, HTML_ELEMENT_FEATURES as M, HTML_MISC_FEATURES as N, type OverflowReport as O, IMAGE_FORMATS as P, IMAGE_SUPPORT as Q, IMAGE_SUPPORT_NOTES as R, type SpamAnalysisOptions as S, type TransformResult as T, type ImageFormat as U, type VmlReport as V, type ImageInfo as W, type ImageIssue as X, type InboxPreviewIssue as Y, type InputFormat as Z, type LinkInfo as _, type CodeFix as a, type OverflowIssue as a0, type PreviewResult as a1, SELECTOR_FEATURES as a2, STRUCTURAL_FIX_PROPERTIES as a3, SUPPORT_CLIENTS as a4, type Severity as a5, type SizeIssue as a6, type SourceLocation as a7, type SpamIssue as a8, type SupportLevel as a9, type TemplateIssue as aa, type TokenEstimate as ab, type TokenEstimateWithWarnings as ac, type VisualIssue as ad, type VmlIssue as ae, estimateAiFixTokens as af, generateFixPrompt as ag, heuristicTokenCount as ah, type ExportPromptOptions as b, type AiFixResult as c, type SpamReport as d, type AccessibilityReport as e, type AccessibilityIssue as f, type InboxPreview as g, type SizeReport as h, type TemplateReport as i, type VisualReport as j, type DesignReport as k, type DeliverabilityReport as l, AT_RULE_FEATURES as m, COMPOUND_VALUE_FEATURES as n, CSS_FUNCTION_FEATURES as o, CSS_PROPERTY_FEATURES as p, CSS_SUPPORT as q, CSS_SUPPORT_NOTES as r, type ClientId as s, type ClientTruncation as t, type DeliverabilityCheck as u, type DeliverabilityIssue as v, type DesignIssue as w, type EstimateOptions as x, type ExportScope as y, FEATURE_LAST_TESTED as z };
519
+ export { type LinkInfo as $, type AiProvider as A, type BaseIssue as B, type CSSWarning as C, type DiffResult as D, type EmailClient as E, type Framework as F, FEATURE_LAST_TESTED as G, type FeatureKey as H, type ImageReport as I, type FixType as J, GRACEFUL_FEATURES as K, type LinkReport as L, HTML_ATTRIBUTE_FEATURES as M, HTML_ELEMENT_FEATURES as N, type OverflowReport as O, HTML_MISC_FEATURES as P, IMAGE_FORMATS as Q, IMAGE_SUPPORT as R, type StyleSurvivalReport as S, type TransformResult as T, IMAGE_SUPPORT_NOTES as U, type VmlReport as V, type ImageFormat as W, type ImageInfo as X, type ImageIssue as Y, type InboxPreviewIssue as Z, type InputFormat as _, type CodeFix as a, type LinkIssue as a0, type OverflowIssue as a1, type PreviewResult as a2, SELECTOR_FEATURES as a3, STRUCTURAL_FIX_PROPERTIES as a4, SUPPORT_CLIENTS as a5, type Severity as a6, type SizeIssue as a7, type SourceLocation as a8, type SpamIssue as a9, type SupportLevel as aa, type TemplateIssue as ab, type TokenEstimate as ac, type TokenEstimateWithWarnings as ad, type VisualIssue as ae, type VmlIssue as af, estimateAiFixTokens as ag, generateFixPrompt as ah, heuristicTokenCount as ai, type ExportPromptOptions as b, type AiFixResult as c, type SpamAnalysisOptions as d, type SpamReport as e, type AccessibilityReport as f, type AccessibilityIssue as g, type InboxPreview as h, type SizeReport as i, type TemplateReport as j, type VisualReport as k, type DesignReport as l, type DeliverabilityReport as m, AT_RULE_FEATURES as n, COMPOUND_VALUE_FEATURES as o, CSS_FUNCTION_FEATURES as p, CSS_PROPERTY_FEATURES as q, CSS_SUPPORT as r, CSS_SUPPORT_NOTES as s, type ClientId as t, type ClientTruncation as u, type DeliverabilityCheck as v, type DeliverabilityIssue as w, type DesignIssue as x, type EstimateOptions as y, type ExportScope as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailens/engine",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Email compatibility engine for HTML, MJML, Maizzle and React Email: transforms CSS per email client, scores compatibility, simulates dark mode, suggests fixes, and runs spam, accessibility, link and image quality analysis.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/compile/maizzle.ts"],"sourcesContent":["import { CompileError } from \"./errors.js\";\r\n\r\n/** Maximum Maizzle source size: 512KB */\r\nconst MAX_SOURCE_SIZE = 512_000;\r\n\r\n/** Compilation timeout: 15 seconds */\r\nconst COMPILE_TIMEOUT_MS = 15_000;\r\n\r\n/**\r\n * PostHTML directives that perform file-system reads or network fetches.\r\n *\r\n * Maizzle's PostHTML pipeline resolves these at compile time: a template\r\n * like `<extends src=\"/etc/passwd\">` causes the server to read that path\r\n * and include the content in rendered output (server-side file read). We\r\n * reject any input containing these directives rather than stripping them,\r\n * because stripping is error-prone with nested or malformed markup.\r\n *\r\n * Affected plugins: posthtml-extend, posthtml-fetch, posthtml-components,\r\n * posthtml-include, posthtml-modules.\r\n */\r\nconst DANGEROUS_DIRECTIVE_RE =\r\n /<\\s*(?:extends|component|fetch|include|module|slot|fill|raw|block|yield)\\b/i;\r\n\r\n/**\r\n * Compile a Maizzle template string into an HTML email string.\r\n *\r\n * Pipeline:\r\n * 1. Validate input (size, basic structure check)\r\n * 2. Reject inputs containing PostHTML file-access directives\r\n * 3. Compile using @maizzle/framework\r\n *\r\n * Security:\r\n * - PostHTML file-system directives are rejected at validation time\r\n * to prevent server-side file reads and SSRF.\r\n * - Template expressions ({{ expr }}) are evaluated by posthtml-expressions\r\n * with empty `locals`, so unknown identifiers like `process` or `require`\r\n * return the literal string '{local}' rather than accessing Node.js globals.\r\n * - A hard timeout prevents pathological PostCSS/Tailwind inputs from\r\n * hanging indefinitely.\r\n *\r\n * Requires peer dependency: @maizzle/framework\r\n */\r\nexport async function compileMaizzle(source: string): Promise<string> {\r\n // ── 1. Validate ──────────────────────────────────────────────────────\r\n if (!source || !source.trim()) {\r\n throw new CompileError(\"Maizzle source must not be empty.\", \"maizzle\", \"validation\");\r\n }\r\n\r\n if (source.length > MAX_SOURCE_SIZE) {\r\n throw new CompileError(\r\n `Maizzle source exceeds ${MAX_SOURCE_SIZE / 1000}KB limit.`,\r\n \"maizzle\",\r\n \"validation\",\r\n );\r\n }\r\n\r\n // ── 2. Block file-system and network PostHTML directives ─────────────\r\n if (DANGEROUS_DIRECTIVE_RE.test(source)) {\r\n throw new CompileError(\r\n \"Maizzle templates may not use <extends>, <component>, <fetch>, <include>, \" +\r\n \"<module>, <slot>, <fill>, <raw>, <block>, or <yield> directives. These directives \" +\r\n \"access the server file system at compile time. Use inline HTML and Tailwind utility classes instead.\",\r\n \"maizzle\",\r\n \"validation\",\r\n );\r\n }\r\n\r\n // ── 3. Load peer dependency ──────────────────────────────────────────\r\n let maizzleRender: (\r\n input: string,\r\n options: Record<string, unknown>,\r\n ) => Promise<{ html: string }>;\r\n\r\n try {\r\n const maizzle = await import(\"@maizzle/framework\");\r\n maizzleRender = maizzle.render;\r\n } catch {\r\n throw new CompileError(\r\n 'Maizzle compilation requires \"@maizzle/framework\". Install it:\\n npm install @maizzle/framework',\r\n \"maizzle\",\r\n \"compile\",\r\n );\r\n }\r\n\r\n // ── 4. Compile with timeout ──────────────────────────────────────────\r\n const compilePromise = maizzleRender(source, {\r\n css: {\r\n inline: {\r\n removeInlinedSelectors: true,\r\n applyWidthAttributes: true,\r\n applyHeightAttributes: true,\r\n },\r\n shorthand: true,\r\n sixHex: true,\r\n },\r\n locals: {},\r\n });\r\n\r\n const timeoutPromise = new Promise<never>((_, reject) => {\r\n const t = setTimeout(() => {\r\n reject(\r\n new CompileError(\r\n `Maizzle compilation timed out after ${COMPILE_TIMEOUT_MS / 1000}s.`,\r\n \"maizzle\",\r\n \"compile\",\r\n ),\r\n );\r\n }, COMPILE_TIMEOUT_MS);\r\n if (typeof t.unref === \"function\") t.unref();\r\n });\r\n\r\n try {\r\n const { html } = await Promise.race([compilePromise, timeoutPromise]);\r\n\r\n if (!html) {\r\n throw new CompileError(\"Maizzle compilation produced empty output.\", \"maizzle\", \"compile\");\r\n }\r\n\r\n return html;\r\n } catch (err: unknown) {\r\n if (err instanceof CompileError) throw err;\r\n const message = err instanceof Error ? err.message : \"Unknown Maizzle compilation error\";\r\n throw new CompileError(`Maizzle compilation failed: ${message}`, \"maizzle\", \"compile\");\r\n }\r\n}\r\n"],"mappings":";;;;;AAGA,IAAM,kBAAkB;AAGxB,IAAM,qBAAqB;AAc3B,IAAM,yBACJ;AAqBF,eAAsB,eAAe,QAAiC;AAEpE,MAAI,CAAC,UAAU,CAAC,OAAO,KAAK,GAAG;AAC7B,UAAM,IAAI,aAAa,qCAAqC,WAAW,YAAY;AAAA,EACrF;AAEA,MAAI,OAAO,SAAS,iBAAiB;AACnC,UAAM,IAAI;AAAA,MACR,0BAA0B,kBAAkB,GAAI;AAAA,MAChD;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,MAAI,uBAAuB,KAAK,MAAM,GAA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6
- export {
7
- compileMaizzle
8
- };
9
- //# sourceMappingURL=maizzle-KKJF7XY7.js.map