@maizzle/framework 6.0.0-rc.20 → 6.0.0-rc.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","names":[],"sources":["../src/build.ts"],"mappings":";;UAciB,WAAA;EACf,KAAA;EACA,MAAA,EAAQ,aAAA;AAAA;;;;;;;;;AAaV;;iBAAsB,KAAA,CAAM,WAAA,GAAc,OAAA,CAAQ,aAAA,aAA0B,OAAA,CAAQ,WAAA"}
1
+ {"version":3,"file":"build.d.ts","names":[],"sources":["../src/build.ts"],"mappings":";;UAeiB,WAAA;EACf,KAAA;EACA,MAAA,EAAQ,aAAA;AAAA;;;;;;;;;AAaV;;iBAAsB,KAAA,CAAM,WAAA,GAAc,OAAA,CAAQ,aAAA,aAA0B,OAAA,CAAQ,WAAA"}
package/dist/build.js CHANGED
@@ -5,8 +5,9 @@ import { normalizeComponentSources } from "./utils/componentSources.js";
5
5
  import { createRenderer } from "./render/createRenderer.js";
6
6
  import { createPlaintext } from "./plaintext.js";
7
7
  import { stripForHtml, stripForPlaintext } from "./utils/output-markers.js";
8
+ import { _setCurrentTemplate } from "./composables/useCurrentTemplate.js";
8
9
  import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
9
- import { basename, dirname, join, relative, resolve } from "node:path";
10
+ import { basename, dirname, join, parse, relative, resolve } from "node:path";
10
11
  import { glob } from "tinyglobby";
11
12
  import ora from "ora";
12
13
  import defu from "defu";
@@ -57,49 +58,58 @@ async function build(configInput) {
57
58
  try {
58
59
  for (const templatePath of templateFiles) {
59
60
  const absolutePath = resolve(templatePath);
60
- let template = readFileSync(absolutePath, "utf-8");
61
- template = await events.fireBeforeRender({
62
- config,
63
- template
64
- });
65
- const rendered = await renderer.render(absolutePath, config);
66
- for (const { name, handler } of rendered.sfcEventHandlers) events.on(name, handler);
67
- let html = await events.fireAfterRender({
68
- config,
69
- template,
70
- html: rendered.html
71
- });
72
- const templateConfig = rendered.templateConfig;
73
- const doctype = rendered.doctype ?? templateConfig.doctype ?? "<!DOCTYPE html>";
74
- if (templateConfig.useTransformers !== false) html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks);
75
- html = await events.fireAfterTransform({
76
- config,
77
- template,
78
- html
79
- });
80
- html = `${doctype}\n${html}`;
81
- const htmlOut = stripForHtml(html);
82
- const outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase);
83
- mkdirSync(dirname(outputFilePath), { recursive: true });
84
- writeFileSync(outputFilePath, htmlOut);
85
- outputFiles.push(outputFilePath);
86
- const globalPlaintext = templateConfig.plaintext;
87
- const sfcPlaintext = rendered.plaintext;
88
- if (globalPlaintext || sfcPlaintext) {
89
- const globalCfg = typeof globalPlaintext === "object" ? globalPlaintext : {};
90
- const stripOptions = defu(sfcPlaintext?.options, globalCfg.options);
91
- const plaintext = createPlaintext(stripForPlaintext(html), stripOptions);
92
- const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? "txt";
93
- let ptOutputPath;
94
- if (sfcPlaintext?.destination) {
95
- const name = basename(templatePath).replace(/\.(vue|md)$/, "");
96
- ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`);
97
- } else if (globalCfg.destination) ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase);
98
- else ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase);
99
- mkdirSync(dirname(ptOutputPath), { recursive: true });
100
- writeFileSync(ptOutputPath, plaintext);
61
+ const parsedPath = parse(absolutePath);
62
+ const template = {
63
+ source: readFileSync(absolutePath, "utf-8"),
64
+ path: parsedPath
65
+ };
66
+ _setCurrentTemplate(parsedPath);
67
+ try {
68
+ await events.fireBeforeRender({
69
+ config,
70
+ template
71
+ });
72
+ const rendered = await renderer.render(absolutePath, config);
73
+ for (const { name, handler } of rendered.sfcEventHandlers) events.on(name, handler);
74
+ let html = await events.fireAfterRender({
75
+ config,
76
+ template,
77
+ html: rendered.html
78
+ });
79
+ const templateConfig = rendered.templateConfig;
80
+ const doctype = rendered.doctype ?? templateConfig.doctype ?? "<!DOCTYPE html>";
81
+ if (templateConfig.useTransformers !== false) html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks);
82
+ html = await events.fireAfterTransform({
83
+ config,
84
+ template,
85
+ html
86
+ });
87
+ html = `${doctype}\n${html}`;
88
+ const htmlOut = stripForHtml(html);
89
+ const outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase);
90
+ mkdirSync(dirname(outputFilePath), { recursive: true });
91
+ writeFileSync(outputFilePath, htmlOut);
92
+ outputFiles.push(outputFilePath);
93
+ const globalPlaintext = templateConfig.plaintext;
94
+ const sfcPlaintext = rendered.plaintext;
95
+ if (globalPlaintext || sfcPlaintext) {
96
+ const globalCfg = typeof globalPlaintext === "object" ? globalPlaintext : {};
97
+ const stripOptions = defu(sfcPlaintext?.options, globalCfg.options);
98
+ const plaintext = createPlaintext(stripForPlaintext(html), stripOptions);
99
+ const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? "txt";
100
+ let ptOutputPath;
101
+ if (sfcPlaintext?.destination) {
102
+ const name = basename(templatePath).replace(/\.(vue|md)$/, "");
103
+ ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`);
104
+ } else if (globalCfg.destination) ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase);
105
+ else ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase);
106
+ mkdirSync(dirname(ptOutputPath), { recursive: true });
107
+ writeFileSync(ptOutputPath, plaintext);
108
+ }
109
+ } finally {
110
+ _setCurrentTemplate(void 0);
111
+ events.clearSfcHandlers();
101
112
  }
102
- events.clearSfcHandlers();
103
113
  }
104
114
  await copyStatic(config, outputPath);
