@maizzle/framework 6.1.7 → 6.2.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.
Files changed (54) hide show
  1. package/dist/composables/definePreviewProps.d.ts +21 -0
  2. package/dist/composables/definePreviewProps.d.ts.map +1 -0
  3. package/dist/composables/definePreviewProps.js +23 -0
  4. package/dist/composables/definePreviewProps.js.map +1 -0
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.js +3 -2
  7. package/dist/plugins/postcss/resolveMaizzleImports.js +15 -8
  8. package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -1
  9. package/dist/render/createRenderer.d.ts.map +1 -1
  10. package/dist/render/createRenderer.js +25 -4
  11. package/dist/render/createRenderer.js.map +1 -1
  12. package/dist/render/index.d.ts +21 -0
  13. package/dist/render/index.d.ts.map +1 -1
  14. package/dist/render/index.js +76 -30
  15. package/dist/render/index.js.map +1 -1
  16. package/dist/render/plugins/previewProps.d.ts +13 -0
  17. package/dist/render/plugins/previewProps.d.ts.map +1 -0
  18. package/dist/render/plugins/previewProps.js +185 -0
  19. package/dist/render/plugins/previewProps.js.map +1 -0
  20. package/dist/render/withPreviewProps.d.ts +15 -0
  21. package/dist/render/withPreviewProps.d.ts.map +1 -0
  22. package/dist/render/withPreviewProps.js +40 -0
  23. package/dist/render/withPreviewProps.js.map +1 -0
  24. package/dist/serve.d.ts.map +1 -1
  25. package/dist/serve.js +4 -1
  26. package/dist/serve.js.map +1 -1
  27. package/dist/server/ui/.vite/deps/@lucide_vue.js +51812 -41607
  28. package/dist/server/ui/.vite/deps/@lucide_vue.js.map +1 -1
  29. package/dist/server/ui/.vite/deps/@vueuse_core.js.map +1 -1
  30. package/dist/server/ui/.vite/deps/@vueuse_shared.js.map +1 -1
  31. package/dist/server/ui/.vite/deps/_metadata.json +13 -13
  32. package/dist/server/ui/.vite/deps/class-variance-authority.js.map +1 -1
  33. package/dist/server/ui/.vite/deps/clsx.js.map +1 -1
  34. package/dist/server/ui/.vite/deps/culori.js.map +1 -1
  35. package/dist/server/ui/.vite/deps/reka-ui.js +240 -73
  36. package/dist/server/ui/.vite/deps/reka-ui.js.map +1 -1
  37. package/dist/server/ui/.vite/deps/tailwind-merge.js +102 -22
  38. package/dist/server/ui/.vite/deps/tailwind-merge.js.map +1 -1
  39. package/dist/server/ui/.vite/deps/vue-router.js +84 -53
  40. package/dist/server/ui/.vite/deps/vue-router.js.map +1 -1
  41. package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-Dq07uCLt.js.map +1 -1
  42. package/dist/transformers/format.d.ts.map +1 -1
  43. package/dist/transformers/minify.d.ts.map +1 -1
  44. package/dist/transformers/purgeCss.d.ts.map +1 -1
  45. package/dist/transformers/shorthandCss.js +11 -5
  46. package/dist/transformers/shorthandCss.js.map +1 -1
  47. package/dist/transformers/tailwindComponent.js +1 -1
  48. package/dist/transformers/tailwindComponent.js.map +1 -1
  49. package/dist/transformers/tailwindcss.js +8 -4
  50. package/dist/transformers/tailwindcss.js.map +1 -1
  51. package/dist/types/config.d.ts.map +1 -1
  52. package/dist/utils/compileTailwindCss.js +1 -1
  53. package/dist/utils/compileTailwindCss.js.map +1 -1
  54. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/render/index.ts"],"sourcesContent":["import { resolve, extname } from 'pathe'\nimport { resolveConfigObject } from '../config/index.ts'\nimport { runTransformers } from '../transformers/index.ts'\nimport { createPlaintext } from '../plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from '../utils/output-markers.ts'\nimport defu from 'defu'\nimport type { Component } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport { createRenderer } from './createRenderer.ts'\nimport { getActiveRenderer } from './active.ts'\nimport { normalizeComponentSources } from '../utils/componentSources.ts'\n\nexport type { Renderer, RenderedTemplate, CreateRendererOptions } from './createRenderer.ts'\nexport { createRenderer } from './createRenderer.ts'\n\nexport interface RenderResult {\n html: string\n config: MaizzleConfig\n plaintext?: string\n}\n\n/**\n * Render a Vue SFC email template to a fully-transformed HTML string.\n * Accepts a file path or a raw SFC source string.\n */\nexport async function render(\n template: string | Component,\n config?: Partial<MaizzleConfig>,\n): Promise<RenderResult> {\n if (template == null) {\n throw new Error(\n `render() received ${template}. If you used \\`import X from './x.vue'\\`, Node cannot load .vue files natively — pass the path string instead: render('./x.vue').`,\n )\n }\n if (typeof template !== 'string' && typeof template !== 'object' && typeof template !== 'function') {\n throw new TypeError(\n `render() expected a file path or SFC source string, got ${typeof template}.`,\n )\n }\n\n const resolvedConfig = resolveConfigObject(config)\n const { props, ...templateConfig } = resolvedConfig\n\n /**\n * Reuse a renderer started by the Vite plugin when one is active.\n * Spinning up a fresh Vite SSR server inside a host Vite dev process\n * (e.g. TanStack Start) collides on env wiring and throws\n * \"outsideEmitter undefined\".\n */\n const active = getActiveRenderer()\n const renderer = active ?? await createRenderer({\n markdown: resolvedConfig.markdown,\n root: resolvedConfig.root,\n componentDirs: normalizeComponentSources(resolvedConfig.components?.source, process.cwd()),\n vite: resolvedConfig.vite,\n customElements: resolvedConfig.vue?.customElements,\n })\n\n try {\n const isFile = typeof template === 'string'\n && ['.vue', '.md'].includes(extname(template))\n && !template.includes('\\n')\n\n const rendered = await renderer.render(isFile ? resolve(template) : template, templateConfig, { props })\n let html = rendered.html\n\n const doctype = rendered.doctype ?? rendered.templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, rendered.templateConfig, isFile ? resolve(template) : undefined, doctype, rendered.tailwindBlocks)\n if (doctype) html = `${doctype}\\n${html}`\n\n const globalPlaintext = rendered.templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n let plaintextResult: string | undefined\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n plaintextResult = createPlaintext(stripForPlaintext(html), stripOptions)\n }\n\n return { html: stripForHtml(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,UAAU,OAAO;GAClE,kBAAkB,gBAAgB,kBAAkB,IAAI,GAAG,YAAY;EACzE;EAEA,OAAO;GAAE,MAAM,aAAa,IAAI;GAAG,QAAQ,SAAS;GAAgB,WAAW;EAAgB;CACjG,UAAU;EACR,IAAI,CAAC,QAAQ,MAAM,SAAS,MAAM;CACpC;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/render/index.ts"],"sourcesContent":["import { resolve, extname } from 'pathe'\nimport { resolveConfigObject } from '../config/index.ts'\nimport { runTransformers } from '../transformers/index.ts'\nimport { createPlaintext } from '../plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from '../utils/output-markers.ts'\nimport defu from 'defu'\nimport type { Component } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport { createRenderer, type Renderer } from './createRenderer.ts'\nimport { getActiveRenderer } from './active.ts'\nimport { normalizeComponentSources } from '../utils/componentSources.ts'\n\nexport type { Renderer, RenderedTemplate, CreateRendererOptions } from './createRenderer.ts'\nexport { createRenderer } from './createRenderer.ts'\n\nexport interface RenderResult {\n html: string\n config: MaizzleConfig\n plaintext?: string\n}\n\nexport interface MaizzleInstance {\n /**\n * Render a template through the full pipeline, reusing this instance's\n * renderer. `config` is merged over the config the instance was created\n * with. Keys that shape the renderer (`root`, `markdown`, `vite`,\n * `components.source`, `vue.customElements`) can only be set when\n * creating the instance and throw here. Safe to call concurrently.\n */\n render(template: string | Component, config?: Partial<MaizzleConfig>): Promise<RenderResult>\n /** Shut down the underlying Vite SSR server. */\n close(): Promise<void>\n}\n\n/**\n * Keys read by rendererOptions() when the instance is created. Passing\n * them per render would silently do nothing, so reject them instead.\n */\nfunction assertNoRendererOverrides(config: Partial<MaizzleConfig>): void {\n const overrides = [\n config.root !== undefined && 'root',\n config.markdown !== undefined && 'markdown',\n config.vite !== undefined && 'vite',\n config.components?.source !== undefined && 'components.source',\n config.vue?.customElements !== undefined && 'vue.customElements',\n ].filter(Boolean)\n\n if (overrides.length) {\n throw new Error(\n `${overrides.join(', ')} can only be set in createMaizzle(), not per render.`,\n )\n }\n}\n\nfunction rendererOptions(config: MaizzleConfig) {\n return {\n markdown: config.markdown,\n root: config.root,\n componentDirs: normalizeComponentSources(config.components?.source, process.cwd()),\n vite: config.vite,\n customElements: config.vue?.customElements,\n }\n}\n\n/**\n * Run a template through a renderer and the post-render pipeline\n * (transformers, doctype, plaintext). Shared by the one-shot render()\n * and instances from createMaizzle().\n */\nasync function renderWith(\n renderer: Renderer,\n template: string | Component,\n resolvedConfig: MaizzleConfig,\n): Promise<RenderResult> {\n if (template == null) {\n throw new Error(\n `render() received ${template}. If you used \\`import X from './x.vue'\\`, Node cannot load .vue files natively — pass the path string instead: render('./x.vue').`,\n )\n }\n if (typeof template !== 'string' && typeof template !== 'object' && typeof template !== 'function') {\n throw new TypeError(\n `render() expected a file path or SFC source string, got ${typeof template}.`,\n )\n }\n\n const { props, ...templateConfig } = resolvedConfig\n\n const isFile = typeof template === 'string'\n && ['.vue', '.md'].includes(extname(template))\n && !template.includes('\\n')\n\n const rendered = await renderer.render(isFile ? resolve(template) : template, templateConfig, { props })\n let html = rendered.html\n\n const doctype = rendered.doctype ?? rendered.templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, rendered.templateConfig, isFile ? resolve(template) : undefined, doctype, rendered.tailwindBlocks)\n if (doctype) html = `${doctype}\\n${html}`\n\n const globalPlaintext = rendered.templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n let plaintextResult: string | undefined\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n plaintextResult = createPlaintext(stripForPlaintext(html), stripOptions)\n }\n\n return { html: stripForHtml(html), config: rendered.templateConfig, plaintext: plaintextResult }\n}\n\n/**\n * Render a Vue SFC email template to a fully-transformed HTML string.\n * Accepts a file path or a raw SFC source string.\n *\n * Starts and stops a Vite SSR server per call. For repeated renders in a\n * long-running process, use createMaizzle() instead.\n */\nexport async function render(\n template: string | Component,\n config?: Partial<MaizzleConfig>,\n): Promise<RenderResult> {\n const resolvedConfig = resolveConfigObject(config)\n\n /**\n * Reuse a renderer started by the Vite plugin when one is active.\n * Spinning up a fresh Vite SSR server inside a host Vite dev process\n * (e.g. TanStack Start) collides on env wiring and throws\n * \"outsideEmitter undefined\".\n */\n const active = getActiveRenderer()\n const renderer = active ?? await createRenderer(rendererOptions(resolvedConfig))\n\n try {\n return await renderWith(renderer, template, resolvedConfig)\n } finally {\n if (!active) await renderer.close()\n }\n}\n\n/**\n * Create a Maizzle instance that keeps one Vite SSR server alive across\n * renders. Use this when rendering emails on demand in a long-running\n * process, where the per-call startup cost of render() adds up.\n */\nexport async function createMaizzle(config?: Partial<MaizzleConfig>): Promise<MaizzleInstance> {\n const baseConfig = config ?? {}\n const renderer = await createRenderer(rendererOptions(resolveConfigObject(baseConfig)))\n\n return {\n async render(template, renderConfig) {\n if (renderConfig) assertNoRendererOverrides(renderConfig)\n return renderWith(renderer, template, resolveConfigObject(defu(renderConfig, baseConfig)))\n },\n close() {\n return renderer.close()\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,SAAS,0BAA0B,QAAsC;CACvE,MAAM,YAAY;EAChB,OAAO,SAAS,KAAA,KAAa;EAC7B,OAAO,aAAa,KAAA,KAAa;EACjC,OAAO,SAAS,KAAA,KAAa;EAC7B,OAAO,YAAY,WAAW,KAAA,KAAa;EAC3C,OAAO,KAAK,mBAAmB,KAAA,KAAa;CAC9C,CAAC,CAAC,OAAO,OAAO;CAEhB,IAAI,UAAU,QACZ,MAAM,IAAI,MACR,GAAG,UAAU,KAAK,IAAI,EAAE,qDAC1B;AAEJ;AAEA,SAAS,gBAAgB,QAAuB;CAC9C,OAAO;EACL,UAAU,OAAO;EACjB,MAAM,OAAO;EACb,eAAe,0BAA0B,OAAO,YAAY,QAAQ,QAAQ,IAAI,CAAC;EACjF,MAAM,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,CAAC;CAE/E,IAAI;EACF,OAAO,MAAM,WAAW,UAAU,UAAU,cAAc;CAC5D,UAAU;EACR,IAAI,CAAC,QAAQ,MAAM,SAAS,MAAM;CACpC;AACF;;;;;;AAOA,eAAsB,cAAc,QAA2D;CAC7F,MAAM,aAAa,UAAU,CAAC;CAC9B,MAAM,WAAW,MAAM,eAAe,gBAAgB,oBAAoB,UAAU,CAAC,CAAC;CAEtF,OAAO;EACL,MAAM,OAAO,UAAU,cAAc;GACnC,IAAI,cAAc,0BAA0B,YAAY;GACxD,OAAO,WAAW,UAAU,UAAU,oBAAoB,KAAK,cAAc,UAAU,CAAC,CAAC;EAC3F;EACA,QAAQ;GACN,OAAO,SAAS,MAAM;EACxB;CACF;AACF"}
@@ -0,0 +1,13 @@
1
+ import { Plugin } from "vite";
2
+ //#region src/render/plugins/previewProps.d.ts
3
+ /**
4
+ * Vite plugin that compiles the `definePreviewProps()` macro.
5
+ *
6
+ * Runs after plugin-vue (and TS stripping), so it sees plain JS. Blanks
7
+ * out the call inside `setup()`, then re-exports the component wrapped
8
+ * with `withPreviewProps()`, which gets the macro argument as a
9
+ * lazy factory evaluated at module scope.
10
+ */
11
+ export declare function previewProps(runtimePath: string): Plugin;
12
+ //#endregion
13
+ //# sourceMappingURL=previewProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewProps.d.ts","names":[],"sources":["../../../src/render/plugins/previewProps.ts"],"mappings":";;;;;;;;;;wBAmIgB,aAAa,sBAAsB"}
@@ -0,0 +1,185 @@
1
+ import { parseAst } from "vite";
2
+ //#region src/render/plugins/previewProps.ts
3
+ const MACRO = "definePreviewProps";
4
+ /**
5
+ * Collect binding names from a declaration target: `a`, `{ a, b: c }`,
6
+ * `[a, ...rest]`, `a = 1`.
7
+ */
8
+ function patternNames(node, out) {
9
+ if (!node) return;
10
+ if (node.type === "Identifier") out.add(node.name);
11
+ else if (node.type === "ObjectPattern") node.properties.forEach((p) => patternNames(p.type === "RestElement" ? p : p.value, out));
12
+ else if (node.type === "ArrayPattern") node.elements.forEach((e) => patternNames(e, out));
13
+ else if (node.type === "AssignmentPattern") patternNames(node.left, out);
14
+ else if (node.type === "RestElement") patternNames(node.argument, out);
15
+ }
16
+ /**
17
+ * Names declared directly in a statement list (not in nested blocks).
18
+ * Imports are left out on purpose: they're allowed in the macro.
19
+ */
20
+ function declaredNames(statements, out) {
21
+ for (let node of statements) {
22
+ if (node.type === "ExportNamedDeclaration") node = node.declaration;
23
+ if (!node) continue;
24
+ if (node.type === "VariableDeclaration") node.declarations.forEach((d) => patternNames(d.id, out));
25
+ else if ((node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") && node.id) out.add(node.id.name);
26
+ }
27
+ }
28
+ /**
29
+ * Identifiers an expression reads, minus the ones it declares itself
30
+ * (arrow function params, inner variables) and property names.
31
+ */
32
+ function referencedNames(root) {
33
+ const refs = /* @__PURE__ */ new Set();
34
+ const own = /* @__PURE__ */ new Set();
35
+ const visit = (node, parent, key) => {
36
+ if (!node || typeof node.type !== "string") return;
37
+ if (node.type === "Identifier") {
38
+ if (!(!parent?.computed && (parent?.type === "MemberExpression" && key === "property" || (parent?.type === "Property" || parent?.type === "MethodDefinition") && key === "key"))) refs.add(node.name);
39
+ return;
40
+ }
41
+ if (node.type === "VariableDeclarator") patternNames(node.id, own);
42
+ if (node.params) node.params.forEach((p) => patternNames(p, own));
43
+ if (node.type === "CatchClause") patternNames(node.param, own);
44
+ for (const [k, value] of Object.entries(node)) if (Array.isArray(value)) value.forEach((child) => visit(child, node, k));
45
+ else if (value && typeof value === "object") visit(value, node, k);
46
+ };
47
+ visit(root);
48
+ return [...refs].filter((name) => !own.has(name));
49
+ }
50
+ /**
51
+ * Imports read only by the macro arguments, plus the `__returned__` getters
52
+ * Vue adds for them in non-TS templates. Every other identifier counts
53
+ * as a use (even property names like `$setup.x`), so when in doubt
54
+ * an import stays where it is.
55
+ */
56
+ function previewOnlyImports(ast, args) {
57
+ const imports = ast.body.filter((n) => n.type === "ImportDeclaration" && n.specifiers.length && !n.attributes?.length);
58
+ const names = new Set(imports.flatMap((n) => n.specifiers.map((s) => s.local.name)));
59
+ let getters = [];
60
+ const used = /* @__PURE__ */ new Set();
61
+ const skip = /* @__PURE__ */ new Set([...args, ...imports]);
62
+ const visit = (node, parent, key) => {
63
+ if (!node || typeof node.type !== "string" || skip.has(node)) return;
64
+ if (node.type === "VariableDeclarator" && node.id.name === "__returned__" && node.init?.type === "ObjectExpression") {
65
+ getters = node.init.properties.filter((p) => p.kind === "get" && names.has(p.key?.name));
66
+ getters.forEach((p) => skip.add(p));
67
+ }
68
+ if (node.type === "Identifier") {
69
+ if (!(parent?.type === "Property" && key === "key" && !parent.computed)) used.add(node.name);
70
+ return;
71
+ }
72
+ for (const [k, value] of Object.entries(node)) if (Array.isArray(value)) value.forEach((child) => visit(child, node, k));
73
+ else if (value && typeof value === "object") visit(value, node, k);
74
+ };
75
+ visit(ast);
76
+ const inArg = new Set(args.flatMap(referencedNames));
77
+ const moved = imports.filter((n) => n.specifiers.every((s) => !used.has(s.local.name)) && n.specifiers.some((s) => inArg.has(s.local.name)));
78
+ const movedNames = new Set(moved.flatMap((n) => n.specifiers.map((s) => s.local.name)));
79
+ return {
80
+ imports: moved,
81
+ getters: getters.filter((p) => movedNames.has(p.key.name))
82
+ };
83
+ }
84
+ /**
85
+ * `import a, { b as c } from 'x'` -> `const { default: a, b: c } = await import('x')`
86
+ */
87
+ function dynamicImport(node) {
88
+ const source = JSON.stringify(node.source.value);
89
+ const namespace = node.specifiers.find((s) => s.type === "ImportNamespaceSpecifier");
90
+ const named = node.specifiers.filter((s) => s.type !== "ImportNamespaceSpecifier").map((s) => {
91
+ if (s.type === "ImportDefaultSpecifier") return `default: ${s.local.name}`;
92
+ return `${s.imported.type === "Identifier" ? s.imported.name : JSON.stringify(s.imported.value)}: ${s.local.name}`;
93
+ });
94
+ return [namespace && `const ${namespace.local.name} = await import(${source})`, named.length && `const { ${named.join(", ")} } = await import(${source})`].filter(Boolean).join("; ");
95
+ }
96
+ /**
97
+ * Vite plugin that compiles the `definePreviewProps()` macro.
98
+ *
99
+ * Runs after plugin-vue (and TS stripping), so it sees plain JS. Blanks
100
+ * out the call inside `setup()`, then re-exports the component wrapped
101
+ * with `withPreviewProps()`, which gets the macro argument as a
102
+ * lazy factory evaluated at module scope.
103
+ */
104
+ function previewProps(runtimePath) {
105
+ return {
106
+ name: "maizzle:preview-props",
107
+ enforce: "post",
108
+ transform(code, id) {
109
+ if (!id.endsWith(".vue") || !code.includes(MACRO)) return;
110
+ const ast = parseAst(code);
111
+ const calls = [];
112
+ const walk = (node, block) => {
113
+ if (!node || typeof node.type !== "string") return;
114
+ if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === MACRO) {
115
+ calls.push({
116
+ node,
117
+ block
118
+ });
119
+ return;
120
+ }
121
+ const inner = node.type === "BlockStatement" ? node.body : block;
122
+ for (const value of Object.values(node)) if (Array.isArray(value)) value.forEach((child) => walk(child, inner));
123
+ else if (value && typeof value === "object") walk(value, inner);
124
+ };
125
+ walk(ast, ast.body);
126
+ if (calls.length === 0) return;
127
+ const exportDefault = ast.body.find((n) => n.type === "ExportDefaultDeclaration");
128
+ if (!exportDefault) return;
129
+ const [{ node: call, block }] = calls;
130
+ const arg = call.expression.arguments[0];
131
+ /**
132
+ * The argument is moved out of `setup()` to module scope, where
133
+ * template variables don't exist. Vue hoists literal consts there
134
+ * though, so check both scopes and reject either one, keeping
135
+ * the rule simple: inline values and imports only.
136
+ */
137
+ let error;
138
+ if (calls.length > 1) error = `${MACRO}() can only be called once per template.`;
139
+ else if (arg) {
140
+ const declared = /* @__PURE__ */ new Set();
141
+ declaredNames(ast.body, declared);
142
+ declaredNames(block, declared);
143
+ const local = referencedNames(arg).find((name) => declared.has(name));
144
+ if (local) error = `${MACRO}() cannot use \`${local}\` declared in this template.\nMove it to an import, or write the value inline.`;
145
+ }
146
+ /**
147
+ * Mistakes throw from the factory instead of failing the compile:
148
+ * it only runs in the dev server, so preview data can never
149
+ * break `build` or a production `render()`. Macro-only imports
150
+ * are removed either way, and only loaded by a valid factory.
151
+ */
152
+ const moved = previewOnlyImports(ast, calls.flatMap(({ node }) => node.expression.arguments));
153
+ let factory = "() => ({})";
154
+ if (error) factory = `() => { throw new Error(${JSON.stringify(`[maizzle] ${error}`)}) }`;
155
+ else if (moved.imports.length) factory = `async () => { ${moved.imports.map(dynamicImport).join("; ")}; return (${code.slice(arg.start, arg.end)}) }`;
156
+ else if (arg) factory = `() => (${code.slice(arg.start, arg.end)})`;
157
+ /**
158
+ * Blank the calls, moved imports and their getters in place (keeping
159
+ * newlines) so line numbers don't shift. A getter takes its comma
160
+ * along, so the `__returned__` object stays valid.
161
+ */
162
+ const blank = (s) => s.replace(/[^\n]/g, " ");
163
+ const ranges = [
164
+ ...calls.map(({ node }) => [node.start, node.end]),
165
+ ...moved.imports.map((node) => [node.start, node.end]),
166
+ ...moved.getters.map((node) => [node.start, node.end + (/^\s*,/.exec(code.slice(node.end))?.[0].length ?? 0)])
167
+ ].sort((a, b) => a[0] - b[0]);
168
+ let out = "";
169
+ let cursor = 0;
170
+ for (const [start, end] of ranges) {
171
+ out += code.slice(cursor, start) + blank(code.slice(start, end));
172
+ cursor = end;
173
+ }
174
+ out += code.slice(cursor, exportDefault.start) + "const __maizzle_sfc = " + code.slice(exportDefault.declaration.start) + `\nimport { withPreviewProps as __maizzle_withPreviewProps } from ${JSON.stringify(runtimePath)}\nexport default __maizzle_withPreviewProps(__maizzle_sfc, ${factory})\n`;
175
+ return {
176
+ code: out,
177
+ map: null
178
+ };
179
+ }
180
+ };
181
+ }
182
+ //#endregion
183
+ export { previewProps };
184
+
185
+ //# sourceMappingURL=previewProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewProps.js","names":[],"sources":["../../../src/render/plugins/previewProps.ts"],"sourcesContent":["import { parseAst } from 'vite'\nimport type { Plugin } from 'vite'\n\nconst MACRO = 'definePreviewProps'\n\n/**\n * Collect binding names from a declaration target: `a`, `{ a, b: c }`,\n * `[a, ...rest]`, `a = 1`.\n */\nfunction patternNames(node: any, out: Set<string>): void {\n if (!node) return\n if (node.type === 'Identifier') out.add(node.name)\n else if (node.type === 'ObjectPattern') node.properties.forEach((p: any) => patternNames(p.type === 'RestElement' ? p : p.value, out))\n else if (node.type === 'ArrayPattern') node.elements.forEach((e: any) => patternNames(e, out))\n else if (node.type === 'AssignmentPattern') patternNames(node.left, out)\n else if (node.type === 'RestElement') patternNames(node.argument, out)\n}\n\n/**\n * Names declared directly in a statement list (not in nested blocks).\n * Imports are left out on purpose: they're allowed in the macro.\n */\nfunction declaredNames(statements: any[], out: Set<string>): void {\n for (let node of statements) {\n if (node.type === 'ExportNamedDeclaration') node = node.declaration\n if (!node) continue\n if (node.type === 'VariableDeclaration') node.declarations.forEach((d: any) => patternNames(d.id, out))\n else if ((node.type === 'FunctionDeclaration' || node.type === 'ClassDeclaration') && node.id) out.add(node.id.name)\n }\n}\n\n/**\n * Identifiers an expression reads, minus the ones it declares itself\n * (arrow function params, inner variables) and property names.\n */\nfunction referencedNames(root: any): string[] {\n const refs = new Set<string>()\n const own = new Set<string>()\n\n const visit = (node: any, parent?: any, key?: string): void => {\n if (!node || typeof node.type !== 'string') return\n if (node.type === 'Identifier') {\n const isPropertyName = !parent?.computed && (\n (parent?.type === 'MemberExpression' && key === 'property')\n || ((parent?.type === 'Property' || parent?.type === 'MethodDefinition') && key === 'key')\n )\n if (!isPropertyName) refs.add(node.name)\n return\n }\n if (node.type === 'VariableDeclarator') patternNames(node.id, own)\n if (node.params) node.params.forEach((p: any) => patternNames(p, own))\n if (node.type === 'CatchClause') patternNames(node.param, own)\n for (const [k, value] of Object.entries(node)) {\n if (Array.isArray(value)) value.forEach(child => visit(child, node, k))\n else if (value && typeof value === 'object') visit(value, node, k)\n }\n }\n visit(root)\n\n return [...refs].filter(name => !own.has(name))\n}\n\n/**\n * Imports read only by the macro arguments, plus the `__returned__` getters\n * Vue adds for them in non-TS templates. Every other identifier counts\n * as a use (even property names like `$setup.x`), so when in doubt\n * an import stays where it is.\n */\nfunction previewOnlyImports(ast: any, args: any[]): { imports: any[]; getters: any[] } {\n const imports = ast.body.filter((n: any) => n.type === 'ImportDeclaration' && n.specifiers.length && !n.attributes?.length)\n const names = new Set<string>(imports.flatMap((n: any) => n.specifiers.map((s: any) => s.local.name)))\n\n let getters: any[] = []\n const used = new Set<string>()\n const skip = new Set([...args, ...imports])\n\n const visit = (node: any, parent?: any, key?: string): void => {\n if (!node || typeof node.type !== 'string' || skip.has(node)) return\n if (node.type === 'VariableDeclarator' && node.id.name === '__returned__' && node.init?.type === 'ObjectExpression') {\n getters = node.init.properties.filter((p: any) => p.kind === 'get' && names.has(p.key?.name))\n getters.forEach(p => skip.add(p))\n }\n if (node.type === 'Identifier') {\n if (!(parent?.type === 'Property' && key === 'key' && !parent.computed)) used.add(node.name)\n return\n }\n for (const [k, value] of Object.entries(node)) {\n if (Array.isArray(value)) value.forEach(child => visit(child, node, k))\n else if (value && typeof value === 'object') visit(value, node, k)\n }\n }\n visit(ast)\n\n const inArg = new Set(args.flatMap(referencedNames))\n const moved = imports.filter((n: any) =>\n n.specifiers.every((s: any) => !used.has(s.local.name))\n && n.specifiers.some((s: any) => inArg.has(s.local.name)),\n )\n const movedNames = new Set(moved.flatMap((n: any) => n.specifiers.map((s: any) => s.local.name)))\n\n return { imports: moved, getters: getters.filter(p => movedNames.has(p.key.name)) }\n}\n\n/**\n * `import a, { b as c } from 'x'` -> `const { default: a, b: c } = await import('x')`\n */\nfunction dynamicImport(node: any): string {\n const source = JSON.stringify(node.source.value)\n const namespace = node.specifiers.find((s: any) => s.type === 'ImportNamespaceSpecifier')\n const named = node.specifiers\n .filter((s: any) => s.type !== 'ImportNamespaceSpecifier')\n .map((s: any) => {\n if (s.type === 'ImportDefaultSpecifier') return `default: ${s.local.name}`\n const imported = s.imported.type === 'Identifier' ? s.imported.name : JSON.stringify(s.imported.value)\n return `${imported}: ${s.local.name}`\n })\n\n return [\n namespace && `const ${namespace.local.name} = await import(${source})`,\n named.length && `const { ${named.join(', ')} } = await import(${source})`,\n ].filter(Boolean).join('; ')\n}\n\n/**\n * Vite plugin that compiles the `definePreviewProps()` macro.\n *\n * Runs after plugin-vue (and TS stripping), so it sees plain JS. Blanks\n * out the call inside `setup()`, then re-exports the component wrapped\n * with `withPreviewProps()`, which gets the macro argument as a\n * lazy factory evaluated at module scope.\n */\nexport function previewProps(runtimePath: string): Plugin {\n return {\n name: 'maizzle:preview-props',\n enforce: 'post',\n transform(code, id) {\n if (!id.endsWith('.vue') || !code.includes(MACRO)) return\n\n const ast = parseAst(code) as any\n const calls: { node: any; block: any[] }[] = []\n\n const walk = (node: any, block: any[]): void => {\n if (!node || typeof node.type !== 'string') return\n if (\n node.type === 'ExpressionStatement'\n && node.expression.type === 'CallExpression'\n && node.expression.callee.type === 'Identifier'\n && node.expression.callee.name === MACRO\n ) {\n calls.push({ node, block })\n return\n }\n const inner = node.type === 'BlockStatement' ? node.body : block\n for (const value of Object.values(node)) {\n if (Array.isArray(value)) value.forEach(child => walk(child, inner))\n else if (value && typeof value === 'object') walk(value, inner)\n }\n }\n walk(ast, ast.body)\n\n if (calls.length === 0) return\n\n const exportDefault = ast.body.find((n: any) => n.type === 'ExportDefaultDeclaration')\n if (!exportDefault) return\n\n const [{ node: call, block }] = calls\n const arg = call.expression.arguments[0]\n\n /**\n * The argument is moved out of `setup()` to module scope, where\n * template variables don't exist. Vue hoists literal consts there\n * though, so check both scopes and reject either one, keeping\n * the rule simple: inline values and imports only.\n */\n let error: string | undefined\n if (calls.length > 1) {\n error = `${MACRO}() can only be called once per template.`\n } else if (arg) {\n const declared = new Set<string>()\n declaredNames(ast.body, declared)\n declaredNames(block, declared)\n\n const local = referencedNames(arg).find(name => declared.has(name))\n if (local) {\n error = `${MACRO}() cannot use \\`${local}\\` declared in this template.\\nMove it to an import, or write the value inline.`\n }\n }\n\n /**\n * Mistakes throw from the factory instead of failing the compile:\n * it only runs in the dev server, so preview data can never\n * break `build` or a production `render()`. Macro-only imports\n * are removed either way, and only loaded by a valid factory.\n */\n const moved = previewOnlyImports(ast, calls.flatMap(({ node }) => node.expression.arguments))\n\n let factory = '() => ({})'\n if (error) {\n factory = `() => { throw new Error(${JSON.stringify(`[maizzle] ${error}`)}) }`\n } else if (moved.imports.length) {\n factory = `async () => { ${moved.imports.map(dynamicImport).join('; ')}; return (${code.slice(arg.start, arg.end)}) }`\n } else if (arg) {\n factory = `() => (${code.slice(arg.start, arg.end)})`\n }\n\n /**\n * Blank the calls, moved imports and their getters in place (keeping\n * newlines) so line numbers don't shift. A getter takes its comma\n * along, so the `__returned__` object stays valid.\n */\n const blank = (s: string) => s.replace(/[^\\n]/g, ' ')\n const ranges = [\n ...calls.map(({ node }) => [node.start, node.end]),\n ...moved.imports.map(node => [node.start, node.end]),\n ...moved.getters.map(node => [node.start, node.end + (/^\\s*,/.exec(code.slice(node.end))?.[0].length ?? 0)]),\n ].sort((a, b) => a[0] - b[0])\n\n let out = ''\n let cursor = 0\n for (const [start, end] of ranges) {\n out += code.slice(cursor, start) + blank(code.slice(start, end))\n cursor = end\n }\n\n out += code.slice(cursor, exportDefault.start)\n + 'const __maizzle_sfc = '\n + code.slice(exportDefault.declaration.start)\n + `\\nimport { withPreviewProps as __maizzle_withPreviewProps } from ${JSON.stringify(runtimePath)}`\n + `\\nexport default __maizzle_withPreviewProps(__maizzle_sfc, ${factory})\\n`\n\n return { code: out, map: null }\n },\n }\n}\n"],"mappings":";;AAGA,MAAM,QAAQ;;;;;AAMd,SAAS,aAAa,MAAW,KAAwB;CACvD,IAAI,CAAC,MAAM;CACX,IAAI,KAAK,SAAS,cAAc,IAAI,IAAI,KAAK,IAAI;MAC5C,IAAI,KAAK,SAAS,iBAAiB,KAAK,WAAW,SAAS,MAAW,aAAa,EAAE,SAAS,gBAAgB,IAAI,EAAE,OAAO,GAAG,CAAC;MAChI,IAAI,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AK,UAAU,aAAa,OAAO,EAAE;QACrE,IAAI,MAAM,QAAQ,QACvB,UAAU,iBAAiB,MAAM,QAAQ,IAAI,aAAa,CAAC,CAAC,KAAK,IAAI,EAAE,YAAY,KAAK,MAAM,IAAI,OAAO,IAAI,GAAG,EAAE;QAC7G,IAAI,KACT,UAAU,UAAU,KAAK,MAAM,IAAI,OAAO,IAAI,GAAG,EAAE;;;;;;GAQrD,MAAM,SAAS,MAAc,EAAE,QAAQ,UAAU,GAAG;GACpD,MAAM,SAAS;IACb,GAAG,MAAM,KAAK,EAAE,WAAW,CAAC,KAAK,OAAO,KAAK,GAAG,CAAC;IACjD,GAAG,MAAM,QAAQ,KAAI,SAAQ,CAAC,KAAK,OAAO,KAAK,GAAG,CAAC;IACnD,GAAG,MAAM,QAAQ,KAAI,SAAQ,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQ,KAAK,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC;GAC7G,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;GAE5B,IAAI,MAAM;GACV,IAAI,SAAS;GACb,KAAK,MAAM,CAAC,OAAO,QAAQ,QAAQ;IACjC,OAAO,KAAK,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,MAAM,OAAO,GAAG,CAAC;IAC/D,SAAS;GACX;GAEA,OAAO,KAAK,MAAM,QAAQ,cAAc,KAAK,IACzC,2BACA,KAAK,MAAM,cAAc,YAAY,KAAK,IAC1C,oEAAoE,KAAK,UAAU,WAAW,EAAA,6DAChC,QAAQ;GAE1E,OAAO;IAAE,MAAM;IAAK,KAAK;GAAK;EAChC;CACF;AACF"}
@@ -0,0 +1,15 @@
1
+ import { Component } from "vue";
2
+ //#region src/render/withPreviewProps.d.ts
3
+ /**
4
+ * Set on a per-render config by the dev server. Global symbol registry
5
+ * so the Node and Vite SSR module instances agree on the key.
6
+ */
7
+ export declare const PreviewPropsKey: unique symbol;
8
+ /**
9
+ * Wrap a template that calls `definePreviewProps()`. Passes the real props
10
+ * through untouched, and only in dev server renders merges the sample
11
+ * props underneath them. The factory is never called otherwise.
12
+ */
13
+ export declare function withPreviewProps(component: Component, previewProps: () => Record<string, any> | Promise<Record<string, any>>): Component;
14
+ //#endregion
15
+ //# sourceMappingURL=withPreviewProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPreviewProps.d.ts","names":[],"sources":["../../src/render/withPreviewProps.ts"],"mappings":";;;;;;qBAQa;;;;;;wBAOG,iBACd,WAAW,WACX,oBAAoB,sBAAsB,QAAQ,uBACjD"}
@@ -0,0 +1,40 @@
1
+ import { MaizzleConfigKey } from "../composables/useConfig.js";
2
+ import { defineComponent, h, inject } from "vue";
3
+ //#region src/render/withPreviewProps.ts
4
+ /**
5
+ * Set on a per-render config by the dev server. Global symbol registry
6
+ * so the Node and Vite SSR module instances agree on the key.
7
+ */
8
+ const PreviewPropsKey = Symbol.for("maizzle.previewProps");
9
+ /**
10
+ * Wrap a template that calls `definePreviewProps()`. Passes the real props
11
+ * through untouched, and only in dev server renders merges the sample
12
+ * props underneath them. The factory is never called otherwise.
13
+ */
14
+ function withPreviewProps(component, previewProps) {
15
+ return defineComponent({
16
+ name: component.__name,
17
+ inheritAttrs: false,
18
+ setup(_, { attrs, slots }) {
19
+ if (!inject(MaizzleConfigKey)?.[PreviewPropsKey]) return () => h(component, attrs, slots);
20
+ const withPreview = (preview) => {
21
+ const props = {
22
+ ...preview,
23
+ ...attrs
24
+ };
25
+ return () => h(component, props, slots);
26
+ };
27
+ /**
28
+ * The factory is async when the sample data comes from imports,
29
+ * which it loads itself. Vue's SSR renderer awaits an async
30
+ * setup(), so those modules only load in the dev server.
31
+ */
32
+ const preview = previewProps();
33
+ return preview instanceof Promise ? preview.then(withPreview) : withPreview(preview);
34
+ }
35
+ });
36
+ }
37
+ //#endregion
38
+ export { PreviewPropsKey, withPreviewProps };
39
+
40
+ //# sourceMappingURL=withPreviewProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPreviewProps.js","names":[],"sources":["../../src/render/withPreviewProps.ts"],"sourcesContent":["import { defineComponent, h, inject } from 'vue'\nimport type { Component } from 'vue'\nimport { MaizzleConfigKey } from '../composables/useConfig.ts'\n\n/**\n * Set on a per-render config by the dev server. Global symbol registry\n * so the Node and Vite SSR module instances agree on the key.\n */\nexport const PreviewPropsKey = Symbol.for('maizzle.previewProps')\n\n/**\n * Wrap a template that calls `definePreviewProps()`. Passes the real props\n * through untouched, and only in dev server renders merges the sample\n * props underneath them. The factory is never called otherwise.\n */\nexport function withPreviewProps(\n component: Component,\n previewProps: () => Record<string, any> | Promise<Record<string, any>>,\n): Component {\n return defineComponent({\n name: (component as { __name?: string }).__name,\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n const config = inject(MaizzleConfigKey) as Record<symbol, unknown> | undefined\n if (!config?.[PreviewPropsKey]) return () => h(component, attrs, slots)\n\n const withPreview = (preview: Record<string, any>) => {\n const props = { ...preview, ...attrs }\n return () => h(component, props, slots)\n }\n\n /**\n * The factory is async when the sample data comes from imports,\n * which it loads itself. Vue's SSR renderer awaits an async\n * setup(), so those modules only load in the dev server.\n */\n const preview = previewProps()\n return preview instanceof Promise ? preview.then(withPreview) : withPreview(preview)\n },\n })\n}\n"],"mappings":";;;;;;;AAQA,MAAa,kBAAkB,OAAO,IAAI,sBAAsB;;;;;;AAOhE,SAAgB,iBACd,WACA,cACW;CACX,OAAO,gBAAgB;EACrB,MAAO,UAAkC;EACzC,cAAc;EACd,MAAM,GAAG,EAAE,OAAO,SAAS;GAEzB,IAAI,CADW,OAAO,gBACZ,CAAC,GAAG,kBAAkB,aAAa,EAAE,WAAW,OAAO,KAAK;GAEtE,MAAM,eAAe,YAAiC;IACpD,MAAM,QAAQ;KAAE,GAAG;KAAS,GAAG;IAAM;IACrC,aAAa,EAAE,WAAW,OAAO,KAAK;GACxC;;;;;;GAOA,MAAM,UAAU,aAAa;GAC7B,OAAO,mBAAmB,UAAU,QAAQ,KAAK,WAAW,IAAI,YAAY,OAAO;EACrF;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","names":[],"sources":["../src/serve.ts"],"mappings":";;;;iBA4DiB;EACf,SAAS,QAAQ;;EAEjB;;EAEA;;EAEA;;;;;;;;;;;wBAYoB,MAAM,UAAS,eAAiB,QAAA;wBA+vBtC,YAAY,QAAQ,eAAe"}
1
+ {"version":3,"file":"serve.d.ts","names":[],"sources":["../src/serve.ts"],"mappings":";;;;iBA6DiB;EACf,SAAS,QAAQ;;EAEjB;;EAEA;;EAEA;;;;;;;;;;;wBAYoB,MAAM,UAAS,eAAiB,QAAA;wBAiwBtC,YAAY,QAAQ,eAAe"}
package/dist/serve.js CHANGED
@@ -9,6 +9,7 @@ import { stripForHtml, stripForPlaintext } from "./utils/output-markers.js";
9
9
  import { _setCurrentTemplate } from "./composables/useCurrentTemplate.js";
10
10
  import { cloneConfig } from "./utils/cloneConfig.js";
11
11
  import { setActiveRenderer } from "./render/active.js";
12
+ import { PreviewPropsKey } from "./render/withPreviewProps.js";
12
13
  import { serveLint } from "./server/linter.js";
13
14
  import { serveCompatibility } from "./server/compatibility.js";
14
15
  import { sendEmail } from "./server/email.js";
@@ -450,9 +451,11 @@ function getRendered(absolutePath, config, renderer, events) {
450
451
  * Mirror the build's per-template event pipeline (see buildTemplate)
451
452
  * so dev preview fires the same beforeRender / afterRender /
452
453
  * afterTransform hooks and matches production output. Clone config so
453
- * beforeRender mutations stay scoped to this render.
454
+ * beforeRender mutations stay scoped to this render. The one deliberate
455
+ * difference: flag it so `definePreviewProps()` sample data applies.
454
456
  */
455
457
  const renderConfig = cloneConfig(config);
458
+ Object.assign(renderConfig, { [PreviewPropsKey]: true });
456
459
  const template = {
457
460
  source: readFileSync(absolutePath, "utf-8"),
458
461
  path: parse(absolutePath)
package/dist/serve.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","names":["parsePath"],"sources":["../src/serve.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve, basename, parse as parsePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { createServer, createLogger, type ViteDevServer } from 'vite'\nimport { renderUnicodeCompact } from 'uqr'\nimport vue from '@vitejs/plugin-vue'\nimport tailwindcss from '@tailwindcss/vite'\nimport { glob } from 'tinyglobby'\nimport { createHighlighter, type Highlighter } from 'shiki'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { resolveConfig } from './config/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { cloneConfig } from './utils/cloneConfig.ts'\nimport { createRenderer, type Renderer, type RenderedTemplate } from './render/createRenderer.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport { setActiveRenderer } from './render/active.ts'\nimport { serveCompatibility } from './server/compatibility.ts'\nimport { serveLint } from './server/linter.ts'\nimport { sendEmail } from './server/email.ts'\nimport { serveStaticFile } from './server/static.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { createWatchedFileMatcher, deriveWatchRoots } from './utils/watchPaths.ts'\nimport { staticBase } from './utils/staticPaths.ts'\nimport type { MaizzleConfig } from './types/index.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst devUIDir = resolve(__dirname, 'server/ui')\n\nconst require = createRequire(import.meta.url)\n\nconst version = JSON.parse(\n readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf-8'),\n).version\n\nconst pkg = (name: string) => {\n const resolved = require.resolve(name).replace(/\\\\/g, '/')\n const marker = `node_modules/${name}`\n const idx = resolved.lastIndexOf(marker)\n\n return resolved.slice(0, idx + marker.length)\n}\n\n/**\n * Resolve a package's ESM entry via its `exports` map. Aliasing to the\n * package directory bypasses `exports` (it only keys off the bare name),\n * so directory resolution can fall back to a UMD/CJS bundle — which Vite 8\n * flags `needsInterop` and then default-imports, breaking ESM-only deps\n * like culori (named exports, no default). Point the alias at the real\n * ESM entry instead.\n */\nconst pkgEsmEntry = (name: string) => {\n const dir = pkg(name)\n const pj = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8'))\n const entry = pj.exports?.['.']?.import ?? pj.module ?? pj.main\n return resolve(dir, entry)\n}\n\nexport interface ServeOptions {\n config?: Partial<MaizzleConfig> | string\n /** Override the dev server port (takes precedence over config.server.port) */\n port?: number\n /** Expose the server on the network (e.g. --host) */\n host?: boolean | string\n /** When true, suppresses the startup banner/URL output. */\n silent?: boolean\n}\n\n/**\n * Start the Maizzle dev server.\n *\n * Creates two things:\n * 1. A Vite dev server for the dev UI (sidebar + preview, with Vue + Tailwind for the UI itself)\n * 2. A Renderer instance for SSR rendering email templates\n *\n * Template rendering goes through the Renderer, not the Vite dev server.\n */\nexport async function serve(options: ServeOptions = {}) {\n const start = performance.now()\n\n let config = await resolveConfig(options.config)\n const port = options.port ?? config.server?.port ?? 3000\n const host = options.host ?? config.server?.host\n\n // Create a renderer for SSR rendering email templates (with dts for dev)\n let renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n /**\n * Register so user-land render() calls reuse this renderer instead of\n * spinning up another Vite SSR server (which collides when the host\n * app is itself a Vite dev process — e.g. TanStack Start).\n */\n setActiveRenderer(renderer)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const server = await createServer({\n configFile: false,\n /**\n * Root at the dev UI directory, not process.cwd(). With the host\n * project as Vite root, the watcher recursively watches the entire\n * host tree (vendor dirs, build output, …) — on large projects this\n * exhausts inotify watch limits — and the host's own\n * `server.watch.ignored` cannot reach this server. The UI is served\n * via middleware + /@fs/ URLs and never needed the cwd root.\n * `appType: 'custom'` keeps Vite from serving devUIDir/index.html\n * itself, which would bypass the config-injecting middleware.\n * The paths Maizzle actually reacts to are added explicitly in\n * maizzleDevPlugin's configureServer.\n */\n root: devUIDir,\n appType: 'custom',\n /**\n * Vite derives `publicDir` from `root`, so keep serving the project's\n * `public/` directory: templates reference images as `/logo.png`\n * (the default `static.source` copies `public/**` on build) and\n * the preview iframe resolves those against this server.\n */\n publicDir: resolve(process.cwd(), 'public'),\n plugins: [\n // Vue and Tailwind are only for the dev UI SPA, not for email templates\n vue(),\n tailwindcss(),\n maizzleDevPlugin(config, renderer, events, options.config),\n ],\n resolve: {\n dedupe: ['vue'],\n alias: [\n { find: '@', replacement: devUIDir },\n { find: 'vue', replacement: resolve(pkg('vue'), 'dist/vue.runtime.esm-bundler.js') },\n // culori is ESM-only — alias to its ESM entry, not the package dir (see pkgEsmEntry)\n { find: 'culori', replacement: pkgEsmEntry('culori') },\n ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge']\n .map(name => ({ find: name, replacement: pkg(name) })),\n ],\n },\n cacheDir: resolve(devUIDir, '.vite'),\n optimizeDeps: {\n noDiscovery: true,\n include: [\n 'vue',\n 'vue-router',\n '@lucide/vue',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n ],\n },\n server: {\n // Cherry-pick Vite's `server` options (e.g. watch.ignored) from the\n // user's `vite` config; Maizzle's required keys below take precedence.\n ...config.vite?.server,\n port,\n host,\n fs: {\n ...config.vite?.server?.fs,\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori'].map(pkg), ...(config.vite?.server?.fs?.allow ?? [])],\n },\n },\n customLogger: customLogger(),\n })\n\n // Store renderer ref on server for cleanup\n const originalClose = server.close.bind(server)\n server.close = async () => {\n setActiveRenderer(null)\n await renderer.close()\n return originalClose()\n }\n\n await server.listen()\n\n const startupTime = Math.round(performance.now() - start)\n\n if (!options.silent) {\n printBanner(server, startupTime)\n }\n\n // Expose startup time so the plugin can print it later\n ; (server as any)._maizzleStartupTime = startupTime\n\n return server\n}\n\n/**\n * Internal Vite plugin that adds Maizzle middleware and file watching to the dev UI server.\n */\nfunction maizzleDevPlugin(\n config: MaizzleConfig,\n renderer: Renderer,\n events: EventManager,\n configInput: Partial<MaizzleConfig> | string | undefined,\n) {\n return {\n name: 'maizzle:dev',\n enforce: 'pre' as const,\n\n hotUpdate: {\n order: 'pre' as const,\n handler({ file }: { file: string }) {\n /**\n * Prevent Tailwind/Vue from triggering a full reload for email template\n * files. Maizzle handles these via custom HMR events in the\n * watcher below.\n */\n if (isTemplateFile(file)) {\n return []\n }\n },\n },\n\n configureServer(server: ViteDevServer) {\n // File watching\n const defaultWatchPaths = [\n 'maizzle.config.js',\n 'maizzle.config.ts',\n 'tailwind.config.js',\n 'tailwind.config.ts',\n 'locales/**',\n ]\n\n /**\n * (Re)establish file watching for a resolved config: the matcher used\n * by the change handler below, and — with the dev UI directory as Vite\n * root, the host cwd is no longer watched wholesale — the directories\n * the watch globs and the template content live in (see\n * deriveWatchRoots). Only derived roots are added to the watcher: the\n * server runs with Vite's default `disableGlobbing`, so raw glob\n * patterns would be treated as literal paths, and plain file paths\n * survive derivation as themselves. Runs once here and again after a\n * config reload, so content, components.source, root, and server.watch\n * edits take effect without a server restart. Roots a reload leaves\n * behind stay watched until restart — superfluous but harmless.\n *\n * Match against cwd, not config.root: the watched paths (maizzle/tailwind\n * configs, locales) are project-root relative, and `watcher.add`\n * resolves them against cwd too. Using config.root would break matching\n * when root points at a subdirectory (e.g. the Vite-plugin setup).\n */\n const applyWatchPaths = (cfg: MaizzleConfig) => {\n const watchPaths = [...defaultWatchPaths, ...(cfg.server?.watch ?? [])]\n const watchRoots = deriveWatchRoots({\n content: cfg.content ?? ['emails/**/*.vue'],\n componentDirs: normalizeComponentSources(cfg.components?.source, process.cwd()).map(s => s.path),\n root: cfg.root,\n watchPaths,\n cwd: process.cwd(),\n })\n\n for (const watchRoot of watchRoots) {\n server.watcher.add(watchRoot)\n }\n\n return createWatchedFileMatcher(watchPaths, process.cwd())\n }\n\n let isWatchedFile = applyWatchPaths(config)\n\n /**\n * Serve the `static.source` directories at `/<static.destination>`,\n * mirroring what `build` copies to the output dir, so templates that\n * reference `/images/logo.png` resolve in the preview iframe. Each\n * positive pattern's glob-free prefix is mounted (looked up on disk\n * per request, so files added after startup are served) and added\n * to the watcher so the preview refreshes on changes. Runs again\n * after a config reload; the middleware below reads the current\n * mounts on every request.\n */\n const applyStaticMounts = (cfg: MaizzleConfig) => {\n const sources = cfg.static?.source ?? ['public/**/*.*']\n const destination = (cfg.static?.destination ?? 'public').replace(/^\\/+|\\/+$/g, '')\n const prefix = destination ? `/${destination}` : ''\n const bases = [...new Set(sources.filter(s => !s.startsWith('!')).map(staticBase))]\n\n for (const base of bases) {\n server.watcher.add(base)\n }\n\n return {\n mounts: bases.map(base => ({ prefix, base })),\n isStaticFile: createWatchedFileMatcher(sources, process.cwd()),\n }\n }\n\n let { mounts: staticMounts, isStaticFile } = applyStaticMounts(config)\n\n /**\n * Serialize watcher work onto one chain. The change handler closes and\n * recreates the renderer across awaits; without serialization a second\n * event firing mid-reload closes a stale renderer and leaks the new one.\n * Errors are caught so one failed task doesn't break the chain.\n */\n let watcherChain: Promise<void> = Promise.resolve()\n const enqueue = (task: () => Promise<void>): Promise<void> => {\n watcherChain = watcherChain.then(task).catch((err) => {\n console.error('[maizzle] watcher task failed:', err)\n })\n return watcherChain\n }\n\n server.watcher.on('add', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n } else if (isStaticFile(file)) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n server.watcher.on('unlink', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n } else if (isStaticFile(file)) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n server.watcher.on('change', file => enqueue(async () => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\n\n // Re-register event handlers against the reloaded config (the config\n // object is replaced wholesale, so old handlers would be stale).\n events.clear()\n events.registerConfig(config)\n\n // Recreate the renderer so config changes (e.g. markdown.shikiTheme) take effect\n await renderer.close()\n renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n // Re-register the new renderer so user-land render() calls don't keep\n // reusing the closed one (see setActiveRenderer above).\n setActiveRenderer(renderer)\n\n // Re-establish watching against the reloaded config so moved\n // content, components.source, root, or server.watch values keep\n // emitting events without a server restart.\n isWatchedFile = applyWatchPaths(config)\n ;({ mounts: staticMounts, isStaticFile } = applyStaticMounts(config))\n\n /**\n * Push UI-relevant config bits so the dev UI reacts to live edits\n * without a page reload. Uses the same shape as the initial\n * inject.\n */\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n /**\n * Invalidate all renderer modules so component and config changes\n * are picked up on the next render (Tailwind recompiles with\n * fresh content).\n */\n await renderer.invalidateAll()\n bumpGeneration()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(file)\n || isStaticFile(file)\n ) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n // API middleware (before Vite's middleware)\n server.middlewares.use(async (req: any, res: any, next: any) => {\n const url = req.url || '/'\n\n if (url === '/__maizzle/templates') {\n return serveTemplateList(config, res)\n }\n\n if (url.startsWith('/__maizzle/render/')) {\n return await serveRenderedTemplate(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/compatibility/')) {\n return await serveCompatibility(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/lint/')) {\n return await serveLint(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/vue-source/')) {\n return await serveVueSource(url, config, res)\n }\n\n if (url.startsWith('/__maizzle/plaintext/')) {\n return await servePlaintext(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer, events)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\n }\n\n next()\n })\n\n // Static assets from `static.source`, mounted at `/<static.destination>`\n server.middlewares.use((req: any, res: any, next: any) => {\n const url: string = req.url || '/'\n\n for (const { prefix, base } of staticMounts) {\n if (url === prefix || url.startsWith(`${prefix}/`) || url.startsWith(`${prefix}?`)) {\n if (serveStaticFile(base, url.slice(prefix.length) || '/', res)) return\n }\n }\n\n next()\n })\n\n // Dev UI fallback (after Vite's middleware)\n return () => {\n server.middlewares.use(async (req: any, res: any, next: any) => {\n if (isNavigationRequest(req)) {\n return await serveDevUI(server, res, req.url || '/', config)\n }\n\n next()\n })\n }\n },\n }\n}\n\nfunction isTemplateFile(file: string): boolean {\n return (file.endsWith('.vue') || file.endsWith('.md')) && !file.includes('server/ui')\n}\n\nfunction isNavigationRequest(req: any): boolean {\n const accept = req.headers?.accept || ''\n return req.method === 'GET' && accept.includes('text/html')\n}\n\n/**\n * Shape exposed to the dev UI both at initial HTML load (as\n * `window.__MAIZZLE_CONFIG__`) and on the `maizzle:config-updated` HMR event.\n * Add UI-visible config bits here; consumers on both ends pick up automatically.\n */\nfunction buildUiConfig(config: MaizzleConfig) {\n return {\n checks: config.server?.checks ?? true,\n }\n}\n\nasync function serveDevUI(server: ViteDevServer, res: any, url: string, config: MaizzleConfig) {\n let indexHtml = readFileSync(resolve(devUIDir, 'index.html'), 'utf-8')\n\n indexHtml = indexHtml.replace('./main.ts', `/@fs/${resolve(devUIDir, 'main.ts')}`)\n indexHtml = indexHtml.replace('./favicon.svg', `/@fs/${resolve(devUIDir, 'favicon.svg')}`)\n\n const configScript = `<script>window.__MAIZZLE_CONFIG__ = ${JSON.stringify(buildUiConfig(config))};</script>`\n indexHtml = indexHtml.replace('</head>', `${configScript}</head>`)\n\n const transformed = await server.transformIndexHtml(url, indexHtml)\n\n res.setHeader('Content-Type', 'text/html')\n res.end(transformed)\n}\n\nasync function serveTemplateList(config: MaizzleConfig, res: any) {\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n\n const data = templates.map(t => ({\n name: basename(t).replace(/\\.(vue|md)$/, ''),\n path: t,\n href: '/' + t.replace(/\\.(vue|md)$/, ''),\n }))\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(data))\n}\n\ninterface DedupedRender {\n /** Transformer output — before doctype prepend / stripForHtml / stripForPlaintext. */\n rawHtml: string\n doctype: string\n templateConfig: MaizzleConfig\n rendered: RenderedTemplate\n}\n\n/**\n * Render-result memo for the dev server. A single template save makes the\n * browser fire several endpoint requests in parallel (render, source, stats,\n * plaintext, email) that each need the same SSR render + transformer output.\n * Keying the in-flight Promise by `${generation}:${path}` collapses those into\n * one render and dedupes concurrent requests. The watcher bumps the generation\n * (and clears the cache) on every file/config change, so results never go\n * stale. Each endpoint applies its own tail step (doctype prepend, strip,\n * highlight, …) on top of `rawHtml`, keeping output byte-identical.\n */\nlet renderGeneration = 0\nconst renderCache = new Map<string, Promise<DedupedRender>>()\n\nfunction bumpGeneration() {\n renderGeneration++\n renderCache.clear()\n}\n\nfunction getRendered(absolutePath: string, config: MaizzleConfig, renderer: Renderer, events: EventManager): Promise<DedupedRender> {\n const key = `${renderGeneration}:${absolutePath}`\n let promise = renderCache.get(key)\n if (!promise) {\n promise = (async () => {\n _setCurrentTemplate(parsePath(absolutePath))\n try {\n /**\n * Mirror the build's per-template event pipeline (see buildTemplate)\n * so dev preview fires the same beforeRender / afterRender /\n * afterTransform hooks and matches production output. Clone config so\n * beforeRender mutations stay scoped to this render.\n */\n const renderConfig = cloneConfig(config)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsePath(absolutePath) }\n const originalSource = template.source\n\n await events.fireBeforeRender({ config: renderConfig, template })\n\n const rendered = await renderer.render(\n absolutePath,\n renderConfig,\n template.source !== originalSource ? { source: template.source } : undefined,\n )\n\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n const templateConfig = rendered.templateConfig\n let html = await events.fireAfterRender({ config: templateConfig, template, html: rendered.html })\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks, rendered.sourceFiles)\n\n const rawHtml = await events.fireAfterTransform({ config: templateConfig, template, html })\n\n return { rawHtml, doctype, templateConfig, rendered }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n })()\n renderCache.set(key, promise)\n }\n return promise\n}\n\n/**\n * SSR render a .vue template using the Renderer (not the dev UI server).\n */\nasync function serveRenderedTemplate(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/render/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n let html = rawHtml\n if (doctype) html = `${doctype}\\n${html}`\n\n res.setHeader('Content-Type', 'text/html')\n res.end(stripForHtml(html))\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['laserwave'],\n langs: ['html', 'vue'],\n })\n }\n return highlighter\n}\n\nasync function serveHighlightedSource(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(doctype ? `${doctype}\\n${rawHtml}` : rawHtml)\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(html, {\n lang: 'html',\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function serveVueSource(url: string, config: MaizzleConfig, res: any) {\n const templateSlug = url.replace('/__maizzle/vue-source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n try {\n const source = readFileSync(resolve(match), 'utf-8')\n const lang = match.endsWith('.md') ? 'html' : 'vue'\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(source, {\n lang,\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function servePlaintext(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/plaintext/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const plaintext = createPlaintext(stripForPlaintext(rawHtml))\n\n res.setHeader('Content-Type', 'text/plain')\n res.end(plaintext)\n } catch (error: any) {\n res.statusCode = 500\n res.end(error.message)\n }\n}\n\nfunction humanFileSize(bytes: number, si = false, dp = 2) {\n const threshold = si ? 1000 : 1024\n\n if (Math.abs(bytes) < threshold) {\n return bytes + ' B'\n }\n\n const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n let u = -1\n const r = 10 ** dp\n\n do {\n bytes /= threshold\n ++u\n } while (Math.round(Math.abs(bytes) * r) / r >= threshold && u < units.length - 1)\n\n return bytes.toFixed(dp) + ' ' + units[u]\n}\n\nasync function serveStats(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/stats/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ error: 'Template not found' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(rawHtml)\n\n const sizeBytes = new TextEncoder().encode(html).length\n\n // Count images: <img> tags and CSS background images\n const imgTags = (html.match(/<img\\b[^>]*>/gi) || []).length\n const bgImages = (html.match(/url\\s*\\([^)]+\\)/gi) || []).length\n const totalImages = imgTags + bgImages\n\n // Count links\n const links = (html.match(/<a\\b[^>]*href\\s*=/gi) || []).length\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n size: {\n bytes: sizeBytes,\n formatted: humanFileSize(sizeBytes),\n },\n images: totalImages,\n links,\n }))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ error: error.message }))\n }\n}\n\nasync function serveEmailEndpoint(url: string, req: any, res: any, config: MaizzleConfig, renderer: Renderer, events: EventManager) {\n const templateSlug = url.replace('/__maizzle/email/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ success: false, message: 'Template not found' }))\n return\n }\n\n let body = ''\n for await (const chunk of req) body += chunk\n\n let payload: { to: string[]; subject: string }\n\n try {\n payload = JSON.parse(body)\n } catch {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Invalid JSON' }))\n return\n }\n\n if (!payload.to?.length) {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Missing recipients' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype, templateConfig } = await getRendered(absolutePath, config, renderer, events)\n let html = doctype ? `${doctype}\\n${rawHtml}` : rawHtml\n\n const text = createPlaintext(stripForPlaintext(html))\n html = stripForHtml(html)\n\n const result = await sendEmail(\n { to: payload.to, subject: payload.subject, html, text },\n config,\n templateConfig,\n )\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ success: false, message: error.message }))\n }\n}\n\nfunction serveEmailConfig(config: MaizzleConfig, res: any) {\n const emailConfig = config.server?.email\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n to: emailConfig?.to ? (Array.isArray(emailConfig.to) ? emailConfig.to : [emailConfig.to]) : [],\n from: emailConfig?.from ?? '',\n subject: emailConfig?.subject ?? '',\n hasTransport: !!emailConfig?.transport,\n }))\n}\n\nexport function printBanner(server: ViteDevServer, startupTime?: number) {\n const info = server.config.logger.info\n const time = startupTime ?? (server as any)._maizzleStartupTime\n\n const networkUrl = server.resolvedUrls?.network[0]\n if (networkUrl) {\n const qr = renderUnicodeCompact(networkUrl, { border: 1 })\n info('')\n info(qr.split('\\n').map(line => ` ${line}`).join('\\n'))\n }\n\n info('')\n info(` \\x1b[32m\\x1b[1mMAIZZLE\\x1b[0m\\x1b[32m v${version}\\x1b[0m \\x1b[2mready in\\x1b[0m \\x1b[1m${time}\\x1b[0m ms`)\n info('')\n server.printUrls()\n info('')\n}\n\nfunction customLogger() {\n const logger = createLogger('info')\n const warn = logger.warn\n\n logger.warn = (message, options) => {\n if (typeof message === 'string' && message.includes('<tr> cannot be child of <table>')) {\n return\n }\n\n warn(message, options)\n }\n\n return logger\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,MAAM,WAAW,QAAQ,WAAW,WAAW;AAE/C,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,MAAM,UAAU,KAAK,MACnB,aAAa,QAAQ,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,iBAAiB,GAAG,OAAO,CAC3F,CAAC,CAAC;AAEF,MAAM,OAAO,SAAiB;CAC5B,MAAM,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,QAAQ,OAAO,GAAG;CACzD,MAAM,SAAS,gBAAgB;CAC/B,MAAM,MAAM,SAAS,YAAY,MAAM;CAEvC,OAAO,SAAS,MAAM,GAAG,MAA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,SAAS,OAAY;EACnB,IAAI,aAAa;EACjB,IAAI,IAAI,KAAK,UAAU;GAAE,SAAS;GAAO,SAAS,MAAM;EAAQ,CAAC,CAAC;CACpE;AACF;AAEA,SAAS,iBAAiB,QAAuB,KAAU;CACzD,MAAM,cAAc,OAAO,QAAQ;CACnC,IAAI,UAAU,gBAAgB,kBAAkB;CAChD,IAAI,IAAI,KAAK,UAAU;EACrB,IAAI,aAAa,KAAM,MAAM,QAAQ,YAAY,EAAE,IAAI,YAAY,KAAK,CAAC,YAAY,EAAE,IAAK,CAAC;EAC7F,MAAM,aAAa,QAAQ;EAC3B,SAAS,aAAa,WAAW;EACjC,cAAc,CAAC,CAAC,aAAa;CAC/B,CAAC,CAAC;AACJ;AAEA,SAAgB,YAAY,QAAuB,aAAsB;CACvE,MAAM,OAAO,OAAO,OAAO,OAAO;CAClC,MAAM,OAAO,eAAgB,OAAe;CAE5C,MAAM,aAAa,OAAO,cAAc,QAAQ;CAChD,IAAI,YAAY;EACd,MAAM,KAAK,qBAAqB,YAAY,EAAE,QAAQ,EAAE,CAAC;EACzD,KAAK,EAAE;EACP,KAAK,GAAG,MAAM,IAAI,CAAC,CAAC,KAAI,SAAQ,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC;CACzD;CAEA,KAAK,EAAE;CACP,KAAK,4CAA4C,QAAQ,yCAAyC,KAAK,WAAW;CAClH,KAAK,EAAE;CACP,OAAO,UAAU;CACjB,KAAK,EAAE;AACT;AAEA,SAAS,eAAe;CACtB,MAAM,SAAS,aAAa,MAAM;CAClC,MAAM,OAAO,OAAO;CAEpB,OAAO,QAAQ,SAAS,YAAY;EAClC,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,iCAAiC,GACnF;EAGF,KAAK,SAAS,OAAO;CACvB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"serve.js","names":["parsePath"],"sources":["../src/serve.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve, basename, parse as parsePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { createServer, createLogger, type ViteDevServer } from 'vite'\nimport { renderUnicodeCompact } from 'uqr'\nimport vue from '@vitejs/plugin-vue'\nimport tailwindcss from '@tailwindcss/vite'\nimport { glob } from 'tinyglobby'\nimport { createHighlighter, type Highlighter } from 'shiki'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { resolveConfig } from './config/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { cloneConfig } from './utils/cloneConfig.ts'\nimport { PreviewPropsKey } from './render/withPreviewProps.ts'\nimport { createRenderer, type Renderer, type RenderedTemplate } from './render/createRenderer.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport { setActiveRenderer } from './render/active.ts'\nimport { serveCompatibility } from './server/compatibility.ts'\nimport { serveLint } from './server/linter.ts'\nimport { sendEmail } from './server/email.ts'\nimport { serveStaticFile } from './server/static.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { createWatchedFileMatcher, deriveWatchRoots } from './utils/watchPaths.ts'\nimport { staticBase } from './utils/staticPaths.ts'\nimport type { MaizzleConfig } from './types/index.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst devUIDir = resolve(__dirname, 'server/ui')\n\nconst require = createRequire(import.meta.url)\n\nconst version = JSON.parse(\n readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf-8'),\n).version\n\nconst pkg = (name: string) => {\n const resolved = require.resolve(name).replace(/\\\\/g, '/')\n const marker = `node_modules/${name}`\n const idx = resolved.lastIndexOf(marker)\n\n return resolved.slice(0, idx + marker.length)\n}\n\n/**\n * Resolve a package's ESM entry via its `exports` map. Aliasing to the\n * package directory bypasses `exports` (it only keys off the bare name),\n * so directory resolution can fall back to a UMD/CJS bundle — which Vite 8\n * flags `needsInterop` and then default-imports, breaking ESM-only deps\n * like culori (named exports, no default). Point the alias at the real\n * ESM entry instead.\n */\nconst pkgEsmEntry = (name: string) => {\n const dir = pkg(name)\n const pj = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8'))\n const entry = pj.exports?.['.']?.import ?? pj.module ?? pj.main\n return resolve(dir, entry)\n}\n\nexport interface ServeOptions {\n config?: Partial<MaizzleConfig> | string\n /** Override the dev server port (takes precedence over config.server.port) */\n port?: number\n /** Expose the server on the network (e.g. --host) */\n host?: boolean | string\n /** When true, suppresses the startup banner/URL output. */\n silent?: boolean\n}\n\n/**\n * Start the Maizzle dev server.\n *\n * Creates two things:\n * 1. A Vite dev server for the dev UI (sidebar + preview, with Vue + Tailwind for the UI itself)\n * 2. A Renderer instance for SSR rendering email templates\n *\n * Template rendering goes through the Renderer, not the Vite dev server.\n */\nexport async function serve(options: ServeOptions = {}) {\n const start = performance.now()\n\n let config = await resolveConfig(options.config)\n const port = options.port ?? config.server?.port ?? 3000\n const host = options.host ?? config.server?.host\n\n // Create a renderer for SSR rendering email templates (with dts for dev)\n let renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n /**\n * Register so user-land render() calls reuse this renderer instead of\n * spinning up another Vite SSR server (which collides when the host\n * app is itself a Vite dev process — e.g. TanStack Start).\n */\n setActiveRenderer(renderer)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const server = await createServer({\n configFile: false,\n /**\n * Root at the dev UI directory, not process.cwd(). With the host\n * project as Vite root, the watcher recursively watches the entire\n * host tree (vendor dirs, build output, …) — on large projects this\n * exhausts inotify watch limits — and the host's own\n * `server.watch.ignored` cannot reach this server. The UI is served\n * via middleware + /@fs/ URLs and never needed the cwd root.\n * `appType: 'custom'` keeps Vite from serving devUIDir/index.html\n * itself, which would bypass the config-injecting middleware.\n * The paths Maizzle actually reacts to are added explicitly in\n * maizzleDevPlugin's configureServer.\n */\n root: devUIDir,\n appType: 'custom',\n /**\n * Vite derives `publicDir` from `root`, so keep serving the project's\n * `public/` directory: templates reference images as `/logo.png`\n * (the default `static.source` copies `public/**` on build) and\n * the preview iframe resolves those against this server.\n */\n publicDir: resolve(process.cwd(), 'public'),\n plugins: [\n // Vue and Tailwind are only for the dev UI SPA, not for email templates\n vue(),\n tailwindcss(),\n maizzleDevPlugin(config, renderer, events, options.config),\n ],\n resolve: {\n dedupe: ['vue'],\n alias: [\n { find: '@', replacement: devUIDir },\n { find: 'vue', replacement: resolve(pkg('vue'), 'dist/vue.runtime.esm-bundler.js') },\n // culori is ESM-only — alias to its ESM entry, not the package dir (see pkgEsmEntry)\n { find: 'culori', replacement: pkgEsmEntry('culori') },\n ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge']\n .map(name => ({ find: name, replacement: pkg(name) })),\n ],\n },\n cacheDir: resolve(devUIDir, '.vite'),\n optimizeDeps: {\n noDiscovery: true,\n include: [\n 'vue',\n 'vue-router',\n '@lucide/vue',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n ],\n },\n server: {\n // Cherry-pick Vite's `server` options (e.g. watch.ignored) from the\n // user's `vite` config; Maizzle's required keys below take precedence.\n ...config.vite?.server,\n port,\n host,\n fs: {\n ...config.vite?.server?.fs,\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori'].map(pkg), ...(config.vite?.server?.fs?.allow ?? [])],\n },\n },\n customLogger: customLogger(),\n })\n\n // Store renderer ref on server for cleanup\n const originalClose = server.close.bind(server)\n server.close = async () => {\n setActiveRenderer(null)\n await renderer.close()\n return originalClose()\n }\n\n await server.listen()\n\n const startupTime = Math.round(performance.now() - start)\n\n if (!options.silent) {\n printBanner(server, startupTime)\n }\n\n // Expose startup time so the plugin can print it later\n ; (server as any)._maizzleStartupTime = startupTime\n\n return server\n}\n\n/**\n * Internal Vite plugin that adds Maizzle middleware and file watching to the dev UI server.\n */\nfunction maizzleDevPlugin(\n config: MaizzleConfig,\n renderer: Renderer,\n events: EventManager,\n configInput: Partial<MaizzleConfig> | string | undefined,\n) {\n return {\n name: 'maizzle:dev',\n enforce: 'pre' as const,\n\n hotUpdate: {\n order: 'pre' as const,\n handler({ file }: { file: string }) {\n /**\n * Prevent Tailwind/Vue from triggering a full reload for email template\n * files. Maizzle handles these via custom HMR events in the\n * watcher below.\n */\n if (isTemplateFile(file)) {\n return []\n }\n },\n },\n\n configureServer(server: ViteDevServer) {\n // File watching\n const defaultWatchPaths = [\n 'maizzle.config.js',\n 'maizzle.config.ts',\n 'tailwind.config.js',\n 'tailwind.config.ts',\n 'locales/**',\n ]\n\n /**\n * (Re)establish file watching for a resolved config: the matcher used\n * by the change handler below, and — with the dev UI directory as Vite\n * root, the host cwd is no longer watched wholesale — the directories\n * the watch globs and the template content live in (see\n * deriveWatchRoots). Only derived roots are added to the watcher: the\n * server runs with Vite's default `disableGlobbing`, so raw glob\n * patterns would be treated as literal paths, and plain file paths\n * survive derivation as themselves. Runs once here and again after a\n * config reload, so content, components.source, root, and server.watch\n * edits take effect without a server restart. Roots a reload leaves\n * behind stay watched until restart — superfluous but harmless.\n *\n * Match against cwd, not config.root: the watched paths (maizzle/tailwind\n * configs, locales) are project-root relative, and `watcher.add`\n * resolves them against cwd too. Using config.root would break matching\n * when root points at a subdirectory (e.g. the Vite-plugin setup).\n */\n const applyWatchPaths = (cfg: MaizzleConfig) => {\n const watchPaths = [...defaultWatchPaths, ...(cfg.server?.watch ?? [])]\n const watchRoots = deriveWatchRoots({\n content: cfg.content ?? ['emails/**/*.vue'],\n componentDirs: normalizeComponentSources(cfg.components?.source, process.cwd()).map(s => s.path),\n root: cfg.root,\n watchPaths,\n cwd: process.cwd(),\n })\n\n for (const watchRoot of watchRoots) {\n server.watcher.add(watchRoot)\n }\n\n return createWatchedFileMatcher(watchPaths, process.cwd())\n }\n\n let isWatchedFile = applyWatchPaths(config)\n\n /**\n * Serve the `static.source` directories at `/<static.destination>`,\n * mirroring what `build` copies to the output dir, so templates that\n * reference `/images/logo.png` resolve in the preview iframe. Each\n * positive pattern's glob-free prefix is mounted (looked up on disk\n * per request, so files added after startup are served) and added\n * to the watcher so the preview refreshes on changes. Runs again\n * after a config reload; the middleware below reads the current\n * mounts on every request.\n */\n const applyStaticMounts = (cfg: MaizzleConfig) => {\n const sources = cfg.static?.source ?? ['public/**/*.*']\n const destination = (cfg.static?.destination ?? 'public').replace(/^\\/+|\\/+$/g, '')\n const prefix = destination ? `/${destination}` : ''\n const bases = [...new Set(sources.filter(s => !s.startsWith('!')).map(staticBase))]\n\n for (const base of bases) {\n server.watcher.add(base)\n }\n\n return {\n mounts: bases.map(base => ({ prefix, base })),\n isStaticFile: createWatchedFileMatcher(sources, process.cwd()),\n }\n }\n\n let { mounts: staticMounts, isStaticFile } = applyStaticMounts(config)\n\n /**\n * Serialize watcher work onto one chain. The change handler closes and\n * recreates the renderer across awaits; without serialization a second\n * event firing mid-reload closes a stale renderer and leaks the new one.\n * Errors are caught so one failed task doesn't break the chain.\n */\n let watcherChain: Promise<void> = Promise.resolve()\n const enqueue = (task: () => Promise<void>): Promise<void> => {\n watcherChain = watcherChain.then(task).catch((err) => {\n console.error('[maizzle] watcher task failed:', err)\n })\n return watcherChain\n }\n\n server.watcher.on('add', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n } else if (isStaticFile(file)) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n server.watcher.on('unlink', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n } else if (isStaticFile(file)) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n server.watcher.on('change', file => enqueue(async () => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\n\n // Re-register event handlers against the reloaded config (the config\n // object is replaced wholesale, so old handlers would be stale).\n events.clear()\n events.registerConfig(config)\n\n // Recreate the renderer so config changes (e.g. markdown.shikiTheme) take effect\n await renderer.close()\n renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n // Re-register the new renderer so user-land render() calls don't keep\n // reusing the closed one (see setActiveRenderer above).\n setActiveRenderer(renderer)\n\n // Re-establish watching against the reloaded config so moved\n // content, components.source, root, or server.watch values keep\n // emitting events without a server restart.\n isWatchedFile = applyWatchPaths(config)\n ;({ mounts: staticMounts, isStaticFile } = applyStaticMounts(config))\n\n /**\n * Push UI-relevant config bits so the dev UI reacts to live edits\n * without a page reload. Uses the same shape as the initial\n * inject.\n */\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n /**\n * Invalidate all renderer modules so component and config changes\n * are picked up on the next render (Tailwind recompiles with\n * fresh content).\n */\n await renderer.invalidateAll()\n bumpGeneration()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(file)\n || isStaticFile(file)\n ) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n // API middleware (before Vite's middleware)\n server.middlewares.use(async (req: any, res: any, next: any) => {\n const url = req.url || '/'\n\n if (url === '/__maizzle/templates') {\n return serveTemplateList(config, res)\n }\n\n if (url.startsWith('/__maizzle/render/')) {\n return await serveRenderedTemplate(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/compatibility/')) {\n return await serveCompatibility(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/lint/')) {\n return await serveLint(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/vue-source/')) {\n return await serveVueSource(url, config, res)\n }\n\n if (url.startsWith('/__maizzle/plaintext/')) {\n return await servePlaintext(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer, events)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\n }\n\n next()\n })\n\n // Static assets from `static.source`, mounted at `/<static.destination>`\n server.middlewares.use((req: any, res: any, next: any) => {\n const url: string = req.url || '/'\n\n for (const { prefix, base } of staticMounts) {\n if (url === prefix || url.startsWith(`${prefix}/`) || url.startsWith(`${prefix}?`)) {\n if (serveStaticFile(base, url.slice(prefix.length) || '/', res)) return\n }\n }\n\n next()\n })\n\n // Dev UI fallback (after Vite's middleware)\n return () => {\n server.middlewares.use(async (req: any, res: any, next: any) => {\n if (isNavigationRequest(req)) {\n return await serveDevUI(server, res, req.url || '/', config)\n }\n\n next()\n })\n }\n },\n }\n}\n\nfunction isTemplateFile(file: string): boolean {\n return (file.endsWith('.vue') || file.endsWith('.md')) && !file.includes('server/ui')\n}\n\nfunction isNavigationRequest(req: any): boolean {\n const accept = req.headers?.accept || ''\n return req.method === 'GET' && accept.includes('text/html')\n}\n\n/**\n * Shape exposed to the dev UI both at initial HTML load (as\n * `window.__MAIZZLE_CONFIG__`) and on the `maizzle:config-updated` HMR event.\n * Add UI-visible config bits here; consumers on both ends pick up automatically.\n */\nfunction buildUiConfig(config: MaizzleConfig) {\n return {\n checks: config.server?.checks ?? true,\n }\n}\n\nasync function serveDevUI(server: ViteDevServer, res: any, url: string, config: MaizzleConfig) {\n let indexHtml = readFileSync(resolve(devUIDir, 'index.html'), 'utf-8')\n\n indexHtml = indexHtml.replace('./main.ts', `/@fs/${resolve(devUIDir, 'main.ts')}`)\n indexHtml = indexHtml.replace('./favicon.svg', `/@fs/${resolve(devUIDir, 'favicon.svg')}`)\n\n const configScript = `<script>window.__MAIZZLE_CONFIG__ = ${JSON.stringify(buildUiConfig(config))};</script>`\n indexHtml = indexHtml.replace('</head>', `${configScript}</head>`)\n\n const transformed = await server.transformIndexHtml(url, indexHtml)\n\n res.setHeader('Content-Type', 'text/html')\n res.end(transformed)\n}\n\nasync function serveTemplateList(config: MaizzleConfig, res: any) {\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n\n const data = templates.map(t => ({\n name: basename(t).replace(/\\.(vue|md)$/, ''),\n path: t,\n href: '/' + t.replace(/\\.(vue|md)$/, ''),\n }))\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(data))\n}\n\ninterface DedupedRender {\n /** Transformer output — before doctype prepend / stripForHtml / stripForPlaintext. */\n rawHtml: string\n doctype: string\n templateConfig: MaizzleConfig\n rendered: RenderedTemplate\n}\n\n/**\n * Render-result memo for the dev server. A single template save makes the\n * browser fire several endpoint requests in parallel (render, source, stats,\n * plaintext, email) that each need the same SSR render + transformer output.\n * Keying the in-flight Promise by `${generation}:${path}` collapses those into\n * one render and dedupes concurrent requests. The watcher bumps the generation\n * (and clears the cache) on every file/config change, so results never go\n * stale. Each endpoint applies its own tail step (doctype prepend, strip,\n * highlight, …) on top of `rawHtml`, keeping output byte-identical.\n */\nlet renderGeneration = 0\nconst renderCache = new Map<string, Promise<DedupedRender>>()\n\nfunction bumpGeneration() {\n renderGeneration++\n renderCache.clear()\n}\n\nfunction getRendered(absolutePath: string, config: MaizzleConfig, renderer: Renderer, events: EventManager): Promise<DedupedRender> {\n const key = `${renderGeneration}:${absolutePath}`\n let promise = renderCache.get(key)\n if (!promise) {\n promise = (async () => {\n _setCurrentTemplate(parsePath(absolutePath))\n try {\n /**\n * Mirror the build's per-template event pipeline (see buildTemplate)\n * so dev preview fires the same beforeRender / afterRender /\n * afterTransform hooks and matches production output. Clone config so\n * beforeRender mutations stay scoped to this render. The one deliberate\n * difference: flag it so `definePreviewProps()` sample data applies.\n */\n const renderConfig = cloneConfig(config)\n Object.assign(renderConfig, { [PreviewPropsKey]: true })\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsePath(absolutePath) }\n const originalSource = template.source\n\n await events.fireBeforeRender({ config: renderConfig, template })\n\n const rendered = await renderer.render(\n absolutePath,\n renderConfig,\n template.source !== originalSource ? { source: template.source } : undefined,\n )\n\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n const templateConfig = rendered.templateConfig\n let html = await events.fireAfterRender({ config: templateConfig, template, html: rendered.html })\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks, rendered.sourceFiles)\n\n const rawHtml = await events.fireAfterTransform({ config: templateConfig, template, html })\n\n return { rawHtml, doctype, templateConfig, rendered }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n })()\n renderCache.set(key, promise)\n }\n return promise\n}\n\n/**\n * SSR render a .vue template using the Renderer (not the dev UI server).\n */\nasync function serveRenderedTemplate(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/render/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n let html = rawHtml\n if (doctype) html = `${doctype}\\n${html}`\n\n res.setHeader('Content-Type', 'text/html')\n res.end(stripForHtml(html))\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['laserwave'],\n langs: ['html', 'vue'],\n })\n }\n return highlighter\n}\n\nasync function serveHighlightedSource(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(doctype ? `${doctype}\\n${rawHtml}` : rawHtml)\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(html, {\n lang: 'html',\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function serveVueSource(url: string, config: MaizzleConfig, res: any) {\n const templateSlug = url.replace('/__maizzle/vue-source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n try {\n const source = readFileSync(resolve(match), 'utf-8')\n const lang = match.endsWith('.md') ? 'html' : 'vue'\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(source, {\n lang,\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function servePlaintext(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/plaintext/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const plaintext = createPlaintext(stripForPlaintext(rawHtml))\n\n res.setHeader('Content-Type', 'text/plain')\n res.end(plaintext)\n } catch (error: any) {\n res.statusCode = 500\n res.end(error.message)\n }\n}\n\nfunction humanFileSize(bytes: number, si = false, dp = 2) {\n const threshold = si ? 1000 : 1024\n\n if (Math.abs(bytes) < threshold) {\n return bytes + ' B'\n }\n\n const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n let u = -1\n const r = 10 ** dp\n\n do {\n bytes /= threshold\n ++u\n } while (Math.round(Math.abs(bytes) * r) / r >= threshold && u < units.length - 1)\n\n return bytes.toFixed(dp) + ' ' + units[u]\n}\n\nasync function serveStats(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/stats/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ error: 'Template not found' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(rawHtml)\n\n const sizeBytes = new TextEncoder().encode(html).length\n\n // Count images: <img> tags and CSS background images\n const imgTags = (html.match(/<img\\b[^>]*>/gi) || []).length\n const bgImages = (html.match(/url\\s*\\([^)]+\\)/gi) || []).length\n const totalImages = imgTags + bgImages\n\n // Count links\n const links = (html.match(/<a\\b[^>]*href\\s*=/gi) || []).length\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n size: {\n bytes: sizeBytes,\n formatted: humanFileSize(sizeBytes),\n },\n images: totalImages,\n links,\n }))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ error: error.message }))\n }\n}\n\nasync function serveEmailEndpoint(url: string, req: any, res: any, config: MaizzleConfig, renderer: Renderer, events: EventManager) {\n const templateSlug = url.replace('/__maizzle/email/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ success: false, message: 'Template not found' }))\n return\n }\n\n let body = ''\n for await (const chunk of req) body += chunk\n\n let payload: { to: string[]; subject: string }\n\n try {\n payload = JSON.parse(body)\n } catch {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Invalid JSON' }))\n return\n }\n\n if (!payload.to?.length) {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Missing recipients' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype, templateConfig } = await getRendered(absolutePath, config, renderer, events)\n let html = doctype ? `${doctype}\\n${rawHtml}` : rawHtml\n\n const text = createPlaintext(stripForPlaintext(html))\n html = stripForHtml(html)\n\n const result = await sendEmail(\n { to: payload.to, subject: payload.subject, html, text },\n config,\n templateConfig,\n )\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ success: false, message: error.message }))\n }\n}\n\nfunction serveEmailConfig(config: MaizzleConfig, res: any) {\n const emailConfig = config.server?.email\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n to: emailConfig?.to ? (Array.isArray(emailConfig.to) ? emailConfig.to : [emailConfig.to]) : [],\n from: emailConfig?.from ?? '',\n subject: emailConfig?.subject ?? '',\n hasTransport: !!emailConfig?.transport,\n }))\n}\n\nexport function printBanner(server: ViteDevServer, startupTime?: number) {\n const info = server.config.logger.info\n const time = startupTime ?? (server as any)._maizzleStartupTime\n\n const networkUrl = server.resolvedUrls?.network[0]\n if (networkUrl) {\n const qr = renderUnicodeCompact(networkUrl, { border: 1 })\n info('')\n info(qr.split('\\n').map(line => ` ${line}`).join('\\n'))\n }\n\n info('')\n info(` \\x1b[32m\\x1b[1mMAIZZLE\\x1b[0m\\x1b[32m v${version}\\x1b[0m \\x1b[2mready in\\x1b[0m \\x1b[1m${time}\\x1b[0m ms`)\n info('')\n server.printUrls()\n info('')\n}\n\nfunction customLogger() {\n const logger = createLogger('info')\n const warn = logger.warn\n\n logger.warn = (message, options) => {\n if (typeof message === 'string' && message.includes('<tr> cannot be child of <table>')) {\n return\n }\n\n warn(message, options)\n }\n\n return logger\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,MAAM,WAAW,QAAQ,WAAW,WAAW;AAE/C,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,MAAM,UAAU,KAAK,MACnB,aAAa,QAAQ,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,iBAAiB,GAAG,OAAO,CAC3F,CAAC,CAAC;AAEF,MAAM,OAAO,SAAiB;CAC5B,MAAM,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,QAAQ,OAAO,GAAG;CACzD,MAAM,SAAS,gBAAgB;CAC/B,MAAM,MAAM,SAAS,YAAY,MAAM;CAEvC,O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