@emabuild/email-renderer 0.7.1 → 0.9.0
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +873 -759
- package/dist/index.js.map +1 -1
- package/dist/layout/document-shell.d.ts +5 -2
- package/dist/layout/document-shell.d.ts.map +1 -1
- package/dist/layout/fluid-hybrid.d.ts +8 -4
- package/dist/layout/fluid-hybrid.d.ts.map +1 -1
- package/dist/layout/web-layout.d.ts +3 -3
- package/dist/layout/web-layout.d.ts.map +1 -1
- package/dist/render.d.ts +5 -4
- package/dist/render.d.ts.map +1 -1
- package/dist/utils/background.d.ts +37 -0
- package/dist/utils/background.d.ts.map +1 -0
- package/dist/utils/border.d.ts.map +1 -1
- package/dist/utils/css-inliner.d.ts.map +1 -1
- package/dist/utils/dark-mode.d.ts +2 -3
- package/dist/utils/dark-mode.d.ts.map +1 -1
- package/dist/utils/html-minifier.d.ts.map +1 -1
- package/dist/utils/markup.d.ts +12 -0
- package/dist/utils/markup.d.ts.map +1 -0
- package/dist/utils/mso.d.ts +27 -0
- package/dist/utils/mso.d.ts.map +1 -0
- package/dist/utils/plain-text.d.ts +2 -2
- package/dist/utils/plain-text.d.ts.map +1 -1
- package/dist/utils/responsive-css.d.ts +3 -0
- package/dist/utils/responsive-css.d.ts.map +1 -1
- package/dist/utils/responsive-overrides.d.ts +5 -4
- package/dist/utils/responsive-overrides.d.ts.map +1 -1
- package/dist/utils/strip-active-content.d.ts +27 -0
- package/dist/utils/strip-active-content.d.ts.map +1 -0
- package/package.json +12 -5
|
@@ -5,8 +5,11 @@ export interface DocumentShellExtras {
|
|
|
5
5
|
fontUrls?: string[];
|
|
6
6
|
/** Additional CSS blocks (e.g. hoisted content styles), emitted after the base styles */
|
|
7
7
|
styles?: string[];
|
|
8
|
-
/** Document `<title>` (escaped; default
|
|
9
|
-
title?: string;
|
|
8
|
+
/** Document `<title>` (escaped; default: the body title, else the preheader) */
|
|
9
|
+
title?: string | undefined;
|
|
10
|
+
/** The design has dark-mode styles: declare `light dark` (default: `light` only, so clients that
|
|
11
|
+
* honour the declaration do not darken transparent areas around content that has no dark styles) */
|
|
12
|
+
darkMode?: boolean;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* Wrap rendered body HTML in an email-safe XHTML document shell
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-shell.d.ts","sourceRoot":"","sources":["../../src/layout/document-shell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"document-shell.d.ts","sourceRoot":"","sources":["../../src/layout/document-shell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B;yGACqG;IACrG,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAaD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,UAAU,EACtB,MAAM,GAAE,mBAAwB,GAC/B,MAAM,CA6ER"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DesignRow, DesignColumn, BodyValues } from '@emabuild/types';
|
|
2
|
-
type ContentRenderer = (values: Record<string, unknown>, ctx:
|
|
1
|
+
import { DesignRow, DesignColumn, BodyValues, ExportRenderContext, DisplayMode } from '@emabuild/types';
|
|
2
|
+
type ContentRenderer = (values: Record<string, unknown>, ctx: ExportRenderContext) => string;
|
|
3
3
|
/**
|
|
4
4
|
* Render a single design row as fluid-hybrid email HTML
|
|
5
5
|
* (inline-block columns with MSO ghost tables for Outlook).
|
|
@@ -10,10 +10,14 @@ type ContentRenderer = (values: Record<string, unknown>, ctx: any) => string;
|
|
|
10
10
|
* hook classes when `_override.mobile` is set.
|
|
11
11
|
* - `noStackMobile` rows get class `no-stack`; each column is wrapped in a
|
|
12
12
|
* `.u_column_ns` percentage-width inline-block so it never stacks.
|
|
13
|
+
* - Outlook for Windows: the row's vertical padding moves to an MSO-only cell
|
|
14
|
+
* (Outlook ignores padding on `<div>`; horizontal padding only matters on
|
|
15
|
+
* narrow screens, which Outlook desktop never has), a background image is
|
|
16
|
+
* painted with a VML rectangle, and `hideDesktop` rows are hidden from it.
|
|
13
17
|
*
|
|
14
18
|
* @param displayMode - Passed to the tool renderers as `ctx.displayMode` (default `'email'`)
|
|
15
19
|
*/
|
|
16
|
-
export declare function renderRow(row: DesignRow, bodyValues: BodyValues, toolRenderers: Map<string, ContentRenderer>, displayMode?:
|
|
20
|
+
export declare function renderRow(row: DesignRow, bodyValues: BodyValues, toolRenderers: Map<string, ContentRenderer>, displayMode?: DisplayMode): string;
|
|
17
21
|
/**
|
|
18
22
|
* Render the contents of a column with the tool renderers: unknown tools
|
|
19
23
|
* become an HTML comment, `hideDesktop`/`hideMobile` wrap the output in a
|
|
@@ -21,6 +25,6 @@ export declare function renderRow(row: DesignRow, bodyValues: BodyValues, toolRe
|
|
|
21
25
|
* tool didn't emit one, and each content's `displayCondition` wraps it.
|
|
22
26
|
* Shared by the email (fluid-hybrid) and web layouts.
|
|
23
27
|
*/
|
|
24
|
-
export declare function renderColumnContents(col: DesignColumn, widthPx: number, bodyValues: BodyValues, toolRenderers: Map<string, ContentRenderer>, displayMode:
|
|
28
|
+
export declare function renderColumnContents(col: DesignColumn, widthPx: number, bodyValues: BodyValues, toolRenderers: Map<string, ContentRenderer>, displayMode: DisplayMode): string;
|
|
25
29
|
export {};
|
|
26
30
|
//# sourceMappingURL=fluid-hybrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluid-hybrid.d.ts","sourceRoot":"","sources":["../../src/layout/fluid-hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"fluid-hybrid.d.ts","sourceRoot":"","sources":["../../src/layout/fluid-hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQ7G,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,mBAAmB,KAAK,MAAM,CAAC;AAE7F;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,WAAW,GAAE,WAAqB,GACjC,MAAM,CAiER;AA6CD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,WAAW,EAAE,WAAW,GACvB,MAAM,CA4BR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DesignRow, BodyValues } from '@emabuild/types';
|
|
2
|
-
type ContentRenderer = (values: Record<string, unknown>, ctx:
|
|
1
|
+
import { DesignRow, BodyValues, ExportRenderContext } from '@emabuild/types';
|
|
2
|
+
type ContentRenderer = (values: Record<string, unknown>, ctx: ExportRenderContext) => string;
|
|
3
3
|
/**
|
|
4
4
|
* Render a single design row as a responsive web `<div>` block
|
|
5
5
|
* (flex columns; see the module docs). The row's `displayCondition` wraps it.
|
|
@@ -32,7 +32,7 @@ export interface WebShellExtras {
|
|
|
32
32
|
/** Additional CSS blocks emitted after the base stylesheet */
|
|
33
33
|
styles?: string[];
|
|
34
34
|
/** Document `<title>` (escaped) */
|
|
35
|
-
title?: string;
|
|
35
|
+
title?: string | undefined;
|
|
36
36
|
/** `<html lang>` (default `en`) */
|
|
37
37
|
lang?: string;
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-layout.d.ts","sourceRoot":"","sources":["../../src/layout/web-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAgB,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web-layout.d.ts","sourceRoot":"","sources":["../../src/layout/web-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAgB,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAUhG,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,mBAAmB,KAAK,MAAM,CAAC;AAK7F;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAC1C,MAAM,CAiCR;AAwBD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMzD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAoBtD;AAqBD,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAE,cAAmB,GAAG,MAAM,CAgC5G"}
|
package/dist/render.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { EmailDesign, ExportResult, ExportOptions } from '@emabuild/types';
|
|
1
|
+
import { EmailDesign, ExportResult, ExportOptions, ExportRenderContext, DisplayMode } from '@emabuild/types';
|
|
2
2
|
import { PlainTextOptions } from './utils/plain-text.js';
|
|
3
|
-
type ContentRenderer = (values: Record<string, unknown>, ctx:
|
|
3
|
+
type ContentRenderer = (values: Record<string, unknown>, ctx: ExportRenderContext) => string;
|
|
4
4
|
/**
|
|
5
5
|
* Export options accepted by the renderer. Extends the shared
|
|
6
6
|
* `ExportOptions` with fields not (yet) declared there.
|
|
7
7
|
*/
|
|
8
8
|
export type RenderOptions = ExportOptions & {
|
|
9
9
|
/** `'web'` renders a responsive web page; anything else (default) renders email HTML */
|
|
10
|
-
displayMode?:
|
|
10
|
+
displayMode?: DisplayMode;
|
|
11
11
|
/** Per-row render cache (same as the 4th argument's `cache`) */
|
|
12
12
|
cache?: RenderCache;
|
|
13
13
|
};
|
|
@@ -54,7 +54,8 @@ export declare function createRenderCache(): RenderCache;
|
|
|
54
54
|
*
|
|
55
55
|
* Pipeline: render (headers → rows → footers) → hoist body `<style>` blocks
|
|
56
56
|
* into the head → mobile override CSS (`_override.mobile`) → merge tags → design tags →
|
|
57
|
-
* CSS inlining (`inlineStyles`) → cleanup (`cleanup`) → minification (`minify
|
|
57
|
+
* CSS inlining (`inlineStyles`) → cleanup (`cleanup`) → minification (`minify`, on by
|
|
58
|
+
* default for email HTML; `minify: false` keeps it readable).
|
|
58
59
|
*
|
|
59
60
|
* @param design - Design JSON
|
|
60
61
|
* @param toolRenderers - Map of tool name → HTML render function. Keep the
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAyB,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAazI,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG/E,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,mBAAmB,KAAK,MAAM,CAAC;AAE7F;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C,wFAAwF;IACxF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gEAAgE;IAChE,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAUD,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAWD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C;AA+CD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EACnB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CA6Gd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,WAAW,EACnB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,OAAO,CAAC,EAAE,aAAa,GAAG,gBAAgB,EAC1C,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAQR;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,SAAS,GAAE,CAAC,MAAM,EAAE,MAAM,CAAgB,GACzC,MAAM,CAOR;AAqBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAY7D;AAqDD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUvD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module background
|
|
3
|
+
*
|
|
4
|
+
* Background images of the body and of rows: the CSS for modern clients and
|
|
5
|
+
* the VML that Outlook for Windows needs (it ignores `background-image`).
|
|
6
|
+
*/
|
|
7
|
+
/** Background image value of the body / a row */
|
|
8
|
+
export type BackgroundImageValue = {
|
|
9
|
+
url?: string;
|
|
10
|
+
repeat?: boolean | string;
|
|
11
|
+
center?: boolean;
|
|
12
|
+
cover?: boolean;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
} | undefined;
|
|
15
|
+
/** A background image resolved for output (URL already made safe) */
|
|
16
|
+
export interface ResolvedBackground {
|
|
17
|
+
url: string;
|
|
18
|
+
repeat: 'repeat' | 'no-repeat';
|
|
19
|
+
/** Inline CSS declarations (`background-image`, `-repeat`, `-position`, `-size`) */
|
|
20
|
+
css: string;
|
|
21
|
+
/** VML fill type: `tile` for repeating images, `frame` (stretched) otherwise */
|
|
22
|
+
fillType: 'tile' | 'frame';
|
|
23
|
+
}
|
|
24
|
+
/** Resolve a background image value, or `null` when there is no usable URL */
|
|
25
|
+
export declare function resolveBackground(img: unknown): ResolvedBackground | null;
|
|
26
|
+
/** Inline CSS for a background image value (empty without a URL) */
|
|
27
|
+
export declare function backgroundImageCss(img: unknown): string;
|
|
28
|
+
/**
|
|
29
|
+
* Outlook-only VML rectangle that paints a background image behind a block of
|
|
30
|
+
* markup: returns the opening and closing conditional comments to put around it.
|
|
31
|
+
* The rectangle is `widthPx` wide and grows with its content.
|
|
32
|
+
*/
|
|
33
|
+
export declare function vmlBackgroundRect(bg: ResolvedBackground, widthPx: number, color: string): {
|
|
34
|
+
open: string;
|
|
35
|
+
close: string;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=background.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../src/utils/background.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,iDAAiD;AACjD,MAAM,MAAM,oBAAoB,GAC5B;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACnG,SAAS,CAAC;AAEd,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC/B,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAC;IACZ,gFAAgF;IAChF,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAYzE;AAED,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAMzH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"border.d.ts","sourceRoot":"","sources":["../../src/utils/border.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"border.d.ts","sourceRoot":"","sources":["../../src/utils/border.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAYnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-inliner.d.ts","sourceRoot":"","sources":["../../src/utils/css-inliner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAkBH,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,0CAA0C;AAC1C,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,oDAAoD;AACpD,UAAU,cAAc;IACtB,8CAA8C;IAC9C,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,wEAAwE;IACxE,WAAW,EAAE,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC9B,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAmBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CA0C9E;
|
|
1
|
+
{"version":3,"file":"css-inliner.d.ts","sourceRoot":"","sources":["../../src/utils/css-inliner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAkBH,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,0CAA0C;AAC1C,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,oDAAoD;AACpD,UAAU,cAAc;IACtB,8CAA8C;IAC9C,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,wEAAwE;IACxE,WAAW,EAAE,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC9B,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAmBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CA0C9E;AAsED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAsG9E"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { EmailDesign } from '@emabuild/types';
|
|
2
|
-
|
|
2
|
+
import { UnknownRecord } from '@emabuild/shared';
|
|
3
3
|
/** The `_override.dark` record of a values object, if any */
|
|
4
|
-
export declare function getDarkOverrides(values: unknown):
|
|
4
|
+
export declare function getDarkOverrides(values: unknown): UnknownRecord | null;
|
|
5
5
|
/** Whether the design defines any dark-mode color */
|
|
6
6
|
export declare function hasDarkMode(design: EmailDesign): boolean;
|
|
7
7
|
/**
|
|
8
8
|
* CSS for every dark-mode color of the design, or `''` when there is none.
|
|
9
9
|
*/
|
|
10
10
|
export declare function buildDarkModeCss(design: EmailDesign): string;
|
|
11
|
-
export {};
|
|
12
11
|
//# sourceMappingURL=dark-mode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dark-mode.d.ts","sourceRoot":"","sources":["../../src/utils/dark-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"dark-mode.d.ts","sourceRoot":"","sources":["../../src/utils/dark-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,iBAAiB,CAAC;AAE7E,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxF,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAEtE;AA6CD,qDAAqD;AACrD,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAsB5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-minifier.d.ts","sourceRoot":"","sources":["../../src/utils/html-minifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAkCH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"html-minifier.d.ts","sourceRoot":"","sources":["../../src/utils/html-minifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAkCH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmD/C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module markup
|
|
3
|
+
*
|
|
4
|
+
* Escaping helpers shared by the layouts (email shell, fluid-hybrid rows, web layout).
|
|
5
|
+
*/
|
|
6
|
+
/** Escape a value for a double-quoted HTML attribute (existing entities are kept) */
|
|
7
|
+
export declare function escapeAttr(value: string): string;
|
|
8
|
+
/** Escape text content (e.g. `<title>`) */
|
|
9
|
+
export { escapeHtmlText as escapeText } from '@emabuild/shared';
|
|
10
|
+
/** Make a URL safe inside `url('…')` and attributes: quotes, parens, backslashes, spaces and `<>` are percent-encoded */
|
|
11
|
+
export declare function safeCssUrl(url: string): string;
|
|
12
|
+
//# sourceMappingURL=markup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markup.d.ts","sourceRoot":"","sources":["../../src/utils/markup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,2CAA2C;AAC3C,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhE,yHAAyH;AACzH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module mso
|
|
3
|
+
*
|
|
4
|
+
* Markup for Outlook for Windows (the Word rendering engine), which ignores
|
|
5
|
+
* `padding` outside table cells, `max-width`/`width` on `<div>`, media
|
|
6
|
+
* queries and `background-image`. Everything here is wrapped in `mso`
|
|
7
|
+
* conditional comments, so other clients never see it.
|
|
8
|
+
*/
|
|
9
|
+
/** CSS padding shorthand split into its four sides (`top right bottom left`) */
|
|
10
|
+
export declare function paddingSides(padding: string | undefined): [string, string, string, string];
|
|
11
|
+
/** Whether a padding shorthand is zero on every side */
|
|
12
|
+
export declare function isZeroPadding(padding: string | undefined): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* An Outlook-only table cell around some markup, carrying the padding (and
|
|
15
|
+
* background color) that Outlook drops from `<div>`s. Returns empty strings
|
|
16
|
+
* when there is nothing to carry.
|
|
17
|
+
*/
|
|
18
|
+
export declare function msoCell(padding: string, bgColor?: string): {
|
|
19
|
+
open: string;
|
|
20
|
+
close: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Hide markup from Outlook for Windows. Used for "hide on desktop": Outlook
|
|
24
|
+
* is a desktop client that never sees the media queries doing the hiding.
|
|
25
|
+
*/
|
|
26
|
+
export declare function hideFromOutlook(html: string): string;
|
|
27
|
+
//# sourceMappingURL=mso.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mso.d.ts","sourceRoot":"","sources":["../../src/utils/mso.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAK1F;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAElE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,SAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAQtF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
/** Options for {@link renderPlainText} */
|
|
9
9
|
export interface PlainTextOptions {
|
|
10
10
|
/** Wrap lines at this column (e.g. 78). Default `false` (no wrapping). Footnote URLs are never wrapped */
|
|
11
|
-
wordwrap?: number | false;
|
|
11
|
+
wordwrap?: number | false | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* How links are written: `'inline'` → `text (url)` (default),
|
|
14
14
|
* `'footnote'` → `text [1]` with a numbered URL list at the end.
|
|
15
15
|
*/
|
|
16
|
-
linkStyle?: 'inline' | 'footnote';
|
|
16
|
+
linkStyle?: 'inline' | 'footnote' | undefined;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Decode HTML character references (named, decimal, hex).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain-text.d.ts","sourceRoot":"","sources":["../../src/utils/plain-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"plain-text.d.ts","sourceRoot":"","sources":["../../src/utils/plain-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,0GAA0G;IAC1G,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;CAC/C;AAgBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASnD;AAiCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CA0JpF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAqB5D"}
|
|
@@ -12,6 +12,9 @@ export declare function mobileMediaQuery(contentWidth: number): string;
|
|
|
12
12
|
* percentage wrappers, so the stacking rule (100% width) only fills that
|
|
13
13
|
* wrapper and the columns stay side by side.
|
|
14
14
|
*
|
|
15
|
+
* On mobile `.u_row` is 100% wide with `box-sizing: border-box`, so the row
|
|
16
|
+
* padding stays inside the screen instead of adding to the width.
|
|
17
|
+
*
|
|
15
18
|
* @param contentWidth - Body content width in px
|
|
16
19
|
*/
|
|
17
20
|
export declare function getResponsiveCss(contentWidth: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responsive-css.d.ts","sourceRoot":"","sources":["../../src/utils/responsive-css.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED
|
|
1
|
+
{"version":3,"file":"responsive-css.d.ts","sourceRoot":"","sources":["../../src/utils/responsive-css.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAyC7D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmailDesign, DesignRow, DesignContent } from '@emabuild/types';
|
|
2
|
-
|
|
2
|
+
import { UnknownRecord } from '@emabuild/shared';
|
|
3
3
|
/** camelCase value key → kebab-case (`fontSize` → `font-size`), same as the tools' `kebab()` */
|
|
4
4
|
export declare function kebabKey(key: string): string;
|
|
5
5
|
/** Responsive hook class for a value key (`fontSize` → `v-font-size`) */
|
|
@@ -13,8 +13,10 @@ export declare function cssId(id: string): string;
|
|
|
13
13
|
export declare function contentElementId(content: Pick<DesignContent, 'id' | 'values'>): string;
|
|
14
14
|
/** HTML id of a row's `u_row` div: `anchor`, else `_meta.htmlID`, else `u_row_<row.id>` */
|
|
15
15
|
export declare function rowElementId(row: Pick<DesignRow, 'id' | 'values'>): string;
|
|
16
|
+
/** The non-empty `_override.<device>` record of a values object, if any */
|
|
17
|
+
export declare function getDeviceOverrides(values: unknown, device: string): UnknownRecord | null;
|
|
16
18
|
/** The `_override.mobile` record of a values object, if it has any usable entry */
|
|
17
|
-
export declare function getMobileOverrides(values: unknown):
|
|
19
|
+
export declare function getMobileOverrides(values: unknown): UnknownRecord | null;
|
|
18
20
|
/** A single override declaration on a hook class */
|
|
19
21
|
export interface OverrideDeclaration {
|
|
20
22
|
/** Hook class without the dot (`v-font-size`) */
|
|
@@ -33,7 +35,7 @@ export interface OverrideDeclaration {
|
|
|
33
35
|
* @param overrides - e.g. `values._override.mobile`
|
|
34
36
|
* @returns Declarations in source order
|
|
35
37
|
*/
|
|
36
|
-
export declare function overrideDeclarations(overrides:
|
|
38
|
+
export declare function overrideDeclarations(overrides: UnknownRecord): OverrideDeclaration[];
|
|
37
39
|
/**
|
|
38
40
|
* Mobile override rules (without the media query) of one row and its
|
|
39
41
|
* contents, in source order. Used by the per-row render cache.
|
|
@@ -57,5 +59,4 @@ export declare function wrapOverrideRules(rules: string[], contentWidth: number)
|
|
|
57
59
|
* @returns A `@media` block, or `''` when the design has no mobile overrides
|
|
58
60
|
*/
|
|
59
61
|
export declare function buildResponsiveOverridesCss(design: EmailDesign): string;
|
|
60
|
-
export {};
|
|
61
62
|
//# sourceMappingURL=responsive-overrides.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responsive-overrides.d.ts","sourceRoot":"","sources":["../../src/utils/responsive-overrides.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"responsive-overrides.d.ts","sourceRoot":"","sources":["../../src/utils/responsive-overrides.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,EAA8C,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGlG,gGAAgG;AAChG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAID,4DAA4D;AAC5D,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAExC;AAOD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,QAAQ,CAAC,GAAG,MAAM,CAEtF;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,QAAQ,CAAC,GAAG,MAAM,CAE1E;AAQD,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAIxF;AAED,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAExE;AA0BD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,aAAa,GAAG,mBAAmB,EAAE,CAwBpF;AAiCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,EAAE,CAMzD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAG/E;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CASvE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module strip-active-content
|
|
3
|
+
*
|
|
4
|
+
* Removes everything that could run code from exported email HTML. Email
|
|
5
|
+
* clients never run scripts, so nothing legitimate is lost, but a host that
|
|
6
|
+
* shows the exported HTML in its own app (a preview, an archive page) would
|
|
7
|
+
* otherwise run whatever an HTML block, an import or an AI result carried:
|
|
8
|
+
*
|
|
9
|
+
* - `<script>` elements with their content;
|
|
10
|
+
* - embedding / navigation elements: iframe, frame(set), object, embed,
|
|
11
|
+
* applet, base, `<meta http-equiv="refresh">` (their content stays);
|
|
12
|
+
* - SVG animation elements (animate, set, …) that can rewrite `href` to
|
|
13
|
+
* `javascript:` after any check;
|
|
14
|
+
* - `on*` handlers, `srcdoc`, `formaction`;
|
|
15
|
+
* - `javascript:` / `vbscript:` / `data:text/html` URLs (also entity- or
|
|
16
|
+
* whitespace-obfuscated) in URL attributes;
|
|
17
|
+
* - `expression(` / `javascript:` / `behavior:` in `style` attributes.
|
|
18
|
+
*
|
|
19
|
+
* Token based (see html-tokenizer): no DOM, same result in the browser and
|
|
20
|
+
* in Node. Comments (MSO conditionals) are left as they are.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Strip scripts, handlers and script URLs from an HTML document or fragment.
|
|
24
|
+
* Returns the input unchanged (same string) when there is nothing to remove.
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripActiveContent(html: string): string;
|
|
27
|
+
//# sourceMappingURL=strip-active-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-active-content.d.ts","sourceRoot":"","sources":["../../src/utils/strip-active-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA2CH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoCvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emabuild/email-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Email HTML renderer — converts design JSON to cross-client email HTML",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
-
"README.md"
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
18
19
|
],
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@emabuild/shared": "^0.
|
|
21
|
-
"@emabuild/types": "^0.
|
|
21
|
+
"@emabuild/shared": "^0.3.0",
|
|
22
|
+
"@emabuild/types": "^0.8.1"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"vite": "^6.2.0",
|
|
@@ -39,10 +40,16 @@
|
|
|
39
40
|
],
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"sideEffects": false,
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/Fabiovarrenti/emabuild.git",
|
|
46
|
+
"directory": "packages/email-renderer"
|
|
47
|
+
},
|
|
42
48
|
"scripts": {
|
|
43
49
|
"build": "vite build",
|
|
44
50
|
"dev": "vite build --watch",
|
|
45
51
|
"test": "vitest run",
|
|
46
|
-
"clean": "rm -rf dist"
|
|
52
|
+
"clean": "rm -rf dist",
|
|
53
|
+
"typecheck": "tsc --noEmit -p ."
|
|
47
54
|
}
|
|
48
55
|
}
|