@cosmicdrift/kumiko-renderer-mail-html 0.413.1 → 0.415.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/dist/chrome-logo.d.ts +2 -0
- package/dist/chrome-logo.js +29 -0
- package/dist/render.js +2 -1
- package/package.json +7 -7
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FileRefTooLargeError, FileStorageUnavailableError, readFileRefContent, } from "@cosmicdrift/kumiko-bundled-features/file-foundation";
|
|
2
|
+
import { isResourceImageContentType, readTemplateResourceMaxBytes, toResourceDataUri, } from "@cosmicdrift/kumiko-bundled-features/template-resolver";
|
|
3
|
+
import { readBrandingLogo, readBrandingLogoUrl } from "./document-kit.js";
|
|
4
|
+
// Pages a recipient opens have no cid attachments, so the uploaded logo travels inline. A
|
|
5
|
+
// logo that cannot be read or embedded falls back to the https address instead of failing
|
|
6
|
+
// the page.
|
|
7
|
+
export async function readChromeLogoSrc(ctx) {
|
|
8
|
+
const fileRefId = await readBrandingLogo(ctx);
|
|
9
|
+
if (fileRefId !== undefined && ctx.filesForTenant !== undefined) {
|
|
10
|
+
try {
|
|
11
|
+
const found = await readFileRefContent({
|
|
12
|
+
db: ctx.db,
|
|
13
|
+
filesForTenant: ctx.filesForTenant,
|
|
14
|
+
fileRefId,
|
|
15
|
+
allowedTenantIds: [ctx.tenantId],
|
|
16
|
+
maxBytes: await readTemplateResourceMaxBytes(ctx.config, ctx.registry),
|
|
17
|
+
});
|
|
18
|
+
if (found !== null && isResourceImageContentType(found.contentType)) {
|
|
19
|
+
return toResourceDataUri(found.contentType, found.content);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
if (!(e instanceof FileRefTooLargeError || e instanceof FileStorageUnavailableError)) {
|
|
24
|
+
throw e;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return readBrandingLogoUrl(ctx);
|
|
29
|
+
}
|
package/dist/render.js
CHANGED
|
@@ -14,6 +14,7 @@ import { collectDocumentResourceKeys, compileDocumentBodyToHandlebars, createTem
|
|
|
14
14
|
import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
|
|
15
15
|
import { convert as htmlToText } from "html-to-text";
|
|
16
16
|
import mjml2html from "mjml";
|
|
17
|
+
import { readChromeLogoSrc } from "./chrome-logo.js";
|
|
17
18
|
import { DEFAULT_MAIL_LAYOUT_SLUG } from "./default-layout.js";
|
|
18
19
|
import { collectRegionResourceKeys, compileDocumentSource, createDocumentHandlebars, LOGO_RESOURCE_KEY, mergeResourceFileRefs, readBrandingAccentColor, readBrandingLogo, readBrandingLogoUrl, readBrandingSiteUrl, readDocumentFormat, readTenantName, resolveResourceFileRefs, } from "./document-kit.js";
|
|
19
20
|
import { buildRenderedPdfAttachments, combineMailAttachments, mergeInheritedAttachments, } from "./mail-attachments.js";
|
|
@@ -477,7 +478,7 @@ export async function readMailChrome(req, ctx, options = {}) {
|
|
|
477
478
|
resolveMailFooter(options, ctx, locale),
|
|
478
479
|
resolveMailSiteUrl(options, ctx, locale),
|
|
479
480
|
resolveBrandSuffix(options, ctx, locale),
|
|
480
|
-
|
|
481
|
+
readChromeLogoSrc(ctx),
|
|
481
482
|
readBrandingAccentColor(ctx),
|
|
482
483
|
]);
|
|
483
484
|
const footerText = footer?.text?.trim() ?? "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-renderer-mail-html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.415.0",
|
|
4
4
|
"description": "Renderer-Foundation plugin for branded HTML emails: mail-kind templates (document HTML + subject meta) rendered with isolated Handlebars into an MJML layout, plus plain text via html-to-text. Templates resolved from template-resolver.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@cosmicdrift/kumiko-bundled-features": "0.
|
|
23
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
24
|
-
"@cosmicdrift/kumiko-renderer": "0.
|
|
25
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
22
|
+
"@cosmicdrift/kumiko-bundled-features": "0.415.0",
|
|
23
|
+
"@cosmicdrift/kumiko-framework": "0.415.0",
|
|
24
|
+
"@cosmicdrift/kumiko-renderer": "0.415.0",
|
|
25
|
+
"@cosmicdrift/kumiko-types": "0.415.0",
|
|
26
26
|
"handlebars": "^4.7.10",
|
|
27
27
|
"html-to-text": "^9.0.5",
|
|
28
28
|
"mjml": "^5.4.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@cosmicdrift/kumiko-locale-de": "0.
|
|
32
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
31
|
+
"@cosmicdrift/kumiko-locale-de": "0.415.0",
|
|
32
|
+
"@cosmicdrift/kumiko-testing": "0.415.0",
|
|
33
33
|
"@types/html-to-text": "^9.0.4",
|
|
34
34
|
"@types/mjml": "5.4.2"
|
|
35
35
|
},
|