@emailens/cli 0.13.1 → 0.13.3

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,50 @@
1
+ import { createRequire as __cr } from "node:module";
2
+ const require = __cr(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __esm = (fn, res) => function __init() {
16
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
+ };
18
+ var __commonJS = (cb, mod) => function __require2() {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ // If the importer is in node compatibility mode or this is not an ESM
35
+ // file that has been converted to a CommonJS file using a Babel-
36
+ // compatible transform (i.e. "__esModule" has not been set), then set
37
+ // "default" to the CommonJS "module.exports" for node compatibility.
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
+ mod
40
+ ));
41
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
+
43
+ export {
44
+ __require,
45
+ __esm,
46
+ __commonJS,
47
+ __export,
48
+ __toESM,
49
+ __toCommonJS
50
+ };
@@ -0,0 +1,127 @@
1
+ import { createRequire as __cr } from "node:module";
2
+ const require = __cr(import.meta.url);
3
+ import {
4
+ CompileError
5
+ } from "./chunk-TQGPCAMW.js";
6
+
7
+ // node_modules/@emailens/engine/dist/chunk-IFRUM6GJ.js
8
+ import { mkdtempSync } from "fs";
9
+ import { tmpdir } from "os";
10
+ import { extname, join } from "path";
11
+ var MAX_SOURCE_SIZE = 512e3;
12
+ var COMPILE_TIMEOUT_MS = 15e3;
13
+ var DANGEROUS_DIRECTIVE_RE = /<\s*(?:extends|component|fetch|include|module|slot|fill|raw|block|yield)\b/i;
14
+ function isVueSfc(source) {
15
+ return /<template[\s>]/i.test(source) && /<\/template>/i.test(source);
16
+ }
17
+ function isSingleLinePath(source) {
18
+ const ext = extname(source);
19
+ return !source.includes("\n") && (ext === ".vue" || ext === ".md");
20
+ }
21
+ var pastedRoot = mkdtempSync(join(tmpdir(), "emailens-maizzle-"));
22
+ var VUE_LOADS_FILE_RE = /\bimport\s*(?:[\s"'*{.(]|\/\*)|\brequire\s*\(|\bexport\s+(?:\*|\{)[\s\S]{0,400}?\bfrom\s*['"]|<\s*(?:script|template|style)\b[^>]*\bsrc\s*=|<\s*link\b[^>]*\binline\b|@(?:import|plugin|config)\b/i;
23
+ function isMaizzle6(mod) {
24
+ return "createRenderer" in mod;
25
+ }
26
+ async function compileMaizzle(source, loadFramework = () => import("@maizzle/framework")) {
27
+ if (!source || !source.trim()) {
28
+ throw new CompileError("Maizzle source must not be empty.", "maizzle", "validation");
29
+ }
30
+ if (source.length > MAX_SOURCE_SIZE) {
31
+ throw new CompileError(
32
+ `Maizzle source exceeds ${MAX_SOURCE_SIZE / 1e3}KB limit.`,
33
+ "maizzle",
34
+ "validation"
35
+ );
36
+ }
37
+ const vue = isVueSfc(source);
38
+ if (!vue && DANGEROUS_DIRECTIVE_RE.test(source)) {
39
+ throw new CompileError(
40
+ "Maizzle templates may not use <extends>, <component>, <fetch>, <include>, <module>, <slot>, <fill>, <raw>, <block>, or <yield> directives. These directives access the server file system at compile time. Use inline HTML and Tailwind utility classes instead.",
41
+ "maizzle",
42
+ "validation"
43
+ );
44
+ }
45
+ if (vue && VUE_LOADS_FILE_RE.test(source)) {
46
+ throw new CompileError(
47
+ "Maizzle Vue templates may not import or require other files. Paste one self-contained .vue component.",
48
+ "maizzle",
49
+ "validation"
50
+ );
51
+ }
52
+ let maizzleRender;
53
+ let maizzle;
54
+ try {
55
+ maizzle = await loadFramework();
56
+ } catch (e) {
57
+ throw new CompileError(
58
+ 'Maizzle compilation requires "@maizzle/framework". Install it:\n npm install @maizzle/framework@5 # HTML templates\n npm install @maizzle/framework@6 # Vue single-file components',
59
+ "maizzle",
60
+ "compile"
61
+ );
62
+ }
63
+ const v6 = isMaizzle6(maizzle);
64
+ if (vue && !v6) {
65
+ throw new CompileError(
66
+ "This is a Vue single-file component, and the installed Maizzle is v5, which compiles HTML.\nInstall the Vue compiler:\n npm install @maizzle/framework@6",
67
+ "maizzle",
68
+ "compile"
69
+ );
70
+ }
71
+ if (!vue && v6) {
72
+ throw new CompileError(
73
+ "Maizzle 6 compiles Vue single-file components, not HTML templates.\nPass the contents of the .vue file, including its <template> block.\nHTML templates need @maizzle/framework@5.",
74
+ "maizzle",
75
+ "compile"
76
+ );
77
+ }
78
+ if (vue && v6 && isSingleLinePath(source)) {
79
+ throw new CompileError(
80
+ "Maizzle 6 would open this string as a file path. Paste the .vue contents, including a newline.",
81
+ "maizzle",
82
+ "validation"
83
+ );
84
+ }
85
+ maizzleRender = maizzle.render;
86
+ const options = v6 ? { root: pastedRoot } : {
87
+ css: {
88
+ inline: {
89
+ removeInlinedSelectors: true,
90
+ applyWidthAttributes: true,
91
+ applyHeightAttributes: true
92
+ },
93
+ shorthand: true,
94
+ sixHex: true
95
+ },
96
+ locals: {}
97
+ };
98
+ const compilePromise = maizzleRender(source, options);
99
+ const timeoutPromise = new Promise((_, reject) => {
100
+ const t = setTimeout(() => {
101
+ reject(
102
+ new CompileError(
103
+ `Maizzle compilation timed out after ${COMPILE_TIMEOUT_MS / 1e3}s.`,
104
+ "maizzle",
105
+ "compile"
106
+ )
107
+ );
108
+ }, COMPILE_TIMEOUT_MS);
109
+ if (typeof t.unref === "function") t.unref();
110
+ });
111
+ try {
112
+ const { html } = await Promise.race([compilePromise, timeoutPromise]);
113
+ if (!html) {
114
+ throw new CompileError("Maizzle compilation produced empty output.", "maizzle", "compile");
115
+ }
116
+ return html;
117
+ } catch (err) {
118
+ if (err instanceof CompileError) throw err;
119
+ const message = err instanceof Error ? err.message : "Unknown Maizzle compilation error";
120
+ throw new CompileError(`Maizzle compilation failed: ${message}`, "maizzle", "compile");
121
+ }
122
+ }
123
+
124
+ export {
125
+ isMaizzle6,
126
+ compileMaizzle
127
+ };
@@ -0,0 +1,52 @@
1
+ import { createRequire as __cr } from "node:module";
2
+ const require = __cr(import.meta.url);
3
+
4
+ // node_modules/@emailens/engine/dist/chunk-Z22AD2IU.js
5
+ var CompileError = class extends Error {
6
+ constructor(message, format, phase) {
7
+ super(message);
8
+ this.name = "CompileError";
9
+ this.format = format;
10
+ this.phase = phase;
11
+ }
12
+ };
13
+
14
+ // node_modules/@emailens/engine/dist/chunk-2NMEKWO5.js
15
+ var __defProp = Object.defineProperty;
16
+ var __defProps = Object.defineProperties;
17
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
18
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
19
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
20
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
21
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
22
+ var __spreadValues = (a, b) => {
23
+ for (var prop in b || (b = {}))
24
+ if (__hasOwnProp.call(b, prop))
25
+ __defNormalProp(a, prop, b[prop]);
26
+ if (__getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(b)) {
28
+ if (__propIsEnum.call(b, prop))
29
+ __defNormalProp(a, prop, b[prop]);
30
+ }
31
+ return a;
32
+ };
33
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
34
+ var __objRest = (source, exclude) => {
35
+ var target = {};
36
+ for (var prop in source)
37
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
38
+ target[prop] = source[prop];
39
+ if (source != null && __getOwnPropSymbols)
40
+ for (var prop of __getOwnPropSymbols(source)) {
41
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
42
+ target[prop] = source[prop];
43
+ }
44
+ return target;
45
+ };
46
+
47
+ export {
48
+ CompileError,
49
+ __spreadValues,
50
+ __spreadProps,
51
+ __objRest
52
+ };