105
115
  await events.fireAfterBuild({
package/dist/build.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","names":[],"sources":["../src/build.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join } from 'node:path'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport defu from 'defu'\nimport type { MaizzleConfig } from './types/index.ts'\n\nexport interface BuildResult {\n files: string[]\n config: MaizzleConfig\n}\n\n/**\n * Build all SFC email templates to HTML files.\n *\n * Creates a single Renderer instance, then loops through each template\n * calling render → transformers → write to disk.\n *\n * Pass a `Partial<MaizzleConfig>` to override config inline, or a string\n * to load config from a specific file path. Omit to load `maizzle.config`\n * from the working directory.\n */\nexport async function build(configInput?: Partial<MaizzleConfig> | string): Promise<BuildResult> {\n const start = Date.now()\n const spinner = ora({ text: 'Building templates...', spinner: 'circleHalves' }).start()\n\n const config = await resolveConfig(configInput)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const outputPath = resolve(config.output?.path ?? 'dist')\n const outputExtension = config.output?.extension ?? 'html'\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const contentBase = computeContentBase(contentPatterns)\n const templateFiles = await glob(contentPatterns)\n\n if (templateFiles.length === 0) {\n spinner.succeed('No templates found')\n return { files: [], config }\n }\n\n // Clear the output directory before writing fresh output\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true })\n }\n\n const renderer = await createRenderer({ markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n const outputFiles: string[] = []\n\n try {\n for (const templatePath of templateFiles) {\n const absolutePath = resolve(templatePath)\n let template = readFileSync(absolutePath, 'utf-8')\n\n template = await events.fireBeforeRender({ config, template })\n\n const rendered = await renderer.render(absolutePath, config)\n\n // Register SFC event handlers collected during render so they participate\n // in the post-render events (afterRender / afterTransform). They're cleared\n // at the end of the iteration so they don't leak into the next template.\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n let html = await events.fireAfterRender({ config, template, html: rendered.html })\n\n // Use the per-template merged config (from defineConfig() in the SFC) so that\n // template-level overrides like css.safe: false are respected by transformers.\n const templateConfig = rendered.templateConfig\n\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n }\n\n html = await events.fireAfterTransform({ config, template, html })\n html = `${doctype}\\n${html}`\n\n const htmlOut = stripForHtml(html)\n const outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase)\n mkdirSync(dirname(outputFilePath), { recursive: true })\n writeFileSync(outputFilePath, htmlOut)\n outputFiles.push(outputFilePath)\n\n // Generate plaintext version if configured\n const globalPlaintext = templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n const plaintext = createPlaintext(stripForPlaintext(html), stripOptions)\n const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? 'txt'\n\n let ptOutputPath: string\n\n if (sfcPlaintext?.destination) {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`)\n } else if (globalCfg.destination) {\n ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase)\n } else {\n ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase)\n }\n\n mkdirSync(dirname(ptOutputPath), { recursive: true })\n writeFileSync(ptOutputPath, plaintext)\n }\n\n events.clearSfcHandlers()\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n}\n\n/**\n * Extract the static (non-glob) prefix from content patterns.\n *\n * For example, `['/abs/path/emails/**\\/*.vue']` → `'/abs/path/emails'`\n *\n * This is used to strip the content base from template paths\n * so the output preserves only the subdirectory structure.\n */\nfunction computeContentBase(patterns: string[]): string {\n // Use the first non-negated pattern\n const pattern = patterns.find(p => !p.startsWith('!')) ?? patterns[0]\n\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n}\n\nfunction resolveOutputPath(templatePath: string, outputDir: string, extension: string, contentBase: string): string {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n const absTemplate = resolve(templatePath)\n const rel = relative(contentBase, dirname(absTemplate))\n\n return join(outputDir, rel, `${name}.${extension}`)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n const files = await glob(sources)\n\n for (const file of files) {\n const destPath = join(outputPath, destination, relative(dirname(sources[0]).replace(/\\*.*$/, ''), file))\n const destDir = dirname(destPath)\n\n if (!existsSync(destDir)) {\n mkdirSync(destDir, { recursive: true })\n }\n\n cpSync(file, destPath)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,MAAM,aAAqE;CAC/F,MAAM,QAAQ,KAAK,KAAK;CACxB,MAAM,UAA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,EAAE;CACzD,MAAM,QAAQ,YAAY;CAC1B,QAAQ,eAAe;EACrB,QAAQ;EACR,MAAM,SAAS,MAAM,WAAW,UAAU,IAAI,MAAM,GAAG,MAAM,SAAS;EACvE,CAAC;CAEF,OAAO;EAAE,OAAO;EAAa;EAAQ;;;;;;;;;;AAWvC,SAAS,mBAAmB,UAA4B;CAKtD,MAAM,cAHU,SAAS,MAAK,MAAK,CAAC,EAAE,WAAW,IAAI,CAAC,IAAI,SAAS,IAGxC,MAAM,SAAS,CAAC;CAG3C,OAAO,QAAQ,WAAW,SAAS,IAAI,GAAG,aAAa,QAAQ,WAAW,CAAC;;AAG7E,SAAS,kBAAkB,cAAsB,WAAmB,WAAmB,aAA6B;CAClH,MAAM,OAAO,SAAS,aAAa,CAAC,QAAQ,eAAe,GAAG;CAI9D,OAAO,KAAK,WAFA,SAAS,aAAa,QADd,QAAQ,aACyB,CAAC,CAE5B,EAAE,GAAG,KAAK,GAAG,YAAY;;AAGrD,eAAe,WAAW,QAAuB,YAAmC;CAClF,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,gBAAgB;CAC1D,MAAM,cAAc,OAAO,QAAQ,eAAe;CAElD,MAAM,QAAQ,MAAM,KAAK,QAAQ;CAEjC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,YAAY,aAAa,SAAS,QAAQ,QAAQ,GAAG,CAAC,QAAQ,SAAS,GAAG,EAAE,KAAK,CAAC;EACxG,MAAM,UAAU,QAAQ,SAAS;EAEjC,IAAI,CAAC,WAAW,QAAQ,EACtB,UAAU,SAAS,EAAE,WAAW,MAAM,CAAC;EAGzC,OAAO,MAAM,SAAS"}
1
+ {"version":3,"file":"build.js","names":["parsePath"],"sources":["../src/build.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join, parse as parsePath } from 'node:path'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport defu from 'defu'\nimport type { MaizzleConfig } from './types/index.ts'\n\nexport interface BuildResult {\n files: string[]\n config: MaizzleConfig\n}\n\n/**\n * Build all SFC email templates to HTML files.\n *\n * Creates a single Renderer instance, then loops through each template\n * calling render → transformers → write to disk.\n *\n * Pass a `Partial<MaizzleConfig>` to override config inline, or a string\n * to load config from a specific file path. Omit to load `maizzle.config`\n * from the working directory.\n */\nexport async function build(configInput?: Partial<MaizzleConfig> | string): Promise<BuildResult> {\n const start = Date.now()\n const spinner = ora({ text: 'Building templates...', spinner: 'circleHalves' }).start()\n\n const config = await resolveConfig(configInput)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const outputPath = resolve(config.output?.path ?? 'dist')\n const outputExtension = config.output?.extension ?? 'html'\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const contentBase = computeContentBase(contentPatterns)\n const templateFiles = await glob(contentPatterns)\n\n if (templateFiles.length === 0) {\n spinner.succeed('No templates found')\n return { files: [], config }\n }\n\n // Clear the output directory before writing fresh output\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true })\n }\n\n const renderer = await createRenderer({ markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n const outputFiles: string[] = []\n\n try {\n for (const templatePath of templateFiles) {\n const absolutePath = resolve(templatePath)\n const parsedPath = parsePath(absolutePath)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsedPath }\n\n _setCurrentTemplate(parsedPath)\n\n try {\n await events.fireBeforeRender({ config, template })\n\n const rendered = await renderer.render(absolutePath, config)\n\n // Register SFC event handlers collected during render so they participate\n // in the post-render events (afterRender / afterTransform). They're cleared\n // at the end of the iteration so they don't leak into the next template.\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n let html = await events.fireAfterRender({ config, template, html: rendered.html })\n\n // Use the per-template merged config (from defineConfig() in the SFC) so that\n // template-level overrides like css.safe: false are respected by transformers.\n const templateConfig = rendered.templateConfig\n\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n }\n\n html = await events.fireAfterTransform({ config, template, html })\n html = `${doctype}\\n${html}`\n\n const htmlOut = stripForHtml(html)\n const outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase)\n mkdirSync(dirname(outputFilePath), { recursive: true })\n writeFileSync(outputFilePath, htmlOut)\n outputFiles.push(outputFilePath)\n\n // Generate plaintext version if configured\n const globalPlaintext = templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n const plaintext = createPlaintext(stripForPlaintext(html), stripOptions)\n const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? 'txt'\n\n let ptOutputPath: string\n\n if (sfcPlaintext?.destination) {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`)\n } else if (globalCfg.destination) {\n ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase)\n } else {\n ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase)\n }\n\n mkdirSync(dirname(ptOutputPath), { recursive: true })\n writeFileSync(ptOutputPath, plaintext)\n }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n}\n\n/**\n * Extract the static (non-glob) prefix from content patterns.\n *\n * For example, `['/abs/path/emails/**\\/*.vue']` → `'/abs/path/emails'`\n *\n * This is used to strip the content base from template paths\n * so the output preserves only the subdirectory structure.\n */\nfunction computeContentBase(patterns: string[]): string {\n // Use the first non-negated pattern\n const pattern = patterns.find(p => !p.startsWith('!')) ?? patterns[0]\n\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n}\n\nfunction resolveOutputPath(templatePath: string, outputDir: string, extension: string, contentBase: string): string {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n const absTemplate = resolve(templatePath)\n const rel = relative(contentBase, dirname(absTemplate))\n\n return join(outputDir, rel, `${name}.${extension}`)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n const files = await glob(sources)\n\n for (const file of files) {\n const destPath = join(outputPath, destination, relative(dirname(sources[0]).replace(/\\*.*$/, ''), file))\n const destDir = dirname(destPath)\n\n if (!existsSync(destDir)) {\n mkdirSync(destDir, { recursive: true })\n }\n\n cpSync(file, destPath)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAsB,MAAM,aAAqE;CAC/F,MAAM,QAAQ,KAAK,KAAK;CACxB,MAAM,UAAU,IAAI;EAAE,MAAM;EAAyB,SAAS;EAAgB,CAAC,C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sePlaintextOptions } from "./usePlaintext.js";
4
4
  import { InjectionKey } from "vue";
5
5
 
@@ -0,0 +1,31 @@
1
+ import { ParsedPath } from "node:path";
2
+
3
+ //#region src/composables/useCurrentTemplate.d.ts
4
+ /**
5
+ * Internal — set by the build loop before each template iteration and
6
+ * cleared in `finally`. Not exported from the package entrypoint.
7
+ */
8
+ declare function _setCurrentTemplate(parsed: ParsedPath | undefined): void;
9
+ /**
10
+ * Returns the parsed path of the template currently being processed,
11
+ * or `undefined` when called outside the per-template scope (e.g. from
12
+ * `beforeCreate` / `afterBuild`, or outside a build entirely).
13
+ *
14
+ * Usage in an SFC `<script setup>`:
15
+ * ```ts
16
+ * const file = useCurrentTemplate()
17
+ * console.log(file?.name) // 'welcome'
18
+ * ```
19
+ *
20
+ * Usage in an event handler:
21
+ * ```ts
22
+ * beforeRender() {
23
+ * const file = useCurrentTemplate()
24
+ * // file?.dir, file?.name, file?.ext, file?.base, file?.root
25
+ * }
26
+ * ```
27
+ */
28
+ declare function useCurrentTemplate(): ParsedPath | undefined;
29
+ //#endregion
30
+ export { _setCurrentTemplate, useCurrentTemplate };
31
+ //# sourceMappingURL=useCurrentTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentTemplate.d.ts","names":[],"sources":["../../src/composables/useCurrentTemplate.ts"],"mappings":";;;;;AAQA;;iBAAgB,mBAAA,CAAoB,MAAA,EAAQ,UAAA;;;AAuB5C;;;;;;;;;;;;;;;;;iBAAgB,kBAAA,CAAA,GAAsB,UAAA"}
@@ -0,0 +1,35 @@
1
+ //#region src/composables/useCurrentTemplate.ts
2
+ let current;
3
+ /**
4
+ * Internal — set by the build loop before each template iteration and
5
+ * cleared in `finally`. Not exported from the package entrypoint.
6
+ */
7
+ function _setCurrentTemplate(parsed) {
8
+ current = parsed;
9
+ }
10
+ /**
11
+ * Returns the parsed path of the template currently being processed,
12
+ * or `undefined` when called outside the per-template scope (e.g. from
13
+ * `beforeCreate` / `afterBuild`, or outside a build entirely).
14
+ *
15
+ * Usage in an SFC `<script setup>`:
16
+ * ```ts
17
+ * const file = useCurrentTemplate()
18
+ * console.log(file?.name) // 'welcome'
19
+ * ```
20
+ *
21
+ * Usage in an event handler:
22
+ * ```ts
23
+ * beforeRender() {
24
+ * const file = useCurrentTemplate()
25
+ * // file?.dir, file?.name, file?.ext, file?.base, file?.root
26
+ * }
27
+ * ```
28
+ */
29
+ function useCurrentTemplate() {
30
+ return current;
31
+ }
32
+ //#endregion
33
+ export { _setCurrentTemplate, useCurrentTemplate };
34
+
35
+ //# sourceMappingURL=useCurrentTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentTemplate.js","names":[],"sources":["../../src/composables/useCurrentTemplate.ts"],"sourcesContent":["import type { ParsedPath } from 'node:path'\n\nlet current: ParsedPath | undefined\n\n/**\n * Internal — set by the build loop before each template iteration and\n * cleared in `finally`. Not exported from the package entrypoint.\n */\nexport function _setCurrentTemplate(parsed: ParsedPath | undefined): void {\n current = parsed\n}\n\n/**\n * Returns the parsed path of the template currently being processed,\n * or `undefined` when called outside the per-template scope (e.g. from\n * `beforeCreate` / `afterBuild`, or outside a build entirely).\n *\n * Usage in an SFC `<script setup>`:\n * ```ts\n * const file = useCurrentTemplate()\n * console.log(file?.name) // 'welcome'\n * ```\n *\n * Usage in an event handler:\n * ```ts\n * beforeRender() {\n * const file = useCurrentTemplate()\n * // file?.dir, file?.name, file?.ext, file?.base, file?.root\n * }\n * ```\n */\nexport function useCurrentTemplate(): ParsedPath | undefined {\n return current\n}\n"],"mappings":";AAEA,IAAI;;;;;AAMJ,SAAgB,oBAAoB,QAAsC;CACxE,UAAU;;;;;;;;;;;;;;;;;;;;;AAsBZ,SAAgB,qBAA6C;CAC3D,OAAO"}
@@ -7,7 +7,7 @@ import { EventMap, EventName } from "../events/index.js";
7
7
  * Usage:
8
8
  * ```ts
9
9
  * useEvent('beforeRender', ({ config, template }) => {
10
- * return template.replace('foo', 'bar')
10
+ * return template.source.replace('foo', 'bar')
11
11
  * })
12
12
  * ```
13
13
  */
@@ -7,7 +7,7 @@ import { inject } from "vue";
7
7
  * Usage:
8
8
  * ```ts
9
9
  * useEvent('beforeRender', ({ config, template }) => {
10
- * return template.replace('foo', 'bar')
10
+ * return template.source.replace('foo', 'bar')
11
11
  * })
12
12
  * ```
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useEvent.js","names":[],"sources":["../../src/composables/useEvent.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\n\n/**\n * Register an event handler from within an SFC's <script setup>.\n *\n * Usage:\n * ```ts\n * useEvent('beforeRender', ({ config, template }) => {\n * return template.replace('foo', 'bar')\n * })\n * ```\n */\nexport function useEvent<K extends EventName>(name: K, handler: EventMap[K]) {\n const ctx = inject(RenderContextKey)\n if (ctx) ctx.sfcEventHandlers.push({ name, handler })\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,SAA8B,MAAS,SAAsB;CAC3E,MAAM,MAAM,OAAO,iBAAiB;CACpC,IAAI,KAAK,IAAI,iBAAiB,KAAK;EAAE;EAAM;EAAS,CAAC"}
1
+ {"version":3,"file":"useEvent.js","names":[],"sources":["../../src/composables/useEvent.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\n\n/**\n * Register an event handler from within an SFC's <script setup>.\n *\n * Usage:\n * ```ts\n * useEvent('beforeRender', ({ config, template }) => {\n * return template.source.replace('foo', 'bar')\n * })\n * ```\n */\nexport function useEvent<K extends EventName>(name: K, handler: EventMap[K]) {\n const ctx = inject(RenderContextKey)\n if (ctx) ctx.sfcEventHandlers.push({ name, handler })\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,SAA8B,MAAS,SAAsB;CAC3E,MAAM,MAAM,OAAO,iBAAiB;CACpC,IAAI,KAAK,IAAI,iBAAiB,KAAK;EAAE;EAAM;EAAS,CAAC"}
@@ -1,22 +1,33 @@
1
1
  import { MaizzleConfig } from "../types/config.js";
2
+ import { ParsedPath } from "node:path";
3
+
2
4
  //#region src/events/index.d.ts
3
5
  type EventName = 'beforeCreate' | 'beforeRender' | 'afterRender' | 'afterTransform' | 'afterBuild';
6
+ /**
7
+ * Info about the template currently being processed, passed to per-template
8
+ * event handlers. `source` is the SFC file contents; `path` is the result of
9
+ * `path.parse(absolutePath)` — `{ root, dir, base, ext, name }`.
10
+ */
11
+ interface TemplateInfo {
12
+ source: string;
13
+ path: ParsedPath;
14
+ }
4
15
  interface EventMap {
5
16
  beforeCreate: (params: {
6
17
  config: MaizzleConfig;
7
18
  }) => void | Promise<void>;
8
19
  beforeRender: (params: {
9
20
  config: MaizzleConfig;
10
- template: string;
21
+ template: TemplateInfo;
11
22
  }) => string | void | Promise<string | void>;
12
23
  afterRender: (params: {
13
24
  config: MaizzleConfig;
14
- template: string;
25
+ template: TemplateInfo;
15
26
  html: string;
16
27
  }) => string | void | Promise<string | void>;
17
28
  afterTransform: (params: {
18
29
  config: MaizzleConfig;
19
- template: string;
30
+ template: TemplateInfo;
20
31
  html: string;
21
32
  }) => string | void | Promise<string | void>;
22
33
  afterBuild: (params: {
@@ -49,18 +60,19 @@ declare class EventManager {
49
60
  config: MaizzleConfig;
50
61
  }): Promise<void>;
51
62
  /**
52
- * Fire beforeRender — if a handler returns a string, it replaces `template`.
63
+ * Fire beforeRender — if a handler returns a string, it replaces
64
+ * `template.source` for subsequent handlers and the renderer.
53
65
  */
54
66
  fireBeforeRender(params: {
55
67
  config: MaizzleConfig;
56
- template: string;
68
+ template: TemplateInfo;
57
69
  }): Promise<string>;
58
70
  /**
59
71
  * Fire afterRender — if a handler returns a string, it replaces `html`.
60
72
  */
61
73
  fireAfterRender(params: {
62
74
  config: MaizzleConfig;
63
- template: string;
75
+ template: TemplateInfo;
64
76
  html: string;
65
77
  }): Promise<string>;
66
78
  /**
@@ -68,7 +80,7 @@ declare class EventManager {
68
80
  */
69
81
  fireAfterTransform(params: {
70
82
  config: MaizzleConfig;
71
- template: string;
83
+ template: TemplateInfo;
72
84
  html: string;
73
85
  }): Promise<string>;
74
86
  /**
@@ -93,5 +105,5 @@ declare class EventManager {
93
105
  clear(): void;
94
106
  }
95
107
  //#endregion
96
- export { EventManager, EventMap, EventName };
108
+ export { EventManager, EventMap, EventName, TemplateInfo };
97
109
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/events/index.ts"],"mappings":";;KAEY,SAAA;AAAA,UAEK,QAAA;EACf,YAAA,GAAe,MAAA;IAAU,MAAA,EAAQ,aAAA;EAAA,aAA2B,OAAA;EAC5D,YAAA,GAAe,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA;EAAA,sBAAuC,OAAA;EACvF,WAAA,GAAc,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA;IAAkB,IAAA;EAAA,sBAAmC,OAAA;EACpG,cAAA,GAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA;IAAkB,IAAA;EAAA,sBAAmC,OAAA;EACvG,UAAA,GAAa,MAAA;IAAU,KAAA;IAAiB,MAAA,EAAQ,aAAA;EAAA,aAA2B,OAAA;AAAA;;;;;;;;cAUhE,YAAA;EAAA,QACH,QAAA;EAAA,QAIA,kBAAA;EAjBR;;;EAsBA,cAAA,CAAe,MAAA,EAAQ,aAAA;EAtB0C;;;EAqCjE,EAAA,WAAa,SAAA,CAAA,CAAW,IAAA,EAAM,CAAA,EAAG,OAAA,EAAS,QAAA,CAAS,CAAA;EApCxB;;;EA+CrB,gBAAA,CAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;EAAA,IAAe,OAAA;EA9CxD;;;EAyDM,gBAAA,CAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA;EAAA,IAAqB,OAAA;EAzDK;AAUpF;;EAkEQ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AgDnD,gBAAA,CAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;EAAA,IAAe,OAAA;EA/CrB;;;;EA2D7B,gBAAA,CAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;EAAA,IAAiB,OAAA;EA1D3C;;;EA2ElC,eAAA,CAAgB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,IAAiB,OAAA;EAjEzE;;;EAoFjB,kBAAA,CAAmB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,IAAiB,OAAA;EApC1D;;;EAuDnC,cAAA,CAAe,MAAA;IAAU,KAAA;IAAiB,MAAA,EAAQ,aAAA;EAAA,IAAe,OAAA;EAnBH;;;;;;;;EAmCpE,gBAAA,CAAiB,MAAA,GAAQ,SAAA;EA7GzB;;;EA2HA,KAAA,CAAA;AAAA"}
@@ -40,19 +40,16 @@ var EventManager = class {
40
40
  for (const handler of handlers) await handler(params);
41
41
  }
42
42
  /**
43
- * Fire beforeRender — if a handler returns a string, it replaces `template`.
43
+ * Fire beforeRender — if a handler returns a string, it replaces
44
+ * `template.source` for subsequent handlers and the renderer.
44
45
  */
45
46
  async fireBeforeRender(params) {
46
47
  const handlers = this.handlers.get("beforeRender") ?? [];
47
- let { template } = params;
48
48
  for (const handler of handlers) {
49
- const result = await handler({
50
- config: params.config,
51
- template
52
- });
53
- if (typeof result === "string") template = result;
49
+ const result = await handler(params);
50
+ if (typeof result === "string") params.template.source = result;
54
51
  }
55
- return template;
52
+ return params.template.source;
56
53
  }
57
54
  /**
58
55
  * Fire afterRender — if a handler returns a string, it replaces `html`.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/events/index.ts"],"sourcesContent":["import type { MaizzleConfig } from '../types/index.ts'\n\nexport type EventName = 'beforeCreate' | 'beforeRender' | 'afterRender' | 'afterTransform' | 'afterBuild'\n\nexport interface EventMap {\n beforeCreate: (params: { config: MaizzleConfig }) => void | Promise<void>\n beforeRender: (params: { config: MaizzleConfig; template: string }) => string | void | Promise<string | void>\n afterRender: (params: { config: MaizzleConfig; template: string; html: string }) => string | void | Promise<string | void>\n afterTransform: (params: { config: MaizzleConfig; template: string; html: string }) => string | void | Promise<string | void>\n afterBuild: (params: { files: string[]; config: MaizzleConfig }) => void | Promise<void>\n}\n\n/**\n * Central event manager that collects handlers from config and useEvent() calls.\n *\n * Handlers are run in order: config handler first, then SFC handlers in registration order.\n * For events that return a value (beforeRender, afterRender, afterTransform),\n * the returned value replaces the corresponding input for the next handler.\n */\nexport class EventManager {\n private handlers = new Map<EventName, EventMap[EventName][]>()\n // Snapshot of config-handler counts per event, captured at registerConfig().\n // clearSfcHandlers() truncates each list back to this count, dropping any\n // SFC-registered handlers that were appended after.\n private configHandlerCount = new Map<EventName, number>()\n\n /**\n * Register handlers from the Maizzle config.\n */\n registerConfig(config: MaizzleConfig) {\n const eventNames: EventName[] = ['beforeCreate', 'beforeRender', 'afterRender', 'afterTransform', 'afterBuild']\n\n for (const name of eventNames) {\n const handler = config[name]\n if (typeof handler === 'function') {\n this.on(name, handler as EventMap[typeof name])\n }\n this.configHandlerCount.set(name, this.handlers.get(name)?.length ?? 0)\n }\n }\n\n /**\n * Register a handler for an event (used by useEvent composable).\n */\n on<K extends EventName>(name: K, handler: EventMap[K]) {\n if (!this.handlers.has(name)) {\n this.handlers.set(name, [])\n }\n\n this.handlers.get(name)!.push(handler)\n }\n\n /**\n * Fire beforeCreate — runs all handlers, config is mutated in place.\n */\n async fireBeforeCreate(params: { config: MaizzleConfig }) {\n const handlers = this.handlers.get('beforeCreate') ?? []\n\n for (const handler of handlers) {\n await (handler as EventMap['beforeCreate'])(params)\n }\n }\n\n /**\n * Fire beforeRender — if a handler returns a string, it replaces `template`.\n */\n async fireBeforeRender(params: { config: MaizzleConfig; template: string }): Promise<string> {\n const handlers = this.handlers.get('beforeRender') ?? []\n\n let { template } = params\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['beforeRender'])({ config: params.config, template })\n\n if (typeof result === 'string') {\n template = result\n }\n }\n\n return template\n }\n\n /**\n * Fire afterRender — if a handler returns a string, it replaces `html`.\n */\n async fireAfterRender(params: { config: MaizzleConfig; template: string; html: string }): Promise<string> {\n const handlers = this.handlers.get('afterRender') ?? []\n\n let { html } = params\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['afterRender'])({ config: params.config, template: params.template, html })\n\n if (typeof result === 'string') {\n html = result\n }\n }\n\n return html\n }\n\n /**\n * Fire afterTransform — if a handler returns a string, it replaces `html`.\n */\n async fireAfterTransform(params: { config: MaizzleConfig; template: string; html: string }): Promise<string> {\n const handlers = this.handlers.get('afterTransform') ?? []\n\n let { html } = params\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['afterTransform'])({ config: params.config, template: params.template, html })\n\n if (typeof result === 'string') {\n html = result\n }\n }\n\n return html\n }\n\n /**\n * Fire afterBuild — runs all handlers with the file list.\n */\n async fireAfterBuild(params: { files: string[]; config: MaizzleConfig }) {\n const handlers = this.handlers.get('afterBuild') ?? []\n\n for (const handler of handlers) {\n await (handler as EventMap['afterBuild'])(params)\n }\n }\n\n /**\n * Drop SFC-registered handlers, keep config-registered ones.\n *\n * Per default, only clears events whose scope is per-template\n * (`beforeRender`, `afterRender`, `afterTransform`). Build-scoped events\n * (`afterBuild`) accumulate across all templates and fire once at end of\n * build. Pass an explicit list to override.\n */\n clearSfcHandlers(events: EventName[] = ['beforeRender', 'afterRender', 'afterTransform']) {\n for (const name of events) {\n const handlers = this.handlers.get(name)\n if (!handlers) continue\n const keep = this.configHandlerCount.get(name) ?? 0\n if (handlers.length > keep) {\n this.handlers.set(name, handlers.slice(0, keep))\n }\n }\n }\n\n /**\n * Clear all handlers entirely.\n */\n clear() {\n this.handlers.clear()\n }\n}\n"],"mappings":";;;;;;;;AAmBA,IAAa,eAAb,MAA0B;CACxB,2BAAmB,IA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AE;EAE1D,IAAI,EAAE,SAAS;EAEf,KAAK,MAAM,WAAW,UAAU;GAC9B,MAAM,SAAS,MAAO,QAAuC;IAAE,QAAQ,OAAO;IAAQ,UAAU,OAAO;IAAU;IAAM,CAAC;GAExH,IAAI,OAAO,WAAW,UACpB,OAAO;;EAIX,OAAO;;;;;CAMT,MAAM,eAAe,QAAoD;EACvE,MAAM,WAAW,KAAK,SAAS,IAAI,aAAa,IAAI,EAAE;EAEtD,KAAK,MAAM,WAAW,UACpB,MAAO,QAAmC,OAAO;;;;;;;;;;CAYrD,iBAAiB,SAAsB;EAAC;EAAgB;EAAe;EAAiB,EAAE;EACxF,KAAK,MAAM,QAAQ,QAAQ;GACzB,MAAM,WAAW,KAAK,SAAS,IAAI,KAAK;GACxC,IAAI,CAAC,UAAU;GACf,MAAM,OAAO,KAAK,mBAAmB,IAAI,KAAK,IAAI;GAClD,IAAI,SAAS,SAAS,MACpB,KAAK,SAAS,IAAI,MAAM,SAAS,MAAM,GAAG,KAAK,CAAC;;;;;;CAQtD,QAAQ;EACN,KAAK,SAAS,OAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/events/index.ts"],"sourcesContent":["import type { ParsedPath } from 'node:path'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport type EventName = 'beforeCreate' | 'beforeRender' | 'afterRender' | 'afterTransform' | 'afterBuild'\n\n/**\n * Info about the template currently being processed, passed to per-template\n * event handlers. `source` is the SFC file contents; `path` is the result of\n * `path.parse(absolutePath)` — `{ root, dir, base, ext, name }`.\n */\nexport interface TemplateInfo {\n source: string\n path: ParsedPath\n}\n\nexport interface EventMap {\n beforeCreate: (params: { config: MaizzleConfig }) => void | Promise<void>\n beforeRender: (params: { config: MaizzleConfig; template: TemplateInfo }) => string | void | Promise<string | void>\n afterRender: (params: { config: MaizzleConfig; template: TemplateInfo; html: string }) => string | void | Promise<string | void>\n afterTransform: (params: { config: MaizzleConfig; template: TemplateInfo; html: string }) => string | void | Promise<string | void>\n afterBuild: (params: { files: string[]; config: MaizzleConfig }) => void | Promise<void>\n}\n\n/**\n * Central event manager that collects handlers from config and useEvent() calls.\n *\n * Handlers are run in order: config handler first, then SFC handlers in registration order.\n * For events that return a value (beforeRender, afterRender, afterTransform),\n * the returned value replaces the corresponding input for the next handler.\n */\nexport class EventManager {\n private handlers = new Map<EventName, EventMap[EventName][]>()\n // Snapshot of config-handler counts per event, captured at registerConfig().\n // clearSfcHandlers() truncates each list back to this count, dropping any\n // SFC-registered handlers that were appended after.\n private configHandlerCount = new Map<EventName, number>()\n\n /**\n * Register handlers from the Maizzle config.\n */\n registerConfig(config: MaizzleConfig) {\n const eventNames: EventName[] = ['beforeCreate', 'beforeRender', 'afterRender', 'afterTransform', 'afterBuild']\n\n for (const name of eventNames) {\n const handler = config[name]\n if (typeof handler === 'function') {\n this.on(name, handler as EventMap[typeof name])\n }\n this.configHandlerCount.set(name, this.handlers.get(name)?.length ?? 0)\n }\n }\n\n /**\n * Register a handler for an event (used by useEvent composable).\n */\n on<K extends EventName>(name: K, handler: EventMap[K]) {\n if (!this.handlers.has(name)) {\n this.handlers.set(name, [])\n }\n\n this.handlers.get(name)!.push(handler)\n }\n\n /**\n * Fire beforeCreate — runs all handlers, config is mutated in place.\n */\n async fireBeforeCreate(params: { config: MaizzleConfig }) {\n const handlers = this.handlers.get('beforeCreate') ?? []\n\n for (const handler of handlers) {\n await (handler as EventMap['beforeCreate'])(params)\n }\n }\n\n /**\n * Fire beforeRender — if a handler returns a string, it replaces\n * `template.source` for subsequent handlers and the renderer.\n */\n async fireBeforeRender(params: { config: MaizzleConfig; template: TemplateInfo }): Promise<string> {\n const handlers = this.handlers.get('beforeRender') ?? []\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['beforeRender'])(params)\n\n if (typeof result === 'string') {\n params.template.source = result\n }\n }\n\n return params.template.source\n }\n\n /**\n * Fire afterRender — if a handler returns a string, it replaces `html`.\n */\n async fireAfterRender(params: { config: MaizzleConfig; template: TemplateInfo; html: string }): Promise<string> {\n const handlers = this.handlers.get('afterRender') ?? []\n\n let { html } = params\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['afterRender'])({ config: params.config, template: params.template, html })\n\n if (typeof result === 'string') {\n html = result\n }\n }\n\n return html\n }\n\n /**\n * Fire afterTransform — if a handler returns a string, it replaces `html`.\n */\n async fireAfterTransform(params: { config: MaizzleConfig; template: TemplateInfo; html: string }): Promise<string> {\n const handlers = this.handlers.get('afterTransform') ?? []\n\n let { html } = params\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['afterTransform'])({ config: params.config, template: params.template, html })\n\n if (typeof result === 'string') {\n html = result\n }\n }\n\n return html\n }\n\n /**\n * Fire afterBuild — runs all handlers with the file list.\n */\n async fireAfterBuild(params: { files: string[]; config: MaizzleConfig }) {\n const handlers = this.handlers.get('afterBuild') ?? []\n\n for (const handler of handlers) {\n await (handler as EventMap['afterBuild'])(params)\n }\n }\n\n /**\n * Drop SFC-registered handlers, keep config-registered ones.\n *\n * Per default, only clears events whose scope is per-template\n * (`beforeRender`, `afterRender`, `afterTransform`). Build-scoped events\n * (`afterBuild`) accumulate across all templates and fire once at end of\n * build. Pass an explicit list to override.\n */\n clearSfcHandlers(events: EventName[] = ['beforeRender', 'afterRender', 'afterTransform']) {\n for (const name of events) {\n const handlers = this.handlers.get(name)\n if (!handlers) continue\n const keep = this.configHandlerCount.get(name) ?? 0\n if (handlers.length > keep) {\n this.handlers.set(name, handlers.slice(0, keep))\n }\n }\n }\n\n /**\n * Clear all handlers entirely.\n */\n clear() {\n this.handlers.clear()\n }\n}\n"],"mappings":";;;;;;;;AA8BA,IAAa,eAAb,MAA0B;CACxB,2BAAmB,IAAI,KAAuC;CAI9D,qCAA6B,IAAI,KAAwB;;;;CAKzD,eAAe,QAAuB;EAGpC,KAAK,MAAM,QAAQ;GAFc;GAAgB;GAAgB;GAAe;GAAkB;GAErE,EAAE;GAC7B,MAAM,UAAU,OAAO;GACvB,IAAI,OAAO,YAAY,YACr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AAoD;EACvE,MAAM,WAAW,KAAK,SAAS,IAAI,aAAa,IAAI,EAAE;EAEtD,KAAK,MAAM,WAAW,UACpB,MAAO,QAAmC,OAAO;;;;;;;;;;CAYrD,iBAAiB,SAAsB;EAAC;EAAgB;EAAe;EAAiB,EAAE;EACxF,KAAK,MAAM,QAAQ,QAAQ;GACzB,MAAM,WAAW,KAAK,SAAS,IAAI,KAAK;GACxC,IAAI,CAAC,UAAU;GACf,MAAM,OAAO,KAAK,mBAAmB,IAAI,KAAK,IAAI;GAClD,IAAI,SAAS,SAAS,MACpB,KAAK,SAAS,IAAI,MAAM,SAAS,MAAM,GAAG,KAAK,CAAC;;;;;;CAQtD,QAAQ;EACN,KAAK,SAAS,OAAO"}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { defineConfig } from "./composables/defineConfig.js";
4
4
  import { usePlaintext } from "./composables/usePlaintext.js";
5
5
  import { useBaseUrl } from "./composables/useBaseUrl.js";
6
6
  import { useConfig } from "./composables/useConfig.js";
7
+ import { useCurrentTemplate } from "./composables/useCurrentTemplate.js";
7
8
  import { useDoctype } from "./composables/useDoctype.js";
8
9
  import { useEvent } from "./composables/useEvent.js";
9
10
  import { useFont } from "./composables/useFont.js";
@@ -35,4 +36,4 @@ import { replaceStrings } from "./transformers/replaceStrings.js";
35
36
  import { FormatOptions, format } from "./transformers/format.js";
36
37
  import { MinifyOptions, minify } from "./transformers/minify.js";
37
38
  import { useHead } from "@unhead/vue";
38
- export { type AttributesConfig, type BaseUrlOptions, type ComponentSource, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, type NormalizedComponentSource, type PlaintextConfig, type PrepareOptions, type PurgeCssOptions, type RemoveAttributeOption, type RemoveAttributeRule, type RenderResult, type RenderedTemplate, type Renderer, type ShorthandCssOptions, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
39
+ export { type AttributesConfig, type BaseUrlOptions, type ComponentSource, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, type NormalizedComponentSource, type PlaintextConfig, type PrepareOptions, type PurgeCssOptions, type RemoveAttributeOption, type RemoveAttributeRule, type RenderResult, type RenderedTemplate, type Renderer, type ShorthandCssOptions, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ import { minify } from "./transformers/minify.js";
20
20
  import { normalizeComponentSources } from "./utils/componentSources.js";
21
21
  import { createRenderer } from "./render/createRenderer.js";
22
22
  import { createPlaintext } from "./plaintext.js";
23
+ import { useCurrentTemplate } from "./composables/useCurrentTemplate.js";
23
24
  import { build } from "./build.js";
24
25
  import { maizzle } from "./plugin.js";
25
26
  import { render } from "./render/index.js";
@@ -34,4 +35,4 @@ import { useTransformers } from "./composables/useTransformers.js";
34
35
  import { useBaseUrl } from "./composables/useBaseUrl.js";
35
36
  import { useUrlQuery } from "./composables/useUrlQuery.js";
36
37
  import { useHead } from "@unhead/vue";
37
- export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
38
+ export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
@@ -246,7 +246,8 @@ async function createRenderer(options = {}) {
246
246
  const app = createSSRApp(component);
247
247
  app.use(head);
248
248
  if (config.vue) {
249
- for (const plugin of config.vue.plugins ?? []) app.use(plugin);
249
+ const plugins = typeof config.vue.plugins === "function" ? config.vue.plugins() : config.vue.plugins ?? [];
250
+ for (const plugin of plugins) app.use(plugin);
250
251
  for (const [name, directive] of Object.entries(config.vue.directives ?? {})) app.directive(name, directive);
251
252
  Object.assign(app.config.globalProperties, config.vue.globalProperties);
252
253
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createRenderer.js","names":["relPath","merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, relative as relPath, resolve } from 'node:path'\nimport { mkdirSync, writeFileSync, existsSync, rmSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { isLaravel } from '../utils/detect.ts'\nimport { rowSourceLocation } from './plugins/rowSourceLocation.ts'\nimport { rawExtract } from './plugins/rawExtract.ts'\nimport { codeBlockExtract } from './plugins/codeBlockExtract.ts'\nimport { markdownExtract } from './plugins/markdownExtract.ts'\nimport { createServer, mergeConfig, type InlineConfig, type Plugin } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport Markdown from 'unplugin-vue-markdown/vite'\nimport AutoImport from 'unplugin-auto-import/vite'\nimport Components from 'unplugin-vue-components/vite'\nimport { unheadVueComposablesImports } from '@unhead/vue'\nimport { defu as merge } from 'defu'\nimport { glob, globSync } from 'tinyglobby'\nimport { createSSRApp } from 'vue'\nimport { renderToString } from 'vue/server-renderer'\nimport { createHead } from '@unhead/vue/server'\nimport { MaizzleConfigKey } from '../composables/useConfig.ts'\nimport { RenderContextKey } from '../composables/renderContext.ts'\nimport { componentNameFromPath, type NormalizedComponentSource } from '../utils/componentSources.ts'\nimport type { Component, InjectionKey } from 'vue'\nimport type { MaizzleConfig, MarkdownConfig } from '../types/index.ts'\nimport type { MarkdownExit } from 'markdown-exit'\nimport type { RenderContext } from '../composables/renderContext.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nconst vuePkgDir = dirname(fileURLToPath(import.meta.resolve('vue/package.json')))\nconst vueServerRendererPkgDir = dirname(fileURLToPath(import.meta.resolve('@vue/server-renderer/package.json')))\nconst unheadVuePkgDir = resolve(dirname(fileURLToPath(import.meta.resolve('@unhead/vue'))), '..')\nconst vueRouterPkgDir = dirname(fileURLToPath(import.meta.resolve('vue-router/package.json')))\n\nexport interface RenderedTemplate {\n html: string\n doctype?: string\n templateConfig: MaizzleConfig\n sfcEventHandlers: RenderContext['sfcEventHandlers']\n plaintext?: RenderContext['plaintext']\n tailwindBlocks?: RenderContext['tailwindBlocks']\n}\n\nexport interface Renderer {\n render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate>\n invalidate(filePath: string): Promise<void>\n invalidateAll(): Promise<void>\n close(): Promise<void>\n}\n\nexport interface CreateRendererOptions {\n /** Generate .d.ts files for auto-imports and components (default: false) */\n dts?: boolean\n /** Options passed to unplugin-vue-markdown */\n markdown?: MarkdownConfig\n /** Root directory for resolving user component dirs and .d.ts output */\n root?: string\n /**\n * Additional component sources to register for auto-import. Already\n * normalized — pass through `normalizeComponentSources()` first.\n */\n componentDirs?: NormalizedComponentSource[]\n /** User Vite config options to merge into the internal SSR server */\n vite?: InlineConfig\n}\n\n/**\n * Lightweight Vite SSR loader for rendering Vue SFC email templates.\n *\n * Uses only Vue + unplugin for component/auto-import resolution.\n * Tailwind CSS compilation is handled by the transformer pipeline.\n */\nexport async function createRenderer(\n options: CreateRendererOptions = {},\n): Promise<Renderer> {\n const { dts = false, markdown: markdownOptionsRaw, root = process.cwd(), componentDirs = [], vite: userViteConfig } = options\n const { shikiTheme = 'github-light', ...markdownOptions } = markdownOptionsRaw ?? {}\n\n // Sources without an explicit prefix get registered via unplugin's `dirs`\n // (folder name auto-namespaces). Sources with an explicit `prefix` are\n // registered through a custom resolver below so we can fully control naming.\n const dirSources = componentDirs.filter(s => s.prefix === undefined)\n const prefixedSources = componentDirs.filter(s => s.prefix !== undefined)\n\n // Absolute component dirs — used to skip auto-wrapping `.md` files that are\n // imported as reusable components (vs. entry-point email templates).\n const componentDirsAbs = [resolve(root, 'components'), ...componentDirs.map(s => s.path)]\n\n const dtsDir = isLaravel()\n ? resolve(process.cwd(), 'resources/js/types/maizzle')\n : resolve(root, '.maizzle')\n\n // Built-in framework components live at this path. When a user provides a\n // top-level file with the same (PascalCased) basename, drop the built-in\n // from unplugin's scan so the user's component is the only candidate. This\n // avoids the \"naming conflicts\" warning and the alphabetical-glob ordering\n // pitfall that decides who wins when both are present in `dirs`.\n const frameworkComponentsDir = resolve(__dirname, '../components')\n\n function topLevelBasenamesLower(dir: string): Set<string> {\n if (!existsSync(dir)) return new Set()\n const files = globSync(['*.vue', '*.md'], { cwd: dir, absolute: false })\n return new Set(files.map(f => f.replace(/\\.(vue|md)$/, '').toLowerCase()))\n }\n\n const frameworkFiles = globSync(['*.vue', '*.md'], { cwd: frameworkComponentsDir, absolute: false })\n const frameworkByLower = new Map(\n frameworkFiles.map(f => [f.replace(/\\.(vue|md)$/, '').toLowerCase(), f]),\n )\n\n const shadowedNames = new Set<string>()\n for (const dir of [resolve(root, 'components'), ...dirSources.map(s => s.path)]) {\n for (const lower of topLevelBasenamesLower(dir)) {\n if (frameworkByLower.has(lower)) shadowedNames.add(lower)\n }\n }\n\n const frameworkExcludes = [...shadowedNames]\n .map(lower => `${frameworkComponentsDir}/${frameworkByLower.get(lower)}`)\n\n // Pre-scanned name → absolute-path map for prefixed sources. Rebuilt on\n // file add/unlink via the watcher hook plugin further down. Powers the\n // runtime resolver and the d.ts file we write for IDE autocompletion.\n const prefixedNameMap = new Map<string, string>()\n\n async function scanPrefixedSources(): Promise<void> {\n prefixedNameMap.clear()\n const seen = new Map<string, string>()\n for (const source of prefixedSources) {\n const files = await glob(['**/*.vue', '**/*.md'], { cwd: source.path, absolute: true })\n for (const file of files) {\n const name = componentNameFromPath({\n filePath: file,\n dirRoot: source.path,\n prefix: source.prefix,\n pathPrefix: source.pathPrefix,\n })\n const existing = seen.get(name)\n if (existing && existing !== file) {\n throw new Error(\n `[maizzle] Component name collision: \"${name}\" resolved from both \"${existing}\" and \"${file}\". `\n + 'Rename one of the files or split them into separate sources with distinct prefixes.',\n )\n }\n seen.set(name, file)\n prefixedNameMap.set(name, file)\n }\n }\n }\n\n await scanPrefixedSources()\n\n const prefixedResolver = (name: string) => prefixedNameMap.get(name)\n\n // unplugin-vue-components' own d.ts only covers components found via `dirs`;\n // its `types` option emits named-import entries which break for SFC `default`\n // exports. Write a sibling d.ts for prefixed sources so editors get correct\n // autocompletion via TypeScript interface merging on `vue.GlobalComponents`.\n const prefixedDtsPath = resolve(dtsDir, 'prefixed-components.d.ts')\n\n function writePrefixedDts(): void {\n if (!dts) return\n if (prefixedNameMap.size === 0) {\n if (existsSync(prefixedDtsPath)) rmSync(prefixedDtsPath)\n return\n }\n const dtsBase = dirname(prefixedDtsPath)\n mkdirSync(dtsBase, { recursive: true })\n const lines = Array.from(prefixedNameMap.entries())\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, file]) => {\n const relativePath = relPath(dtsBase, file).replace(/\\\\/g, '/')\n const importPath = relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n return ` ${name}: typeof import('${importPath}')['default']`\n })\n .join('\\n')\n writeFileSync(\n prefixedDtsPath,\n `/* eslint-disable */\\n// @ts-nocheck\\n// biome-ignore lint: disable\\n// oxlint-disable\\n// Generated by Maizzle for prefixed component sources\\n\\nexport {}\\n\\n/* prettier-ignore */\\ndeclare module 'vue' {\\n export interface GlobalComponents {\\n${lines}\\n }\\n}\\n`,\n )\n }\n\n writePrefixedDts()\n\n /**\n * Watches prefixed source dirs and rebuilds {@link prefixedNameMap} when\n * files are added/removed. Vite's watcher already covers `dirSources`\n * via unplugin-vue-components' own filesystem hooks.\n */\n const prefixedSourceWatcher: Plugin | null = prefixedSources.length > 0\n ? {\n name: 'maizzle:prefixed-component-watcher',\n configureServer(server) {\n for (const source of prefixedSources) {\n server.watcher.add(source.path)\n }\n const refresh = async (file: string) => {\n if (!prefixedSources.some(s => file.startsWith(`${s.path}/`))) return\n if (!/\\.(vue|md)$/.test(file)) return\n await scanPrefixedSources()\n writePrefixedDts()\n }\n server.watcher.on('add', refresh)\n server.watcher.on('unlink', refresh)\n },\n }\n : null\n\n const VIRTUAL_SFC_ID = 'virtual:maizzle-sfc.vue'\n let virtualSfcSource = ''\n\n // Never load the host project's vite.config.ts here. Doing so pulls every\n // host plugin (Nitro, TanStack Start, the Maizzle plugin itself, …) into\n // this isolated SSR pipeline, where they override env factories, re-trigger\n // configureServer hooks, and break Vite's hot channel wiring. Users that\n // need extra Vite plugins for SSR pass them explicitly via the `vite` option.\n const maizzleConfig: InlineConfig = {\n configFile: false,\n plugins: [\n rawExtract(),\n codeBlockExtract(),\n markdownExtract(),\n rowSourceLocation(),\n {\n name: 'maizzle:virtual-sfc',\n resolveId(id) {\n if (id === VIRTUAL_SFC_ID) return id\n },\n load(id) {\n if (id === VIRTUAL_SFC_ID) return virtualSfcSource\n },\n },\n vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n },\n }),\n Markdown(merge(markdownOptions ?? {}, {\n headEnabled: true,\n wrapperDiv: false,\n wrapperClasses: 'prose',\n wrapperComponent: (id: string, raw: string) => {\n const fm = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1]\n const layout = fm?.match(/^[ \\t]*layout[ \\t]*:[ \\t]*['\"]?([A-Za-z][\\w-]*|false|none)['\"]?[ \\t]*$/m)?.[1]\n if (layout === 'false' || layout === 'none') return null\n if (layout) return layout\n // No `layout:` set — default to the built-in `MarkdownLayout` for\n // entry-template `.md` files. Skip for `.md` files inside component\n // dirs, which are reusable fragments imported into other templates.\n const inComponentDir = componentDirsAbs.some(d => id === d || id.startsWith(`${d}/`))\n return inComponentDir ? null : 'MarkdownLayout'\n },\n markdownOptions: {\n async highlight(code: string, lang: string) {\n const { codeToHtml } = await import('shiki')\n return codeToHtml(code, { lang, theme: shikiTheme })\n },\n },\n markdownSetup(md: MarkdownExit) {\n const wrapPre = (html: string) =>\n `<table class=\"w-full\"><tr><td class=\"max-w-0 mso-padding-alt-4\">${html}</td></tr></table>\\n`\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) => {\n const result = defaultFence(...args)\n if (typeof result === 'string') return wrapPre(result)\n return result.then(wrapPre)\n }\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => wrapPre(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n dts: dts ? resolve(dtsDir, 'auto-imports.d.ts') : false,\n }),\n Components({\n extensions: ['vue', 'md'],\n include: [/\\.vue$/, /\\.vue\\?vue/, /\\.md$/],\n dirs: [\n frameworkComponentsDir,\n resolve(root, 'components'),\n ...dirSources.map(s => s.path),\n ],\n // Drop built-in component files whose name the user has shadowed.\n // This makes the user's version the only match — no \"naming\n // conflicts\" warning, no glob-ordering games.\n globsExclude: frameworkExcludes,\n directoryAsNamespace: true,\n collapseSamePrefixes: true,\n resolvers: prefixedSources.length > 0 ? [prefixedResolver] : undefined,\n dts: dts ? resolve(dtsDir, 'components.d.ts') : false,\n }),\n ...(prefixedSourceWatcher ? [prefixedSourceWatcher] : []),\n ],\n resolve: {\n alias: {\n 'vue/server-renderer': resolve(vueServerRendererPkgDir, 'dist/server-renderer.esm-bundler.js'),\n 'vue': resolve(vuePkgDir, 'dist/vue.runtime.esm-bundler.js'),\n 'vue-router': vueRouterPkgDir,\n '@unhead/vue/server': resolve(unheadVuePkgDir, 'dist/server.mjs'),\n '@unhead/vue': resolve(unheadVuePkgDir, 'dist/index.mjs'),\n },\n },\n server: {\n middlewareMode: true,\n hmr: false,\n // Watcher is required so unplugin-vue-components and unplugin-auto-import\n // detect added/removed component files and rewrite their .d.ts on the fly.\n // (We only render via SSR — HMR is off, but chokidar still drives the plugins.)\n fs: {\n allow: [process.cwd(), root, ...componentDirs.map(s => s.path), vuePkgDir, vueServerRendererPkgDir, unheadVuePkgDir, vueRouterPkgDir],\n },\n },\n appType: 'custom',\n logLevel: 'silent',\n optimizeDeps: {\n noDiscovery: true,\n },\n }\n\n // Merge user's vite config (from config.vite) under Maizzle's config.\n // mergeConfig(a, b) → b overrides a for scalars, arrays are concatenated.\n // This ensures Maizzle's critical settings (middlewareMode, appType, etc.) always win,\n // while user plugins and other options are included.\n const finalConfig = userViteConfig\n ? mergeConfig(userViteConfig, maizzleConfig)\n : maizzleConfig\n\n const server = await createServer(finalConfig)\n\n return {\n async render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate> {\n let component: Component\n let configKey: InjectionKey<MaizzleConfig>\n let contextKey: InjectionKey<RenderContext>\n\n if (typeof input === 'string') {\n // String input goes through Vite — must use ssrLoadModule for injection keys\n // so they share the same module instance as the SFC\n const configModule = await server.ssrLoadModule(resolve(__dirname, '../composables/useConfig'))\n const contextModule = await server.ssrLoadModule(resolve(__dirname, '../composables/renderContext'))\n configKey = configModule.MaizzleConfigKey\n contextKey = contextModule.RenderContextKey\n\n if (input.includes('<template') || input.includes('<script')) {\n virtualSfcSource = input\n const mod = server.moduleGraph.getModuleById(VIRTUAL_SFC_ID)\n if (mod) server.moduleGraph.invalidateModule(mod)\n component = (await server.ssrLoadModule(VIRTUAL_SFC_ID)).default\n } else {\n component = (await server.ssrLoadModule(input)).default\n }\n } else {\n // Pre-compiled component — use directly imported keys\n component = input\n configKey = MaizzleConfigKey\n contextKey = RenderContextKey\n }\n\n const renderContext: RenderContext = {\n doctype: undefined,\n sfcConfig: undefined,\n sfcEventHandlers: [],\n }\n\n const head = createHead({ disableDefaults: true })\n const app = createSSRApp(component)\n app.use(head)\n\n // Register user Vue plugins, directives, and global properties\n if (config.vue) {\n for (const plugin of config.vue.plugins ?? []) {\n app.use(plugin)\n }\n for (const [name, directive] of Object.entries(config.vue.directives ?? {})) {\n app.directive(name, directive)\n }\n Object.assign(app.config.globalProperties, config.vue.globalProperties)\n }\n\n app.provide(configKey, config)\n app.provide(contextKey, renderContext)\n\n const ssrContext: Record<string, any> = {}\n let html: string = await renderToString(app, ssrContext)\n\n const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = head.render()\n\n // Inject head entries into the rendered HTML\n if (htmlAttrs) {\n html = html.replace(/<html([^>]*)>/, `<html$1 ${htmlAttrs}>`)\n }\n if (headTags) {\n html = html.replace('</head>', `${headTags}\\n</head>`)\n }\n if (bodyAttrs) {\n html = html.replace(/<body([^>]*)>/, `<body$1 ${bodyAttrs}>`)\n }\n if (bodyTagsOpen) {\n html = html.replace(/<body([^>]*)>/, `<body$1>\\n${bodyTagsOpen}`)\n }\n if (bodyTags) {\n html = html.replace('</body>', `${bodyTags}\\n</body>`)\n }\n\n // Inject SSR teleport content into their target elements\n const hasTeleports = ssrContext.teleports && Object.keys(ssrContext.teleports).length > 0\n const hasFonts = (renderContext.fonts?.length ?? 0) > 0\n\n if (hasTeleports || hasFonts) {\n const { parse: parseDom, serialize: serializeDom, walk } = await import('../utils/ast/index.ts')\n let dom = parseDom(html)\n\n if (hasTeleports) {\n for (const [rawTarget, content] of Object.entries(ssrContext.teleports) as [string, string][]) {\n if (!content) continue\n\n const prepend = rawTarget.endsWith(':start')\n const target = prepend ? rawTarget.slice(0, -6) : rawTarget\n const targetChildren = parseDom(content)\n\n walk(dom, (node) => {\n const el = node as import('domhandler').Element\n\n if (!el.name) return\n\n const matched\n = target === el.name\n || (target.startsWith('#') && el.attribs?.id === target.slice(1))\n || (target.startsWith('.') && el.attribs?.class?.split(/\\s+/).includes(target.slice(1)))\n\n if (matched) {\n for (const child of targetChildren) {\n child.parent = el as any\n }\n\n el.children = prepend\n ? [...targetChildren, ...(el.children || [])] as any\n : [...(el.children || []), ...targetChildren] as any\n }\n })\n }\n }\n\n if (hasFonts) {\n const { injectFonts } = await import('./injectFonts.ts')\n injectFonts(dom, renderContext.fonts!, parseDom, walk)\n }\n\n html = serializeDom(dom)\n }\n\n // Inject preheader text from usePreheader() composable\n if (renderContext.preheader) {\n const { text, fillerCount, shyCount } = renderContext.preheader\n const filler = '\\u2007\\u034F '.repeat(fillerCount)\n const shys = '\\u00AD '.repeat(shyCount)\n const previewHtml = `<div style=\"display:none\">${text}${filler}${shys}\\u00A0</div>`\n html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`)\n }\n\n // Strip Vue SSR fragment markers + teleport anchor comments. These are\n // rendering hygiene, not transformer concerns — must run regardless of\n // `useTransformers` state. Fragment markers contain `-->`, which would\n // prematurely terminate MSO conditional comments downstream.\n html = html\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n return {\n html,\n doctype: renderContext.doctype,\n // Layer sfcConfig over config — sfcConfig is a partial override\n // emitted by composables (defineConfig, useTransformers, etc.).\n // A naive replacement (`sfcConfig ?? config`) drops defaults from\n // the resolved config when the SFC only sets a single key, since\n // the composables' inject() of globalConfig can return `{}` in\n // dev when ssrLoadModule and the SFC's auto-imported module\n // resolve to different module instances (different Symbols).\n templateConfig: renderContext.sfcConfig ? merge(renderContext.sfcConfig, config) : config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\n tailwindBlocks: renderContext.tailwindBlocks,\n }\n },\n\n async invalidate(filePath: string): Promise<void> {\n const mod = await server.moduleGraph.getModuleByUrl(filePath)\n if (mod) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async invalidateAll(): Promise<void> {\n for (const mod of server.moduleGraph.idToModuleMap.values()) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async close(): Promise<void> {\n await server.close()\n // unplugin-auto-import schedules a 500ms-throttled, fire-and-forget\n // d.ts write on its first scan. server.close() doesn't drain that\n // pending write, so callers tearing down the working dir right after\n // close (tests, ephemeral build pipelines) can race the mkdir against\n // a missing parent directory. Wait one throttle window past close so\n // that lingering write resolves while the dir still exists.\n if (dts) {\n await new Promise(resolve => setTimeout(resolve, 600))\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,QAAQ,mBAAmB,CAAC,CAAC;AACjF,MAAM,0BAA0B,QAAQ,cAAc,OAAO,KAAK,QAAQ,oCAAoC,CAAC,CAAC;AAChH,MAAM,kBAAkB,QAAQ,QAAQ,cAAc,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,EAAE,KAAK;AACjG,MAAM,kBAAkB,QAAQ,cAAc,OAAO,KAAK,QAAQ,0BAA0B,CAAC,CAAC;;;;;;;AAwC9F,eAAsB,eACpB,UAAiC,EAAE,EAChB;CACnB,MAAM,EAAE,MAAM,OAAO,UAAU,oBAAoB,OAAO,QAAQ,KAAK,EAAE,gBAAgB,EAAE,EAAE,MAAM,mBAAmB;CACtH,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merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, relative as relPath, resolve } from 'node:path'\nimport { mkdirSync, writeFileSync, existsSync, rmSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { isLaravel } from '../utils/detect.ts'\nimport { rowSourceLocation } from './plugins/rowSourceLocation.ts'\nimport { rawExtract } from './plugins/rawExtract.ts'\nimport { codeBlockExtract } from './plugins/codeBlockExtract.ts'\nimport { markdownExtract } from './plugins/markdownExtract.ts'\nimport { createServer, mergeConfig, type InlineConfig, type Plugin } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport Markdown from 'unplugin-vue-markdown/vite'\nimport AutoImport from 'unplugin-auto-import/vite'\nimport Components from 'unplugin-vue-components/vite'\nimport { unheadVueComposablesImports } from '@unhead/vue'\nimport { defu as merge } from 'defu'\nimport { glob, globSync } from 'tinyglobby'\nimport { createSSRApp } from 'vue'\nimport { renderToString } from 'vue/server-renderer'\nimport { createHead } from '@unhead/vue/server'\nimport { MaizzleConfigKey } from '../composables/useConfig.ts'\nimport { RenderContextKey } from '../composables/renderContext.ts'\nimport { componentNameFromPath, type NormalizedComponentSource } from '../utils/componentSources.ts'\nimport type { Component, InjectionKey } from 'vue'\nimport type { MaizzleConfig, MarkdownConfig } from '../types/index.ts'\nimport type { MarkdownExit } from 'markdown-exit'\nimport type { RenderContext } from '../composables/renderContext.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nconst vuePkgDir = dirname(fileURLToPath(import.meta.resolve('vue/package.json')))\nconst vueServerRendererPkgDir = dirname(fileURLToPath(import.meta.resolve('@vue/server-renderer/package.json')))\nconst unheadVuePkgDir = resolve(dirname(fileURLToPath(import.meta.resolve('@unhead/vue'))), '..')\nconst vueRouterPkgDir = dirname(fileURLToPath(import.meta.resolve('vue-router/package.json')))\n\nexport interface RenderedTemplate {\n html: string\n doctype?: string\n templateConfig: MaizzleConfig\n sfcEventHandlers: RenderContext['sfcEventHandlers']\n plaintext?: RenderContext['plaintext']\n tailwindBlocks?: RenderContext['tailwindBlocks']\n}\n\nexport interface Renderer {\n render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate>\n invalidate(filePath: string): Promise<void>\n invalidateAll(): Promise<void>\n close(): Promise<void>\n}\n\nexport interface CreateRendererOptions {\n /** Generate .d.ts files for auto-imports and components (default: false) */\n dts?: boolean\n /** Options passed to unplugin-vue-markdown */\n markdown?: MarkdownConfig\n /** Root directory for resolving user component dirs and .d.ts output */\n root?: string\n /**\n * Additional component sources to register for auto-import. Already\n * normalized — pass through `normalizeComponentSources()` first.\n */\n componentDirs?: NormalizedComponentSource[]\n /** User Vite config options to merge into the internal SSR server */\n vite?: InlineConfig\n}\n\n/**\n * Lightweight Vite SSR loader for rendering Vue SFC email templates.\n *\n * Uses only Vue + unplugin for component/auto-import resolution.\n * Tailwind CSS compilation is handled by the transformer pipeline.\n */\nexport async function createRenderer(\n options: CreateRendererOptions = {},\n): Promise<Renderer> {\n const { dts = false, markdown: markdownOptionsRaw, root = process.cwd(), componentDirs = [], vite: userViteConfig } = options\n const { shikiTheme = 'github-light', ...markdownOptions } = markdownOptionsRaw ?? {}\n\n // Sources without an explicit prefix get registered via unplugin's `dirs`\n // (folder name auto-namespaces). Sources with an explicit `prefix` are\n // registered through a custom resolver below so we can fully control naming.\n const dirSources = componentDirs.filter(s => s.prefix === undefined)\n const prefixedSources = componentDirs.filter(s => s.prefix !== undefined)\n\n // Absolute component dirs — used to skip auto-wrapping `.md` files that are\n // imported as reusable components (vs. entry-point email templates).\n const componentDirsAbs = [resolve(root, 'components'), ...componentDirs.map(s => s.path)]\n\n const dtsDir = isLaravel()\n ? resolve(process.cwd(), 'resources/js/types/maizzle')\n : resolve(root, '.maizzle')\n\n // Built-in framework components live at this path. When a user provides a\n // top-level file with the same (PascalCased) basename, drop the built-in\n // from unplugin's scan so the user's component is the only candidate. This\n // avoids the \"naming conflicts\" warning and the alphabetical-glob ordering\n // pitfall that decides who wins when both are present in `dirs`.\n const frameworkComponentsDir = resolve(__dirname, '../components')\n\n function topLevelBasenamesLower(dir: string): Set<string> {\n if (!existsSync(dir)) return new Set()\n const files = globSync(['*.vue', '*.md'], { cwd: dir, absolute: false })\n return new Set(files.map(f => f.replace(/\\.(vue|md)$/, '').toLowerCase()))\n }\n\n const frameworkFiles = globSync(['*.vue', '*.md'], { cwd: frameworkComponentsDir, absolute: false })\n const frameworkByLower = new Map(\n frameworkFiles.map(f => [f.replace(/\\.(vue|md)$/, '').toLowerCase(), f]),\n )\n\n const shadowedNames = new Set<string>()\n for (const dir of [resolve(root, 'components'), ...dirSources.map(s => s.path)]) {\n for (const lower of topLevelBasenamesLower(dir)) {\n if (frameworkByLower.has(lower)) shadowedNames.add(lower)\n }\n }\n\n const frameworkExcludes = [...shadowedNames]\n .map(lower => `${frameworkComponentsDir}/${frameworkByLower.get(lower)}`)\n\n // Pre-scanned name → absolute-path map for prefixed sources. Rebuilt on\n // file add/unlink via the watcher hook plugin further down. Powers the\n // runtime resolver and the d.ts file we write for IDE autocompletion.\n const prefixedNameMap = new Map<string, string>()\n\n async function scanPrefixedSources(): Promise<void> {\n prefixedNameMap.clear()\n const seen = new Map<string, string>()\n for (const source of prefixedSources) {\n const files = await glob(['**/*.vue', '**/*.md'], { cwd: source.path, absolute: true })\n for (const file of files) {\n const name = componentNameFromPath({\n filePath: file,\n dirRoot: source.path,\n prefix: source.prefix,\n pathPrefix: source.pathPrefix,\n })\n const existing = seen.get(name)\n if (existing && existing !== file) {\n throw new Error(\n `[maizzle] Component name collision: \"${name}\" resolved from both \"${existing}\" and \"${file}\". `\n + 'Rename one of the files or split them into separate sources with distinct prefixes.',\n )\n }\n seen.set(name, file)\n prefixedNameMap.set(name, file)\n }\n }\n }\n\n await scanPrefixedSources()\n\n const prefixedResolver = (name: string) => prefixedNameMap.get(name)\n\n // unplugin-vue-components' own d.ts only covers components found via `dirs`;\n // its `types` option emits named-import entries which break for SFC `default`\n // exports. Write a sibling d.ts for prefixed sources so editors get correct\n // autocompletion via TypeScript interface merging on `vue.GlobalComponents`.\n const prefixedDtsPath = resolve(dtsDir, 'prefixed-components.d.ts')\n\n function writePrefixedDts(): void {\n if (!dts) return\n if (prefixedNameMap.size === 0) {\n if (existsSync(prefixedDtsPath)) rmSync(prefixedDtsPath)\n return\n }\n const dtsBase = dirname(prefixedDtsPath)\n mkdirSync(dtsBase, { recursive: true })\n const lines = Array.from(prefixedNameMap.entries())\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, file]) => {\n const relativePath = relPath(dtsBase, file).replace(/\\\\/g, '/')\n const importPath = relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n return ` ${name}: typeof import('${importPath}')['default']`\n })\n .join('\\n')\n writeFileSync(\n prefixedDtsPath,\n `/* eslint-disable */\\n// @ts-nocheck\\n// biome-ignore lint: disable\\n// oxlint-disable\\n// Generated by Maizzle for prefixed component sources\\n\\nexport {}\\n\\n/* prettier-ignore */\\ndeclare module 'vue' {\\n export interface GlobalComponents {\\n${lines}\\n }\\n}\\n`,\n )\n }\n\n writePrefixedDts()\n\n /**\n * Watches prefixed source dirs and rebuilds {@link prefixedNameMap} when\n * files are added/removed. Vite's watcher already covers `dirSources`\n * via unplugin-vue-components' own filesystem hooks.\n */\n const prefixedSourceWatcher: Plugin | null = prefixedSources.length > 0\n ? {\n name: 'maizzle:prefixed-component-watcher',\n configureServer(server) {\n for (const source of prefixedSources) {\n server.watcher.add(source.path)\n }\n const refresh = async (file: string) => {\n if (!prefixedSources.some(s => file.startsWith(`${s.path}/`))) return\n if (!/\\.(vue|md)$/.test(file)) return\n await scanPrefixedSources()\n writePrefixedDts()\n }\n server.watcher.on('add', refresh)\n server.watcher.on('unlink', refresh)\n },\n }\n : null\n\n const VIRTUAL_SFC_ID = 'virtual:maizzle-sfc.vue'\n let virtualSfcSource = ''\n\n // Never load the host project's vite.config.ts here. Doing so pulls every\n // host plugin (Nitro, TanStack Start, the Maizzle plugin itself, …) into\n // this isolated SSR pipeline, where they override env factories, re-trigger\n // configureServer hooks, and break Vite's hot channel wiring. Users that\n // need extra Vite plugins for SSR pass them explicitly via the `vite` option.\n const maizzleConfig: InlineConfig = {\n configFile: false,\n plugins: [\n rawExtract(),\n codeBlockExtract(),\n markdownExtract(),\n rowSourceLocation(),\n {\n name: 'maizzle:virtual-sfc',\n resolveId(id) {\n if (id === VIRTUAL_SFC_ID) return id\n },\n load(id) {\n if (id === VIRTUAL_SFC_ID) return virtualSfcSource\n },\n },\n vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n },\n }),\n Markdown(merge(markdownOptions ?? {}, {\n headEnabled: true,\n wrapperDiv: false,\n wrapperClasses: 'prose',\n wrapperComponent: (id: string, raw: string) => {\n const fm = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1]\n const layout = fm?.match(/^[ \\t]*layout[ \\t]*:[ \\t]*['\"]?([A-Za-z][\\w-]*|false|none)['\"]?[ \\t]*$/m)?.[1]\n if (layout === 'false' || layout === 'none') return null\n if (layout) return layout\n // No `layout:` set — default to the built-in `MarkdownLayout` for\n // entry-template `.md` files. Skip for `.md` files inside component\n // dirs, which are reusable fragments imported into other templates.\n const inComponentDir = componentDirsAbs.some(d => id === d || id.startsWith(`${d}/`))\n return inComponentDir ? null : 'MarkdownLayout'\n },\n markdownOptions: {\n async highlight(code: string, lang: string) {\n const { codeToHtml } = await import('shiki')\n return codeToHtml(code, { lang, theme: shikiTheme })\n },\n },\n markdownSetup(md: MarkdownExit) {\n const wrapPre = (html: string) =>\n `<table class=\"w-full\"><tr><td class=\"max-w-0 mso-padding-alt-4\">${html}</td></tr></table>\\n`\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) => {\n const result = defaultFence(...args)\n if (typeof result === 'string') return wrapPre(result)\n return result.then(wrapPre)\n }\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => wrapPre(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n dts: dts ? resolve(dtsDir, 'auto-imports.d.ts') : false,\n }),\n Components({\n extensions: ['vue', 'md'],\n include: [/\\.vue$/, /\\.vue\\?vue/, /\\.md$/],\n dirs: [\n frameworkComponentsDir,\n resolve(root, 'components'),\n ...dirSources.map(s => s.path),\n ],\n // Drop built-in component files whose name the user has shadowed.\n // This makes the user's version the only match — no \"naming\n // conflicts\" warning, no glob-ordering games.\n globsExclude: frameworkExcludes,\n directoryAsNamespace: true,\n collapseSamePrefixes: true,\n resolvers: prefixedSources.length > 0 ? [prefixedResolver] : undefined,\n dts: dts ? resolve(dtsDir, 'components.d.ts') : false,\n }),\n ...(prefixedSourceWatcher ? [prefixedSourceWatcher] : []),\n ],\n resolve: {\n alias: {\n 'vue/server-renderer': resolve(vueServerRendererPkgDir, 'dist/server-renderer.esm-bundler.js'),\n 'vue': resolve(vuePkgDir, 'dist/vue.runtime.esm-bundler.js'),\n 'vue-router': vueRouterPkgDir,\n '@unhead/vue/server': resolve(unheadVuePkgDir, 'dist/server.mjs'),\n '@unhead/vue': resolve(unheadVuePkgDir, 'dist/index.mjs'),\n },\n },\n server: {\n middlewareMode: true,\n hmr: false,\n // Watcher is required so unplugin-vue-components and unplugin-auto-import\n // detect added/removed component files and rewrite their .d.ts on the fly.\n // (We only render via SSR — HMR is off, but chokidar still drives the plugins.)\n fs: {\n allow: [process.cwd(), root, ...componentDirs.map(s => s.path), vuePkgDir, vueServerRendererPkgDir, unheadVuePkgDir, vueRouterPkgDir],\n },\n },\n appType: 'custom',\n logLevel: 'silent',\n optimizeDeps: {\n noDiscovery: true,\n },\n }\n\n // Merge user's vite config (from config.vite) under Maizzle's config.\n // mergeConfig(a, b) → b overrides a for scalars, arrays are concatenated.\n // This ensures Maizzle's critical settings (middlewareMode, appType, etc.) always win,\n // while user plugins and other options are included.\n const finalConfig = userViteConfig\n ? mergeConfig(userViteConfig, maizzleConfig)\n : maizzleConfig\n\n const server = await createServer(finalConfig)\n\n return {\n async render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate> {\n let component: Component\n let configKey: InjectionKey<MaizzleConfig>\n let contextKey: InjectionKey<RenderContext>\n\n if (typeof input === 'string') {\n // String input goes through Vite — must use ssrLoadModule for injection keys\n // so they share the same module instance as the SFC\n const configModule = await server.ssrLoadModule(resolve(__dirname, '../composables/useConfig'))\n const contextModule = await server.ssrLoadModule(resolve(__dirname, '../composables/renderContext'))\n configKey = configModule.MaizzleConfigKey\n contextKey = contextModule.RenderContextKey\n\n if (input.includes('<template') || input.includes('<script')) {\n virtualSfcSource = input\n const mod = server.moduleGraph.getModuleById(VIRTUAL_SFC_ID)\n if (mod) server.moduleGraph.invalidateModule(mod)\n component = (await server.ssrLoadModule(VIRTUAL_SFC_ID)).default\n } else {\n component = (await server.ssrLoadModule(input)).default\n }\n } else {\n // Pre-compiled component — use directly imported keys\n component = input\n configKey = MaizzleConfigKey\n contextKey = RenderContextKey\n }\n\n const renderContext: RenderContext = {\n doctype: undefined,\n sfcConfig: undefined,\n sfcEventHandlers: [],\n }\n\n const head = createHead({ disableDefaults: true })\n const app = createSSRApp(component)\n app.use(head)\n\n // Register user Vue plugins, directives, and global properties\n if (config.vue) {\n const plugins = typeof config.vue.plugins === 'function'\n ? config.vue.plugins()\n : config.vue.plugins ?? []\n for (const plugin of plugins) {\n app.use(plugin)\n }\n for (const [name, directive] of Object.entries(config.vue.directives ?? {})) {\n app.directive(name, directive)\n }\n Object.assign(app.config.globalProperties, config.vue.globalProperties)\n }\n\n app.provide(configKey, config)\n app.provide(contextKey, renderContext)\n\n const ssrContext: Record<string, any> = {}\n let html: string = await renderToString(app, ssrContext)\n\n const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = head.render()\n\n // Inject head entries into the rendered HTML\n if (htmlAttrs) {\n html = html.replace(/<html([^>]*)>/, `<html$1 ${htmlAttrs}>`)\n }\n if (headTags) {\n html = html.replace('</head>', `${headTags}\\n</head>`)\n }\n if (bodyAttrs) {\n html = html.replace(/<body([^>]*)>/, `<body$1 ${bodyAttrs}>`)\n }\n if (bodyTagsOpen) {\n html = html.replace(/<body([^>]*)>/, `<body$1>\\n${bodyTagsOpen}`)\n }\n if (bodyTags) {\n html = html.replace('</body>', `${bodyTags}\\n</body>`)\n }\n\n // Inject SSR teleport content into their target elements\n const hasTeleports = ssrContext.teleports && Object.keys(ssrContext.teleports).length > 0\n const hasFonts = (renderContext.fonts?.length ?? 0) > 0\n\n if (hasTeleports || hasFonts) {\n const { parse: parseDom, serialize: serializeDom, walk } = await import('../utils/ast/index.ts')\n let dom = parseDom(html)\n\n if (hasTeleports) {\n for (const [rawTarget, content] of Object.entries(ssrContext.teleports) as [string, string][]) {\n if (!content) continue\n\n const prepend = rawTarget.endsWith(':start')\n const target = prepend ? rawTarget.slice(0, -6) : rawTarget\n const targetChildren = parseDom(content)\n\n walk(dom, (node) => {\n const el = node as import('domhandler').Element\n\n if (!el.name) return\n\n const matched\n = target === el.name\n || (target.startsWith('#') && el.attribs?.id === target.slice(1))\n || (target.startsWith('.') && el.attribs?.class?.split(/\\s+/).includes(target.slice(1)))\n\n if (matched) {\n for (const child of targetChildren) {\n child.parent = el as any\n }\n\n el.children = prepend\n ? [...targetChildren, ...(el.children || [])] as any\n : [...(el.children || []), ...targetChildren] as any\n }\n })\n }\n }\n\n if (hasFonts) {\n const { injectFonts } = await import('./injectFonts.ts')\n injectFonts(dom, renderContext.fonts!, parseDom, walk)\n }\n\n html = serializeDom(dom)\n }\n\n // Inject preheader text from usePreheader() composable\n if (renderContext.preheader) {\n const { text, fillerCount, shyCount } = renderContext.preheader\n const filler = '\\u2007\\u034F '.repeat(fillerCount)\n const shys = '\\u00AD '.repeat(shyCount)\n const previewHtml = `<div style=\"display:none\">${text}${filler}${shys}\\u00A0</div>`\n html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`)\n }\n\n // Strip Vue SSR fragment markers + teleport anchor comments. These are\n // rendering hygiene, not transformer concerns — must run regardless of\n // `useTransformers` state. Fragment markers contain `-->`, which would\n // prematurely terminate MSO conditional comments downstream.\n html = html\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n return {\n html,\n doctype: renderContext.doctype,\n // Layer sfcConfig over config — sfcConfig is a partial override\n // emitted by composables (defineConfig, useTransformers, etc.).\n // A naive replacement (`sfcConfig ?? config`) drops defaults from\n // the resolved config when the SFC only sets a single key, since\n // the composables' inject() of globalConfig can return `{}` in\n // dev when ssrLoadModule and the SFC's auto-imported module\n // resolve to different module instances (different Symbols).\n templateConfig: renderContext.sfcConfig ? merge(renderContext.sfcConfig, config) : config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\n tailwindBlocks: renderContext.tailwindBlocks,\n }\n },\n\n async invalidate(filePath: string): Promise<void> {\n const mod = await server.moduleGraph.getModuleByUrl(filePath)\n if (mod) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async invalidateAll(): Promise<void> {\n for (const mod of server.moduleGraph.idToModuleMap.values()) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async close(): Promise<void> {\n await server.close()\n // unplugin-auto-import schedules a 500ms-throttled, fire-and-forget\n // d.ts write on its first scan. server.close() doesn't drain that\n // pending write, so callers tearing down the working dir right after\n // close (tests, ephemeral build pipelines) can race the mkdir against\n // a missing parent directory. Wait one throttle window past close so\n // that lingering write resolves while the dir still exists.\n if (dts) {\n await new Promise(resolve => setTimeout(resolve, 600))\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAM,YAAY,QAAQ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S,cAAc;IAQvB,gBAAgB,cAAc,YAAYA,OAAM,cAAc,WAAW,OAAO,GAAG;IACnF,kBAAkB,cAAc;IAChC,WAAW,cAAc;IACzB,gBAAgB,cAAc;IAC/B;;EAGH,MAAM,WAAW,UAAiC;GAChD,MAAM,MAAM,MAAM,OAAO,YAAY,eAAe,SAAS;GAC7D,IAAI,KACF,OAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,gBAA+B;GACnC,KAAK,MAAM,OAAO,OAAO,YAAY,cAAc,QAAQ,EACzD,OAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,QAAuB;GAC3B,MAAM,OAAO,OAAO;GAOpB,IAAI,KACF,MAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,IAAI,CAAC;;EAG3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","names":[],"sources":["../src/serve.ts"],"mappings":";;;;UAkCiB,YAAA;EACf,MAAA,GAAS,OAAA,CAAQ,aAAA;;EAEjB,IAAA;EAH2B;EAK3B,IAAA;EAJgB;EAMhB,MAAA;AAAA;;;;;;;AAYF;;;iBAAsB,KAAA,CAAM,OAAA,GAAS,YAAA,GAAiB,OAAA,CAAA,aAAA;AAAA,iBA+jBtC,WAAA,CAAY,MAAA,EAAQ,aAAA,EAAe,WAAA"}
1
+ {"version":3,"file":"serve.d.ts","names":[],"sources":["../src/serve.ts"],"mappings":";;;;UAmCiB,YAAA;EACf,MAAA,GAAS,OAAA,CAAQ,aAAA;;EAEjB,IAAA;EAH2B;EAK3B,IAAA;EAJgB;EAMhB,MAAA;AAAA;;;;;;;AAYF;;;iBAAsB,KAAA,CAAM,OAAA,GAAS,YAAA,GAAiB,OAAA,CAAA,aAAA;AAAA,iBA+jBtC,WAAA,CAAY,MAAA,EAAQ,aAAA,EAAe,WAAA"}
package/dist/serve.js CHANGED
@@ -8,9 +8,10 @@ import { setActiveRenderer } from "./render/active.js";
8
8
  import { serveLint } from "./server/linter.js";
9
9
  import { serveCompatibility } from "./server/compatibility.js";
10
10
  import { sendEmail } from "./server/email.js";
11
+ import { createWatchedFileMatcher } from "./utils/watchPaths.js";
11
12
  import { createRequire } from "node:module";
12
13
  import { readFileSync } from "node:fs";
13
- import { basename, dirname, matchesGlob, resolve } from "node:path";
14
+ import { basename, dirname, resolve } from "node:path";
14
15
  import { glob } from "tinyglobby";
15
16
  import { fileURLToPath } from "node:url";
16
17
  import { createLogger, createServer } from "vite";
@@ -159,7 +160,7 @@ function maizzleDevPlugin(config, renderer, configInput) {
159
160
  ];
160
161
  const userWatchPaths = config.server?.watch ?? [];
161
162
  const watchPaths = [...defaultWatchPaths, ...userWatchPaths];
162
- const isWatchedFile = (file) => watchPaths.some((p) => matchesGlob(file, p));
163
+ const isWatchedFile = createWatchedFileMatcher(watchPaths, config.root ?? process.cwd());
163
164
  for (const watchPath of watchPaths) server.watcher.add(watchPath);
164
165
  server.watcher.on("add", async (file) => {
165
166
  if (isTemplateFile(file)) {
package/dist/serve.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","names":[],"sources":["../src/serve.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve, basename, matchesGlob } 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 { createRenderer, type Renderer } from './render/createRenderer.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 { normalizeComponentSources } from './utils/componentSources.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)\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\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 banner/URL output (used by the Vite plugin, which prints its own) */\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\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 })\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 app\n // is itself a Vite dev process — e.g. TanStack Start).\n setActiveRenderer(renderer)\n\n const server = await createServer({\n configFile: false,\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, 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 ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', 'lucide-vue-next', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori', 'postcss-safe-parser']\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-next',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n 'postcss-safe-parser',\n ],\n },\n server: {\n port,\n host: options.host,\n fs: {\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', 'lucide-vue-next', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori', 'postcss-safe-parser'].map(pkg)],\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 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 // Prevent Tailwind/Vue from triggering a full reload for email template files.\n // Maizzle handles these via custom HMR events in the watcher below.\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 const userWatchPaths = config.server?.watch ?? []\n const watchPaths = [...defaultWatchPaths, ...userWatchPaths]\n const isWatchedFile = (file: string) => watchPaths.some(p => matchesGlob(file, p))\n\n for (const watchPath of watchPaths) {\n server.watcher.add(watchPath)\n }\n\n server.watcher.on('add', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('unlink', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('change', async (file) => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\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 })\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 inject.\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n // Invalidate all renderer modules so component and config changes\n // are picked up on the next render (Tailwind recompiles with fresh content)\n await renderer.invalidateAll()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(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, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, 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, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\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\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, 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 try {\n const absolutePath = resolve(match)\n\n // Invalidate all modules so template + component changes are picked up\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n 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, 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 try {\n const absolutePath = resolve(match)\n\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n html = stripForHtml(`${doctype}\\n${html}`)\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, 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 try {\n const absolutePath = resolve(match)\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n const plaintext = createPlaintext(stripForPlaintext(html))\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, 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 try {\n const absolutePath = resolve(match)\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = stripForHtml(html)\n\n const sizeBytes = Buffer.byteLength(html, 'utf-8')\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) {\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 try {\n const absolutePath = resolve(match)\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = `${doctype}\\n${html}`\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 v6.0.0\\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":";;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,WAAW,QADC,QAAQ,cAAc,OAAO,KAAK,IAAI,CACtB,EAAE,YAAY;AAEhD,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAC9C,MAAM,OAAO,SAAiB;CAC5B,MAAM,WAAW,QAAQ,QAAQ,KAAK,CAAC,QAAQ,OAAO,IAAI;CAC1D,MAAM,SAAS,gBAAgB;CAC/B,MAAM,MAAM,SAAS,YAAY,OAAO;CAExC,OAAO,SAAS,MAAM,GAAG,MAAM,OAAO,OAAO;;;;;;;;;;;AAsB/C,eAAsB,MAAM,UAAwB,EAAE,EAAE;CACtD,MAAM,QAAQ,YAAY,KAA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Sync } from 'node:fs'\nimport { dirname, resolve, basename } 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 { createRenderer, type Renderer } from './render/createRenderer.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 { normalizeComponentSources } from './utils/componentSources.ts'\nimport { createWatchedFileMatcher } from './utils/watchPaths.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)\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\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 banner/URL output (used by the Vite plugin, which prints its own) */\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\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 })\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 app\n // is itself a Vite dev process — e.g. TanStack Start).\n setActiveRenderer(renderer)\n\n const server = await createServer({\n configFile: false,\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, 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 ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', 'lucide-vue-next', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori', 'postcss-safe-parser']\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-next',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n 'postcss-safe-parser',\n ],\n },\n server: {\n port,\n host: options.host,\n fs: {\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', 'lucide-vue-next', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori', 'postcss-safe-parser'].map(pkg)],\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 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 // Prevent Tailwind/Vue from triggering a full reload for email template files.\n // Maizzle handles these via custom HMR events in the watcher below.\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 const userWatchPaths = config.server?.watch ?? []\n const watchPaths = [...defaultWatchPaths, ...userWatchPaths]\n const isWatchedFile = createWatchedFileMatcher(watchPaths, config.root ?? process.cwd())\n\n for (const watchPath of watchPaths) {\n server.watcher.add(watchPath)\n }\n\n server.watcher.on('add', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('unlink', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('change', async (file) => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\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 })\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 inject.\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n // Invalidate all renderer modules so component and config changes\n // are picked up on the next render (Tailwind recompiles with fresh content)\n await renderer.invalidateAll()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(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, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, 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, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\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\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, 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 try {\n const absolutePath = resolve(match)\n\n // Invalidate all modules so template + component changes are picked up\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n 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, 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 try {\n const absolutePath = resolve(match)\n\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n html = stripForHtml(`${doctype}\\n${html}`)\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, 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 try {\n const absolutePath = resolve(match)\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n const plaintext = createPlaintext(stripForPlaintext(html))\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, 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 try {\n const absolutePath = resolve(match)\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = stripForHtml(html)\n\n const sizeBytes = Buffer.byteLength(html, 'utf-8')\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) {\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 try {\n const absolutePath = resolve(match)\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = `${doctype}\\n${html}`\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 v6.0.0\\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":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,WAAW,QADC,QAAQ,cAAc,OAAO,KAAK,IAAI,CACtB,EAAE,YAAY;AAEhD,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAC9C,MAAM,OAAO,SAAiB;CAC5B,MAAM,WAAW,QAAQ,QAAQ,KAAK,CAAC,QAAQ,OAAO,IAAI;CAC1D,MAAM,SAAS,gBAAgB;CAC/B,MAAM,MAAM,SAAS,YAAY,OAAO;CAExC,OAAO,SAAS,MAAM,GAAG,MAAM,OAAO,OAAO;;;;;;;;;;;AAsB/C,eAAsB,MAAM,UAAwB,EAAE,EAAE;CACtD,MAAM,QAAQ,YAAY,KAAK;CAE/B,IAAI,SAAS,MAAM,cAAc,QAAQ,OAAO;CAChD,MAAM,OAAO,QAAQ,QAAQ,OAAO,QAAQ,QAAQ;CAGpD,IAAI,WAAW,MAAM,eAAe;EAAE,KAAK;EAAM,UAAU,OAAO;EAAU,MAAM,OAAO;EAAM,eAAe,0BAA0B,OAAO,YAAY,QAAQ,QAAQ,KAAK,CAAC;EAAE,MAAM,OAAO;EAAM,CAAC;CAKvM,kBAAkB,SAAS;CAE3B,MAAM,SAAS,MAAM,aAAa;EAChC,YAAY;EACZ,SAAS;GAEP,KAAK;GACL,aAAa;GACb,iBAAiB,QAAQ,UAAU,QAAQ,OAAO;GACnD;EACD,SAAS;GACP,QAAQ,CAAC,MAAM;GACf,OAAO;IACL;KAAE,MAAM;KAAK,aAAa;KAAU;IACpC;KAAE,MAAM;KAAO,aAAa,QAAQ,IAAI,MAAM,EAAE,kCAAkC;KAAE;IACpF,GAAG;KAAC;KAAc;KAAW;KAAgB;KAAkB;KAAmB;KAA4B;KAAQ;KAAkB;KAAU;KAAsB,CACrK,K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OAAO,cAAc,QAAQ;CAChD,IAAI,YAAY;EACd,MAAM,KAAK,qBAAqB,YAAY,EAAE,QAAQ,GAAG,CAAC;EAC1D,KAAK,GAAG;EACR,KAAK,GAAG,MAAM,KAAK,CAAC,KAAI,SAAQ,KAAK,OAAO,CAAC,KAAK,KAAK,CAAC;;CAG1D,KAAK,GAAG;CACR,KAAK,wFAAwF,KAAK,YAAY;CAC9G,KAAK,GAAG;CACR,OAAO,WAAW;CAClB,KAAK,GAAG;;AAGV,SAAS,eAAe;CACtB,MAAM,SAAS,aAAa,OAAO;CACnC,MAAM,OAAO,OAAO;CAEpB,OAAO,QAAQ,SAAS,YAAY;EAClC,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,kCAAkC,EACpF;EAGF,KAAK,SAAS,QAAQ;;CAGxB,OAAO"}
@@ -1,4 +1,4 @@
1
- import { parse } from "../utils/ast/parser.js";
1
+ import { parse as parse$1 } from "../utils/ast/parser.js";
2
2
  import { walk } from "../utils/ast/walker.js";
3
3
  import { serialize } from "../utils/ast/serializer.js";
4
4
  import "../utils/ast/index.js";
@@ -28,7 +28,7 @@ import { dirname, resolve } from "node:path";
28
28
  * )
29
29
  */
30
30
  async function inlineLink(html, filePath) {
31
- return serialize(await inlineLinkDom(parse(html), filePath));
31
+ return serialize(await inlineLinkDom(parse$1(html), filePath));
32
32
  }
33
33
  /**
34
34
  * DOM-form of {@link inlineLink} used by the internal transformer pipeline.
@@ -1 +1 @@
1
- {"version":3,"file":"inlineLink.js","names":[],"sources":["../../src/transformers/inlineLink.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\n\n/**\n * Inline `<link rel=\"stylesheet\">` tags as `<style>` tags.\n *\n * - Local file paths are inlined when `filePath` is provided (resolved\n * relative to it).\n * - Remote URLs (`http://` / `https://`) are only inlined when the link\n * carries an `inline` attribute, e.g. `<link rel=\"stylesheet\" inline href=\"…\">`.\n *\n * @param html HTML string to transform.\n * @param filePath Path of the source file the HTML came from, used as the\n * base for resolving relative `href` values. Required for\n * local-file inlining; remote `inline` links work without it.\n * @returns The transformed HTML string.\n *\n * @example\n * import { inlineLink } from '@maizzle/framework'\n *\n * const out = await inlineLink(\n * '<link rel=\"stylesheet\" href=\"./styles.css\">',\n * '/path/to/template.html',\n * )\n */\nexport async function inlineLink(html: string, filePath?: string): Promise<string> {\n return serialize(await inlineLinkDom(parse(html), filePath))\n}\n\n/**\n * DOM-form of {@link inlineLink} used by the internal transformer pipeline.\n * Takes a parsed DOM, returns a parsed DOM — avoids redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport async function inlineLinkDom(dom: ChildNode[], filePath?: string): Promise<ChildNode[]> {\n const links: { node: Element; parent: ChildNode; index: number }[] = []\n\n walk(dom, (node) => {\n if ((node as Element).name !== 'link') return\n\n const el = node as Element\n const attrs = el.attribs || {}\n\n if (attrs.rel !== 'stylesheet' || !attrs.href) return\n\n const parent = el.parent as ChildNode\n\n if (parent && 'children' in parent) {\n const index = (parent.children as ChildNode[]).indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent, index })\n }\n } else {\n // Top-level node\n const index = dom.indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent: null as any, index })\n }\n }\n })\n\n for (const { node, parent, index } of links) {\n const href = node.attribs.href\n const isRemote = href.startsWith('http://') || href.startsWith('https://')\n\n let css: string | undefined\n\n if (isRemote) {\n if (!('inline' in node.attribs)) continue\n\n try {\n const response = await fetch(href)\n css = await response.text()\n } catch {\n continue\n }\n } else {\n if (!filePath) continue\n\n try {\n const absolutePath = resolve(dirname(filePath), href)\n css = readFileSync(absolutePath, 'utf8')\n } catch {\n continue\n }\n }\n\n const styleNode = {\n type: 'tag',\n name: 'style',\n attribs: {},\n children: [{\n type: 'text',\n data: css,\n parent: null as any,\n }],\n parent: parent || null,\n } as any\n\n // Set parent reference on the text child\n styleNode.children[0].parent = styleNode\n\n const siblings = parent && 'children' in parent\n ? parent.children as ChildNode[]\n : dom\n\n siblings.splice(index, 1, styleNode)\n }\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,eAAsB,WAAW,MAAc,UAAoC;CACjF,OAAO,UAAU,MAAM,cAAc,MAAM,KAAK,EAAE,SAAS,CAAC;;;;;;;AAQ9D,eAAsB,cAAc,KAAkB,UAAyC;CAC7F,MAAM,QAA+D,EAAE;CAEvE,KAAK,MAAM,SAAS;EAClB,IAAK,KAAiB,SAAS,QAAQ;EAEvC,MAAM,KAAK;EACX,MAAM,QAAQ,GAAG,WAAW,EAAE;EAE9B,IAAI,MAAM,QAAQ,gBAAgB,CAAC,MAAM,MAAM;EAE/C,MAAM,SAAS,GAAG;EAElB,IAAI,UAAU,cAAc,QAAQ;GAClC,MAAM,QAAS,OAAO,SAAyB,QAAQ,GAAG;GAC1D,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI;IAAQ;IAAO,CAAC;SAEpC;GAEL,MAAM,QAAQ,IAAI,QAAQ,GAAG;GAC7B,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI,QAAQ;IAAa;IAAO,CAAC;;GAGxD;CAEF,KAAK,MAAM,EAAE,MAAM,QAAQ,WAAW,OAAO;EAC3C,MAAM,OAAO,KAAK,QAAQ;EAC1B,MAAM,WAAW,KAAK,WAAW,UAAU,IAAI,KAAK,WAAW,WAAW;EAE1E,IAAI;EAEJ,IAAI,UAAU;GACZ,IAAI,EAAE,YAAY,KAAK,UAAU;GAEjC,IAAI;IAEF,MAAM,OAAM,MADW,MAAM,KAAK,EACb,MAAM;WACrB;IACN;;SAEG;GACL,IAAI,CAAC,UAAU;GAEf,IAAI;IAEF,MAAM,aADe,QAAQ,QAAQ,SAAS,EAAE,KACjB,EAAE,OAAO;WAClC;IACN;;;EAIJ,MAAM,YAAY;GAChB,MAAM;GACN,MAAM;GACN,SAAS,EAAE;GACX,UAAU,CAAC;IACT,MAAM;IACN,MAAM;IACN,QAAQ;IACT,CAAC;GACF,QAAQ,UAAU;GACnB;EAGD,UAAU,SAAS,GAAG,SAAS;EAM/B,CAJiB,UAAU,cAAc,SACrC,OAAO,WACP,KAEK,OAAO,OAAO,GAAG,UAAU;;CAGtC,OAAO"}
1
+ {"version":3,"file":"inlineLink.js","names":["parse"],"sources":["../../src/transformers/inlineLink.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\n\n/**\n * Inline `<link rel=\"stylesheet\">` tags as `<style>` tags.\n *\n * - Local file paths are inlined when `filePath` is provided (resolved\n * relative to it).\n * - Remote URLs (`http://` / `https://`) are only inlined when the link\n * carries an `inline` attribute, e.g. `<link rel=\"stylesheet\" inline href=\"…\">`.\n *\n * @param html HTML string to transform.\n * @param filePath Path of the source file the HTML came from, used as the\n * base for resolving relative `href` values. Required for\n * local-file inlining; remote `inline` links work without it.\n * @returns The transformed HTML string.\n *\n * @example\n * import { inlineLink } from '@maizzle/framework'\n *\n * const out = await inlineLink(\n * '<link rel=\"stylesheet\" href=\"./styles.css\">',\n * '/path/to/template.html',\n * )\n */\nexport async function inlineLink(html: string, filePath?: string): Promise<string> {\n return serialize(await inlineLinkDom(parse(html), filePath))\n}\n\n/**\n * DOM-form of {@link inlineLink} used by the internal transformer pipeline.\n * Takes a parsed DOM, returns a parsed DOM — avoids redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport async function inlineLinkDom(dom: ChildNode[], filePath?: string): Promise<ChildNode[]> {\n const links: { node: Element; parent: ChildNode; index: number }[] = []\n\n walk(dom, (node) => {\n if ((node as Element).name !== 'link') return\n\n const el = node as Element\n const attrs = el.attribs || {}\n\n if (attrs.rel !== 'stylesheet' || !attrs.href) return\n\n const parent = el.parent as ChildNode\n\n if (parent && 'children' in parent) {\n const index = (parent.children as ChildNode[]).indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent, index })\n }\n } else {\n // Top-level node\n const index = dom.indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent: null as any, index })\n }\n }\n })\n\n for (const { node, parent, index } of links) {\n const href = node.attribs.href\n const isRemote = href.startsWith('http://') || href.startsWith('https://')\n\n let css: string | undefined\n\n if (isRemote) {\n if (!('inline' in node.attribs)) continue\n\n try {\n const response = await fetch(href)\n css = await response.text()\n } catch {\n continue\n }\n } else {\n if (!filePath) continue\n\n try {\n const absolutePath = resolve(dirname(filePath), href)\n css = readFileSync(absolutePath, 'utf8')\n } catch {\n continue\n }\n }\n\n const styleNode = {\n type: 'tag',\n name: 'style',\n attribs: {},\n children: [{\n type: 'text',\n data: css,\n parent: null as any,\n }],\n parent: parent || null,\n } as any\n\n // Set parent reference on the text child\n styleNode.children[0].parent = styleNode\n\n const siblings = parent && 'children' in parent\n ? parent.children as ChildNode[]\n : dom\n\n siblings.splice(index, 1, styleNode)\n }\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,eAAsB,WAAW,MAAc,UAAoC;CACjF,OAAO,UAAU,MAAM,cAAcA,QAAM,KAAK,EAAE,SAAS,CAAC;;;;;;;AAQ9D,eAAsB,cAAc,KAAkB,UAAyC;CAC7F,MAAM,QAA+D,EAAE;CAEvE,KAAK,MAAM,SAAS;EAClB,IAAK,KAAiB,SAAS,QAAQ;EAEvC,MAAM,KAAK;EACX,MAAM,QAAQ,GAAG,WAAW,EAAE;EAE9B,IAAI,MAAM,QAAQ,gBAAgB,CAAC,MAAM,MAAM;EAE/C,MAAM,SAAS,GAAG;EAElB,IAAI,UAAU,cAAc,QAAQ;GAClC,MAAM,QAAS,OAAO,SAAyB,QAAQ,GAAG;GAC1D,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI;IAAQ;IAAO,CAAC;SAEpC;GAEL,MAAM,QAAQ,IAAI,QAAQ,GAAG;GAC7B,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI,QAAQ;IAAa;IAAO,CAAC;;GAGxD;CAEF,KAAK,MAAM,EAAE,MAAM,QAAQ,WAAW,OAAO;EAC3C,MAAM,OAAO,KAAK,QAAQ;EAC1B,MAAM,WAAW,KAAK,WAAW,UAAU,IAAI,KAAK,WAAW,WAAW;EAE1E,IAAI;EAEJ,IAAI,UAAU;GACZ,IAAI,EAAE,YAAY,KAAK,UAAU;GAEjC,IAAI;IAEF,MAAM,OAAM,MADW,MAAM,KAAK,EACb,MAAM;WACrB;IACN;;SAEG;GACL,IAAI,CAAC,UAAU;GAEf,IAAI;IAEF,MAAM,aADe,QAAQ,QAAQ,SAAS,EAAE,KACjB,EAAE,OAAO;WAClC;IACN;;;EAIJ,MAAM,YAAY;GAChB,MAAM;GACN,MAAM;GACN,SAAS,EAAE;GACX,UAAU,CAAC;IACT,MAAM;IACN,MAAM;IACN,QAAQ;IACT,CAAC;GACF,QAAQ,UAAU;GACnB;EAGD,UAAU,SAAS,GAAG,SAAS;EAM/B,CAJiB,UAAU,cAAc,SACrC,OAAO,WACP,KAEK,OAAO,OAAO,GAAG,UAAU;;CAGtC,OAAO"}
@@ -3,7 +3,7 @@ import "../utils/ast/index.js";
3
3
  import { compileTailwindCss } from "../utils/compileTailwindCss.js";
4
4
  import { resolve } from "node:path";
5
5
  //#region src/transformers/tailwindComponent.ts
6
- const DEFAULT_SEED = "@import \"@maizzle/tailwindcss\";";
6
+ const DEFAULT_SEED = "@import \"@maizzle/tailwindcss\" source(none);";
7
7
  const OPEN_RE = /^mz-tw:(\S+)$/;
8
8
  const CLOSE_RE = /^\/mz-tw:(\S+)$/;
9
9
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tailwindComponent.js","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport type { ChildNode, Element, Comment } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport { compileTailwindCss } from '../utils/compileTailwindCss.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\nconst DEFAULT_SEED = '@import \"@maizzle/tailwindcss\";'\n\ninterface BlockMeta {\n id: string\n configCss?: string\n nested: boolean\n classes: Set<string>\n}\n\nconst OPEN_RE = /^mz-tw:(\\S+)$/\nconst CLOSE_RE = /^\\/mz-tw:(\\S+)$/\n\n/**\n * Compile Tailwind CSS for each top-level <Tailwind> block in the render\n * context. Nested <Tailwind> instances are flattened: their classes flow\n * up to the outermost block, their `#config` slot (if any) is ignored.\n * One <style> per outermost block is appended to <head>; marker comments\n * are stripped after.\n */\nexport async function tailwindComponent(\n dom: ChildNode[],\n blocks: TailwindBlock[],\n config: MaizzleConfig,\n filePath?: string,\n): Promise<ChildNode[]> {\n if (!blocks.length) return dom\n\n const map = new Map<string, BlockMeta>()\n for (const b of blocks) {\n map.set(b.id, { id: b.id, configCss: b.css, nested: false, classes: new Set() })\n }\n\n const stack: string[] = []\n const markers: Comment[] = []\n\n walk(dom, (node) => {\n if (node.type === 'comment') {\n const data = (node as Comment).data\n const open = data.match(OPEN_RE)\n const close = data.match(CLOSE_RE)\n if (open) {\n const id = open[1]\n const meta = map.get(id)\n if (meta && stack.length > 0) meta.nested = true\n if (meta) stack.push(id)\n markers.push(node as Comment)\n } else if (close) {\n const id = close[1]\n if (stack[stack.length - 1] === id) stack.pop()\n markers.push(node as Comment)\n }\n return\n }\n\n const el = node as Element\n // Always assign to the OUTERMOST active marker (stack[0]) so nested\n // <Tailwind> blocks merge their classes into the parent's scope.\n if (el.attribs?.class && stack.length > 0) {\n map.get(stack[0])!.classes.add(el.attribs.class)\n }\n })\n\n const fromPath = filePath ?? resolve(process.cwd(), 'template.vue')\n\n let head: Element | undefined\n walk(dom, (n) => {\n if (!head && (n as Element).name === 'head') head = n as Element\n })\n\n if (!head) {\n throw new Error('`Tailwind` component requires `Head` component to be present in the template.')\n }\n\n // Compile + inject one <style raw> per outermost block. `raw` opts the\n // existing tailwindcss transformer out of recompiling already-compiled CSS.\n for (const meta of map.values()) {\n if (meta.nested) continue\n\n const cssInput = buildCssInput(meta.configCss, meta.classes)\n const css = (await compileTailwindCss(cssInput, config, `${fromPath}?tw=${meta.id}`)).trim()\n if (!css) continue\n\n const styleNode: Element = {\n type: 'tag',\n name: 'style',\n attribs: { raw: '' },\n children: [],\n parent: head,\n prev: null,\n next: null,\n } as any\n\n const textNode = {\n type: 'text',\n data: css,\n parent: styleNode,\n prev: null,\n next: null,\n } as any\n\n styleNode.children = [textNode]\n head.children.push(styleNode)\n }\n\n // Strip marker comments from their parents\n for (const c of markers) {\n const parent = c.parent as Element | null\n if (!parent?.children) continue\n const i = parent.children.indexOf(c)\n if (i >= 0) parent.children.splice(i, 1)\n }\n\n return dom\n}\n\nfunction buildCssInput(configCss: string | undefined, classes: Set<string>): string {\n const seed = configCss ?? DEFAULT_SEED\n\n if (!classes.size) return seed\n\n const inline = [...classes].join(' ').replace(/\"/g, '\\\\\"')\n return `${seed}\\n@source inline(\"${inline}\");`\n}\n"],"mappings":";;;;;AAOA,MAAM,eAAe;AASrB,MAAM,UAAU;AAChB,MAAM,WAAW;;;;;;;;AASjB,eAAsB,kBACpB,KACA,QACA,QACA,UACsB;CACtB,IAAI,CAAC,OAAO,QAAQ,OAAO;CAE3B,MAAM,sBAAM,IAAI,KAAwB;CACxC,KAAK,MAAM,KAAK,QACd,IAAI,IAAI,EAAE,IAAI;EAAE,IAAI,EAAE;EAAI,WAAW,EAAE;EAAK,QAAQ;EAAO,yBAAS,IAAI,KAAK;EAAE,CAAC;CAGlF,MAAM,QAAkB,EAAE;CAC1B,MAAM,UAAqB,EAAE;CAE7B,KAAK,MAAM,SAAS;EAClB,IAAI,KAAK,SAAS,WAAW;GAC3B,MAAM,OAAQ,KAAiB;GAC/B,MAAM,OAAO,KAAK,MAAM,QAAQ;GAChC,MAAM,QAAQ,KAAK,MAAM,SAAS;GAClC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AAS,QAAQ,EAAE;EACpC,IAAI,KAAK,GAAG,OAAO,SAAS,OAAO,GAAG,EAAE;;CAG1C,OAAO;;AAGT,SAAS,cAAc,WAA+B,SAA8B;CAClF,MAAM,OAAO,aAAa;CAE1B,IAAI,CAAC,QAAQ,MAAM,OAAO;CAG1B,OAAO,GAAG,KAAK,oBADA,CAAC,GAAG,QAAQ,CAAC,KAAK,IAAI,CAAC,QAAQ,MAAM,OACX,CAAC"}
1
+ {"version":3,"file":"tailwindComponent.js","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport type { ChildNode, Element, Comment } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport { compileTailwindCss } from '../utils/compileTailwindCss.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\nconst DEFAULT_SEED = '@import \"@maizzle/tailwindcss\" source(none);'\n\ninterface BlockMeta {\n id: string\n configCss?: string\n nested: boolean\n classes: Set<string>\n}\n\nconst OPEN_RE = /^mz-tw:(\\S+)$/\nconst CLOSE_RE = /^\\/mz-tw:(\\S+)$/\n\n/**\n * Compile Tailwind CSS for each top-level <Tailwind> block in the render\n * context. Nested <Tailwind> instances are flattened: their classes flow\n * up to the outermost block, their `#config` slot (if any) is ignored.\n * One <style> per outermost block is appended to <head>; marker comments\n * are stripped after.\n */\nexport async function tailwindComponent(\n dom: ChildNode[],\n blocks: TailwindBlock[],\n config: MaizzleConfig,\n filePath?: string,\n): Promise<ChildNode[]> {\n if (!blocks.length) return dom\n\n const map = new Map<string, BlockMeta>()\n for (const b of blocks) {\n map.set(b.id, { id: b.id, configCss: b.css, nested: false, classes: new Set() })\n }\n\n const stack: string[] = []\n const markers: Comment[] = []\n\n walk(dom, (node) => {\n if (node.type === 'comment') {\n const data = (node as Comment).data\n const open = data.match(OPEN_RE)\n const close = data.match(CLOSE_RE)\n if (open) {\n const id = open[1]\n const meta = map.get(id)\n if (meta && stack.length > 0) meta.nested = true\n if (meta) stack.push(id)\n markers.push(node as Comment)\n } else if (close) {\n const id = close[1]\n if (stack[stack.length - 1] === id) stack.pop()\n markers.push(node as Comment)\n }\n return\n }\n\n const el = node as Element\n // Always assign to the OUTERMOST active marker (stack[0]) so nested\n // <Tailwind> blocks merge their classes into the parent's scope.\n if (el.attribs?.class && stack.length > 0) {\n map.get(stack[0])!.classes.add(el.attribs.class)\n }\n })\n\n const fromPath = filePath ?? resolve(process.cwd(), 'template.vue')\n\n let head: Element | undefined\n walk(dom, (n) => {\n if (!head && (n as Element).name === 'head') head = n as Element\n })\n\n if (!head) {\n throw new Error('`Tailwind` component requires `Head` component to be present in the template.')\n }\n\n // Compile + inject one <style raw> per outermost block. `raw` opts the\n // existing tailwindcss transformer out of recompiling already-compiled CSS.\n for (const meta of map.values()) {\n if (meta.nested) continue\n\n const cssInput = buildCssInput(meta.configCss, meta.classes)\n const css = (await compileTailwindCss(cssInput, config, `${fromPath}?tw=${meta.id}`)).trim()\n if (!css) continue\n\n const styleNode: Element = {\n type: 'tag',\n name: 'style',\n attribs: { raw: '' },\n children: [],\n parent: head,\n prev: null,\n next: null,\n } as any\n\n const textNode = {\n type: 'text',\n data: css,\n parent: styleNode,\n prev: null,\n next: null,\n } as any\n\n styleNode.children = [textNode]\n head.children.push(styleNode)\n }\n\n // Strip marker comments from their parents\n for (const c of markers) {\n const parent = c.parent as Element | null\n if (!parent?.children) continue\n const i = parent.children.indexOf(c)\n if (i >= 0) parent.children.splice(i, 1)\n }\n\n return dom\n}\n\nfunction buildCssInput(configCss: string | undefined, classes: Set<string>): string {\n const seed = configCss ?? DEFAULT_SEED\n\n if (!classes.size) return seed\n\n const inline = [...classes].join(' ').replace(/\"/g, '\\\\\"')\n return `${seed}\\n@source inline(\"${inline}\");`\n}\n"],"mappings":";;;;;AAOA,MAAM,eAAe;AASrB,MAAM,UAAU;AAChB,MAAM,WAAW;;;;;;;;AASjB,eAAsB,kBACpB,KACA,QACA,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,GAAG,SAAS,MAAM,KAAK,KAAK,EAAE,MAAM;EAC5F,IAAI,CAAC,KAAK;EAEV,MAAM,YAAqB;GACzB,MAAM;GACN,MAAM;GACN,SAAS,EAAE,KAAK,IAAI;GACpB,UAAU,EAAE;GACZ,QAAQ;GACR,MAAM;GACN,MAAM;GACP;EAUD,UAAU,WAAW,CAAC;GAPpB,MAAM;GACN,MAAM;GACN,QAAQ;GACR,MAAM;GACN,MAAM;GAGsB,CAAC;EAC/B,KAAK,SAAS,KAAK,UAAU;;CAI/B,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,SAAS,EAAE;EACjB,IAAI,CAAC,QAAQ,UAAU;EACvB,MAAM,IAAI,OAAO,SAAS,QAAQ,EAAE;EACpC,IAAI,KAAK,GAAG,OAAO,SAAS,OAAO,GAAG,EAAE;;CAG1C,OAAO;;AAGT,SAAS,cAAc,WAA+B,SAA8B;CAClF,MAAM,OAAO,aAAa;CAE1B,IAAI,CAAC,QAAQ,MAAM,OAAO;CAG1B,OAAO,GAAG,KAAK,oBADA,CAAC,GAAG,QAAQ,CAAC,KAAK,IAAI,CAAC,QAAQ,MAAM,OACX,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { RemoveValue } from "../plugins/postcss/removeDeclarations.js";
2
+ import { TemplateInfo } from "../events/index.js";
2
3
  import { Directive, Plugin } from "vue";
3
4
  import { Options } from "juice";
4
5
  import * as _$oxfmt from "oxfmt";
@@ -374,8 +375,15 @@ interface MarkdownConfig extends Options$1 {
374
375
  shikiTheme?: _$shiki.BundledTheme;
375
376
  }
376
377
  interface VueConfig {
377
- /** Vue plugins to register on the app instance before rendering. */
378
- plugins?: Plugin[];
378
+ /**
379
+ * Vue plugins to register on the app instance before rendering.
380
+ *
381
+ * Pass a factory (`() => Plugin[]`) for stateful plugins like vue-i18n
382
+ * or Pinia to get a fresh instance per render — otherwise state leaks
383
+ * across templates (e.g. one template setting `locale.value = 'fr'`
384
+ * affects the next render).
385
+ */
386
+ plugins?: Plugin[] | (() => Plugin[]);
379
387
  /** Custom Vue directives to register globally. */
380
388
  directives?: Record<string, Directive>;
381
389
  /** Properties added to `app.config.globalProperties`, available in all templates. */
@@ -688,7 +696,9 @@ interface MaizzleConfig {
688
696
  *
689
697
  * @example
690
698
  * vue: {
691
- * plugins: [createI18n({ locale: 'en', messages })],
699
+ * // Use a factory for stateful plugins (vue-i18n, Pinia, vue-router)
700
+ * // so each render gets a fresh instance.
701
+ * plugins: () => [createI18n({ locale: 'en', messages })],
692
702
  * directives: { focus: vFocus },
693
703
  * globalProperties: { $format: dateFormat },
694
704
  * }
@@ -698,21 +708,21 @@ interface MaizzleConfig {
698
708
  beforeCreate?: (params: {
699
709
  config: MaizzleConfig;
700
710
  }) => void | Promise<void>;
701
- /** Called before each template is rendered. Return a string to replace the template source. */
711
+ /** Called before each template is rendered. Return a string to replace `template.source`. */
702
712
  beforeRender?: (params: {
703
713
  config: MaizzleConfig;
704
- template: string;
714
+ template: TemplateInfo;
705
715
  }) => string | void | Promise<string | void>;
706
716
  /** Called after each template is rendered but before transformers run. Return a string to replace the output HTML. */
707
717
  afterRender?: (params: {
708
718
  config: MaizzleConfig;
709
- template: string;
719
+ template: TemplateInfo;
710
720
  html: string;
711
721
  }) => string | void | Promise<string | void>;
712
722
  /** Called after transformers have run on each template. Return a string to replace the output HTML. */
713
723
  afterTransform?: (params: {
714
724
  config: MaizzleConfig;
715
- template: string;
725
+ template: TemplateInfo;
716
726
  html: string;
717
727
  }) => string | void | Promise<string | void>;
718
728
  /** Called after all templates have been built. */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/types/config.ts"],"mappings":";;;;;;;;;;;UAKiB,eAAA;;;;;;EAMf,IAAA;EANe;;;;;EAYf,UAAA;EAMA;;;;;EAAA,MAAA;EASkB;;;;;EAHlB,EAAA,GAAK,MAAA;AAAA;AAAA,KAGK,QAAA,GAAW,MAAA;EACrB,QAAA,GAAW,eAAA;AAAA;AAAA,UAGI,S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,sBAAmC,OAAA;;EAE9F,WAAA,IAAe,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,sBAAmC,OAAA;;EAE3G,cAAA,IAAkB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,sBAAmC,OAAA;;EAE9G,UAAA,IAAc,MAAA;IAAU,KAAA;IAAiB,MAAA,EAAQ,aAAA;EAAA,aAA2B,OAAA;EAAA,CAG3E,GAAA;AAAA"}
@@ -0,0 +1,11 @@
1
+ //#region src/utils/watchPaths.d.ts
2
+ /**
3
+ * Build a predicate that tells whether an absolute file path emitted by
4
+ * chokidar matches any of the given globs. Patterns are interpreted as
5
+ * project-relative; a leading `./` is stripped so user-supplied globs like
6
+ * `./locales/**` behave identically to `locales/**`.
7
+ */
8
+ declare function createWatchedFileMatcher(patterns: string[], cwd: string): (file: string) => boolean;
9
+ //#endregion
10
+ export { createWatchedFileMatcher };
11
+ //# sourceMappingURL=watchPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchPaths.d.ts","names":[],"sources":["../../src/utils/watchPaths.ts"],"mappings":";;AAQA;;;;;iBAAgB,wBAAA,CAAyB,QAAA,YAAoB,GAAA,YAEnD,IAAA"}
@@ -0,0 +1,19 @@
1
+ import { matchesGlob, relative } from "node:path";
2
+ //#region src/utils/watchPaths.ts
3
+ /**
4
+ * Build a predicate that tells whether an absolute file path emitted by
5
+ * chokidar matches any of the given globs. Patterns are interpreted as
6
+ * project-relative; a leading `./` is stripped so user-supplied globs like
7
+ * `./locales/**` behave identically to `locales/**`.
8
+ */
9
+ function createWatchedFileMatcher(patterns, cwd) {
10
+ const normalized = patterns.map((p) => p.replace(/^\.\//, ""));
11
+ return (file) => {
12
+ const rel = relative(cwd, file).replace(/\\/g, "/");
13
+ return normalized.some((p) => matchesGlob(rel, p));
14
+ };
15
+ }
16
+ //#endregion
17
+ export { createWatchedFileMatcher };
18
+
19
+ //# sourceMappingURL=watchPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchPaths.js","names":[],"sources":["../../src/utils/watchPaths.ts"],"sourcesContent":["import { matchesGlob, relative } from 'node:path'\n\n/**\n * Build a predicate that tells whether an absolute file path emitted by\n * chokidar matches any of the given globs. Patterns are interpreted as\n * project-relative; a leading `./` is stripped so user-supplied globs like\n * `./locales/**` behave identically to `locales/**`.\n */\nexport function createWatchedFileMatcher(patterns: string[], cwd: string) {\n const normalized = patterns.map(p => p.replace(/^\\.\\//, ''))\n return (file: string) => {\n const rel = relative(cwd, file).replace(/\\\\/g, '/')\n return normalized.some(p => matchesGlob(rel, p))\n }\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,yBAAyB,UAAoB,KAAa;CACxE,MAAM,aAAa,SAAS,KAAI,MAAK,EAAE,QAAQ,SAAS,GAAG,CAAC;CAC5D,QAAQ,SAAiB;EACvB,MAAM,MAAM,SAAS,KAAK,KAAK,CAAC,QAAQ,OAAO,IAAI;EACnD,OAAO,WAAW,MAAK,MAAK,YAAY,KAAK,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "6.0.0-rc.20",
3
+ "version": "6.0.0-rc.21",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "type": "module",