@h-k-dev/dawn 1.3.0 → 1.3.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.
|
@@ -323,11 +323,17 @@ function declaresDark(doc) {
|
|
|
323
323
|
return Array.from(doc.querySelectorAll('style')).some((sheet) => /(?:supported-)?color-schemes?\s*:[^;}]*\bdark\b/i.test(sheet.textContent ?? ''));
|
|
324
324
|
}
|
|
325
325
|
/** The surface, and the browser's own colours a message leans on — its ink
|
|
326
|
-
and its links — as Dawn draws them on `scheme`.
|
|
326
|
+
and its links — as Dawn draws them on `scheme`.
|
|
327
|
+
|
|
328
|
+
The body paints the surface as the root does: a message that clears its
|
|
329
|
+
root (`<html style="background-color: transparent">`) would else leave
|
|
330
|
+
the frame nothing painted at all, and a frame on another scheme than the
|
|
331
|
+
page round it is then filled by the browser — white, under Dawn's light
|
|
332
|
+
ink. */
|
|
327
333
|
function dawnSurfaceRules(scheme) {
|
|
328
334
|
const paint = (token) => (scheme === 'dark' ? dawnDarkColor(token) : token);
|
|
329
335
|
return (`html { background: ${DAWN_SURFACE[scheme]}; }` +
|
|
330
|
-
` body { background:
|
|
336
|
+
` body { background: ${DAWN_SURFACE[scheme]}; color: ${paint('#000000')}; }` +
|
|
331
337
|
` :where(a:link) { color: ${paint('#0000ee')}; }` +
|
|
332
338
|
` :where(a:visited) { color: ${paint('#551a8b')}; }`);
|
|
333
339
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h-k-dev-dawn.mjs","sources":["../../../projects/dawn/src/lib/color.ts","../../../projects/dawn/src/lib/css.ts","../../../projects/dawn/src/lib/client-support.ts","../../../projects/dawn/src/lib/envelope.ts","../../../projects/dawn/src/lib/style-text.ts","../../../projects/dawn/src/lib/sent.ts","../../../projects/dawn/src/lib/client-rendering.ts","../../../projects/dawn/src/lib/render.ts","../../../projects/dawn/src/lib/layout.ts","../../../projects/dawn/src/public-api.ts","../../../projects/dawn/src/h-k-dev-dawn.ts"],"sourcesContent":["/**\n * Dawn's colours: reading every colour CSS writes, and drawing one dark.\n *\n * Dawn draws a colour dark as a WebKit-based mail client does, with\n * WebKit's invert-lightness filter (`InvertLightnessFilterOperation::\n * transformColor`, Source/WebCore/platform/graphics/filters/\n * FilterOperation.cpp, safari-7614-branch): the hue turned half a turn in\n * HSL, then a 5×3 colour matrix. White comes out #333333, black white, a\n * hue stays its hue. Its constants are WebKit's, used under WebKit's BSD\n * licence (Copyright © Apple Inc.). Dawn is our own code; it is not made,\n * approved or endorsed by Apple.\n */\n\n/** An sRGB colour, components 0–1. */\nexport type Rgba = readonly [r: number, g: number, b: number, a: number];\n\n/** The surfaces a message lies on: the light reading pane, and the dark one\n — the editor's papers too. */\nexport const DAWN_SURFACE = { light: '#ffffff', dark: '#1e1e1e' } as const;\n\n/** Light or dark: the paper an email is drawn on. */\nexport type DawnScheme = keyof typeof DAWN_SURFACE;\n\n/** The CSS named colours, as rrggbb. */\nconst NAMED: Readonly<Record<string, string>> = Object.fromEntries(\n (\n 'aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,' +\n 'bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,' +\n 'burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,' +\n 'cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,' +\n 'darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkgrey:a9a9a9,' +\n 'darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,' +\n 'darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,' +\n 'darkslateblue:483d8b,darkslategray:2f4f4f,darkslategrey:2f4f4f,darkturquoise:00ced1,' +\n 'darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dimgrey:696969,' +\n 'dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,' +\n 'gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,' +\n 'greenyellow:adff2f,grey:808080,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,' +\n 'ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,' +\n 'lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,' +\n 'lightgoldenrodyellow:fafad2,lightgray:d3d3d3,lightgreen:90ee90,lightgrey:d3d3d3,' +\n 'lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,' +\n 'lightslategray:778899,lightslategrey:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,' +\n 'lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,' +\n 'mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370db,' +\n 'mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,' +\n 'mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,' +\n 'mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,' +\n 'olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,' +\n 'palegreen:98fb98,paleturquoise:afeeee,palevioletred:db7093,papayawhip:ffefd5,' +\n 'peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,' +\n 'rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,' +\n 'salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,' +\n 'skyblue:87ceeb,slateblue:6a5acd,slategray:708090,slategrey:708090,snow:fffafa,' +\n 'springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,' +\n 'turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,' +\n 'yellowgreen:9acd32'\n )\n .split(',')\n .map((pair) => pair.split(':') as [string, string]),\n);\n\nconst HEX_TOKEN = '#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3,4})(?![0-9a-z_-])';\nconst FUNCTION_TOKEN = '(?:rgba?|hsla?)\\\\([^()]*\\\\)';\nconst NAME_TOKEN = `\\\\b(?:${Object.keys(NAMED).join('|')})\\\\b`;\n\n/** In a colour-painting value: a `url(…)` (kept as it is) or a colour. */\nexport const VALUE_TOKEN = new RegExp(\n `url\\\\([^)]*\\\\)|${HEX_TOKEN}|${FUNCTION_TOKEN}|${NAME_TOKEN}`,\n 'gi',\n);\n\nconst clamp = (value: number): number => Math.min(1, Math.max(0, value));\n\n/** A number of a colour function: plain, or a percentage of `full`. */\nfunction component(text: string, full: number): number {\n const value = parseFloat(text);\n return text.trim().endsWith('%') ? (value / 100) * full : value;\n}\n\nfunction hslToRgb(h: number, s: number, l: number): [number, number, number] {\n const k = (n: number) => (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n const f = (n: number) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));\n return [f(0), f(8), f(4)];\n}\n\n/** A colour token — a name, a hex, `rgb()`/`hsl()` — as an sRGB colour, or\n null where it is none this reads. */\nexport function parseCssColor(token: string): Rgba | null {\n const text = token.trim().toLowerCase();\n const named = NAMED[text];\n if (named) return parseCssColor(`#${named}`);\n if (/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(text)) {\n const hex = text.slice(1);\n const full = hex.length <= 4 ? [...hex].map((c) => c + c).join('') : hex;\n const [r, g, b, a = 255] = (full.match(/../g) ?? []).map((pair) => parseInt(pair, 16));\n return [r / 255, g / 255, b / 255, a / 255];\n }\n const fn = /^(rgba?|hsla?)\\(([^()]*)\\)$/.exec(text);\n if (!fn) return null;\n const parts = fn[2].split(/[\\s,/]+/).filter(Boolean);\n if (parts.length < 3) return null;\n const alpha = parts[3] === undefined ? 1 : component(parts[3], 1);\n if (fn[1].startsWith('rgb')) {\n const [r, g, b] = parts.slice(0, 3).map((part) => component(part, 255) / 255);\n return [r, g, b, alpha];\n }\n const [r, g, b] = hslToRgb(parseFloat(parts[0]), component(parts[1], 1), component(parts[2], 1));\n return [r, g, b, alpha];\n}\n\nconst byte = (value: number): number => Math.round(clamp(value) * 255);\n\n/** A colour as CSS: `rgb()`, or `rgba()` where it is not opaque. */\nexport function rgbaToCss([r, g, b, a]: Rgba): string {\n return a >= 1\n ? `rgb(${byte(r)}, ${byte(g)}, ${byte(b)})`\n : `rgba(${byte(r)}, ${byte(g)}, ${byte(b)}, ${Math.round(a * 1000) / 1000})`;\n}\n\n/** A colour as #rrggbb, for the legacy attributes that read no CSS. */\nexport function rgbaToHex([r, g, b]: Rgba): string {\n return `#${[r, g, b].map((c) => byte(c).toString(16).padStart(2, '0')).join('')}`;\n}\n\n// ————————————————————————————————————————————————————— Dawn's colour maths\n\n/** WebKit's `toDarkModeMatrix`: per channel, r, g, b, a and an offset. */\nconst TO_DARK_MODE: readonly (readonly number[])[] = [\n [-0.77, 0.059, -0.089, 0, 1],\n [0.03, -0.741, -0.089, 0, 1],\n [0.03, 0.059, -0.89, 0, 1],\n];\n\n/** WebKit's `hueRotate` helper: to HSL, the hue turned by `amount` of a\n turn, back to RGB. */\nfunction hueRotate([r, g, b, a]: Rgba, amount: number): Rgba {\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n const chroma = max - min;\n const lightness = 0.5 * (max + min);\n const saturation =\n chroma === 0 ? 0 : lightness <= 0.5 ? chroma / (max + min) : chroma / (2 - (max + min));\n let hue = 0;\n if (chroma !== 0) {\n if (max === r) hue = (g - b) / chroma + (g < b ? 6 : 0);\n else if (max === g) hue = (b - r) / chroma + 2;\n else hue = (r - g) / chroma + 4;\n hue /= 6;\n }\n hue = (hue + amount) % 1;\n const temp2 =\n lightness <= 0.5\n ? lightness * (1 + saturation)\n : lightness + saturation - lightness * saturation;\n const temp1 = 2 * lightness - temp2;\n const sixths = hue * 6;\n const channel = (at: number): number => {\n const h = at < 0 ? at + 6 : at >= 6 ? at - 6 : at;\n if (h < 1) return temp1 + (temp2 - temp1) * h;\n if (h < 3) return temp2;\n if (h < 4) return temp1 + (temp2 - temp1) * (4 - h);\n return temp1;\n };\n return [channel(sixths + 2), channel(sixths), channel(sixths - 2), a];\n}\n\n/** The invert-lightness transform on one colour. */\nexport function invertLightness(color: Rgba): Rgba {\n const [r, g, b, a] = hueRotate(color, 0.5);\n const [red, green, blue] = TO_DARK_MODE.map((row) =>\n clamp(row[0] * r + row[1] * g + row[2] * b + row[3] * a + row[4]),\n );\n return [red, green, blue, a];\n}\n\n/** What a colour paints: a `surface` (a background) or `ink` (text). */\nexport type DawnRole = 'surface' | 'ink';\n\n/** How light a colour reads, 0–1 (Rec. 709 weights). */\nconst luma = ([r, g, b]: Rgba): number => 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n/** One CSS colour token as Dawn draws it dark — the light value in, the\n drawn value out; anything that is no colour (a `url(…)`, a keyword) as\n it was. What a swatch on a dark paper shows.\n\n With a `role`, what is dark already stays as written, as a mail client\n on a phone keeps it: a surface is never drawn lighter (an ink band\n stays ink, and a white logo on it stays readable), ink is never drawn\n darker (white text on that band stays white). Without one — a border,\n a swatch — the colour is always drawn. */\nexport function dawnDarkColor(token: string, role?: DawnRole): string {\n const color = parseCssColor(token);\n if (!color) return token;\n const drawn = invertLightness(color);\n if (role === 'surface' && luma(drawn) >= luma(color)) return token;\n if (role === 'ink' && luma(drawn) <= luma(color)) return token;\n return rgbaToCss(drawn);\n}\n","import {\n DAWN_SURFACE,\n DawnRole,\n DawnScheme,\n VALUE_TOKEN,\n dawnDarkColor,\n parseCssColor,\n rgbaToHex,\n} from './color';\n\n/*\n * Dawn on CSS and HTML: every colour a declaration, a sheet, a legacy\n * attribute or a whole message paints, drawn dark by `dawnDarkColor` — and\n * nothing else touched. A background that is dark already and text that is\n * light already stay as written (`DawnRole`). A border, an outline, a\n * shadow follow the band they lie on (`DawnBand`): as written on a\n * background kept as written, drawn on any other.\n */\n\n/** The properties that paint a colour. */\nconst COLOR_PROPERTY =\n /color|background|border|outline|shadow|fill|stroke|decoration|column-rule|caret|accent/i;\n\n/** The properties that paint text. */\nconst INK_PROPERTY =\n /^(?:color|caret-color|fill|stroke|-webkit-text-(?:fill|stroke)-color|text-(?:decoration|emphasis)(?:-color)?)$/i;\n\n/** What a colour-painting property paints: text, a background, or — a\n border, an outline, a shadow — neither: those follow their band. */\nfunction roleOf(property: string): DawnRole | undefined {\n if (INK_PROPERTY.test(property)) return 'ink';\n return /^background/i.test(property) ? 'surface' : undefined;\n}\n\n/** A background as dark draws it: `kept` as written (dark already) or\n `drawn`. What lies on it follows: a border on a kept band stays as\n written too. */\nexport type DawnBand = 'kept' | 'drawn';\n\n/** The band a declaration block paints — its `background` or\n `background-color`, the last colour said — or null where it paints\n none (no colour, or one mostly clear). */\nexport function dawnBandOf(text: string): DawnBand | null {\n let band: DawnBand | null = null;\n for (const [, property, value] of text.matchAll(/([\\w-]+)\\s*:\\s*([^;]*)/g)) {\n if (!/^background(?:-color)?$/i.test(property)) continue;\n for (const token of value.match(VALUE_TOKEN) ?? []) {\n const color = parseCssColor(token);\n if (!color || color[3] < 0.5) continue;\n band = dawnDarkColor(token, 'surface') === token ? 'kept' : 'drawn';\n }\n }\n return band;\n}\n\n/** One declaration's value with each colour drawn dark; its `url(…)`s as\n they were — and all of it as it was where it follows a kept `band`. */\nfunction darkValue(property: string, value: string, band?: DawnBand | null): string {\n const role = roleOf(property);\n if (!role && band === 'kept') return value;\n return value.replace(VALUE_TOKEN, (token) =>\n token.toLowerCase().startsWith('url(') ? token : dawnDarkColor(token, role),\n );\n}\n\n/** The colour-painting declarations of a block that dark changes, each\n drawn dark, as `[property, value]` — what a sheet laid over the block\n needs (the editor's dark paper). A border on a block that paints no\n band of its own follows the band beneath it, which only the page\n knows: it comes with its `written` value too, to keep on a kept band. */\nexport function dawnDarkDeclarationsOf(\n text: string,\n): [property: string, value: string, written?: string][] {\n const out: [string, string, string?][] = [];\n const own = dawnBandOf(text);\n for (const [, property, value] of text.matchAll(/([\\w-]+)\\s*:\\s*([^;]*)/g)) {\n if (!COLOR_PROPERTY.test(property)) continue;\n const written = value.trim();\n const drawn = darkValue(property, written, own);\n if (drawn === written) continue;\n if (own || roleOf(property)) out.push([property.toLowerCase(), drawn]);\n else out.push([property.toLowerCase(), drawn, written]);\n }\n return out;\n}\n\n/** A declaration block's text with each colour it paints drawn dark — its\n `url(…)`s and every other property untouched. Its borders follow the\n band it paints itself, else the one `beneath` it. */\nexport function dawnDarkDeclarations(text: string, beneath?: DawnBand | null): string {\n const band = dawnBandOf(text) ?? beneath;\n return text.replace(\n /([\\w-]+)(\\s*:\\s*)([^;]*)/g,\n (whole, property: string, colon: string, value: string) =>\n COLOR_PROPERTY.test(property) ? property + colon + darkValue(property, value, band) : whole,\n );\n}\n\n/** A style sheet with each declaration block drawn dark — its selectors and\n at-rules as they were. */\nexport function dawnDarkStyleSheet(text: string): string {\n return text.replace(/\\{([^{}]*)\\}/g, (_, block: string) => `{${dawnDarkDeclarations(block)}}`);\n}\n\n/** The legacy colour attributes HTML email still writes. */\nconst LEGACY_COLOR_ATTRIBUTES: readonly [attribute: string, role?: DawnRole][] = [\n ['bgcolor', 'surface'],\n ['color', 'ink'],\n ['text', 'ink'],\n ['link', 'ink'],\n ['vlink', 'ink'],\n ['alink', 'ink'],\n ['bordercolor'],\n];\n\n/** A legacy attribute's colour drawn dark, as the #rrggbb it must be — null\n where it holds no colour, or one its `role` keeps as written. */\nexport function dawnDarkLegacyColor(value: string, role?: DawnRole): string | null {\n if (!parseCssColor(value)) return null;\n const token = dawnDarkColor(value, role);\n const drawn = parseCssColor(token);\n return drawn && token !== value ? rgbaToHex(drawn) : null;\n}\n\n/** A message drawn dark, in place: every style sheet, every style attribute,\n every legacy colour attribute. Pictures are not touched. */\nexport function dawnDarkDocument(doc: Document): void {\n // The bands first, read off the colours as written: an element's own\n // inline fill, else its `bgcolor`.\n const bands = new Map<Element, DawnBand>();\n for (const element of Array.from(doc.querySelectorAll('[style], [bgcolor]'))) {\n const band =\n dawnBandOf(element.getAttribute('style') ?? '') ??\n dawnBandOf(`background-color: ${element.getAttribute('bgcolor') ?? ''}`);\n if (band) bands.set(element, band);\n }\n /** The nearest band at or above an element. */\n const bandAt = (element: Element | null): DawnBand | null => {\n for (let at = element; at; at = at.parentElement) {\n const band = bands.get(at);\n if (band) return band;\n }\n return null;\n };\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = dawnDarkStyleSheet(sheet.textContent ?? '');\n }\n for (const element of Array.from(doc.querySelectorAll('[style]'))) {\n element.setAttribute(\n 'style',\n dawnDarkDeclarations(element.getAttribute('style') ?? '', bandAt(element.parentElement)),\n );\n }\n for (const [attribute, role] of LEGACY_COLOR_ATTRIBUTES) {\n for (const element of Array.from(doc.querySelectorAll(`[${attribute}]`))) {\n // A border colour on a kept band stays as written, like any border.\n if (!role && bandAt(element) === 'kept') continue;\n const drawn = dawnDarkLegacyColor(element.getAttribute(attribute) ?? '', role);\n if (drawn) element.setAttribute(attribute, drawn);\n }\n }\n}\n\n/** Whether the message says it handles dark itself: a `color-scheme` or\n `supported-color-schemes` naming dark, in a `<meta>` or its CSS. Dawn\n draws such a message with its own dark rules. */\nexport function declaresDark(doc: Document): boolean {\n for (const meta of Array.from(doc.querySelectorAll('meta[name]'))) {\n const name = meta.getAttribute('name')?.toLowerCase();\n if (\n (name === 'color-scheme' || name === 'supported-color-schemes') &&\n /\\bdark\\b/i.test(meta.getAttribute('content') ?? '')\n ) {\n return true;\n }\n }\n return Array.from(doc.querySelectorAll('style')).some((sheet) =>\n /(?:supported-)?color-schemes?\\s*:[^;}]*\\bdark\\b/i.test(sheet.textContent ?? ''),\n );\n}\n\n/** The surface, and the browser's own colours a message leans on — its ink\n and its links — as Dawn draws them on `scheme`. */\nexport function dawnSurfaceRules(scheme: DawnScheme): string {\n const paint = (token: string) => (scheme === 'dark' ? dawnDarkColor(token) : token);\n return (\n `html { background: ${DAWN_SURFACE[scheme]}; }` +\n ` body { background: transparent; color: ${paint('#000000')}; }` +\n ` :where(a:link) { color: ${paint('#0000ee')}; }` +\n ` :where(a:visited) { color: ${paint('#551a8b')}; }`\n );\n}\n","/**\n * The client-support data module (M3): a curated, versioned subset of what\n * caniemail documents about our floor clients. Pure data + lookups — the\n * lint engine, tooltips and (later) autocomplete all read from here.\n *\n * Curation rule: only entries we are confident about, phrased as what\n * *actually happens* in the client. Accuracy beats coverage.\n */\n\nexport type EmailClient = 'gmail' | 'outlook-desktop' | 'outlook-web' | 'apple-mail' | 'yahoo';\n\nexport const CLIENT_LABELS: Record<EmailClient, string> = {\n gmail: 'Gmail',\n 'outlook-desktop': 'Outlook (Windows)',\n 'outlook-web': 'Outlook.com',\n 'apple-mail': 'Apple Mail',\n yahoo: 'Yahoo Mail',\n};\n\nexport function clientList(clients: EmailClient[]): string {\n return clients.map((client) => CLIENT_LABELS[client]).join(', ');\n}\n\nexport interface CssSupportIssue {\n /** Lower-cased CSS property this entry describes. */\n property: string;\n /** Restrict to matching values (e.g. display:flex, background:url(…)). */\n valuePattern?: RegExp;\n /** Restrict to these tags (e.g. padding is fine on table cells). */\n onTags?: string[];\n /** Clients where the declaration does not do what it says. */\n ignoredBy: EmailClient[];\n /** What actually happens — this is the tooltip. */\n note: string;\n}\n\nexport const CSS_SUPPORT: CssSupportIssue[] = [\n {\n property: 'max-width',\n ignoredBy: ['outlook-desktop'],\n note: 'it sizes from the width attribute instead — pair both (the hybrid) or the cap is lost',\n },\n {\n property: 'padding',\n onTags: ['div', 'p', 'span', 'a'],\n ignoredBy: ['outlook-desktop'],\n note: 'the Word engine only honours padding on table cells — a button gets its size from borders in its background colour instead',\n },\n {\n property: 'display',\n valuePattern: /^inline-block\\b/i,\n ignoredBy: ['outlook-desktop'],\n note: 'renders inline, or stacks — never side by side; the fluid columns pattern (width: 100% + max-width) stacks on purpose there, and a bordered anchor button keeps its box',\n },\n {\n property: 'border-radius',\n ignoredBy: ['outlook-desktop'],\n note: 'corners render square',\n },\n {\n property: 'background-image',\n ignoredBy: ['outlook-desktop'],\n note: 'image backgrounds need VML there; the background color shows instead',\n },\n {\n property: 'background',\n valuePattern: /url\\s*\\(/i,\n ignoredBy: ['outlook-desktop'],\n note: 'image backgrounds need VML there; the background color shows instead',\n },\n {\n property: 'position',\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'elements fall back into normal flow',\n },\n {\n property: 'display',\n valuePattern: /^(inline-)?(flex|grid)\\b/i,\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'modern layout falls back to block flow — use spongy inline-block columns instead',\n },\n {\n property: 'float',\n ignoredBy: ['outlook-desktop'],\n note: 'content stacks instead of wrapping around',\n },\n {\n property: 'opacity',\n ignoredBy: ['outlook-desktop'],\n note: 'renders fully opaque',\n },\n {\n property: 'box-shadow',\n ignoredBy: ['outlook-desktop'],\n note: 'shadows simply vanish',\n },\n {\n property: 'transform',\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'renders untransformed in place',\n },\n {\n property: 'animation',\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'nothing animates; the first frame is the email',\n },\n {\n property: 'font',\n ignoredBy: ['outlook-desktop'],\n note: 'the Word engine misreads the shorthand — set font-size and font-family separately',\n },\n {\n property: 'line-height',\n ignoredBy: ['outlook-desktop'],\n note: 'the Word engine may substitute its own unless mso-line-height-rule is set',\n },\n];\n\n/** Issues that apply to a concrete declaration on a concrete tag. */\nexport function findCssIssues(property: string, value: string, tag: string): CssSupportIssue[] {\n return CSS_SUPPORT.filter(\n (issue) =>\n issue.property === property &&\n (!issue.valuePattern || issue.valuePattern.test(value)) &&\n (!issue.onTags || issue.onTags.includes(tag)),\n );\n}\n\n/** Attributes worth suggesting per email-safe tag; `'*'` applies to all.\n The schema knows what is legal — autocomplete offers only that. */\nexport const EMAIL_TAG_ATTRIBUTES: Record<string, string[]> = {\n '*': ['style', 'title'],\n a: ['href', 'target', 'rel'],\n img: ['src', 'alt', 'width'],\n};\n\n/** Style properties safe enough to *suggest*. Anything here that still has\n a CSS_SUPPORT entry (max-width, padding) is legitimate but situational —\n the lint explains the situation when it applies. */\nexport const EMAIL_SAFE_STYLE_PROPERTIES: string[] = [\n 'background-color',\n 'border',\n 'color',\n 'font-family',\n 'font-size',\n 'font-style',\n 'font-weight',\n 'height',\n 'letter-spacing',\n 'margin-left',\n 'max-width',\n 'padding',\n 'text-align',\n 'text-decoration',\n 'width',\n];\n\n/** Gmail clips messages above ~102 KB — the recipient sees a truncated email\n with a \"[View entire message]\" link, and tracking of anything below the\n clip is lost. The hardest size constraint in email. */\nexport const GMAIL_CLIP_BYTES = 102 * 1024;\n\nexport interface SizeBudget {\n bytes: number;\n limit: number;\n level: 'ok' | 'warning' | 'error';\n}\n\n/** UTF-8 size of the canonical HTML against the Gmail clipping limit;\n warning from 80% of the budget, error above it. */\nexport function emailSizeBudget(html: string): SizeBudget {\n const bytes = new TextEncoder().encode(html).length;\n const level =\n bytes > GMAIL_CLIP_BYTES ? 'error' : bytes > GMAIL_CLIP_BYTES * 0.8 ? 'warning' : 'ok';\n return { bytes, limit: GMAIL_CLIP_BYTES, level };\n}\n","/** Whether the HTML is a whole document — its own `<!doctype>`, `<html>`,\n `<head>` or `<body>` — rather than a fragment (a message body). */\nexport function hasDocumentEnvelope(html: string): boolean {\n return /<(?:!doctype|html|head|body)(?=[\\s>/])/i.test(html);\n}\n","/**\n * A style attribute read as its own text — never through the CSSOM, which\n * engines read differently (a server's DOM most of all).\n */\n\nexport interface Declaration {\n name: string;\n value: string;\n important: boolean;\n}\n\n/** A style attribute's declarations: split on `;` outside parentheses and\n quotes (a `url(data:…;base64,…)` holds one), names lower-cased,\n `!important` lifted off the value. Empty and nameless parts dropped. */\nexport function parseDeclarations(style: string): Declaration[] {\n const declarations: Declaration[] = [];\n for (const text of splitDeclarations(style)) {\n const colon = text.indexOf(':');\n if (colon < 0) continue;\n const name = text.slice(0, colon).trim().toLowerCase();\n let value = text.slice(colon + 1).trim();\n const important = /!\\s*important$/i.test(value);\n if (important) value = value.replace(/!\\s*important$/i, '').trim();\n if (!name || !value) continue;\n declarations.push({ name, value, important });\n }\n return declarations;\n}\n\nfunction splitDeclarations(style: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let quote: string | null = null;\n let start = 0;\n for (let i = 0; i < style.length; i++) {\n const ch = style[i];\n if (quote) {\n if (ch === quote && style[i - 1] !== '\\\\') quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\") quote = ch;\n else if (ch === '(') depth++;\n else if (ch === ')') depth = Math.max(0, depth - 1);\n else if (ch === ';' && depth === 0) {\n parts.push(style.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(style.slice(start));\n return parts.map((part) => part.trim()).filter(Boolean);\n}\n","import { parseDeclarations } from './style-text';\n\n/*\n * The email as sent: what a fragment (the editor's canonical HTML) becomes\n * in the body of the sent document — and so what Dawn and the client\n * simulations draw of a fragment, so a preview is the email.\n */\n\n/**\n * The class a stacking column carries in the sent email — the hook of the\n * one rule the email document's head holds ({@link STACK_RULE}): on a phone\n * a stacked column takes the whole width instead of its desktop cap. Where\n * a client drops the head, the column keeps its cap: narrower, still whole.\n * The editor's HTML never carries it ({@link markStackingColumns} adds it\n * at send), so the canonical form stays class-free.\n */\nexport const STACK_CLASS = 'aee-stack';\n\n/** The phone rule for {@link STACK_CLASS} — MJML's breakpoint. */\nexport const STACK_RULE =\n `@media only screen and (max-width: 479px) { ` +\n `.${STACK_CLASS} { max-width: 100% !important; } }`;\n\n/** The opening of a stacking column as the editor writes it (its\n `columnStyle`), its layout marker first — a held column's `width` is a\n percentage, and never matches. */\nconst STACKING_COLUMN =\n /<div (?:class=\"([^\"]*)\" )?style=\"display: inline-block; width: 100%; max-width: \\d+px;/g;\n\n/** Canonical HTML with every stacking column carrying {@link STACK_CLASS}\n beside its marker — for the email document only. */\nexport function markStackingColumns(html: string): string {\n return html.replace(STACKING_COLUMN, (open, classes: string | undefined) =>\n classes === undefined\n ? open.replace('<div style=', `<div class=\"${STACK_CLASS}\" style=`)\n : open.replace(`class=\"${classes}\"`, `class=\"${classes} ${STACK_CLASS}\"`),\n );\n}\n\n/** The tags a line of the email is written in — what an image can stand\n alone on. */\nconst LINE_TAGS = new Set(['DIV', 'P', 'TD', 'TH', 'LI', 'H1', 'H2', 'H3', 'H4']);\n\n/** Whether `node` is nothing a reader would see beside an image: blank\n text, a comment. */\nconst isBlank = (node: globalThis.Node): boolean =>\n node.nodeType === 8 || (node.nodeType === 3 && !(node.textContent ?? '').trim());\n\n/** The line `image` stands alone on — itself, or the one link round it, the\n only thing there — or null where it shares its line. */\nfunction soleLineOf(image: HTMLImageElement): HTMLElement | null {\n let box: HTMLElement = image;\n const parent = image.parentElement;\n if (\n parent?.tagName === 'A' &&\n Array.from(parent.childNodes).every((n) => n === image || isBlank(n))\n ) {\n box = parent;\n }\n const line = box.parentElement;\n if (!line || !LINE_TAGS.has(line.tagName)) return null;\n return Array.from(line.childNodes).every((n) => n === box || isBlank(n)) ? line : null;\n}\n\n/** A line's alignment, as a client reads it: its `text-align`, else its\n legacy `align`. */\nfunction alignmentOfLine(line: HTMLElement): string | null {\n const declared = parseDeclarations(line.getAttribute('style') ?? '').filter(\n ({ name }) => name === 'text-align',\n );\n return (declared.at(-1)?.value ?? line.getAttribute('align') ?? '').trim().toLowerCase() || null;\n}\n\n/** Appends declarations to an element's style text — as text, never\n through the CSSOM — leaving the ones it already says alone. */\nfunction addStyle(element: Element, declarations: [name: string, value: string][]): void {\n const style = element.getAttribute('style') ?? '';\n const said = new Set(parseDeclarations(style).map(({ name }) => name));\n const added = declarations.filter(([name]) => !said.has(name)).map(([n, v]) => `${n}: ${v};`);\n if (!added.length) return;\n const base = style.trim();\n element.setAttribute(\n 'style',\n `${base}${base && !base.endsWith(';') ? ';' : ''}${base ? ' ' : ''}${added.join(' ')}`,\n );\n}\n\n/**\n * The images of the email as sent, made what Outlook and the rest draw\n * cleanly — for the email document only; the editor's HTML stays as it is\n * (`emailDocument` runs this, as it adds the columns' stacking class).\n *\n * - **No border**: Outlook draws a link's border round a linked image unless\n * told not to — `border=\"0\"` for its Word engine, `border: 0` for the rest.\n * - **No gap under one alone on its line** (a logo, a banner, a linked\n * picture): an inline image sits on the line's baseline, and the room for\n * the letters' descenders shows under it as a few px of the line's\n * colour. Alone on its line, it is a block instead (`display: block`),\n * kept where the line put it — centred or right by auto margins, the\n * line's `text-align` no longer reaching a block. An image sharing its\n * line with words stays inline: a block would break the line.\n *\n * Idempotent: what an image already says it keeps.\n */\nexport function fitEmailImages(html: string): string {\n if (!/<img\\b/i.test(html)) return html;\n const template = document.createElement('template');\n template.innerHTML = html;\n for (const image of Array.from(template.content.querySelectorAll('img'))) {\n if (!image.hasAttribute('border')) image.setAttribute('border', '0');\n addStyle(image, [['border', '0']]);\n const line = soleLineOf(image);\n if (!line) continue;\n const align = alignmentOfLine(line);\n addStyle(image, [\n ['display', 'block'],\n ...(align === 'center'\n ? ([\n ['margin-left', 'auto'],\n ['margin-right', 'auto'],\n ] as [string, string][])\n : align === 'right'\n ? ([['margin-left', 'auto']] as [string, string][])\n : []),\n ]);\n }\n return template.innerHTML;\n}\n\n/**\n * The editor's canonical HTML as {@link emailDocument} puts it in the body:\n * images first — no border, and no gap under one alone on its line\n * (image.ts) — then the columns' stacking class, by pattern, on the markup\n * as the editor wrote it. The head's {@link STACK_RULE} is what that class\n * hangs on. Anything that draws a fragment as it is sent (client-rendering.ts)\n * takes both, so a preview stacks a phone's columns as the email does.\n */\nexport function sentBody(html: string): string {\n return markStackingColumns(fitEmailImages(html));\n}\n","import { CSS_SUPPORT, EmailClient } from './client-support';\nimport { hasDocumentEnvelope } from './envelope';\nimport { STACK_RULE, sentBody } from './sent';\n\n/** The clients a rendering can be drawn for: the three that matter, and\n that read HTML differently enough to look at one by one. */\nexport type RenderingClient = 'apple-mail' | 'gmail' | 'outlook-desktop';\n\nexport const RENDERING_CLIENTS: readonly RenderingClient[] = [\n 'apple-mail',\n 'gmail',\n 'outlook-desktop',\n];\n\nexport interface ClientRenderingOptions {\n /** Draw the client's dark mode: Apple Mail's dark surface under the\n email's own dark-mode rules, Gmail's and classic Outlook's forced\n inversion. */\n dark?: boolean;\n /** The reading pane: a phone draws the message edge to edge (iOS Mail,\n the Gmail app), a desktop pane keeps a margin round it. Default\n desktop. */\n pane?: 'phone' | 'desktop';\n}\n\n/**\n * The email as a client would draw it — a simulation, in a browser, of what\n * each client keeps of the HTML and what it drops, from the same\n * client-support data the linter reads. Not a screenshot service: what the\n * data says a client ignores is taken out, what only that client reads is\n * put in, and the client's own surface (its default face, size and colours)\n * is laid underneath. The result is a whole document for a sandboxed frame.\n *\n * - **Apple Mail** reads it all: the document as it is, on Apple's surface;\n * in dark mode its `prefers-color-scheme: dark` rules apply, on the dark\n * surface. An email that declares no dark — every email the editor sends\n * — is drawn dark by Dawn instead (`renderDawn`), as the client does.\n * - **Gmail** drops the comments, the form controls (a hamburger's\n * checkbox and label), every `<style>` rule whose selector it cannot\n * match (pseudo-classes, attribute selectors, sibling combinators), and\n * the declarations the data marks as ignored there (position, flex and\n * grid, transforms, animation). It reads no `prefers-color-scheme`,\n * and its dark mode inverts the colours.\n * - **Outlook on Windows** reads what the Word engine reads: the\n * conditional comments meant for it are opened (`[if mso]`, `[if mso |\n * IE]`, `[if gte mso 9]`) and the parts kept from it are taken out\n * (`[if !mso]><!-->` … `<!--<![endif]`); media queries go; the\n * declarations the data marks as ignored go (`max-width`, a padding on\n * anything but a cell, `border-radius`, background images, floats,\n * shadows, and the rest), and an `inline-block` block stacks. VML is left\n * standing — a browser draws none of it, so a picture behind text shows\n * as the colour beneath, which is what an Outlook without VML shows too.\n * Its dark mode (classic Outlook; the new one is Outlook.com's) recolours\n * the message itself, as Gmail's does, onto its own dark surface.\n *\n * Takes a fragment (the editor's canonical HTML) or a whole document (an\n * import as it was pasted): a document keeps its head — its `<style>`,\n * subject to the client — with the client's surface laid before it. A\n * fragment is drawn as `emailDocument` sends it: its body as sent\n * (`sentBody` — the images fitted, the stacking columns marked, under the\n * head's phone rule).\n * Outlook.com's markers (`[data-ogsc]`) are set by none\n * of the three, so their rules never apply here.\n */\nexport function renderForClient(\n html: string,\n client: RenderingClient,\n options: ClientRenderingOptions = {},\n): string {\n const fragment = !hasDocumentEnvelope(html);\n const sent = fragment ? sentBody(html) : html;\n const source = client === 'outlook-desktop' ? openOutlookConditionals(sent) : sent;\n const doc = new DOMParser().parseFromString(source, 'text/html');\n if (fragment) {\n const sheet = doc.createElement('style');\n sheet.textContent = STACK_RULE;\n doc.head.appendChild(sheet);\n }\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = resolveColorScheme(\n dropRules(sheet.textContent ?? '', OUTLOOK_COM_MARKER),\n client === 'apple-mail' && !!options.dark,\n );\n }\n if (client !== 'apple-mail') dropComments(doc);\n if (client === 'gmail') {\n for (const el of Array.from(\n doc.querySelectorAll('input, label, form, button, select, textarea'),\n )) {\n el.replaceWith(...Array.from(el.childNodes));\n }\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = keepGmailRules(sheet.textContent ?? '');\n }\n }\n if (client === 'outlook-desktop') {\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = dropMediaQueries(sheet.textContent ?? '');\n }\n }\n if (client !== 'apple-mail') dropIgnoredDeclarations(doc, client);\n const surface = doc.createElement('style');\n surface.textContent =\n SURFACE[client] +\n (options.pane === 'phone' ? ' body { margin: 0; }' : '') +\n (options.dark ? DARK[client] : '');\n doc.head.insertBefore(surface, doc.head.firstChild);\n const charset = doc.createElement('meta');\n charset.setAttribute('charset', 'utf-8');\n doc.head.insertBefore(charset, doc.head.firstChild);\n return '<!doctype html>' + doc.documentElement.outerHTML;\n}\n\n/** Each client's surface: its reading pane's default face, size and\n colours, under whatever the email says for itself. Light whatever the\n viewer's own scheme is: the frame is the client, not the page round it. */\nconst SURFACE: Record<RenderingClient, string> = {\n 'apple-mail': `\n :root { color-scheme: light !important; }\n body { margin: 16px; background: #ffffff; color: #000000;\n font-family: -apple-system, \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n font-size: 15px; line-height: 1.35; -webkit-text-size-adjust: 100%; }\n `,\n gmail: `\n :root { color-scheme: light !important; }\n body { margin: 16px; background: #ffffff; color: #222222;\n font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.4;\n word-wrap: break-word; }\n `,\n 'outlook-desktop': `\n :root { color-scheme: light !important; }\n body { margin: 16px; background: #ffffff; color: #000000;\n font-family: Calibri, Arial, sans-serif; font-size: 14.67px; line-height: 1.2; }\n /* The Word engine draws no block side by side: a column stacks. */\n div[style*=\"inline-block\"] { display: block !important; width: auto !important; }\n `,\n};\n\n/** Each client's dark mode. Apple Mail turns the surface dark and leaves\n the message's colours to the message — its own dark-mode rules\n included. Gmail inverts the message, keeping the hue. Classic Outlook\n for Windows recolours it too (Litmus' \"full invert\"; it reads no\n dark-mode rule), onto its own #292929: `invert(a)` takes white to\n 1 - a, so a = 1 - 41/255 lands the white page on it, and a picture,\n put through the inversion once more, comes out eased into the page's\n range. */\nconst DARK: Record<RenderingClient, string> = {\n 'apple-mail': `\n :root { color-scheme: dark !important; }\n html { background: #1e1e1e; } body { background: #1e1e1e; color: #ffffff; }\n `,\n gmail: `\n html { filter: invert(1) hue-rotate(180deg); background: #ffffff; }\n img { filter: invert(1) hue-rotate(180deg); }\n `,\n 'outlook-desktop': `\n html { filter: invert(0.8392) hue-rotate(180deg); background: #ffffff; }\n img { filter: invert(1) hue-rotate(180deg); }\n `,\n};\n\n/** Outlook.com's markers: set on a message it darkens, by none of the\n clients drawn here. */\nconst OUTLOOK_COM_MARKER = /\\[data-ogs[bc]\\]/i;\n\n/** The stylesheet without the rules whose selector `marker` matches. */\nfunction dropRules(css: string, marker: RegExp): string {\n return marker.test(css) ? rewriteRules(css, (selector) => !marker.test(selector)) : css;\n}\n\n/** `prefers-color-scheme` answered for the frame: `dark` true where the\n client is drawn dark and reads the query (Apple Mail), false everywhere\n else — a client that reads no such query never matches it, whatever\n the viewer's own scheme. */\nexport function resolveColorScheme(css: string, dark: boolean): string {\n return css.replace(/\\(\\s*prefers-color-scheme\\s*:\\s*(dark|light)\\s*\\)/gi, (_, scheme: string) =>\n (scheme.toLowerCase() === 'dark') === dark ? '(min-width: 0px)' : '(max-width: -1px)',\n );\n}\n\n/** The Word engine reads what the conditional comments keep for it, and\n not what they keep from it. */\nfunction openOutlookConditionals(html: string): string {\n return (\n html\n // `<!--[if !mso]><!-->` … `<!--<![endif]-->`: for everyone but Outlook.\n .replace(/<!--\\[if\\s+!mso\\]><!-->[\\s\\S]*?<!--<!\\[endif\\]-->/gi, '')\n // `<!--[if mso]>` … `<![endif]-->` (and `mso | IE`, `gte mso 9`): Outlook's own.\n .replace(\n /<!--\\[if\\s+(?:gte\\s+|lte\\s+|gt\\s+|lt\\s+)?mso(?:\\s*\\|\\s*IE)?[^\\]]*\\]>([\\s\\S]*?)<!\\[endif\\]-->/gi,\n '$1',\n )\n );\n}\n\nfunction dropComments(doc: Document): void {\n const walker = doc.createTreeWalker(doc, NodeFilter.SHOW_COMMENT);\n const comments: Node[] = [];\n while (walker.nextNode()) comments.push(walker.currentNode);\n for (const comment of comments) comment.parentNode?.removeChild(comment);\n}\n\n/** Gmail keeps a rule whose selector it can match — elements, classes,\n ids, descendants — and drops one with a pseudo-class, an attribute\n selector or a sibling combinator; media queries it keeps. */\nexport function keepGmailRules(css: string): string {\n return rewriteRules(css, (selector) => !/[:\\[~+]/.test(selector));\n}\n\n/** The Word engine reads no media query. */\nexport function dropMediaQueries(css: string): string {\n let out = '';\n let i = 0;\n while (i < css.length) {\n const at = css.indexOf('@media', i);\n if (at < 0) {\n out += css.slice(i);\n break;\n }\n out += css.slice(i, at);\n const open = css.indexOf('{', at);\n if (open < 0) break;\n i = matchingBrace(css, open) + 1;\n }\n return out;\n}\n\n/** The stylesheet with only the rules `keep` says yes to, inside media\n queries too. */\nfunction rewriteRules(css: string, keep: (selector: string) => boolean): string {\n let out = '';\n let i = 0;\n while (i < css.length) {\n const open = css.indexOf('{', i);\n if (open < 0) break;\n const head = css.slice(i, open).trim();\n const close = matchingBrace(css, open);\n if (close < 0) break;\n const body = css.slice(open + 1, close);\n if (head.startsWith('@media')) {\n out += `${head} {${rewriteRules(body, keep)}}\\n`;\n } else if (head.startsWith('@')) {\n out += `${head} {${body}}\\n`;\n } else {\n const selectors = head\n .split(',')\n .map((s) => s.trim())\n .filter(keep);\n if (selectors.length) out += `${selectors.join(', ')} {${body}}\\n`;\n }\n i = close + 1;\n }\n return out;\n}\n\nfunction matchingBrace(text: string, open: number): number {\n let depth = 0;\n for (let i = open; i < text.length; i++) {\n if (text[i] === '{') depth++;\n else if (text[i] === '}' && --depth === 0) return i;\n }\n return -1;\n}\n\n/** Takes out of every inline style what the data says the client ignores. */\nfunction dropIgnoredDeclarations(doc: Document, client: EmailClient): void {\n for (const el of Array.from(doc.querySelectorAll<HTMLElement>('[style]'))) {\n const tag = el.tagName.toLowerCase();\n const kept = (el.getAttribute('style') ?? '')\n .split(';')\n .map((declaration) => declaration.trim())\n .filter(Boolean)\n .filter((declaration) => {\n const colon = declaration.indexOf(':');\n if (colon < 0) return true;\n const property = declaration.slice(0, colon).trim().toLowerCase();\n const value = declaration.slice(colon + 1).trim();\n return !CSS_SUPPORT.some(\n (issue) =>\n issue.property === property &&\n issue.ignoredBy.includes(client) &&\n (!issue.valuePattern || issue.valuePattern.test(value)) &&\n (!issue.onTags || issue.onTags.includes(tag)),\n );\n });\n if (kept.length) el.setAttribute('style', kept.join('; ') + ';');\n else el.removeAttribute('style');\n }\n}\n","import { renderForClient } from './client-rendering';\nimport { DawnScheme } from './color';\nimport { dawnDarkDocument, dawnSurfaceRules, declaresDark } from './css';\n\nexport interface DawnRenderOptions {\n /** Light or dark paper. */\n readonly scheme: DawnScheme;\n /** The reading pane: a phone draws the message edge to edge, a desktop\n pane keeps a margin round it. Default desktop. */\n readonly pane?: 'phone' | 'desktop';\n}\n\n/**\n * An email as Dawn draws it to be read — the one drawing of every view of\n * a message: a reading pane, a thumbnail, a bench. Takes a fragment (a\n * message body) or a whole document; returns a document for a sandboxed\n * frame.\n *\n * Drawn as the library's WebKit client draws it (`renderForClient`'s\n * `apple-mail`). Dark is drawn here, never written into an email. In dark, a\n * message that declares dark keeps its own rules on the dark surface; any\n * other has every colour it paints drawn dark (`dawnDarkDocument`), its\n * pictures as they are, and lies on the dark surface with Dawn's ink and\n * links — laid right after the client's surface, under the message's own\n * rules.\n */\nexport function renderDawn(html: string, { scheme, pane }: DawnRenderOptions): string {\n const client = { pane } as const;\n if (scheme === 'light') return renderForClient(html, 'apple-mail', client);\n const message = new DOMParser().parseFromString(html, 'text/html');\n if (declaresDark(message)) return renderForClient(html, 'apple-mail', { ...client, dark: true });\n dawnDarkDocument(message);\n const drawn = renderForClient(\n '<!doctype html>' + message.documentElement.outerHTML,\n 'apple-mail',\n client,\n );\n const doc = new DOMParser().parseFromString(drawn, 'text/html');\n const surface = doc.head.querySelector('style');\n const sheet = doc.createElement('style');\n sheet.textContent = dawnSurfaceRules('dark');\n doc.head.insertBefore(sheet, surface ? surface.nextSibling : doc.head.firstChild);\n return '<!doctype html>' + doc.documentElement.outerHTML;\n}\n","import { hasDocumentEnvelope } from './envelope';\nimport { parseDeclarations } from './style-text';\n\n/** The narrowest column that is a layout's, px: a card is 480px and up (600\n is the norm), a signature or a logo rarely is. */\nconst COLUMN = 480;\n\n/**\n * Whether an email lays itself out, edge to edge, rather than being a\n * letter: text that a reader sets in from the frame's sides. An email lays\n * itself out when it sets a column of its own — any part of it 480px wide\n * or more (`width`, `min-width` or `max-width`, in px: a fixed 600px card,\n * a centred `max-width` wrapper) — or when its body is wrapped whole in one\n * full-width table, a page. Such an email centres its column on its own\n * fill; an inset round it only squeezes the column, and scrolls it sideways\n * where it no longer fits.\n *\n * Asked of the body, a fragment's or a whole document's alike: how a client\n * packed the message (Outlook, Apple Mail and Thunderbird send even a\n * two-line letter as a whole document) says nothing of how it is laid out.\n * A quote (`<blockquote>`) is someone else's email, not this one's layout,\n * and an image is a figure in the text, however wide.\n */\nexport function laysItselfOut(html: string): boolean {\n const body = new DOMParser().parseFromString(\n hasDocumentEnvelope(html) ? html : `<body>${html}`,\n 'text/html',\n ).body;\n return isPage(body) || Array.from(body.querySelectorAll<HTMLElement>('*')).some(setsAColumn);\n}\n\n/** A body wrapped whole in one full-width table: the editor's page\n (`aee-layout-page`), or one written by hand round its card. */\nfunction isPage(body: HTMLElement): boolean {\n const [page, ...rest] = Array.from(body.children);\n if (!(page instanceof HTMLTableElement) || rest.length) return false;\n if ((body.textContent ?? '').trim() !== (page.textContent ?? '').trim()) return false;\n return page.getAttribute('width')?.trim() === '100%' || styleOf(page).get('width') === '100%';\n}\n\nfunction setsAColumn(element: HTMLElement): boolean {\n if (element instanceof HTMLImageElement || element.closest('blockquote')) return false;\n const style = styleOf(element);\n return [\n element.getAttribute('width'),\n ...['width', 'min-width', 'max-width'].map((name) => style.get(name)),\n ].some((length) => pixels(length) >= COLUMN);\n}\n\n/** An element's inline style, read off its attribute: a server DOM's\n `style` can lose the whole of it over one declaration it does not know\n (jsdom does, at a `border-radius` after a `background`). */\nfunction styleOf(element: Element): Map<string, string> {\n return new Map(\n parseDeclarations(element.getAttribute('style') ?? '').map(({ name, value }) => [name, value]),\n );\n}\n\n/** A length in px — `600`, `600px` — or NaN: a percentage, or a unit a\n layout is not drawn in (Word measures its letters in pt). */\nfunction pixels(length: string | null | undefined): number {\n const match = /^\\s*(\\d+(?:\\.\\d+)?)(?:px)?\\s*$/i.exec(length ?? '');\n return match ? Number(match[1]) : NaN;\n}\n","/*\n * Public API Surface of @h-k-dev/dawn — the email render engine, with no\n * framework in it: every function needs only a DOM (a browser's, or on a\n * server linkedom / happy-dom / jsdom set as the globals).\n */\n\nexport type { DawnRole, DawnScheme, Rgba } from './lib/color';\nexport {\n DAWN_SURFACE,\n dawnDarkColor,\n invertLightness,\n parseCssColor,\n rgbaToCss,\n rgbaToHex,\n} from './lib/color';\nexport * from './lib/css';\nexport * from './lib/render';\nexport * from './lib/client-rendering';\nexport * from './lib/client-support';\nexport * from './lib/sent';\nexport * from './lib/style-text';\nexport * from './lib/envelope';\nexport * from './lib/layout';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;AAWG;AAKH;AACiC;AAC1B,MAAM,YAAY,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS;AAK/D;AACA,MAAM,KAAK,GAAqC,MAAM,CAAC,WAAW,CAChE,CACE,+FAA+F;IAC/F,8FAA8F;IAC9F,oFAAoF;IACpF,mFAAmF;IACnF,wFAAwF;IACxF,8EAA8E;IAC9E,yEAAyE;IACzE,sFAAsF;IACtF,qFAAqF;IACrF,0FAA0F;IAC1F,2FAA2F;IAC3F,+FAA+F;IAC/F,kFAAkF;IAClF,0EAA0E;IAC1E,kFAAkF;IAClF,+EAA+E;IAC/E,uFAAuF;IACvF,yEAAyE;IACzE,oFAAoF;IACpF,wEAAwE;IACxE,qFAAqF;IACrF,8FAA8F;IAC9F,qFAAqF;IACrF,+EAA+E;IAC/E,uFAAuF;IACvF,uFAAuF;IACvF,8FAA8F;IAC9F,gFAAgF;IAChF,0FAA0F;IAC1F,2FAA2F;AAC3F,IAAA,oBAAoB;KAEnB,KAAK,CAAC,GAA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,SAAS,MAAM,CAAC,MAAiC,EAAA;IAC/C,MAAM,KAAK,GAAG,iCAAiC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;AAClE,IAAA,OAAO,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;AACvC;;AC/DA;;;;AAIG;;ACJH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"h-k-dev-dawn.mjs","sources":["../../../projects/dawn/src/lib/color.ts","../../../projects/dawn/src/lib/css.ts","../../../projects/dawn/src/lib/client-support.ts","../../../projects/dawn/src/lib/envelope.ts","../../../projects/dawn/src/lib/style-text.ts","../../../projects/dawn/src/lib/sent.ts","../../../projects/dawn/src/lib/client-rendering.ts","../../../projects/dawn/src/lib/render.ts","../../../projects/dawn/src/lib/layout.ts","../../../projects/dawn/src/public-api.ts","../../../projects/dawn/src/h-k-dev-dawn.ts"],"sourcesContent":["/**\n * Dawn's colours: reading every colour CSS writes, and drawing one dark.\n *\n * Dawn draws a colour dark as a WebKit-based mail client does, with\n * WebKit's invert-lightness filter (`InvertLightnessFilterOperation::\n * transformColor`, Source/WebCore/platform/graphics/filters/\n * FilterOperation.cpp, safari-7614-branch): the hue turned half a turn in\n * HSL, then a 5×3 colour matrix. White comes out #333333, black white, a\n * hue stays its hue. Its constants are WebKit's, used under WebKit's BSD\n * licence (Copyright © Apple Inc.). Dawn is our own code; it is not made,\n * approved or endorsed by Apple.\n */\n\n/** An sRGB colour, components 0–1. */\nexport type Rgba = readonly [r: number, g: number, b: number, a: number];\n\n/** The surfaces a message lies on: the light reading pane, and the dark one\n — the editor's papers too. */\nexport const DAWN_SURFACE = { light: '#ffffff', dark: '#1e1e1e' } as const;\n\n/** Light or dark: the paper an email is drawn on. */\nexport type DawnScheme = keyof typeof DAWN_SURFACE;\n\n/** The CSS named colours, as rrggbb. */\nconst NAMED: Readonly<Record<string, string>> = Object.fromEntries(\n (\n 'aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,' +\n 'bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,' +\n 'burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,' +\n 'cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,' +\n 'darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkgrey:a9a9a9,' +\n 'darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,' +\n 'darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,' +\n 'darkslateblue:483d8b,darkslategray:2f4f4f,darkslategrey:2f4f4f,darkturquoise:00ced1,' +\n 'darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dimgrey:696969,' +\n 'dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,' +\n 'gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,' +\n 'greenyellow:adff2f,grey:808080,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,' +\n 'ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,' +\n 'lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,' +\n 'lightgoldenrodyellow:fafad2,lightgray:d3d3d3,lightgreen:90ee90,lightgrey:d3d3d3,' +\n 'lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,' +\n 'lightslategray:778899,lightslategrey:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,' +\n 'lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,' +\n 'mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370db,' +\n 'mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,' +\n 'mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,' +\n 'mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,' +\n 'olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,' +\n 'palegreen:98fb98,paleturquoise:afeeee,palevioletred:db7093,papayawhip:ffefd5,' +\n 'peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,' +\n 'rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,' +\n 'salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,' +\n 'skyblue:87ceeb,slateblue:6a5acd,slategray:708090,slategrey:708090,snow:fffafa,' +\n 'springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,' +\n 'turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,' +\n 'yellowgreen:9acd32'\n )\n .split(',')\n .map((pair) => pair.split(':') as [string, string]),\n);\n\nconst HEX_TOKEN = '#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3,4})(?![0-9a-z_-])';\nconst FUNCTION_TOKEN = '(?:rgba?|hsla?)\\\\([^()]*\\\\)';\nconst NAME_TOKEN = `\\\\b(?:${Object.keys(NAMED).join('|')})\\\\b`;\n\n/** In a colour-painting value: a `url(…)` (kept as it is) or a colour. */\nexport const VALUE_TOKEN = new RegExp(\n `url\\\\([^)]*\\\\)|${HEX_TOKEN}|${FUNCTION_TOKEN}|${NAME_TOKEN}`,\n 'gi',\n);\n\nconst clamp = (value: number): number => Math.min(1, Math.max(0, value));\n\n/** A number of a colour function: plain, or a percentage of `full`. */\nfunction component(text: string, full: number): number {\n const value = parseFloat(text);\n return text.trim().endsWith('%') ? (value / 100) * full : value;\n}\n\nfunction hslToRgb(h: number, s: number, l: number): [number, number, number] {\n const k = (n: number) => (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n const f = (n: number) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));\n return [f(0), f(8), f(4)];\n}\n\n/** A colour token — a name, a hex, `rgb()`/`hsl()` — as an sRGB colour, or\n null where it is none this reads. */\nexport function parseCssColor(token: string): Rgba | null {\n const text = token.trim().toLowerCase();\n const named = NAMED[text];\n if (named) return parseCssColor(`#${named}`);\n if (/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(text)) {\n const hex = text.slice(1);\n const full = hex.length <= 4 ? [...hex].map((c) => c + c).join('') : hex;\n const [r, g, b, a = 255] = (full.match(/../g) ?? []).map((pair) => parseInt(pair, 16));\n return [r / 255, g / 255, b / 255, a / 255];\n }\n const fn = /^(rgba?|hsla?)\\(([^()]*)\\)$/.exec(text);\n if (!fn) return null;\n const parts = fn[2].split(/[\\s,/]+/).filter(Boolean);\n if (parts.length < 3) return null;\n const alpha = parts[3] === undefined ? 1 : component(parts[3], 1);\n if (fn[1].startsWith('rgb')) {\n const [r, g, b] = parts.slice(0, 3).map((part) => component(part, 255) / 255);\n return [r, g, b, alpha];\n }\n const [r, g, b] = hslToRgb(parseFloat(parts[0]), component(parts[1], 1), component(parts[2], 1));\n return [r, g, b, alpha];\n}\n\nconst byte = (value: number): number => Math.round(clamp(value) * 255);\n\n/** A colour as CSS: `rgb()`, or `rgba()` where it is not opaque. */\nexport function rgbaToCss([r, g, b, a]: Rgba): string {\n return a >= 1\n ? `rgb(${byte(r)}, ${byte(g)}, ${byte(b)})`\n : `rgba(${byte(r)}, ${byte(g)}, ${byte(b)}, ${Math.round(a * 1000) / 1000})`;\n}\n\n/** A colour as #rrggbb, for the legacy attributes that read no CSS. */\nexport function rgbaToHex([r, g, b]: Rgba): string {\n return `#${[r, g, b].map((c) => byte(c).toString(16).padStart(2, '0')).join('')}`;\n}\n\n// ————————————————————————————————————————————————————— Dawn's colour maths\n\n/** WebKit's `toDarkModeMatrix`: per channel, r, g, b, a and an offset. */\nconst TO_DARK_MODE: readonly (readonly number[])[] = [\n [-0.77, 0.059, -0.089, 0, 1],\n [0.03, -0.741, -0.089, 0, 1],\n [0.03, 0.059, -0.89, 0, 1],\n];\n\n/** WebKit's `hueRotate` helper: to HSL, the hue turned by `amount` of a\n turn, back to RGB. */\nfunction hueRotate([r, g, b, a]: Rgba, amount: number): Rgba {\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n const chroma = max - min;\n const lightness = 0.5 * (max + min);\n const saturation =\n chroma === 0 ? 0 : lightness <= 0.5 ? chroma / (max + min) : chroma / (2 - (max + min));\n let hue = 0;\n if (chroma !== 0) {\n if (max === r) hue = (g - b) / chroma + (g < b ? 6 : 0);\n else if (max === g) hue = (b - r) / chroma + 2;\n else hue = (r - g) / chroma + 4;\n hue /= 6;\n }\n hue = (hue + amount) % 1;\n const temp2 =\n lightness <= 0.5\n ? lightness * (1 + saturation)\n : lightness + saturation - lightness * saturation;\n const temp1 = 2 * lightness - temp2;\n const sixths = hue * 6;\n const channel = (at: number): number => {\n const h = at < 0 ? at + 6 : at >= 6 ? at - 6 : at;\n if (h < 1) return temp1 + (temp2 - temp1) * h;\n if (h < 3) return temp2;\n if (h < 4) return temp1 + (temp2 - temp1) * (4 - h);\n return temp1;\n };\n return [channel(sixths + 2), channel(sixths), channel(sixths - 2), a];\n}\n\n/** The invert-lightness transform on one colour. */\nexport function invertLightness(color: Rgba): Rgba {\n const [r, g, b, a] = hueRotate(color, 0.5);\n const [red, green, blue] = TO_DARK_MODE.map((row) =>\n clamp(row[0] * r + row[1] * g + row[2] * b + row[3] * a + row[4]),\n );\n return [red, green, blue, a];\n}\n\n/** What a colour paints: a `surface` (a background) or `ink` (text). */\nexport type DawnRole = 'surface' | 'ink';\n\n/** How light a colour reads, 0–1 (Rec. 709 weights). */\nconst luma = ([r, g, b]: Rgba): number => 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\n/** One CSS colour token as Dawn draws it dark — the light value in, the\n drawn value out; anything that is no colour (a `url(…)`, a keyword) as\n it was. What a swatch on a dark paper shows.\n\n With a `role`, what is dark already stays as written, as a mail client\n on a phone keeps it: a surface is never drawn lighter (an ink band\n stays ink, and a white logo on it stays readable), ink is never drawn\n darker (white text on that band stays white). Without one — a border,\n a swatch — the colour is always drawn. */\nexport function dawnDarkColor(token: string, role?: DawnRole): string {\n const color = parseCssColor(token);\n if (!color) return token;\n const drawn = invertLightness(color);\n if (role === 'surface' && luma(drawn) >= luma(color)) return token;\n if (role === 'ink' && luma(drawn) <= luma(color)) return token;\n return rgbaToCss(drawn);\n}\n","import {\n DAWN_SURFACE,\n DawnRole,\n DawnScheme,\n VALUE_TOKEN,\n dawnDarkColor,\n parseCssColor,\n rgbaToHex,\n} from './color';\n\n/*\n * Dawn on CSS and HTML: every colour a declaration, a sheet, a legacy\n * attribute or a whole message paints, drawn dark by `dawnDarkColor` — and\n * nothing else touched. A background that is dark already and text that is\n * light already stay as written (`DawnRole`). A border, an outline, a\n * shadow follow the band they lie on (`DawnBand`): as written on a\n * background kept as written, drawn on any other.\n */\n\n/** The properties that paint a colour. */\nconst COLOR_PROPERTY =\n /color|background|border|outline|shadow|fill|stroke|decoration|column-rule|caret|accent/i;\n\n/** The properties that paint text. */\nconst INK_PROPERTY =\n /^(?:color|caret-color|fill|stroke|-webkit-text-(?:fill|stroke)-color|text-(?:decoration|emphasis)(?:-color)?)$/i;\n\n/** What a colour-painting property paints: text, a background, or — a\n border, an outline, a shadow — neither: those follow their band. */\nfunction roleOf(property: string): DawnRole | undefined {\n if (INK_PROPERTY.test(property)) return 'ink';\n return /^background/i.test(property) ? 'surface' : undefined;\n}\n\n/** A background as dark draws it: `kept` as written (dark already) or\n `drawn`. What lies on it follows: a border on a kept band stays as\n written too. */\nexport type DawnBand = 'kept' | 'drawn';\n\n/** The band a declaration block paints — its `background` or\n `background-color`, the last colour said — or null where it paints\n none (no colour, or one mostly clear). */\nexport function dawnBandOf(text: string): DawnBand | null {\n let band: DawnBand | null = null;\n for (const [, property, value] of text.matchAll(/([\\w-]+)\\s*:\\s*([^;]*)/g)) {\n if (!/^background(?:-color)?$/i.test(property)) continue;\n for (const token of value.match(VALUE_TOKEN) ?? []) {\n const color = parseCssColor(token);\n if (!color || color[3] < 0.5) continue;\n band = dawnDarkColor(token, 'surface') === token ? 'kept' : 'drawn';\n }\n }\n return band;\n}\n\n/** One declaration's value with each colour drawn dark; its `url(…)`s as\n they were — and all of it as it was where it follows a kept `band`. */\nfunction darkValue(property: string, value: string, band?: DawnBand | null): string {\n const role = roleOf(property);\n if (!role && band === 'kept') return value;\n return value.replace(VALUE_TOKEN, (token) =>\n token.toLowerCase().startsWith('url(') ? token : dawnDarkColor(token, role),\n );\n}\n\n/** The colour-painting declarations of a block that dark changes, each\n drawn dark, as `[property, value]` — what a sheet laid over the block\n needs (the editor's dark paper). A border on a block that paints no\n band of its own follows the band beneath it, which only the page\n knows: it comes with its `written` value too, to keep on a kept band. */\nexport function dawnDarkDeclarationsOf(\n text: string,\n): [property: string, value: string, written?: string][] {\n const out: [string, string, string?][] = [];\n const own = dawnBandOf(text);\n for (const [, property, value] of text.matchAll(/([\\w-]+)\\s*:\\s*([^;]*)/g)) {\n if (!COLOR_PROPERTY.test(property)) continue;\n const written = value.trim();\n const drawn = darkValue(property, written, own);\n if (drawn === written) continue;\n if (own || roleOf(property)) out.push([property.toLowerCase(), drawn]);\n else out.push([property.toLowerCase(), drawn, written]);\n }\n return out;\n}\n\n/** A declaration block's text with each colour it paints drawn dark — its\n `url(…)`s and every other property untouched. Its borders follow the\n band it paints itself, else the one `beneath` it. */\nexport function dawnDarkDeclarations(text: string, beneath?: DawnBand | null): string {\n const band = dawnBandOf(text) ?? beneath;\n return text.replace(\n /([\\w-]+)(\\s*:\\s*)([^;]*)/g,\n (whole, property: string, colon: string, value: string) =>\n COLOR_PROPERTY.test(property) ? property + colon + darkValue(property, value, band) : whole,\n );\n}\n\n/** A style sheet with each declaration block drawn dark — its selectors and\n at-rules as they were. */\nexport function dawnDarkStyleSheet(text: string): string {\n return text.replace(/\\{([^{}]*)\\}/g, (_, block: string) => `{${dawnDarkDeclarations(block)}}`);\n}\n\n/** The legacy colour attributes HTML email still writes. */\nconst LEGACY_COLOR_ATTRIBUTES: readonly [attribute: string, role?: DawnRole][] = [\n ['bgcolor', 'surface'],\n ['color', 'ink'],\n ['text', 'ink'],\n ['link', 'ink'],\n ['vlink', 'ink'],\n ['alink', 'ink'],\n ['bordercolor'],\n];\n\n/** A legacy attribute's colour drawn dark, as the #rrggbb it must be — null\n where it holds no colour, or one its `role` keeps as written. */\nexport function dawnDarkLegacyColor(value: string, role?: DawnRole): string | null {\n if (!parseCssColor(value)) return null;\n const token = dawnDarkColor(value, role);\n const drawn = parseCssColor(token);\n return drawn && token !== value ? rgbaToHex(drawn) : null;\n}\n\n/** A message drawn dark, in place: every style sheet, every style attribute,\n every legacy colour attribute. Pictures are not touched. */\nexport function dawnDarkDocument(doc: Document): void {\n // The bands first, read off the colours as written: an element's own\n // inline fill, else its `bgcolor`.\n const bands = new Map<Element, DawnBand>();\n for (const element of Array.from(doc.querySelectorAll('[style], [bgcolor]'))) {\n const band =\n dawnBandOf(element.getAttribute('style') ?? '') ??\n dawnBandOf(`background-color: ${element.getAttribute('bgcolor') ?? ''}`);\n if (band) bands.set(element, band);\n }\n /** The nearest band at or above an element. */\n const bandAt = (element: Element | null): DawnBand | null => {\n for (let at = element; at; at = at.parentElement) {\n const band = bands.get(at);\n if (band) return band;\n }\n return null;\n };\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = dawnDarkStyleSheet(sheet.textContent ?? '');\n }\n for (const element of Array.from(doc.querySelectorAll('[style]'))) {\n element.setAttribute(\n 'style',\n dawnDarkDeclarations(element.getAttribute('style') ?? '', bandAt(element.parentElement)),\n );\n }\n for (const [attribute, role] of LEGACY_COLOR_ATTRIBUTES) {\n for (const element of Array.from(doc.querySelectorAll(`[${attribute}]`))) {\n // A border colour on a kept band stays as written, like any border.\n if (!role && bandAt(element) === 'kept') continue;\n const drawn = dawnDarkLegacyColor(element.getAttribute(attribute) ?? '', role);\n if (drawn) element.setAttribute(attribute, drawn);\n }\n }\n}\n\n/** Whether the message says it handles dark itself: a `color-scheme` or\n `supported-color-schemes` naming dark, in a `<meta>` or its CSS. Dawn\n draws such a message with its own dark rules. */\nexport function declaresDark(doc: Document): boolean {\n for (const meta of Array.from(doc.querySelectorAll('meta[name]'))) {\n const name = meta.getAttribute('name')?.toLowerCase();\n if (\n (name === 'color-scheme' || name === 'supported-color-schemes') &&\n /\\bdark\\b/i.test(meta.getAttribute('content') ?? '')\n ) {\n return true;\n }\n }\n return Array.from(doc.querySelectorAll('style')).some((sheet) =>\n /(?:supported-)?color-schemes?\\s*:[^;}]*\\bdark\\b/i.test(sheet.textContent ?? ''),\n );\n}\n\n/** The surface, and the browser's own colours a message leans on — its ink\n and its links — as Dawn draws them on `scheme`.\n\n The body paints the surface as the root does: a message that clears its\n root (`<html style=\"background-color: transparent\">`) would else leave\n the frame nothing painted at all, and a frame on another scheme than the\n page round it is then filled by the browser — white, under Dawn's light\n ink. */\nexport function dawnSurfaceRules(scheme: DawnScheme): string {\n const paint = (token: string) => (scheme === 'dark' ? dawnDarkColor(token) : token);\n return (\n `html { background: ${DAWN_SURFACE[scheme]}; }` +\n ` body { background: ${DAWN_SURFACE[scheme]}; color: ${paint('#000000')}; }` +\n ` :where(a:link) { color: ${paint('#0000ee')}; }` +\n ` :where(a:visited) { color: ${paint('#551a8b')}; }`\n );\n}\n","/**\n * The client-support data module (M3): a curated, versioned subset of what\n * caniemail documents about our floor clients. Pure data + lookups — the\n * lint engine, tooltips and (later) autocomplete all read from here.\n *\n * Curation rule: only entries we are confident about, phrased as what\n * *actually happens* in the client. Accuracy beats coverage.\n */\n\nexport type EmailClient = 'gmail' | 'outlook-desktop' | 'outlook-web' | 'apple-mail' | 'yahoo';\n\nexport const CLIENT_LABELS: Record<EmailClient, string> = {\n gmail: 'Gmail',\n 'outlook-desktop': 'Outlook (Windows)',\n 'outlook-web': 'Outlook.com',\n 'apple-mail': 'Apple Mail',\n yahoo: 'Yahoo Mail',\n};\n\nexport function clientList(clients: EmailClient[]): string {\n return clients.map((client) => CLIENT_LABELS[client]).join(', ');\n}\n\nexport interface CssSupportIssue {\n /** Lower-cased CSS property this entry describes. */\n property: string;\n /** Restrict to matching values (e.g. display:flex, background:url(…)). */\n valuePattern?: RegExp;\n /** Restrict to these tags (e.g. padding is fine on table cells). */\n onTags?: string[];\n /** Clients where the declaration does not do what it says. */\n ignoredBy: EmailClient[];\n /** What actually happens — this is the tooltip. */\n note: string;\n}\n\nexport const CSS_SUPPORT: CssSupportIssue[] = [\n {\n property: 'max-width',\n ignoredBy: ['outlook-desktop'],\n note: 'it sizes from the width attribute instead — pair both (the hybrid) or the cap is lost',\n },\n {\n property: 'padding',\n onTags: ['div', 'p', 'span', 'a'],\n ignoredBy: ['outlook-desktop'],\n note: 'the Word engine only honours padding on table cells — a button gets its size from borders in its background colour instead',\n },\n {\n property: 'display',\n valuePattern: /^inline-block\\b/i,\n ignoredBy: ['outlook-desktop'],\n note: 'renders inline, or stacks — never side by side; the fluid columns pattern (width: 100% + max-width) stacks on purpose there, and a bordered anchor button keeps its box',\n },\n {\n property: 'border-radius',\n ignoredBy: ['outlook-desktop'],\n note: 'corners render square',\n },\n {\n property: 'background-image',\n ignoredBy: ['outlook-desktop'],\n note: 'image backgrounds need VML there; the background color shows instead',\n },\n {\n property: 'background',\n valuePattern: /url\\s*\\(/i,\n ignoredBy: ['outlook-desktop'],\n note: 'image backgrounds need VML there; the background color shows instead',\n },\n {\n property: 'position',\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'elements fall back into normal flow',\n },\n {\n property: 'display',\n valuePattern: /^(inline-)?(flex|grid)\\b/i,\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'modern layout falls back to block flow — use spongy inline-block columns instead',\n },\n {\n property: 'float',\n ignoredBy: ['outlook-desktop'],\n note: 'content stacks instead of wrapping around',\n },\n {\n property: 'opacity',\n ignoredBy: ['outlook-desktop'],\n note: 'renders fully opaque',\n },\n {\n property: 'box-shadow',\n ignoredBy: ['outlook-desktop'],\n note: 'shadows simply vanish',\n },\n {\n property: 'transform',\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'renders untransformed in place',\n },\n {\n property: 'animation',\n ignoredBy: ['outlook-desktop', 'gmail'],\n note: 'nothing animates; the first frame is the email',\n },\n {\n property: 'font',\n ignoredBy: ['outlook-desktop'],\n note: 'the Word engine misreads the shorthand — set font-size and font-family separately',\n },\n {\n property: 'line-height',\n ignoredBy: ['outlook-desktop'],\n note: 'the Word engine may substitute its own unless mso-line-height-rule is set',\n },\n];\n\n/** Issues that apply to a concrete declaration on a concrete tag. */\nexport function findCssIssues(property: string, value: string, tag: string): CssSupportIssue[] {\n return CSS_SUPPORT.filter(\n (issue) =>\n issue.property === property &&\n (!issue.valuePattern || issue.valuePattern.test(value)) &&\n (!issue.onTags || issue.onTags.includes(tag)),\n );\n}\n\n/** Attributes worth suggesting per email-safe tag; `'*'` applies to all.\n The schema knows what is legal — autocomplete offers only that. */\nexport const EMAIL_TAG_ATTRIBUTES: Record<string, string[]> = {\n '*': ['style', 'title'],\n a: ['href', 'target', 'rel'],\n img: ['src', 'alt', 'width'],\n};\n\n/** Style properties safe enough to *suggest*. Anything here that still has\n a CSS_SUPPORT entry (max-width, padding) is legitimate but situational —\n the lint explains the situation when it applies. */\nexport const EMAIL_SAFE_STYLE_PROPERTIES: string[] = [\n 'background-color',\n 'border',\n 'color',\n 'font-family',\n 'font-size',\n 'font-style',\n 'font-weight',\n 'height',\n 'letter-spacing',\n 'margin-left',\n 'max-width',\n 'padding',\n 'text-align',\n 'text-decoration',\n 'width',\n];\n\n/** Gmail clips messages above ~102 KB — the recipient sees a truncated email\n with a \"[View entire message]\" link, and tracking of anything below the\n clip is lost. The hardest size constraint in email. */\nexport const GMAIL_CLIP_BYTES = 102 * 1024;\n\nexport interface SizeBudget {\n bytes: number;\n limit: number;\n level: 'ok' | 'warning' | 'error';\n}\n\n/** UTF-8 size of the canonical HTML against the Gmail clipping limit;\n warning from 80% of the budget, error above it. */\nexport function emailSizeBudget(html: string): SizeBudget {\n const bytes = new TextEncoder().encode(html).length;\n const level =\n bytes > GMAIL_CLIP_BYTES ? 'error' : bytes > GMAIL_CLIP_BYTES * 0.8 ? 'warning' : 'ok';\n return { bytes, limit: GMAIL_CLIP_BYTES, level };\n}\n","/** Whether the HTML is a whole document — its own `<!doctype>`, `<html>`,\n `<head>` or `<body>` — rather than a fragment (a message body). */\nexport function hasDocumentEnvelope(html: string): boolean {\n return /<(?:!doctype|html|head|body)(?=[\\s>/])/i.test(html);\n}\n","/**\n * A style attribute read as its own text — never through the CSSOM, which\n * engines read differently (a server's DOM most of all).\n */\n\nexport interface Declaration {\n name: string;\n value: string;\n important: boolean;\n}\n\n/** A style attribute's declarations: split on `;` outside parentheses and\n quotes (a `url(data:…;base64,…)` holds one), names lower-cased,\n `!important` lifted off the value. Empty and nameless parts dropped. */\nexport function parseDeclarations(style: string): Declaration[] {\n const declarations: Declaration[] = [];\n for (const text of splitDeclarations(style)) {\n const colon = text.indexOf(':');\n if (colon < 0) continue;\n const name = text.slice(0, colon).trim().toLowerCase();\n let value = text.slice(colon + 1).trim();\n const important = /!\\s*important$/i.test(value);\n if (important) value = value.replace(/!\\s*important$/i, '').trim();\n if (!name || !value) continue;\n declarations.push({ name, value, important });\n }\n return declarations;\n}\n\nfunction splitDeclarations(style: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let quote: string | null = null;\n let start = 0;\n for (let i = 0; i < style.length; i++) {\n const ch = style[i];\n if (quote) {\n if (ch === quote && style[i - 1] !== '\\\\') quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\") quote = ch;\n else if (ch === '(') depth++;\n else if (ch === ')') depth = Math.max(0, depth - 1);\n else if (ch === ';' && depth === 0) {\n parts.push(style.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(style.slice(start));\n return parts.map((part) => part.trim()).filter(Boolean);\n}\n","import { parseDeclarations } from './style-text';\n\n/*\n * The email as sent: what a fragment (the editor's canonical HTML) becomes\n * in the body of the sent document — and so what Dawn and the client\n * simulations draw of a fragment, so a preview is the email.\n */\n\n/**\n * The class a stacking column carries in the sent email — the hook of the\n * one rule the email document's head holds ({@link STACK_RULE}): on a phone\n * a stacked column takes the whole width instead of its desktop cap. Where\n * a client drops the head, the column keeps its cap: narrower, still whole.\n * The editor's HTML never carries it ({@link markStackingColumns} adds it\n * at send), so the canonical form stays class-free.\n */\nexport const STACK_CLASS = 'aee-stack';\n\n/** The phone rule for {@link STACK_CLASS} — MJML's breakpoint. */\nexport const STACK_RULE =\n `@media only screen and (max-width: 479px) { ` +\n `.${STACK_CLASS} { max-width: 100% !important; } }`;\n\n/** The opening of a stacking column as the editor writes it (its\n `columnStyle`), its layout marker first — a held column's `width` is a\n percentage, and never matches. */\nconst STACKING_COLUMN =\n /<div (?:class=\"([^\"]*)\" )?style=\"display: inline-block; width: 100%; max-width: \\d+px;/g;\n\n/** Canonical HTML with every stacking column carrying {@link STACK_CLASS}\n beside its marker — for the email document only. */\nexport function markStackingColumns(html: string): string {\n return html.replace(STACKING_COLUMN, (open, classes: string | undefined) =>\n classes === undefined\n ? open.replace('<div style=', `<div class=\"${STACK_CLASS}\" style=`)\n : open.replace(`class=\"${classes}\"`, `class=\"${classes} ${STACK_CLASS}\"`),\n );\n}\n\n/** The tags a line of the email is written in — what an image can stand\n alone on. */\nconst LINE_TAGS = new Set(['DIV', 'P', 'TD', 'TH', 'LI', 'H1', 'H2', 'H3', 'H4']);\n\n/** Whether `node` is nothing a reader would see beside an image: blank\n text, a comment. */\nconst isBlank = (node: globalThis.Node): boolean =>\n node.nodeType === 8 || (node.nodeType === 3 && !(node.textContent ?? '').trim());\n\n/** The line `image` stands alone on — itself, or the one link round it, the\n only thing there — or null where it shares its line. */\nfunction soleLineOf(image: HTMLImageElement): HTMLElement | null {\n let box: HTMLElement = image;\n const parent = image.parentElement;\n if (\n parent?.tagName === 'A' &&\n Array.from(parent.childNodes).every((n) => n === image || isBlank(n))\n ) {\n box = parent;\n }\n const line = box.parentElement;\n if (!line || !LINE_TAGS.has(line.tagName)) return null;\n return Array.from(line.childNodes).every((n) => n === box || isBlank(n)) ? line : null;\n}\n\n/** A line's alignment, as a client reads it: its `text-align`, else its\n legacy `align`. */\nfunction alignmentOfLine(line: HTMLElement): string | null {\n const declared = parseDeclarations(line.getAttribute('style') ?? '').filter(\n ({ name }) => name === 'text-align',\n );\n return (declared.at(-1)?.value ?? line.getAttribute('align') ?? '').trim().toLowerCase() || null;\n}\n\n/** Appends declarations to an element's style text — as text, never\n through the CSSOM — leaving the ones it already says alone. */\nfunction addStyle(element: Element, declarations: [name: string, value: string][]): void {\n const style = element.getAttribute('style') ?? '';\n const said = new Set(parseDeclarations(style).map(({ name }) => name));\n const added = declarations.filter(([name]) => !said.has(name)).map(([n, v]) => `${n}: ${v};`);\n if (!added.length) return;\n const base = style.trim();\n element.setAttribute(\n 'style',\n `${base}${base && !base.endsWith(';') ? ';' : ''}${base ? ' ' : ''}${added.join(' ')}`,\n );\n}\n\n/**\n * The images of the email as sent, made what Outlook and the rest draw\n * cleanly — for the email document only; the editor's HTML stays as it is\n * (`emailDocument` runs this, as it adds the columns' stacking class).\n *\n * - **No border**: Outlook draws a link's border round a linked image unless\n * told not to — `border=\"0\"` for its Word engine, `border: 0` for the rest.\n * - **No gap under one alone on its line** (a logo, a banner, a linked\n * picture): an inline image sits on the line's baseline, and the room for\n * the letters' descenders shows under it as a few px of the line's\n * colour. Alone on its line, it is a block instead (`display: block`),\n * kept where the line put it — centred or right by auto margins, the\n * line's `text-align` no longer reaching a block. An image sharing its\n * line with words stays inline: a block would break the line.\n *\n * Idempotent: what an image already says it keeps.\n */\nexport function fitEmailImages(html: string): string {\n if (!/<img\\b/i.test(html)) return html;\n const template = document.createElement('template');\n template.innerHTML = html;\n for (const image of Array.from(template.content.querySelectorAll('img'))) {\n if (!image.hasAttribute('border')) image.setAttribute('border', '0');\n addStyle(image, [['border', '0']]);\n const line = soleLineOf(image);\n if (!line) continue;\n const align = alignmentOfLine(line);\n addStyle(image, [\n ['display', 'block'],\n ...(align === 'center'\n ? ([\n ['margin-left', 'auto'],\n ['margin-right', 'auto'],\n ] as [string, string][])\n : align === 'right'\n ? ([['margin-left', 'auto']] as [string, string][])\n : []),\n ]);\n }\n return template.innerHTML;\n}\n\n/**\n * The editor's canonical HTML as {@link emailDocument} puts it in the body:\n * images first — no border, and no gap under one alone on its line\n * (image.ts) — then the columns' stacking class, by pattern, on the markup\n * as the editor wrote it. The head's {@link STACK_RULE} is what that class\n * hangs on. Anything that draws a fragment as it is sent (client-rendering.ts)\n * takes both, so a preview stacks a phone's columns as the email does.\n */\nexport function sentBody(html: string): string {\n return markStackingColumns(fitEmailImages(html));\n}\n","import { CSS_SUPPORT, EmailClient } from './client-support';\nimport { hasDocumentEnvelope } from './envelope';\nimport { STACK_RULE, sentBody } from './sent';\n\n/** The clients a rendering can be drawn for: the three that matter, and\n that read HTML differently enough to look at one by one. */\nexport type RenderingClient = 'apple-mail' | 'gmail' | 'outlook-desktop';\n\nexport const RENDERING_CLIENTS: readonly RenderingClient[] = [\n 'apple-mail',\n 'gmail',\n 'outlook-desktop',\n];\n\nexport interface ClientRenderingOptions {\n /** Draw the client's dark mode: Apple Mail's dark surface under the\n email's own dark-mode rules, Gmail's and classic Outlook's forced\n inversion. */\n dark?: boolean;\n /** The reading pane: a phone draws the message edge to edge (iOS Mail,\n the Gmail app), a desktop pane keeps a margin round it. Default\n desktop. */\n pane?: 'phone' | 'desktop';\n}\n\n/**\n * The email as a client would draw it — a simulation, in a browser, of what\n * each client keeps of the HTML and what it drops, from the same\n * client-support data the linter reads. Not a screenshot service: what the\n * data says a client ignores is taken out, what only that client reads is\n * put in, and the client's own surface (its default face, size and colours)\n * is laid underneath. The result is a whole document for a sandboxed frame.\n *\n * - **Apple Mail** reads it all: the document as it is, on Apple's surface;\n * in dark mode its `prefers-color-scheme: dark` rules apply, on the dark\n * surface. An email that declares no dark — every email the editor sends\n * — is drawn dark by Dawn instead (`renderDawn`), as the client does.\n * - **Gmail** drops the comments, the form controls (a hamburger's\n * checkbox and label), every `<style>` rule whose selector it cannot\n * match (pseudo-classes, attribute selectors, sibling combinators), and\n * the declarations the data marks as ignored there (position, flex and\n * grid, transforms, animation). It reads no `prefers-color-scheme`,\n * and its dark mode inverts the colours.\n * - **Outlook on Windows** reads what the Word engine reads: the\n * conditional comments meant for it are opened (`[if mso]`, `[if mso |\n * IE]`, `[if gte mso 9]`) and the parts kept from it are taken out\n * (`[if !mso]><!-->` … `<!--<![endif]`); media queries go; the\n * declarations the data marks as ignored go (`max-width`, a padding on\n * anything but a cell, `border-radius`, background images, floats,\n * shadows, and the rest), and an `inline-block` block stacks. VML is left\n * standing — a browser draws none of it, so a picture behind text shows\n * as the colour beneath, which is what an Outlook without VML shows too.\n * Its dark mode (classic Outlook; the new one is Outlook.com's) recolours\n * the message itself, as Gmail's does, onto its own dark surface.\n *\n * Takes a fragment (the editor's canonical HTML) or a whole document (an\n * import as it was pasted): a document keeps its head — its `<style>`,\n * subject to the client — with the client's surface laid before it. A\n * fragment is drawn as `emailDocument` sends it: its body as sent\n * (`sentBody` — the images fitted, the stacking columns marked, under the\n * head's phone rule).\n * Outlook.com's markers (`[data-ogsc]`) are set by none\n * of the three, so their rules never apply here.\n */\nexport function renderForClient(\n html: string,\n client: RenderingClient,\n options: ClientRenderingOptions = {},\n): string {\n const fragment = !hasDocumentEnvelope(html);\n const sent = fragment ? sentBody(html) : html;\n const source = client === 'outlook-desktop' ? openOutlookConditionals(sent) : sent;\n const doc = new DOMParser().parseFromString(source, 'text/html');\n if (fragment) {\n const sheet = doc.createElement('style');\n sheet.textContent = STACK_RULE;\n doc.head.appendChild(sheet);\n }\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = resolveColorScheme(\n dropRules(sheet.textContent ?? '', OUTLOOK_COM_MARKER),\n client === 'apple-mail' && !!options.dark,\n );\n }\n if (client !== 'apple-mail') dropComments(doc);\n if (client === 'gmail') {\n for (const el of Array.from(\n doc.querySelectorAll('input, label, form, button, select, textarea'),\n )) {\n el.replaceWith(...Array.from(el.childNodes));\n }\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = keepGmailRules(sheet.textContent ?? '');\n }\n }\n if (client === 'outlook-desktop') {\n for (const sheet of Array.from(doc.querySelectorAll('style'))) {\n sheet.textContent = dropMediaQueries(sheet.textContent ?? '');\n }\n }\n if (client !== 'apple-mail') dropIgnoredDeclarations(doc, client);\n const surface = doc.createElement('style');\n surface.textContent =\n SURFACE[client] +\n (options.pane === 'phone' ? ' body { margin: 0; }' : '') +\n (options.dark ? DARK[client] : '');\n doc.head.insertBefore(surface, doc.head.firstChild);\n const charset = doc.createElement('meta');\n charset.setAttribute('charset', 'utf-8');\n doc.head.insertBefore(charset, doc.head.firstChild);\n return '<!doctype html>' + doc.documentElement.outerHTML;\n}\n\n/** Each client's surface: its reading pane's default face, size and\n colours, under whatever the email says for itself. Light whatever the\n viewer's own scheme is: the frame is the client, not the page round it. */\nconst SURFACE: Record<RenderingClient, string> = {\n 'apple-mail': `\n :root { color-scheme: light !important; }\n body { margin: 16px; background: #ffffff; color: #000000;\n font-family: -apple-system, \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n font-size: 15px; line-height: 1.35; -webkit-text-size-adjust: 100%; }\n `,\n gmail: `\n :root { color-scheme: light !important; }\n body { margin: 16px; background: #ffffff; color: #222222;\n font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.4;\n word-wrap: break-word; }\n `,\n 'outlook-desktop': `\n :root { color-scheme: light !important; }\n body { margin: 16px; background: #ffffff; color: #000000;\n font-family: Calibri, Arial, sans-serif; font-size: 14.67px; line-height: 1.2; }\n /* The Word engine draws no block side by side: a column stacks. */\n div[style*=\"inline-block\"] { display: block !important; width: auto !important; }\n `,\n};\n\n/** Each client's dark mode. Apple Mail turns the surface dark and leaves\n the message's colours to the message — its own dark-mode rules\n included. Gmail inverts the message, keeping the hue. Classic Outlook\n for Windows recolours it too (Litmus' \"full invert\"; it reads no\n dark-mode rule), onto its own #292929: `invert(a)` takes white to\n 1 - a, so a = 1 - 41/255 lands the white page on it, and a picture,\n put through the inversion once more, comes out eased into the page's\n range. */\nconst DARK: Record<RenderingClient, string> = {\n 'apple-mail': `\n :root { color-scheme: dark !important; }\n html { background: #1e1e1e; } body { background: #1e1e1e; color: #ffffff; }\n `,\n gmail: `\n html { filter: invert(1) hue-rotate(180deg); background: #ffffff; }\n img { filter: invert(1) hue-rotate(180deg); }\n `,\n 'outlook-desktop': `\n html { filter: invert(0.8392) hue-rotate(180deg); background: #ffffff; }\n img { filter: invert(1) hue-rotate(180deg); }\n `,\n};\n\n/** Outlook.com's markers: set on a message it darkens, by none of the\n clients drawn here. */\nconst OUTLOOK_COM_MARKER = /\\[data-ogs[bc]\\]/i;\n\n/** The stylesheet without the rules whose selector `marker` matches. */\nfunction dropRules(css: string, marker: RegExp): string {\n return marker.test(css) ? rewriteRules(css, (selector) => !marker.test(selector)) : css;\n}\n\n/** `prefers-color-scheme` answered for the frame: `dark` true where the\n client is drawn dark and reads the query (Apple Mail), false everywhere\n else — a client that reads no such query never matches it, whatever\n the viewer's own scheme. */\nexport function resolveColorScheme(css: string, dark: boolean): string {\n return css.replace(/\\(\\s*prefers-color-scheme\\s*:\\s*(dark|light)\\s*\\)/gi, (_, scheme: string) =>\n (scheme.toLowerCase() === 'dark') === dark ? '(min-width: 0px)' : '(max-width: -1px)',\n );\n}\n\n/** The Word engine reads what the conditional comments keep for it, and\n not what they keep from it. */\nfunction openOutlookConditionals(html: string): string {\n return (\n html\n // `<!--[if !mso]><!-->` … `<!--<![endif]-->`: for everyone but Outlook.\n .replace(/<!--\\[if\\s+!mso\\]><!-->[\\s\\S]*?<!--<!\\[endif\\]-->/gi, '')\n // `<!--[if mso]>` … `<![endif]-->` (and `mso | IE`, `gte mso 9`): Outlook's own.\n .replace(\n /<!--\\[if\\s+(?:gte\\s+|lte\\s+|gt\\s+|lt\\s+)?mso(?:\\s*\\|\\s*IE)?[^\\]]*\\]>([\\s\\S]*?)<!\\[endif\\]-->/gi,\n '$1',\n )\n );\n}\n\nfunction dropComments(doc: Document): void {\n const walker = doc.createTreeWalker(doc, NodeFilter.SHOW_COMMENT);\n const comments: Node[] = [];\n while (walker.nextNode()) comments.push(walker.currentNode);\n for (const comment of comments) comment.parentNode?.removeChild(comment);\n}\n\n/** Gmail keeps a rule whose selector it can match — elements, classes,\n ids, descendants — and drops one with a pseudo-class, an attribute\n selector or a sibling combinator; media queries it keeps. */\nexport function keepGmailRules(css: string): string {\n return rewriteRules(css, (selector) => !/[:\\[~+]/.test(selector));\n}\n\n/** The Word engine reads no media query. */\nexport function dropMediaQueries(css: string): string {\n let out = '';\n let i = 0;\n while (i < css.length) {\n const at = css.indexOf('@media', i);\n if (at < 0) {\n out += css.slice(i);\n break;\n }\n out += css.slice(i, at);\n const open = css.indexOf('{', at);\n if (open < 0) break;\n i = matchingBrace(css, open) + 1;\n }\n return out;\n}\n\n/** The stylesheet with only the rules `keep` says yes to, inside media\n queries too. */\nfunction rewriteRules(css: string, keep: (selector: string) => boolean): string {\n let out = '';\n let i = 0;\n while (i < css.length) {\n const open = css.indexOf('{', i);\n if (open < 0) break;\n const head = css.slice(i, open).trim();\n const close = matchingBrace(css, open);\n if (close < 0) break;\n const body = css.slice(open + 1, close);\n if (head.startsWith('@media')) {\n out += `${head} {${rewriteRules(body, keep)}}\\n`;\n } else if (head.startsWith('@')) {\n out += `${head} {${body}}\\n`;\n } else {\n const selectors = head\n .split(',')\n .map((s) => s.trim())\n .filter(keep);\n if (selectors.length) out += `${selectors.join(', ')} {${body}}\\n`;\n }\n i = close + 1;\n }\n return out;\n}\n\nfunction matchingBrace(text: string, open: number): number {\n let depth = 0;\n for (let i = open; i < text.length; i++) {\n if (text[i] === '{') depth++;\n else if (text[i] === '}' && --depth === 0) return i;\n }\n return -1;\n}\n\n/** Takes out of every inline style what the data says the client ignores. */\nfunction dropIgnoredDeclarations(doc: Document, client: EmailClient): void {\n for (const el of Array.from(doc.querySelectorAll<HTMLElement>('[style]'))) {\n const tag = el.tagName.toLowerCase();\n const kept = (el.getAttribute('style') ?? '')\n .split(';')\n .map((declaration) => declaration.trim())\n .filter(Boolean)\n .filter((declaration) => {\n const colon = declaration.indexOf(':');\n if (colon < 0) return true;\n const property = declaration.slice(0, colon).trim().toLowerCase();\n const value = declaration.slice(colon + 1).trim();\n return !CSS_SUPPORT.some(\n (issue) =>\n issue.property === property &&\n issue.ignoredBy.includes(client) &&\n (!issue.valuePattern || issue.valuePattern.test(value)) &&\n (!issue.onTags || issue.onTags.includes(tag)),\n );\n });\n if (kept.length) el.setAttribute('style', kept.join('; ') + ';');\n else el.removeAttribute('style');\n }\n}\n","import { renderForClient } from './client-rendering';\nimport { DawnScheme } from './color';\nimport { dawnDarkDocument, dawnSurfaceRules, declaresDark } from './css';\n\nexport interface DawnRenderOptions {\n /** Light or dark paper. */\n readonly scheme: DawnScheme;\n /** The reading pane: a phone draws the message edge to edge, a desktop\n pane keeps a margin round it. Default desktop. */\n readonly pane?: 'phone' | 'desktop';\n}\n\n/**\n * An email as Dawn draws it to be read — the one drawing of every view of\n * a message: a reading pane, a thumbnail, a bench. Takes a fragment (a\n * message body) or a whole document; returns a document for a sandboxed\n * frame.\n *\n * Drawn as the library's WebKit client draws it (`renderForClient`'s\n * `apple-mail`). Dark is drawn here, never written into an email. In dark, a\n * message that declares dark keeps its own rules on the dark surface; any\n * other has every colour it paints drawn dark (`dawnDarkDocument`), its\n * pictures as they are, and lies on the dark surface with Dawn's ink and\n * links — laid right after the client's surface, under the message's own\n * rules.\n */\nexport function renderDawn(html: string, { scheme, pane }: DawnRenderOptions): string {\n const client = { pane } as const;\n if (scheme === 'light') return renderForClient(html, 'apple-mail', client);\n const message = new DOMParser().parseFromString(html, 'text/html');\n if (declaresDark(message)) return renderForClient(html, 'apple-mail', { ...client, dark: true });\n dawnDarkDocument(message);\n const drawn = renderForClient(\n '<!doctype html>' + message.documentElement.outerHTML,\n 'apple-mail',\n client,\n );\n const doc = new DOMParser().parseFromString(drawn, 'text/html');\n const surface = doc.head.querySelector('style');\n const sheet = doc.createElement('style');\n sheet.textContent = dawnSurfaceRules('dark');\n doc.head.insertBefore(sheet, surface ? surface.nextSibling : doc.head.firstChild);\n return '<!doctype html>' + doc.documentElement.outerHTML;\n}\n","import { hasDocumentEnvelope } from './envelope';\nimport { parseDeclarations } from './style-text';\n\n/** The narrowest column that is a layout's, px: a card is 480px and up (600\n is the norm), a signature or a logo rarely is. */\nconst COLUMN = 480;\n\n/**\n * Whether an email lays itself out, edge to edge, rather than being a\n * letter: text that a reader sets in from the frame's sides. An email lays\n * itself out when it sets a column of its own — any part of it 480px wide\n * or more (`width`, `min-width` or `max-width`, in px: a fixed 600px card,\n * a centred `max-width` wrapper) — or when its body is wrapped whole in one\n * full-width table, a page. Such an email centres its column on its own\n * fill; an inset round it only squeezes the column, and scrolls it sideways\n * where it no longer fits.\n *\n * Asked of the body, a fragment's or a whole document's alike: how a client\n * packed the message (Outlook, Apple Mail and Thunderbird send even a\n * two-line letter as a whole document) says nothing of how it is laid out.\n * A quote (`<blockquote>`) is someone else's email, not this one's layout,\n * and an image is a figure in the text, however wide.\n */\nexport function laysItselfOut(html: string): boolean {\n const body = new DOMParser().parseFromString(\n hasDocumentEnvelope(html) ? html : `<body>${html}`,\n 'text/html',\n ).body;\n return isPage(body) || Array.from(body.querySelectorAll<HTMLElement>('*')).some(setsAColumn);\n}\n\n/** A body wrapped whole in one full-width table: the editor's page\n (`aee-layout-page`), or one written by hand round its card. */\nfunction isPage(body: HTMLElement): boolean {\n const [page, ...rest] = Array.from(body.children);\n if (!(page instanceof HTMLTableElement) || rest.length) return false;\n if ((body.textContent ?? '').trim() !== (page.textContent ?? '').trim()) return false;\n return page.getAttribute('width')?.trim() === '100%' || styleOf(page).get('width') === '100%';\n}\n\nfunction setsAColumn(element: HTMLElement): boolean {\n if (element instanceof HTMLImageElement || element.closest('blockquote')) return false;\n const style = styleOf(element);\n return [\n element.getAttribute('width'),\n ...['width', 'min-width', 'max-width'].map((name) => style.get(name)),\n ].some((length) => pixels(length) >= COLUMN);\n}\n\n/** An element's inline style, read off its attribute: a server DOM's\n `style` can lose the whole of it over one declaration it does not know\n (jsdom does, at a `border-radius` after a `background`). */\nfunction styleOf(element: Element): Map<string, string> {\n return new Map(\n parseDeclarations(element.getAttribute('style') ?? '').map(({ name, value }) => [name, value]),\n );\n}\n\n/** A length in px — `600`, `600px` — or NaN: a percentage, or a unit a\n layout is not drawn in (Word measures its letters in pt). */\nfunction pixels(length: string | null | undefined): number {\n const match = /^\\s*(\\d+(?:\\.\\d+)?)(?:px)?\\s*$/i.exec(length ?? '');\n return match ? Number(match[1]) : NaN;\n}\n","/*\n * Public API Surface of @h-k-dev/dawn — the email render engine, with no\n * framework in it: every function needs only a DOM (a browser's, or on a\n * server linkedom / happy-dom / jsdom set as the globals).\n */\n\nexport type { DawnRole, DawnScheme, Rgba } from './lib/color';\nexport {\n DAWN_SURFACE,\n dawnDarkColor,\n invertLightness,\n parseCssColor,\n rgbaToCss,\n rgbaToHex,\n} from './lib/color';\nexport * from './lib/css';\nexport * from './lib/render';\nexport * from './lib/client-rendering';\nexport * from './lib/client-support';\nexport * from './lib/sent';\nexport * from './lib/style-text';\nexport * from './lib/envelope';\nexport * from './lib/layout';\n","/**\n * Generated bundle index. Do not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IACvC,IAAI,OAAO,YAAY,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;AAAE,QAAA,OAAO,KAAK;AACtF,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAC9B,OAAO;AACL,QAAA,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC;QAC7B,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtE,KAAA,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;AAC9C;AAEA;;AAE+D;AAC/D,SAAS,OAAO,CAAC,OAAgB,EAAA;AAC/B,IAAA,OAAO,IAAI,GAAG,CACZ,iBAAiB,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAC/F;AACH;AAEA;AACgE;AAChE,SAAS,MAAM,CAAC,MAAiC,EAAA;IAC/C,MAAM,KAAK,GAAG,iCAAiC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;AAClE,IAAA,OAAO,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;AACvC;;AC/DA;;;;AAIG;;ACJH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-k-dev/dawn",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Dawn, the email render engine: an email drawn as a mail client draws it, light and dark — framework-free, for the browser and the server.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "h-k-dev",
|
package/types/h-k-dev-dawn.d.ts
CHANGED
|
@@ -74,7 +74,13 @@ declare function dawnDarkDocument(doc: Document): void;
|
|
|
74
74
|
draws such a message with its own dark rules. */
|
|
75
75
|
declare function declaresDark(doc: Document): boolean;
|
|
76
76
|
/** The surface, and the browser's own colours a message leans on — its ink
|
|
77
|
-
and its links — as Dawn draws them on `scheme`.
|
|
77
|
+
and its links — as Dawn draws them on `scheme`.
|
|
78
|
+
|
|
79
|
+
The body paints the surface as the root does: a message that clears its
|
|
80
|
+
root (`<html style="background-color: transparent">`) would else leave
|
|
81
|
+
the frame nothing painted at all, and a frame on another scheme than the
|
|
82
|
+
page round it is then filled by the browser — white, under Dawn's light
|
|
83
|
+
ink. */
|
|
78
84
|
declare function dawnSurfaceRules(scheme: DawnScheme): string;
|
|
79
85
|
|
|
80
86
|
interface DawnRenderOptions {
|