@zyther/tzmail 0.1.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +411 -78
- package/dist/core/enums/theme.enum.d.ts +11 -1
- package/dist/core/enums/theme.enum.d.ts.map +1 -1
- package/dist/core/enums/theme.enum.js +10 -0
- package/dist/core/interfaces/email.interface.d.ts +95 -5
- package/dist/core/interfaces/email.interface.d.ts.map +1 -1
- package/dist/core/interfaces/template.interface.d.ts +12 -1
- package/dist/core/interfaces/template.interface.d.ts.map +1 -1
- package/dist/factories/email-factory.d.ts +32 -6
- package/dist/factories/email-factory.d.ts.map +1 -1
- package/dist/factories/email-factory.js +110 -6
- package/dist/factories/template-factory.d.ts.map +1 -1
- package/dist/factories/template-factory.js +170 -60
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/providers/mailgun.transport.d.ts +10 -0
- package/dist/providers/mailgun.transport.d.ts.map +1 -0
- package/dist/providers/mailgun.transport.js +85 -0
- package/dist/providers/nodemailer.transport.d.ts +11 -0
- package/dist/providers/nodemailer.transport.d.ts.map +1 -0
- package/dist/providers/nodemailer.transport.js +23 -0
- package/dist/providers/provider-utils.d.ts +17 -0
- package/dist/providers/provider-utils.d.ts.map +1 -0
- package/dist/providers/provider-utils.js +89 -0
- package/dist/providers/provider.interface.d.ts +30 -0
- package/dist/providers/provider.interface.d.ts.map +1 -0
- package/dist/providers/provider.interface.js +2 -0
- package/dist/providers/sendgrid.transport.d.ts +10 -0
- package/dist/providers/sendgrid.transport.d.ts.map +1 -0
- package/dist/providers/sendgrid.transport.js +76 -0
- package/dist/queues/bullmq-email-queue.d.ts +153 -0
- package/dist/queues/bullmq-email-queue.d.ts.map +1 -0
- package/dist/queues/bullmq-email-queue.js +292 -0
- package/dist/services/attachment.service.d.ts +15 -37
- package/dist/services/attachment.service.d.ts.map +1 -1
- package/dist/services/attachment.service.js +58 -46
- package/dist/services/email.service.d.ts +22 -22
- package/dist/services/email.service.d.ts.map +1 -1
- package/dist/services/email.service.js +117 -33
- package/dist/services/template.service.d.ts +24 -111
- package/dist/services/template.service.d.ts.map +1 -1
- package/dist/services/template.service.js +273 -362
- package/dist/templates/base/color-accessibility.d.ts +4 -0
- package/dist/templates/base/color-accessibility.d.ts.map +1 -0
- package/dist/templates/base/color-accessibility.js +38 -0
- package/dist/templates/base/template-builder.d.ts +4 -1
- package/dist/templates/base/template-builder.d.ts.map +1 -1
- package/dist/templates/base/template-builder.js +276 -527
- package/dist/templates/themes/aurora.theme.d.ts +12 -0
- package/dist/templates/themes/aurora.theme.d.ts.map +1 -0
- package/dist/templates/themes/aurora.theme.js +88 -0
- package/dist/templates/themes/corporate.theme.d.ts +2 -1
- package/dist/templates/themes/corporate.theme.d.ts.map +1 -1
- package/dist/templates/themes/corporate.theme.js +139 -102
- package/dist/templates/themes/editorial.theme.d.ts +12 -0
- package/dist/templates/themes/editorial.theme.d.ts.map +1 -0
- package/dist/templates/themes/editorial.theme.js +90 -0
- package/dist/templates/themes/forest.theme.d.ts +12 -0
- package/dist/templates/themes/forest.theme.d.ts.map +1 -0
- package/dist/templates/themes/forest.theme.js +89 -0
- package/dist/templates/themes/glass.theme.d.ts +12 -0
- package/dist/templates/themes/glass.theme.d.ts.map +1 -0
- package/dist/templates/themes/glass.theme.js +88 -0
- package/dist/templates/themes/lavender.theme.d.ts +12 -0
- package/dist/templates/themes/lavender.theme.d.ts.map +1 -0
- package/dist/templates/themes/lavender.theme.js +91 -0
- package/dist/templates/themes/midnight.theme.d.ts +12 -0
- package/dist/templates/themes/midnight.theme.d.ts.map +1 -0
- package/dist/templates/themes/midnight.theme.js +91 -0
- package/dist/templates/themes/minimal.theme.d.ts +2 -1
- package/dist/templates/themes/minimal.theme.d.ts.map +1 -1
- package/dist/templates/themes/minimal.theme.js +142 -107
- package/dist/templates/themes/modern.theme.d.ts +2 -1
- package/dist/templates/themes/modern.theme.d.ts.map +1 -1
- package/dist/templates/themes/modern.theme.js +109 -74
- package/dist/templates/themes/monokai.theme.d.ts +2 -1
- package/dist/templates/themes/monokai.theme.d.ts.map +1 -1
- package/dist/templates/themes/monokai.theme.js +102 -66
- package/dist/templates/themes/neobrutal.theme.d.ts +12 -0
- package/dist/templates/themes/neobrutal.theme.d.ts.map +1 -0
- package/dist/templates/themes/neobrutal.theme.js +91 -0
- package/dist/templates/themes/ocean.theme.d.ts +12 -0
- package/dist/templates/themes/ocean.theme.d.ts.map +1 -0
- package/dist/templates/themes/ocean.theme.js +90 -0
- package/dist/templates/themes/pastel.theme.d.ts +12 -0
- package/dist/templates/themes/pastel.theme.d.ts.map +1 -0
- package/dist/templates/themes/pastel.theme.js +89 -0
- package/dist/templates/themes/sunset.theme.d.ts +12 -0
- package/dist/templates/themes/sunset.theme.d.ts.map +1 -0
- package/dist/templates/themes/sunset.theme.js +90 -0
- package/dist/templates/themes/system.theme.d.ts +2 -1
- package/dist/templates/themes/system.theme.d.ts.map +1 -1
- package/dist/templates/themes/system.theme.js +81 -47
- package/dist/templates/themes/theme.interface.d.ts +48 -0
- package/dist/templates/themes/theme.interface.d.ts.map +1 -1
- package/package.json +36 -14
- package/src/core/enums/template-part.enum.ts +7 -0
- package/src/core/enums/theme.enum.ts +18 -0
- package/src/core/interfaces/email.interface.ts +116 -0
- package/src/core/interfaces/template.interface.ts +71 -0
- package/src/factories/email-factory.ts +208 -0
- package/src/factories/template-factory.ts +201 -0
- package/src/index.ts +53 -0
- package/src/providers/mailgun.transport.ts +80 -0
- package/src/providers/nodemailer.transport.ts +20 -0
- package/src/providers/provider-utils.ts +91 -0
- package/src/providers/provider.interface.ts +26 -0
- package/src/providers/sendgrid.transport.ts +80 -0
- package/src/queues/bullmq-email-queue.ts +418 -0
- package/src/services/attachment.service.ts +98 -0
- package/src/services/email.service.ts +151 -0
- package/src/services/template.service.ts +431 -0
- package/src/templates/base/color-accessibility.ts +31 -0
- package/src/templates/base/template-builder.ts +438 -0
- package/src/templates/themes/aurora.theme.ts +91 -0
- package/src/templates/themes/corporate.theme.ts +156 -0
- package/src/templates/themes/editorial.theme.ts +93 -0
- package/src/templates/themes/forest.theme.ts +92 -0
- package/src/templates/themes/glass.theme.ts +91 -0
- package/src/templates/themes/lavender.theme.ts +94 -0
- package/src/templates/themes/midnight.theme.ts +94 -0
- package/src/templates/themes/minimal.theme.ts +158 -0
- package/src/templates/themes/modern.theme.ts +124 -0
- package/src/templates/themes/monokai.theme.ts +117 -0
- package/src/templates/themes/neobrutal.theme.ts +94 -0
- package/src/templates/themes/ocean.theme.ts +93 -0
- package/src/templates/themes/pastel.theme.ts +92 -0
- package/src/templates/themes/sunset.theme.ts +93 -0
- package/src/templates/themes/system.theme.ts +92 -0
- package/src/templates/themes/theme.interface.ts +95 -0
- package/src/tests/template.service.test.ts +1 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function contrastRatio(foreground: string, background: string): number;
|
|
2
|
+
export declare function accessibleTextColor(background: string): '#000000' | '#ffffff';
|
|
3
|
+
export declare function readableTextColor(preferred: string, background: string, fallback?: string): string;
|
|
4
|
+
//# sourceMappingURL=color-accessibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-accessibility.d.ts","sourceRoot":"","sources":["../../../src/templates/base/color-accessibility.ts"],"names":[],"mappings":"AASA,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAO5E;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAM7E;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAIlG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contrastRatio = contrastRatio;
|
|
4
|
+
exports.accessibleTextColor = accessibleTextColor;
|
|
5
|
+
exports.readableTextColor = readableTextColor;
|
|
6
|
+
function relativeLuminance(color) {
|
|
7
|
+
const hex = color.replace(/^#/, '');
|
|
8
|
+
const normalized = hex.length === 3 ? hex.split('').map(channel => channel + channel).join('') : hex;
|
|
9
|
+
if (!/^[\da-f]{6}$/i.test(normalized))
|
|
10
|
+
return undefined;
|
|
11
|
+
const channels = [0, 2, 4].map(offset => Number.parseInt(normalized.slice(offset, offset + 2), 16) / 255);
|
|
12
|
+
return channels.map(channel => channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4)
|
|
13
|
+
.reduce((sum, channel, index) => sum + channel * [0.2126, 0.7152, 0.0722][index], 0);
|
|
14
|
+
}
|
|
15
|
+
function contrastRatio(foreground, background) {
|
|
16
|
+
const foregroundLuminance = relativeLuminance(foreground);
|
|
17
|
+
const backgroundLuminance = relativeLuminance(background);
|
|
18
|
+
if (foregroundLuminance === undefined || backgroundLuminance === undefined)
|
|
19
|
+
return 0;
|
|
20
|
+
const lighter = Math.max(foregroundLuminance, backgroundLuminance);
|
|
21
|
+
const darker = Math.min(foregroundLuminance, backgroundLuminance);
|
|
22
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
23
|
+
}
|
|
24
|
+
function accessibleTextColor(background) {
|
|
25
|
+
const luminance = relativeLuminance(background);
|
|
26
|
+
if (luminance === undefined)
|
|
27
|
+
return '#ffffff';
|
|
28
|
+
const whiteContrast = 1.05 / (luminance + 0.05);
|
|
29
|
+
const blackContrast = (luminance + 0.05) / 0.05;
|
|
30
|
+
return whiteContrast >= blackContrast ? '#ffffff' : '#000000';
|
|
31
|
+
}
|
|
32
|
+
function readableTextColor(preferred, background, fallback) {
|
|
33
|
+
if (contrastRatio(preferred, background) >= 4.5)
|
|
34
|
+
return preferred;
|
|
35
|
+
if (fallback && contrastRatio(fallback, background) >= 4.5)
|
|
36
|
+
return fallback;
|
|
37
|
+
return accessibleTextColor(background);
|
|
38
|
+
}
|
|
@@ -6,6 +6,8 @@ export declare class TemplateBuilder {
|
|
|
6
6
|
private config;
|
|
7
7
|
private variant;
|
|
8
8
|
constructor(theme: ITheme, config: ITemplateConfig, variant: 'light' | 'dark');
|
|
9
|
+
private get emailStyles();
|
|
10
|
+
buildPreheader(): this;
|
|
9
11
|
buildHeader(content?: string): this;
|
|
10
12
|
private buildLogo;
|
|
11
13
|
buildBody(content: string): this;
|
|
@@ -13,9 +15,10 @@ export declare class TemplateBuilder {
|
|
|
13
15
|
private formatMinimalContent;
|
|
14
16
|
private highlightCode;
|
|
15
17
|
private applySyntaxHighlighting;
|
|
16
|
-
buildButton(text: string, url: string, variant?: 'primary' | 'secondary'): this;
|
|
18
|
+
buildButton(text: string, url: string, variant?: 'primary' | 'secondary' | 'success' | 'danger'): this;
|
|
17
19
|
buildFooter(): this;
|
|
18
20
|
private buildFooterLinks;
|
|
21
|
+
private linkDecorationStyle;
|
|
19
22
|
private buildSocialLinks;
|
|
20
23
|
private getSocialIcon;
|
|
21
24
|
build(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-builder.d.ts","sourceRoot":"","sources":["../../../src/templates/base/template-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"template-builder.d.ts","sourceRoot":"","sources":["../../../src/templates/base/template-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAqD,MAAM,2BAA2B,CAAC;AAoCtG,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAmB;gBAEtB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM;IAM7E,OAAO,KAAK,WAAW,GAEtB;IAED,cAAc,IAAI,IAAI;IAOtB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAoCnC,OAAO,CAAC,SAAS;IA+BjB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAgChC,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,uBAAuB;IAmB/B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAoB,GAAG,IAAI;IAyCjH,WAAW,IAAI,IAAI;IAiDnB,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,gBAAgB;IAgCxB,OAAO,CAAC,aAAa;IAuBrB,KAAK,IAAI,MAAM;CA+DhB"}
|