@emailens/engine 0.3.0 → 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.
@@ -0,0 +1,47 @@
1
+ import { n as InputFormat } from '../react-email-BQljgXbo.cjs';
2
+ export { g as CompileError, h as CompileReactEmailOptions, p as SandboxStrategy, x as compileReactEmail } from '../react-email-BQljgXbo.cjs';
3
+
4
+ /**
5
+ * Compile an MJML source string into an HTML email string.
6
+ *
7
+ * MJML is a declarative markup language with no code execution capability
8
+ * (unlike JSX). The mjml library parses XML and generates HTML; there is
9
+ * no sandboxing concern.
10
+ *
11
+ * Requires peer dependency: mjml
12
+ */
13
+ declare function compileMjml(source: string): Promise<string>;
14
+
15
+ /**
16
+ * Compile a Maizzle template string into an HTML email string.
17
+ *
18
+ * Pipeline:
19
+ * 1. Validate input (size, basic structure check)
20
+ * 2. Reject inputs containing PostHTML file-access directives
21
+ * 3. Compile using @maizzle/framework
22
+ *
23
+ * Security:
24
+ * - PostHTML file-system directives are rejected at validation time
25
+ * to prevent server-side file reads and SSRF.
26
+ * - Template expressions ({{ expr }}) are evaluated by posthtml-expressions
27
+ * with empty `locals`, so unknown identifiers like `process` or `require`
28
+ * return the literal string '{local}' rather than accessing Node.js globals.
29
+ * - A hard timeout prevents pathological PostCSS/Tailwind inputs from
30
+ * hanging indefinitely.
31
+ *
32
+ * Requires peer dependency: @maizzle/framework
33
+ */
34
+ declare function compileMaizzle(source: string): Promise<string>;
35
+
36
+ /**
37
+ * Compile source to HTML based on format.
38
+ * Returns the HTML unchanged if format is "html".
39
+ * Lazily imports per-format compilers to avoid loading unnecessary deps.
40
+ */
41
+ declare function compile(source: string, format: InputFormat, filePath?: string): Promise<string>;
42
+ /**
43
+ * Auto-detect input format from file extension.
44
+ */
45
+ declare function detectFormat(filePath: string): InputFormat;
46
+
47
+ export { compile, compileMaizzle, compileMjml, detectFormat };
@@ -0,0 +1,47 @@
1
+ import { n as InputFormat } from '../react-email-BQljgXbo.js';
2
+ export { g as CompileError, h as CompileReactEmailOptions, p as SandboxStrategy, x as compileReactEmail } from '../react-email-BQljgXbo.js';
3
+
4
+ /**
5
+ * Compile an MJML source string into an HTML email string.
6
+ *
7
+ * MJML is a declarative markup language with no code execution capability
8
+ * (unlike JSX). The mjml library parses XML and generates HTML; there is
9
+ * no sandboxing concern.
10
+ *
11
+ * Requires peer dependency: mjml
12
+ */
13
+ declare function compileMjml(source: string): Promise<string>;
14
+
15
+ /**
16
+ * Compile a Maizzle template string into an HTML email string.
17
+ *
18
+ * Pipeline:
19
+ * 1. Validate input (size, basic structure check)
20
+ * 2. Reject inputs containing PostHTML file-access directives
21
+ * 3. Compile using @maizzle/framework
22
+ *
23
+ * Security:
24
+ * - PostHTML file-system directives are rejected at validation time
25
+ * to prevent server-side file reads and SSRF.
26
+ * - Template expressions ({{ expr }}) are evaluated by posthtml-expressions
27
+ * with empty `locals`, so unknown identifiers like `process` or `require`
28
+ * return the literal string '{local}' rather than accessing Node.js globals.
29
+ * - A hard timeout prevents pathological PostCSS/Tailwind inputs from
30
+ * hanging indefinitely.
31
+ *
32
+ * Requires peer dependency: @maizzle/framework
33
+ */
34
+ declare function compileMaizzle(source: string): Promise<string>;
35
+
36
+ /**
37
+ * Compile source to HTML based on format.
38
+ * Returns the HTML unchanged if format is "html".
39
+ * Lazily imports per-format compilers to avoid loading unnecessary deps.
40
+ */
41
+ declare function compile(source: string, format: InputFormat, filePath?: string): Promise<string>;
42
+ /**
43
+ * Auto-detect input format from file extension.
44
+ */
45
+ declare function detectFormat(filePath: string): InputFormat;
46
+
47
+ export { compile, compileMaizzle, compileMjml, detectFormat };
@@ -0,0 +1,59 @@
1
+ import {
2
+ compileReactEmail
3
+ } from "../chunk-LW2IMTBA.js";
4
+ import {
5
+ compileMjml
6
+ } from "../chunk-W4SPWESS.js";
7
+ import {
8
+ compileMaizzle
9
+ } from "../chunk-SZ5O5PDZ.js";
10
+ import {
11
+ CompileError
12
+ } from "../chunk-PFONR3YC.js";
13
+
14
+ // src/compile/index.ts
15
+ import { extname } from "path";
16
+ async function compile(source, format, filePath) {
17
+ switch (format) {
18
+ case "html":
19
+ return source;
20
+ case "jsx": {
21
+ const { compileReactEmail: compileReactEmail2 } = await import("../react-email-AN62KVVF.js");
22
+ return compileReactEmail2(source);
23
+ }
24
+ case "mjml": {
25
+ const { compileMjml: compileMjml2 } = await import("../mjml-IYGC6AOM.js");
26
+ return compileMjml2(source);
27
+ }
28
+ case "maizzle": {
29
+ const { compileMaizzle: compileMaizzle2 } = await import("../maizzle-YDSYDVSM.js");
30
+ return compileMaizzle2(source);
31
+ }
32
+ default:
33
+ throw new Error(`Unknown format: "${format}". Use html, jsx, mjml, or maizzle.`);
34
+ }
35
+ }
36
+ function detectFormat(filePath) {
37
+ const ext = extname(filePath).toLowerCase();
38
+ switch (ext) {
39
+ case ".tsx":
40
+ case ".jsx":
41
+ return "jsx";
42
+ case ".mjml":
43
+ return "mjml";
44
+ case ".html":
45
+ case ".htm":
46
+ return "html";
47
+ default:
48
+ return "html";
49
+ }
50
+ }
51
+ export {
52
+ CompileError,
53
+ compile,
54
+ compileMaizzle,
55
+ compileMjml,
56
+ compileReactEmail,
57
+ detectFormat
58
+ };
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/compile/index.ts"],"sourcesContent":["import { extname } from \"node:path\";\r\nimport type { InputFormat } from \"../types.js\";\r\n\r\nexport { CompileError } from \"./errors.js\";\r\nexport { compileReactEmail } from \"./react-email.js\";\r\nexport type { SandboxStrategy, CompileReactEmailOptions } from \"./react-email.js\";\r\nexport { compileMjml } from \"./mjml.js\";\r\nexport { compileMaizzle } from \"./maizzle.js\";\r\n\r\n/**\r\n * Compile source to HTML based on format.\r\n * Returns the HTML unchanged if format is \"html\".\r\n * Lazily imports per-format compilers to avoid loading unnecessary deps.\r\n */\r\nexport async function compile(\r\n source: string,\r\n format: InputFormat,\r\n filePath?: string,\r\n): Promise<string> {\r\n switch (format) {\r\n case \"html\":\r\n return source;\r\n\r\n case \"jsx\": {\r\n const { compileReactEmail } = await import(\"./react-email.js\");\r\n return compileReactEmail(source);\r\n }\r\n\r\n case \"mjml\": {\r\n const { compileMjml } = await import(\"./mjml.js\");\r\n return compileMjml(source);\r\n }\r\n\r\n case \"maizzle\": {\r\n const { compileMaizzle } = await import(\"./maizzle.js\");\r\n return compileMaizzle(source);\r\n }\r\n\r\n default:\r\n throw new Error(`Unknown format: \"${format}\". Use html, jsx, mjml, or maizzle.`);\r\n }\r\n}\r\n\r\n/**\r\n * Auto-detect input format from file extension.\r\n */\r\nexport function detectFormat(filePath: string): InputFormat {\r\n const ext = extname(filePath).toLowerCase();\r\n\r\n switch (ext) {\r\n case \".tsx\":\r\n case \".jsx\":\r\n return \"jsx\";\r\n case \".mjml\":\r\n return \"mjml\";\r\n case \".html\":\r\n case \".htm\":\r\n return \"html\";\r\n default:\r\n return \"html\";\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,eAAe;AAcxB,eAAsB,QACpB,QACA,QACA,UACiB;AACjB,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IAET,KAAK,OAAO;AACV,YAAM,EAAE,mBAAAA,mBAAkB,IAAI,MAAM,OAAO,4BAAkB;AAC7D,aAAOA,mBAAkB,MAAM;AAAA,IACjC;AAAA,IAEA,KAAK,QAAQ;AACX,YAAM,EAAE,aAAAC,aAAY,IAAI,MAAM,OAAO,qBAAW;AAChD,aAAOA,aAAY,MAAM;AAAA,IAC3B;AAAA,IAEA,KAAK,WAAW;AACd,YAAM,EAAE,gBAAAC,gBAAe,IAAI,MAAM,OAAO,wBAAc;AACtD,aAAOA,gBAAe,MAAM;AAAA,IAC9B;AAAA,IAEA;AACE,YAAM,IAAI,MAAM,oBAAoB,MAAM,qCAAqC;AAAA,EACnF;AACF;AAKO,SAAS,aAAa,UAA+B;AAC1D,QAAM,MAAM,QAAQ,QAAQ,EAAE,YAAY;AAE1C,UAAQ,KAAK;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":["compileReactEmail","compileMjml","compileMaizzle"]}