@maizzle/framework 6.1.1 → 6.1.2

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.
@@ -57,7 +57,7 @@ async function buildTemplate(templatePath, ctx) {
57
57
  html: rendered.html
58
58
  });
59
59
  const doctype = rendered.doctype ?? templateConfig.doctype ?? "<!DOCTYPE html>";
60
- if (templateConfig.useTransformers !== false) html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks);
60
+ if (templateConfig.useTransformers !== false) html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks, rendered.sourceFiles);
61
61
  html = await events.fireAfterTransform({
62
62
  config: templateConfig,
63
63
  template,
@@ -1 +1 @@
1
- {"version":3,"file":"buildTemplate.js","names":["parsePath"],"sources":["../../src/render/buildTemplate.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join, sep, parse as parsePath } from 'node:path'\nimport defu from 'defu'\nimport { runTransformers } from '../transformers/index.ts'\nimport { createPlaintext } from '../plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from '../utils/output-markers.ts'\nimport { _setCurrentTemplate } from '../composables/useCurrentTemplate.ts'\nimport { cloneConfig } from '../utils/cloneConfig.ts'\nimport type { EventManager } from '../events/index.ts'\nimport type { Renderer } from './createRenderer.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport interface BuildTemplateContext {\n config: MaizzleConfig\n renderer: Renderer\n events: EventManager\n outputPath: string\n outputExtension: string\n contentBase: string\n}\n\nexport interface BuildTemplateResult {\n /** Output files written for this template (html + optional plaintext). */\n files: string[]\n /**\n * Number of SFC-registered `afterBuild` handlers seen while rendering. They\n * only fire once at end of build on the main thread, so a worker can't run\n * them — the count lets the orchestrator warn instead of silently dropping.\n */\n sfcAfterBuildCount: number\n}\n\n/**\n * Render a single template through the full pipeline and write its output.\n *\n * Shared by the sequential build loop and the parallel build worker so both\n * paths produce byte-identical output. `events` is the manager the per-template\n * events fire on (config handlers registered via `registerConfig`, SFC handlers\n * registered here from the render). The caller owns build-scoped events\n * (`beforeCreate`/`afterBuild`).\n */\nexport async function buildTemplate(\n templatePath: string,\n ctx: BuildTemplateContext,\n): Promise<BuildTemplateResult> {\n const { config, renderer, events, outputPath, outputExtension, contentBase } = ctx\n const absolutePath = resolve(templatePath)\n const parsedPath = parsePath(absolutePath)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsedPath }\n const files: string[] = []\n let sfcAfterBuildCount = 0\n\n _setCurrentTemplate(parsedPath)\n\n try {\n /**\n * Clone config per template so beforeRender mutations (setting a\n * preheader, injecting fetched data, etc.) stay scoped to this template\n * instead of leaking into later ones through the shared config object.\n */\n const renderConfig = cloneConfig(config)\n const originalSource = template.source\n\n await events.fireBeforeRender({ config: renderConfig, template })\n\n const rendered = await renderer.render(\n absolutePath,\n renderConfig,\n template.source !== originalSource ? { source: template.source } : undefined,\n )\n\n /**\n * Register SFC event handlers collected during render so they take part in\n * the post-render events. Cleared at the end of this call so they don't\n * leak into the next template (afterBuild is the exception — it's never\n * cleared by clearSfcHandlers; see the count above).\n */\n for (const { name, handler } of rendered.sfcEventHandlers) {\n if (name === 'afterBuild') sfcAfterBuildCount++\n events.on(name, handler)\n }\n\n const templateConfig = rendered.templateConfig\n\n let html = await events.fireAfterRender({ config: templateConfig, template, html: rendered.html })\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: templateConfig, template, html })\n if (doctype) html = `${doctype}\\n${html}`\n\n const htmlOut = stripForHtml(html)\n const sfcOutputPath = rendered.outputPath\n let outputFilePath: string\n\n if (sfcOutputPath) {\n const parsed = parsePath(resolve(sfcOutputPath))\n const ext = parsed.ext ? parsed.ext.slice(1) : outputExtension\n outputFilePath = join(parsed.dir, `${parsed.name}.${ext}`)\n } else {\n outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase)\n }\n\n mkdirSync(dirname(outputFilePath), { recursive: true })\n writeFileSync(outputFilePath, htmlOut)\n files.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 ptOutputPath = resolveOutputPath(templatePath, resolve(sfcPlaintext.destination), ptExtension, contentBase)\n } else if (sfcOutputPath) {\n const parsed = parsePath(outputFilePath)\n ptOutputPath = join(parsed.dir, `${parsed.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 files.push(ptOutputPath)\n }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n\n return { files, sfcAfterBuildCount }\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 * Used to strip the content base from template paths so the output preserves\n * only the subdirectory structure.\n *\n * With multiple positive patterns (multi-root setups), returns their common\n * ancestor directory so templates from every root keep a clean relative path.\n */\nexport function computeContentBase(patterns: string[]): string {\n const positives = patterns.filter(p => !p.startsWith('!'))\n const sources = positives.length > 0 ? positives : patterns\n\n const bases = sources.map((pattern) => {\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n })\n\n return bases.reduce(commonPath)\n}\n\n/** Longest common directory path shared by two absolute paths. */\nfunction commonPath(a: string, b: string): string {\n const aSegments = a.split(sep)\n const bSegments = b.split(sep)\n const shared: string[] = []\n\n for (let i = 0; i < Math.min(aSegments.length, bSegments.length); i++) {\n if (aSegments[i] !== bSegments[i]) break\n shared.push(aSegments[i])\n }\n\n return shared.join(sep) || sep\n}\n\nexport function 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"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,eAAsB,cACpB,cACA,KAC8B;CAC9B,MAAM,EAAE,QAAQ,UAAU,QAAQ,YAAY,iBAAiB,gBAAgB;CAC/E,MAAM,eAAe,QAAQ,YAAY;CACzC,MAAM,aAAaA,MAAU,YAAY;CACzC,MAAM,WAAW;EAAE,QAAQ,aAAa,cAAc,OAAO;EAAG,MAAM;CAAW;CACjF,MAAM,QAAkB,CAAC;CACzB,IAAI,qBAAqB;CAEzB,oBAAoB,UAAU;CAE9B,IAAI;;;;;;EAMF,MAAM,eAAe,YAAY,MAAM;EACvC,MAAM,iBAAiB,SAAS;EAEhC,MAAM,OAAO,iBAAiB;GAAE,QAAQ;GAAc;EAAS,CAAC;EAEhE,MAAM,WAAW,MAAM,SAAS,OAC9B,cACA,cACA,SAAS,WAAW,iBAAiB,EAAE,QAAQ,SAAS,OAAO,IAAI,KAAA,CACrE;;;;;;;EAQA,KAAK,MAAM,EAAE,MAAM,aAAa,SAAS,kBAAkB;GACzD,IAAI,SAAS,cAAc;GAC3B,OAAO,GAAG,MAAM,OAAO;EACzB;EAEA,MAAM,i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AAC;CAEtD,OAAO,KAAK,WAAW,KAAK,GAAG,KAAK,GAAG,WAAW;AACpD"}
1
+ {"version":3,"file":"buildTemplate.js","names":["parsePath"],"sources":["../../src/render/buildTemplate.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join, sep, parse as parsePath } from 'node:path'\nimport defu from 'defu'\nimport { runTransformers } from '../transformers/index.ts'\nimport { createPlaintext } from '../plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from '../utils/output-markers.ts'\nimport { _setCurrentTemplate } from '../composables/useCurrentTemplate.ts'\nimport { cloneConfig } from '../utils/cloneConfig.ts'\nimport type { EventManager } from '../events/index.ts'\nimport type { Renderer } from './createRenderer.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport interface BuildTemplateContext {\n config: MaizzleConfig\n renderer: Renderer\n events: EventManager\n outputPath: string\n outputExtension: string\n contentBase: string\n}\n\nexport interface BuildTemplateResult {\n /** Output files written for this template (html + optional plaintext). */\n files: string[]\n /**\n * Number of SFC-registered `afterBuild` handlers seen while rendering. They\n * only fire once at end of build on the main thread, so a worker can't run\n * them — the count lets the orchestrator warn instead of silently dropping.\n */\n sfcAfterBuildCount: number\n}\n\n/**\n * Render a single template through the full pipeline and write its output.\n *\n * Shared by the sequential build loop and the parallel build worker so both\n * paths produce byte-identical output. `events` is the manager the per-template\n * events fire on (config handlers registered via `registerConfig`, SFC handlers\n * registered here from the render). The caller owns build-scoped events\n * (`beforeCreate`/`afterBuild`).\n */\nexport async function buildTemplate(\n templatePath: string,\n ctx: BuildTemplateContext,\n): Promise<BuildTemplateResult> {\n const { config, renderer, events, outputPath, outputExtension, contentBase } = ctx\n const absolutePath = resolve(templatePath)\n const parsedPath = parsePath(absolutePath)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsedPath }\n const files: string[] = []\n let sfcAfterBuildCount = 0\n\n _setCurrentTemplate(parsedPath)\n\n try {\n /**\n * Clone config per template so beforeRender mutations (setting a\n * preheader, injecting fetched data, etc.) stay scoped to this template\n * instead of leaking into later ones through the shared config object.\n */\n const renderConfig = cloneConfig(config)\n const originalSource = template.source\n\n await events.fireBeforeRender({ config: renderConfig, template })\n\n const rendered = await renderer.render(\n absolutePath,\n renderConfig,\n template.source !== originalSource ? { source: template.source } : undefined,\n )\n\n /**\n * Register SFC event handlers collected during render so they take part in\n * the post-render events. Cleared at the end of this call so they don't\n * leak into the next template (afterBuild is the exception — it's never\n * cleared by clearSfcHandlers; see the count above).\n */\n for (const { name, handler } of rendered.sfcEventHandlers) {\n if (name === 'afterBuild') sfcAfterBuildCount++\n events.on(name, handler)\n }\n\n const templateConfig = rendered.templateConfig\n\n let html = await events.fireAfterRender({ config: templateConfig, template, html: rendered.html })\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, rendered.sourceFiles)\n }\n\n html = await events.fireAfterTransform({ config: templateConfig, template, html })\n if (doctype) html = `${doctype}\\n${html}`\n\n const htmlOut = stripForHtml(html)\n const sfcOutputPath = rendered.outputPath\n let outputFilePath: string\n\n if (sfcOutputPath) {\n const parsed = parsePath(resolve(sfcOutputPath))\n const ext = parsed.ext ? parsed.ext.slice(1) : outputExtension\n outputFilePath = join(parsed.dir, `${parsed.name}.${ext}`)\n } else {\n outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase)\n }\n\n mkdirSync(dirname(outputFilePath), { recursive: true })\n writeFileSync(outputFilePath, htmlOut)\n files.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 ptOutputPath = resolveOutputPath(templatePath, resolve(sfcPlaintext.destination), ptExtension, contentBase)\n } else if (sfcOutputPath) {\n const parsed = parsePath(outputFilePath)\n ptOutputPath = join(parsed.dir, `${parsed.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 files.push(ptOutputPath)\n }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n\n return { files, sfcAfterBuildCount }\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 * Used to strip the content base from template paths so the output preserves\n * only the subdirectory structure.\n *\n * With multiple positive patterns (multi-root setups), returns their common\n * ancestor directory so templates from every root keep a clean relative path.\n */\nexport function computeContentBase(patterns: string[]): string {\n const positives = patterns.filter(p => !p.startsWith('!'))\n const sources = positives.length > 0 ? positives : patterns\n\n const bases = sources.map((pattern) => {\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n })\n\n return bases.reduce(commonPath)\n}\n\n/** Longest common directory path shared by two absolute paths. */\nfunction commonPath(a: string, b: string): string {\n const aSegments = a.split(sep)\n const bSegments = b.split(sep)\n const shared: string[] = []\n\n for (let i = 0; i < Math.min(aSegments.length, bSegments.length); i++) {\n if (aSegments[i] !== bSegments[i]) break\n shared.push(aSegments[i])\n }\n\n return shared.join(sep) || sep\n}\n\nexport function 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"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,eAAsB,cACpB,cACA,KAC8B;CAC9B,MAAM,EAAE,QAAQ,UAAU,QAAQ,YAAY,iBAAiB,gBAAgB;CAC/E,MAAM,eAAe,QAAQ,YAAY;CACzC,MAAM,aAAaA,MAAU,YAAY;CACzC,MAAM,WAAW;EAAE,QAAQ,aAAa,cAAc,OAAO;EAAG,MAAM;CAAW;CACjF,MAAM,QAAkB,CAAC;CACzB,IAAI,qBAAqB;CAEzB,oBAAoB,UAAU;CAE9B,IAAI;;;;;;EAMF,MAAM,eAAe,YAAY,MAAM;EACvC,MAAM,iBAAiB,SAAS;EAEhC,MAAM,OAAO,iBAAiB;GAAE,QAAQ;GAAc;EAAS,CAAC;EAEhE,MAAM,WAAW,MAAM,SAAS,OAC9B,cACA,cACA,SAAS,WAAW,iBAAiB,EAAE,QAAQ,SAAS,OAAO,IAAI,KAAA,CACrE;;;;;;;EAQA,KAAK,MAAM,EAAE,MAAM,aAAa,SAAS,kBAAkB;GACzD,IAAI,SAAS,cAAc;GAC3B,OAAO,GAAG,MAAM,OAAO;EACzB;EAEA,MAAM,iBAAiB,SAAS;EAEhC,IAAI,OAAO,MAAM,OAAO,gBAAgB;GAAE,QAAQ;GAAgB;GAAU,MAAM,SAAS;EAAK,CAAC;EAEjG,MAAM,UAAU,SAAS,WAAW,eAAe,WAAW;EAE9D,IAAI,eAAe,oBAAoB,OACrC,OAAO,MAAM,gBAAgB,MAAM,gBAAgB,cAAc,SAAS,SAAS,gBAAgB,SAAS,WAAW;EAGzH,OAAO,MAAM,OAAO,mBAAmB;GAAE,QAAQ;GAAgB;GAAU;EAAK,CAAC;EACjF,IAAI,SAAS,OAAO,GAAG,QAAQ,IAAI;EAEnC,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mB;AACrC;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,UAA4B;CAC7D,MAAM,YAAY,SAAS,QAAO,MAAK,CAAC,EAAE,WAAW,GAAG,CAAC;CAUzD,QATgB,UAAU,SAAS,IAAI,YAAY,SAAA,CAE7B,KAAK,YAAY;EAErC,MAAM,aAAa,QAAQ,MAAM,QAAQ,CAAC,CAAC;EAE3C,OAAO,QAAQ,WAAW,SAAS,GAAG,IAAI,aAAa,QAAQ,UAAU,CAAC;CAC5E,CAEW,CAAC,CAAC,OAAO,UAAU;AAChC;;AAGA,SAAS,WAAW,GAAW,GAAmB;CAChD,MAAM,YAAY,EAAE,MAAM,GAAG;CAC7B,MAAM,YAAY,EAAE,MAAM,GAAG;CAC7B,MAAM,SAAmB,CAAC;CAE1B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IAAI,UAAU,QAAQ,UAAU,MAAM,GAAG,KAAK;EACrE,IAAI,UAAU,OAAO,UAAU,IAAI;EACnC,OAAO,KAAK,UAAU,EAAE;CAC1B;CAEA,OAAO,OAAO,KAAK,GAAG,KAAK;AAC7B;AAEA,SAAgB,kBAAkB,cAAsB,WAAmB,WAAmB,aAA6B;CACzH,MAAM,OAAO,SAAS,YAAY,CAAC,CAAC,QAAQ,eAAe,EAAE;CAC7D,MAAM,cAAc,QAAQ,YAAY;CACxC,MAAM,MAAM,SAAS,aAAa,QAAQ,WAAW,CAAC;CAEtD,OAAO,KAAK,WAAW,KAAK,GAAG,KAAK,GAAG,WAAW;AACpD"}
@@ -13,6 +13,13 @@ interface RenderedTemplate {
13
13
  plaintext?: RenderContext['plaintext'];
14
14
  outputPath?: RenderContext['outputPath'];
15
15
  tailwindBlocks?: RenderContext['tailwindBlocks'];
16
+ /**
17
+ * Absolute paths of every project file in the template's module
18
+ * import closure (the template itself, its components, imported
19
+ * modules). Undefined for virtual/pre-compiled renders where no
20
+ * file entry exists.
21
+ */
22
+ sourceFiles?: string[];
16
23
  }
17
24
  interface Renderer {
18
25
  render(input: string | Component, config: MaizzleConfig, opts?: {
@@ -1 +1 @@
1
- {"version":3,"file":"createRenderer.d.ts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":";;;;;;;UAmCiB;EACf;EACA;EACA,gBAAgB;EAChB,kBAAkB;EAClB,YAAY;EACZ,aAAa;EACb,iBAAiB;;UAGF;EACf,OAAO,gBAAgB,WAAW,QAAQ,eAAe;IAAS;IAAiB,QAAQ;MAAwB,QAAQ;EAC3H,WAAW,mBAAmB;EAC9B,iBAAiB;EACjB,SAAS;;UAGM;;EAEf;;EAEA,WAAW;;EAEX;;;;;EAKA,gBAAgB;;EAEhB,OAAO;;;;;EAKP,iBAAiB;;;;;;;;iBAsCG,eACpB,UAAS,wBACR,QAAQ"}
1
+ {"version":3,"file":"createRenderer.d.ts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":";;;;;;;UAmCiB;EACf;EACA;EACA,gBAAgB;EAChB,kBAAkB;EAClB,YAAY;EACZ,aAAa;EACb,iBAAiB;;;;;;;EAOjB;;UAGe;EACf,OAAO,gBAAgB,WAAW,QAAQ,eAAe;IAAS;IAAiB,QAAQ;MAAwB,QAAQ;EAC3H,WAAW,mBAAmB;EAC9B,iBAAiB;EACjB,SAAS;;UAGM;;EAEf;;EAEA,WAAW;;EAEX;;;;;EAKA,gBAAgB;;EAEhB,OAAO;;;;;EAKP,iBAAiB;;;;;;;;iBAsCG,eACpB,UAAS,wBACR,QAAQ"}
@@ -8,12 +8,12 @@ import { markdownExtract } from "./plugins/markdownExtract.js";
8
8
  import { componentNameFromPath } from "../utils/componentSources.js";
9
9
  import { shikiToCodeBlock } from "../components/utils.js";
10
10
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
11
- import { dirname, relative, resolve } from "node:path";
11
+ import { dirname, isAbsolute, relative, resolve } from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
  import { glob, globSync } from "tinyglobby";
14
14
  import { defu as defu$1 } from "defu";
15
15
  import { createSSRApp } from "vue";
16
- import { createServer, mergeConfig } from "vite";
16
+ import { createServer, mergeConfig, normalizePath } from "vite";
17
17
  import vue from "@vitejs/plugin-vue";
18
18
  import Markdown from "unplugin-vue-markdown/vite";
19
19
  import AutoImport from "unplugin-auto-import/vite";
@@ -351,6 +351,40 @@ async function createRenderer(options = {}) {
351
351
  */
352
352
  const finalConfig = userViteConfig ? mergeConfig(userViteConfig, maizzleConfig) : maizzleConfig;
353
353
  const server = await createServer(finalConfig);
354
+ /**
355
+ * Walk the SSR module graph from a template entry and collect every
356
+ * project file it (transitively) imports — components resolved by
357
+ * unplugin appear as real static imports, so built-ins and userland
358
+ * components are all reachable here. node_modules deps are skipped.
359
+ */
360
+ function collectSourceFiles(entryPath) {
361
+ const mods = server.moduleGraph.getModulesByFile(normalizePath(entryPath));
362
+ if (!mods || mods.size === 0) return void 0;
363
+ const builtinsDir = normalizePath(frameworkComponentsDir);
364
+ const files = /* @__PURE__ */ new Set();
365
+ const visited = /* @__PURE__ */ new Set();
366
+ const queue = [...mods];
367
+ while (queue.length) {
368
+ const m = queue.pop();
369
+ if (!m || visited.has(m)) continue;
370
+ visited.add(m);
371
+ const file = m.file ? normalizePath(m.file) : void 0;
372
+ /**
373
+ * Prune node_modules subtrees (their imports can't be project
374
+ * files), but keep the framework's own built-in components
375
+ * (in node_modules when installed from npm).
376
+ */
377
+ if (file && file.includes("/node_modules/") && !file.startsWith(`${builtinsDir}/`)) continue;
378
+ if (file && isAbsolute(file)) files.add(file);
379
+ /**
380
+ * Traversal is tracked per module node, not per file, so virtual
381
+ * modules (no file) and query variants of an already-seen file
382
+ * still contribute their imports.
383
+ */
384
+ for (const dep of [...m.ssrImportedModules ?? [], ...m.importedModules ?? []]) queue.push(dep);
385
+ }
386
+ return [...files];
387
+ }
354
388
  return {
355
389
  async render(input, config, opts) {
356
390
  let component;
@@ -463,9 +497,11 @@ async function createRenderer(options = {}) {
463
497
  const previewHtml = `<div style="display:none">${text}${" ͏ ".repeat(fillerCount)}\u00A0</div>`;
464
498
  html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`);
465
499
  }
500
+ const sourceFiles = typeof input === "string" && !input.includes("<template") && !input.includes("<script") ? collectSourceFiles(input) : void 0;
466
501
  return {
467
502
  html,
468
503
  doctype: renderContext.doctype,
504
+ sourceFiles,
469
505
  /**
470
506
  * Layer sfcConfig over config — sfcConfig is a partial override
471
507
  * emitted by composables (defineConfig, useTransformers, etc.).
@@ -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 { shikiToCodeBlock } from '../components/utils.ts'\nimport type { Component, InjectionKey } from 'vue'\nimport type { MaizzleConfig, MarkdownConfig, VueConfig } 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 outputPath?: RenderContext['outputPath']\n tailwindBlocks?: RenderContext['tailwindBlocks']\n}\n\nexport interface Renderer {\n render(input: string | Component, config: MaizzleConfig, opts?: { source?: string; props?: Record<string, any> }): 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 * Extra tags to treat as native custom elements (in addition to the\n * built-in `amp-*`), so the compiler skips component resolution for them.\n */\n customElements?: VueConfig['customElements']\n}\n\n/**\n * Build a predicate from the user's `vue.customElements` option. Accepts an\n * exact tag name, a `RegExp`, an array of either, or a predicate function.\n */\nfunction toCustomElementPredicate(\n value: VueConfig['customElements'],\n): (tag: string) => boolean {\n if (typeof value === 'function') return value\n if (value == null) return () => false\n\n const patterns = Array.isArray(value) ? value : [value]\n const exact = new Set<string>()\n const regexes: RegExp[] = []\n for (const pattern of patterns) {\n if (pattern instanceof RegExp) {\n /**\n * Strip `g`/`y` flags: `test()` on a global/sticky regex advances\n * `lastIndex`, so reusing the user's instance across tags would\n * match intermittently. Clone without them (and don't mutate the\n * user's regex) — for a tag test these flags carry no useful meaning.\n */\n regexes.push(new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, '')))\n }\n else exact.add(pattern)\n }\n\n return (tag: string) => exact.has(tag) || regexes.some(re => re.test(tag))\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, customElements } = options\n const isUserCustomElement = toCustomElementPredicate(customElements)\n const { shikiTheme = 'github-light', markdownSetup: userMarkdownSetup, ...restMarkdownConfig } = markdownOptionsRaw ?? {}\n\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 fully control naming.\n */\n const dirSources = componentDirs.filter(s => s.prefix === undefined)\n const prefixedSources = componentDirs.filter(s => s.prefix !== undefined)\n\n /**\n * Absolute component dirs — used to skip auto-wrapping `.md` files that\n * are imported as reusable components (vs. entry-point email templates).\n */\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 /**\n * Built-in framework components live at this path. When a user provides\n * a top-level file with the same (PascalCased) basename, drop the\n * built-in from unplugin's scan so the user's component is the only\n * candidate. This avoids the \"naming conflicts\" warning and the\n * alphabetical-glob ordering pitfall that decides who wins when\n * both are present in `dirs`.\n */\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 /**\n * Pre-scanned name → absolute-path map for prefixed sources. Rebuilt\n * on file add/unlink via the watcher hook plugin further down. Drives\n * the runtime resolver and the d.ts we emit for IDE autocompletion.\n */\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 /**\n * unplugin-vue-components' own d.ts only covers components found via\n * `dirs`; its `types` option emits named-import entries which break\n * for SFC `default` exports. Write a sibling d.ts for prefixed\n * sources so editors get correct autocompletion via TypeScript\n * interface merging on `vue.GlobalComponents`.\n */\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 /**\n * Per-render source overrides keyed by absolute template path. Lets the\n * build's beforeRender event rewrite a template's source before compile\n * while keeping the real file id — so relative imports, asset URLs and\n * component resolution still resolve against the actual file location\n * (which the virtual-SFC path can't do).\n */\n const sourceOverrides = new Map<string, string>()\n\n /**\n * Never load the host project's vite.config.ts here. Doing so pulls\n * every host plugin (Nitro, TanStack Start, the Maizzle plugin\n * itself, …) into this isolated SSR pipeline, where they override\n * env factories, re-trigger configureServer hooks, and break\n * Vite's hot channel wiring. Users who need extra Vite plugins\n * for SSR pass them explicitly via the `vite` option.\n */\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 {\n name: 'maizzle:source-override',\n load(id) {\n const override = sourceOverrides.get(id.split('?')[0])\n if (override !== undefined) return override\n },\n },\n vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n compilerOptions: {\n /**\n * Keep template whitespace intact — the default `condense`\n * mode collapses/strips whitespace between tags,\n * which can alter plaintext output.\n */\n whitespace: 'preserve',\n /**\n * AMP4Email tags (<amp-carousel>, <amp-img>, <amp-list> ...)\n * render verbatim — skip the component resolver. Users who\n * want to wrap an amp tag in a Vue component should register\n * it under a PascalCase name (e.g. `components/AmpCarousel.vue`\n * → `<AmpCarousel>`).\n *\n * User-defined tags (config `vue.customElements`, e.g. VML `v:*`)\n * extend this — they render verbatim for the same reason.\n */\n isCustomElement: (tag: string) => tag.startsWith('amp-') || isUserCustomElement(tag),\n },\n },\n }),\n Markdown(merge(restMarkdownConfig, {\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 /**\n * No `layout:` set — default to the built-in `MarkdownLayout`\n * for entry-template `.md` files. Skip for `.md` files inside\n * component dirs, which are reusable fragments imported into\n * other templates.\n */\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 try {\n return await codeToHtml(code, { lang, theme: shikiTheme })\n } catch {\n return ''\n }\n },\n },\n /**\n * Run the user's `markdownSetup` first (defu would otherwise drop the\n * built-in one when both are functions), then always install the\n * email-safe code-block wrapping on top — mirroring the `<Markdown>`\n * component so `.md` templates and the component behave identically.\n */\n async markdownSetup(md: MarkdownExit) {\n // `md` is cast because unplugin-vue-markdown bundles its own\n // markdown-exit copy, so its `MarkdownExit` is nominally distinct\n // from ours despite being structurally identical.\n await userMarkdownSetup?.(md as unknown as Parameters<NonNullable<typeof userMarkdownSetup>>[0])\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) =>\n Promise.resolve(defaultFence(...args)).then(shikiToCodeBlock)\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => shikiToCodeBlock(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n /**\n * unplugin-auto-import's default `include` doesn't match `.md`, so\n * auto-imports (Vue, unhead and Maizzle composables/filters) were\n * never injected into Markdown templates — `useConfig()` and friends\n * threw at runtime. Extend the default list with `.md` (and its\n * `?vue` script sub-requests) to mirror the `.md` coverage the\n * Components plugin already declares below.\n */\n include: [/\\.[jt]sx?$/, /\\.vue$/, /\\.vue\\?vue/, /\\.md$/, /\\.md\\?vue/],\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 /**\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 */\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 /**\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 plugins.)\n */\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 /**\n * Merge user's vite config (from config.vite) under Maizzle's config.\n * mergeConfig(a, b) → b overrides a for scalars, arrays concatenate.\n * This ensures Maizzle's critical settings (middlewareMode, appType,\n * etc.) always win, while user plugins and other options remain.\n */\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, opts?: { source?: string; props?: Record<string, any> }): Promise<RenderedTemplate> {\n let component: Component\n let configKey: InjectionKey<MaizzleConfig>\n let contextKey: InjectionKey<RenderContext>\n\n if (typeof input === 'string') {\n /**\n * String input goes through Vite — must use ssrLoadModule for\n * injection keys so they share the same module instance as SFC.\n */\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 /**\n * A beforeRender handler may have rewritten the source. Register it\n * under the real path id and invalidate so ssrLoadModule compiles\n * the override; clear + invalidate afterwards so the override never\n * leaks into a later render of the same path.\n */\n const hasOverride = opts?.source !== undefined\n if (hasOverride) {\n sourceOverrides.set(input, opts!.source!)\n const mod = await server.moduleGraph.getModuleByUrl(input)\n if (mod) server.moduleGraph.invalidateModule(mod)\n }\n try {\n component = (await server.ssrLoadModule(input)).default\n } finally {\n if (hasOverride) {\n sourceOverrides.delete(input)\n const mod = await server.moduleGraph.getModuleByUrl(input)\n if (mod) server.moduleGraph.invalidateModule(mod)\n }\n }\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, opts?.props)\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 /**\n * Strip Vue SSR fragment markers + teleport anchor comments. These\n * are rendering hygiene, not transformer concerns — must run\n * regardless of `useTransformers` state. Fragment markers contain\n * `-->`, which would prematurely terminate MSO conditional\n * comments downstream — including in the DOM round-trip below,\n * whose parser would otherwise close `<!--[if mso]>` at a\n * marker's `-->` and mangle the conditional on re-serialize.\n */\n const stripSsrMarkers = (str: string) => str\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n html = stripSsrMarkers(html)\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(stripSsrMarkers(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 } = renderContext.preheader\n const filler = '\\u2007\\uFEFF\\u034F '.repeat(fillerCount)\n const previewHtml = `<div style=\"display:none\">${text}${filler}\\u00A0</div>`\n html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`)\n }\n\n return {\n html,\n doctype: renderContext.doctype,\n /**\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\n * from the resolved config when the SFC only sets a single\n * key, since the composables' inject() of globalConfig can\n * return `{}` in dev when ssrLoadModule and the SFC's\n * auto-imported module resolve to different module\n * instances (different Symbols).\n */\n templateConfig: renderContext.sfcConfig ? merge(renderContext.sfcConfig, config) : config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\n outputPath: renderContext.outputPath,\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 /**\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\n * after close (tests, ephemeral build pipelines) can race the\n * mkdir against a missing parent directory. Wait one throttle\n * window past close so the lingering write resolves while\n * the dir still exists.\n */\n if (dts) {\n await new Promise(resolve => setTimeout(resolve, 600))\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,MAAM,YAAY,QAAQ,cAAc,YAAY,QAAQ,kBAAkB,CAAC,CAAC;AAChF,MAAM,0BAA0B,QAAQ,cAAc,YAAY,QAAQ,mCAAmC,CAAC,CAAC;AAC/G,MAAM,kBAAkB,QAAQ,QAAQ,cAAc,YAAY,QAAQ,aAAa,CAAC,CAAC,GAAG,IAAI;AAChG,MAAM,kBAAkB,QAAQ,cAAc,YAAY,QAAQ,yBAAyB,CAAC,CAAC;;;;;AA4C7F,SAAS,yBACP,OAC0B;CAC1B,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,IAAI,SAAS,MAAM,aAAa;CAEhC,MAAM,WAAW,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;CACtD,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,WAAW,UACpB,IAAI,mBAAmB;;;;;;;CAOrB,QAAQ,KAAK,IAAI,OAAO,QAAQ,QAAQ,QAAQ,MAAM,QAAQ,SAAS,EAAE,CAAC,CAAC;MAExE,MAAM,IAAI,OAAO;CAGxB,QAAQ,QAAgB,MAAM,IAAI,GAAG,KAAK,QAAQ,MAAK,OAAM,GAAG,KAAK,GAAG,CAAC;AAC3E;;;;;;;AAQA,eAAsB,eACpB,UAAiC,CAAC,GACf;CACnB,MAAM,EAAE,MAAM,OAAO,UAAU,oBAAoB,OAAO,QAAQ,IAAI,GAAG,gBAAgB,CAAC,GAAG,MAAM,gBAAgB,mBAAmB;CACtI,MAAM,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"file":"createRenderer.js","names":["relPath","merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, isAbsolute, 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, normalizePath, 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 { shikiToCodeBlock } from '../components/utils.ts'\nimport type { Component, InjectionKey } from 'vue'\nimport type { MaizzleConfig, MarkdownConfig, VueConfig } 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 outputPath?: RenderContext['outputPath']\n tailwindBlocks?: RenderContext['tailwindBlocks']\n /**\n * Absolute paths of every project file in the template's module\n * import closure (the template itself, its components, imported\n * modules). Undefined for virtual/pre-compiled renders where no\n * file entry exists.\n */\n sourceFiles?: string[]\n}\n\nexport interface Renderer {\n render(input: string | Component, config: MaizzleConfig, opts?: { source?: string; props?: Record<string, any> }): 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 * Extra tags to treat as native custom elements (in addition to the\n * built-in `amp-*`), so the compiler skips component resolution for them.\n */\n customElements?: VueConfig['customElements']\n}\n\n/**\n * Build a predicate from the user's `vue.customElements` option. Accepts an\n * exact tag name, a `RegExp`, an array of either, or a predicate function.\n */\nfunction toCustomElementPredicate(\n value: VueConfig['customElements'],\n): (tag: string) => boolean {\n if (typeof value === 'function') return value\n if (value == null) return () => false\n\n const patterns = Array.isArray(value) ? value : [value]\n const exact = new Set<string>()\n const regexes: RegExp[] = []\n for (const pattern of patterns) {\n if (pattern instanceof RegExp) {\n /**\n * Strip `g`/`y` flags: `test()` on a global/sticky regex advances\n * `lastIndex`, so reusing the user's instance across tags would\n * match intermittently. Clone without them (and don't mutate the\n * user's regex) — for a tag test these flags carry no useful meaning.\n */\n regexes.push(new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, '')))\n }\n else exact.add(pattern)\n }\n\n return (tag: string) => exact.has(tag) || regexes.some(re => re.test(tag))\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, customElements } = options\n const isUserCustomElement = toCustomElementPredicate(customElements)\n const { shikiTheme = 'github-light', markdownSetup: userMarkdownSetup, ...restMarkdownConfig } = markdownOptionsRaw ?? {}\n\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 fully control naming.\n */\n const dirSources = componentDirs.filter(s => s.prefix === undefined)\n const prefixedSources = componentDirs.filter(s => s.prefix !== undefined)\n\n /**\n * Absolute component dirs — used to skip auto-wrapping `.md` files that\n * are imported as reusable components (vs. entry-point email templates).\n */\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 /**\n * Built-in framework components live at this path. When a user provides\n * a top-level file with the same (PascalCased) basename, drop the\n * built-in from unplugin's scan so the user's component is the only\n * candidate. This avoids the \"naming conflicts\" warning and the\n * alphabetical-glob ordering pitfall that decides who wins when\n * both are present in `dirs`.\n */\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 /**\n * Pre-scanned name → absolute-path map for prefixed sources. Rebuilt\n * on file add/unlink via the watcher hook plugin further down. Drives\n * the runtime resolver and the d.ts we emit for IDE autocompletion.\n */\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 /**\n * unplugin-vue-components' own d.ts only covers components found via\n * `dirs`; its `types` option emits named-import entries which break\n * for SFC `default` exports. Write a sibling d.ts for prefixed\n * sources so editors get correct autocompletion via TypeScript\n * interface merging on `vue.GlobalComponents`.\n */\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 /**\n * Per-render source overrides keyed by absolute template path. Lets the\n * build's beforeRender event rewrite a template's source before compile\n * while keeping the real file id — so relative imports, asset URLs and\n * component resolution still resolve against the actual file location\n * (which the virtual-SFC path can't do).\n */\n const sourceOverrides = new Map<string, string>()\n\n /**\n * Never load the host project's vite.config.ts here. Doing so pulls\n * every host plugin (Nitro, TanStack Start, the Maizzle plugin\n * itself, …) into this isolated SSR pipeline, where they override\n * env factories, re-trigger configureServer hooks, and break\n * Vite's hot channel wiring. Users who need extra Vite plugins\n * for SSR pass them explicitly via the `vite` option.\n */\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 {\n name: 'maizzle:source-override',\n load(id) {\n const override = sourceOverrides.get(id.split('?')[0])\n if (override !== undefined) return override\n },\n },\n vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n compilerOptions: {\n /**\n * Keep template whitespace intact — the default `condense`\n * mode collapses/strips whitespace between tags,\n * which can alter plaintext output.\n */\n whitespace: 'preserve',\n /**\n * AMP4Email tags (<amp-carousel>, <amp-img>, <amp-list> ...)\n * render verbatim — skip the component resolver. Users who\n * want to wrap an amp tag in a Vue component should register\n * it under a PascalCase name (e.g. `components/AmpCarousel.vue`\n * → `<AmpCarousel>`).\n *\n * User-defined tags (config `vue.customElements`, e.g. VML `v:*`)\n * extend this — they render verbatim for the same reason.\n */\n isCustomElement: (tag: string) => tag.startsWith('amp-') || isUserCustomElement(tag),\n },\n },\n }),\n Markdown(merge(restMarkdownConfig, {\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 /**\n * No `layout:` set — default to the built-in `MarkdownLayout`\n * for entry-template `.md` files. Skip for `.md` files inside\n * component dirs, which are reusable fragments imported into\n * other templates.\n */\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 try {\n return await codeToHtml(code, { lang, theme: shikiTheme })\n } catch {\n return ''\n }\n },\n },\n /**\n * Run the user's `markdownSetup` first (defu would otherwise drop the\n * built-in one when both are functions), then always install the\n * email-safe code-block wrapping on top — mirroring the `<Markdown>`\n * component so `.md` templates and the component behave identically.\n */\n async markdownSetup(md: MarkdownExit) {\n // `md` is cast because unplugin-vue-markdown bundles its own\n // markdown-exit copy, so its `MarkdownExit` is nominally distinct\n // from ours despite being structurally identical.\n await userMarkdownSetup?.(md as unknown as Parameters<NonNullable<typeof userMarkdownSetup>>[0])\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) =>\n Promise.resolve(defaultFence(...args)).then(shikiToCodeBlock)\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => shikiToCodeBlock(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n /**\n * unplugin-auto-import's default `include` doesn't match `.md`, so\n * auto-imports (Vue, unhead and Maizzle composables/filters) were\n * never injected into Markdown templates — `useConfig()` and friends\n * threw at runtime. Extend the default list with `.md` (and its\n * `?vue` script sub-requests) to mirror the `.md` coverage the\n * Components plugin already declares below.\n */\n include: [/\\.[jt]sx?$/, /\\.vue$/, /\\.vue\\?vue/, /\\.md$/, /\\.md\\?vue/],\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 /**\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 */\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 /**\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 plugins.)\n */\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 /**\n * Merge user's vite config (from config.vite) under Maizzle's config.\n * mergeConfig(a, b) → b overrides a for scalars, arrays concatenate.\n * This ensures Maizzle's critical settings (middlewareMode, appType,\n * etc.) always win, while user plugins and other options remain.\n */\n const finalConfig = userViteConfig\n ? mergeConfig(userViteConfig, maizzleConfig)\n : maizzleConfig\n\n const server = await createServer(finalConfig)\n\n /**\n * Walk the SSR module graph from a template entry and collect every\n * project file it (transitively) imports — components resolved by\n * unplugin appear as real static imports, so built-ins and userland\n * components are all reachable here. node_modules deps are skipped.\n */\n function collectSourceFiles(entryPath: string): string[] | undefined {\n const mods = server.moduleGraph.getModulesByFile(normalizePath(entryPath))\n if (!mods || mods.size === 0) return undefined\n const builtinsDir = normalizePath(frameworkComponentsDir)\n const files = new Set<string>()\n const visited = new Set<unknown>()\n const queue = [...mods]\n while (queue.length) {\n const m = queue.pop() as any\n if (!m || visited.has(m)) continue\n visited.add(m)\n const file = m.file ? normalizePath(m.file) : undefined\n /**\n * Prune node_modules subtrees (their imports can't be project\n * files), but keep the framework's own built-in components\n * (in node_modules when installed from npm).\n */\n if (file && file.includes('/node_modules/') && !file.startsWith(`${builtinsDir}/`)) continue\n if (file && isAbsolute(file)) files.add(file)\n /**\n * Traversal is tracked per module node, not per file, so virtual\n * modules (no file) and query variants of an already-seen file\n * still contribute their imports.\n */\n for (const dep of [...(m.ssrImportedModules ?? []), ...(m.importedModules ?? [])]) queue.push(dep)\n }\n return [...files]\n }\n\n return {\n async render(input: string | Component, config: MaizzleConfig, opts?: { source?: string; props?: Record<string, any> }): Promise<RenderedTemplate> {\n let component: Component\n let configKey: InjectionKey<MaizzleConfig>\n let contextKey: InjectionKey<RenderContext>\n\n if (typeof input === 'string') {\n /**\n * String input goes through Vite — must use ssrLoadModule for\n * injection keys so they share the same module instance as SFC.\n */\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 /**\n * A beforeRender handler may have rewritten the source. Register it\n * under the real path id and invalidate so ssrLoadModule compiles\n * the override; clear + invalidate afterwards so the override never\n * leaks into a later render of the same path.\n */\n const hasOverride = opts?.source !== undefined\n if (hasOverride) {\n sourceOverrides.set(input, opts!.source!)\n const mod = await server.moduleGraph.getModuleByUrl(input)\n if (mod) server.moduleGraph.invalidateModule(mod)\n }\n try {\n component = (await server.ssrLoadModule(input)).default\n } finally {\n if (hasOverride) {\n sourceOverrides.delete(input)\n const mod = await server.moduleGraph.getModuleByUrl(input)\n if (mod) server.moduleGraph.invalidateModule(mod)\n }\n }\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, opts?.props)\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 /**\n * Strip Vue SSR fragment markers + teleport anchor comments. These\n * are rendering hygiene, not transformer concerns — must run\n * regardless of `useTransformers` state. Fragment markers contain\n * `-->`, which would prematurely terminate MSO conditional\n * comments downstream — including in the DOM round-trip below,\n * whose parser would otherwise close `<!--[if mso]>` at a\n * marker's `-->` and mangle the conditional on re-serialize.\n */\n const stripSsrMarkers = (str: string) => str\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n html = stripSsrMarkers(html)\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(stripSsrMarkers(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 } = renderContext.preheader\n const filler = '\\u2007\\uFEFF\\u034F '.repeat(fillerCount)\n const previewHtml = `<div style=\"display:none\">${text}${filler}\\u00A0</div>`\n html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`)\n }\n\n const sourceFiles = typeof input === 'string' && !input.includes('<template') && !input.includes('<script')\n ? collectSourceFiles(input)\n : undefined\n\n return {\n html,\n doctype: renderContext.doctype,\n sourceFiles,\n /**\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\n * from the resolved config when the SFC only sets a single\n * key, since the composables' inject() of globalConfig can\n * return `{}` in dev when ssrLoadModule and the SFC's\n * auto-imported module resolve to different module\n * instances (different Symbols).\n */\n templateConfig: renderContext.sfcConfig ? merge(renderContext.sfcConfig, config) : config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\n outputPath: renderContext.outputPath,\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 /**\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\n * after close (tests, ephemeral build pipelines) can race the\n * mkdir against a missing parent directory. Wait one throttle\n * window past close so the lingering write resolves while\n * the dir still exists.\n */\n if (dts) {\n await new Promise(resolve => setTimeout(resolve, 600))\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,MAAM,YAAY,QAAQ,cAAc,YAAY,QAAQ,kBAAkB,CAAC,CAAC;AAChF,MAAM,0BAA0B,QAAQ,cAAc,YAAY,QAAQ,mCAAmC,CAAC,CAAC;AAC/G,MAAM,kBAAkB,QAAQ,QAAQ,cAAc,YAAY,QAAQ,aAAa,CAAC,CAAC,GAAG,IAAI;AAChG,MAAM,kBAAkB,QAAQ,cAAc,YAAY,QAAQ,yBAAyB,CAAC,CAAC;;;;;AAmD7F,SAAS,yBACP,OAC0B;CAC1B,IAAI,OAAO,UAAU,YAAY,OAAO;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AAG;EAE3C;EAEA,MAAM,gBAA+B;GACnC,KAAK,MAAM,OAAO,OAAO,YAAY,cAAc,OAAO,GACxD,OAAO,YAAY,iBAAiB,GAAG;EAE3C;EAEA,MAAM,QAAuB;GAC3B,MAAM,OAAO,MAAM;;;;;;;;;;GAUnB,IAAI,KACF,MAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC;EAEzD;CACF;AACF"}
package/dist/serve.js CHANGED
@@ -379,7 +379,7 @@ function getRendered(absolutePath, config, renderer, events) {
379
379
  html: rendered.html
380
380
  });
381
381
  const doctype = rendered.doctype ?? templateConfig.doctype ?? "<!DOCTYPE html>";
382
- if (templateConfig.useTransformers !== false) html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks);
382
+ if (templateConfig.useTransformers !== false) html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks, rendered.sourceFiles);
383
383
  return {
384
384
  rawHtml: await events.fireAfterTransform({
385
385
  config: templateConfig,
package/dist/serve.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","names":["parsePath"],"sources":["../src/serve.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve, basename, parse as parsePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { createServer, createLogger, type ViteDevServer } from 'vite'\nimport { renderUnicodeCompact } from 'uqr'\nimport vue from '@vitejs/plugin-vue'\nimport tailwindcss from '@tailwindcss/vite'\nimport { glob } from 'tinyglobby'\nimport { createHighlighter, type Highlighter } from 'shiki'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { resolveConfig } from './config/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { cloneConfig } from './utils/cloneConfig.ts'\nimport { createRenderer, type Renderer, type RenderedTemplate } from './render/createRenderer.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport { setActiveRenderer } from './render/active.ts'\nimport { serveCompatibility } from './server/compatibility.ts'\nimport { serveLint } from './server/linter.ts'\nimport { sendEmail } from './server/email.ts'\nimport { 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)\n\nconst version = JSON.parse(\n readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf-8'),\n).version\n\nconst pkg = (name: string) => {\n const resolved = require.resolve(name).replace(/\\\\/g, '/')\n const marker = `node_modules/${name}`\n const idx = resolved.lastIndexOf(marker)\n\n return resolved.slice(0, idx + marker.length)\n}\n\n/**\n * Resolve a package's ESM entry via its `exports` map. Aliasing to the\n * package directory bypasses `exports` (it only keys off the bare name),\n * so directory resolution can fall back to a UMD/CJS bundle — which Vite 8\n * flags `needsInterop` and then default-imports, breaking ESM-only deps\n * like culori (named exports, no default). Point the alias at the real\n * ESM entry instead.\n */\nconst pkgEsmEntry = (name: string) => {\n const dir = pkg(name)\n const pj = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8'))\n const entry = pj.exports?.['.']?.import ?? pj.module ?? pj.main\n return resolve(dir, entry)\n}\n\nexport interface ServeOptions {\n config?: Partial<MaizzleConfig> | string\n /** Override the dev server port (takes precedence over config.server.port) */\n port?: number\n /** Expose the server on the network (e.g. --host) */\n host?: boolean | string\n /** When true, suppresses the startup banner/URL output. */\n silent?: boolean\n}\n\n/**\n * Start the Maizzle dev server.\n *\n * Creates two things:\n * 1. A Vite dev server for the dev UI (sidebar + preview, with Vue + Tailwind for the UI itself)\n * 2. A Renderer instance for SSR rendering email templates\n *\n * Template rendering goes through the Renderer, not the Vite dev server.\n */\nexport async function serve(options: ServeOptions = {}) {\n const start = performance.now()\n\n let config = await resolveConfig(options.config)\n const port = options.port ?? config.server?.port ?? 3000\n const host = options.host ?? config.server?.host\n\n // Create a renderer for SSR rendering email templates (with dts for dev)\n let renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n /**\n * Register so user-land render() calls reuse this renderer instead of\n * spinning up another Vite SSR server (which collides when the host\n * app is itself a Vite dev process — e.g. TanStack Start).\n */\n setActiveRenderer(renderer)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const server = await createServer({\n configFile: false,\n plugins: [\n // Vue and Tailwind are only for the dev UI SPA, not for email templates\n vue(),\n tailwindcss(),\n maizzleDevPlugin(config, renderer, events, options.config),\n ],\n resolve: {\n dedupe: ['vue'],\n alias: [\n { find: '@', replacement: devUIDir },\n { find: 'vue', replacement: resolve(pkg('vue'), 'dist/vue.runtime.esm-bundler.js') },\n // culori is ESM-only — alias to its ESM entry, not the package dir (see pkgEsmEntry)\n { find: 'culori', replacement: pkgEsmEntry('culori') },\n ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge']\n .map(name => ({ find: name, replacement: pkg(name) })),\n ],\n },\n cacheDir: resolve(devUIDir, '.vite'),\n optimizeDeps: {\n noDiscovery: true,\n include: [\n 'vue',\n 'vue-router',\n '@lucide/vue',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n ],\n },\n server: {\n // Cherry-pick Vite's `server` options (e.g. watch.ignored) from the\n // user's `vite` config; Maizzle's required keys below take precedence.\n ...config.vite?.server,\n port,\n host,\n fs: {\n ...config.vite?.server?.fs,\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori'].map(pkg), ...(config.vite?.server?.fs?.allow ?? [])],\n },\n },\n customLogger: customLogger(),\n })\n\n // Store renderer ref on server for cleanup\n const originalClose = server.close.bind(server)\n server.close = async () => {\n setActiveRenderer(null)\n await renderer.close()\n return originalClose()\n }\n\n await server.listen()\n\n const startupTime = Math.round(performance.now() - start)\n\n if (!options.silent) {\n printBanner(server, startupTime)\n }\n\n // Expose startup time so the plugin can print it later\n ; (server as any)._maizzleStartupTime = startupTime\n\n return server\n}\n\n/**\n * Internal Vite plugin that adds Maizzle middleware and file watching to the dev UI server.\n */\nfunction maizzleDevPlugin(\n config: MaizzleConfig,\n renderer: Renderer,\n events: EventManager,\n configInput: Partial<MaizzleConfig> | string | undefined,\n) {\n return {\n name: 'maizzle:dev',\n enforce: 'pre' as const,\n\n hotUpdate: {\n order: 'pre' as const,\n handler({ file }: { file: string }) {\n /**\n * Prevent Tailwind/Vue from triggering a full reload for email template\n * files. Maizzle handles these via custom HMR events in the\n * watcher below.\n */\n if (isTemplateFile(file)) {\n return []\n }\n },\n },\n\n configureServer(server: ViteDevServer) {\n // File watching\n const defaultWatchPaths = [\n 'maizzle.config.js',\n 'maizzle.config.ts',\n 'tailwind.config.js',\n 'tailwind.config.ts',\n 'locales/**',\n ]\n\n const userWatchPaths = config.server?.watch ?? []\n const watchPaths = [...defaultWatchPaths, ...userWatchPaths]\n // Match against cwd, not config.root: the watched paths (maizzle/tailwind\n // configs, locales) are project-root relative, and `watcher.add` below\n // resolves them against cwd too. Using config.root would break matching\n // when root points at a subdirectory (e.g. the Vite-plugin setup).\n const isWatchedFile = createWatchedFileMatcher(watchPaths, process.cwd())\n\n for (const watchPath of watchPaths) {\n server.watcher.add(watchPath)\n }\n\n /**\n * Serialize watcher work onto one chain. The change handler closes and\n * recreates the renderer across awaits; without serialization a second\n * event firing mid-reload closes a stale renderer and leaks the new one.\n * Errors are caught so one failed task doesn't break the chain.\n */\n let watcherChain: Promise<void> = Promise.resolve()\n const enqueue = (task: () => Promise<void>): Promise<void> => {\n watcherChain = watcherChain.then(task).catch((err) => {\n console.error('[maizzle] watcher task failed:', err)\n })\n return watcherChain\n }\n\n server.watcher.on('add', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n }))\n\n server.watcher.on('unlink', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n }))\n\n server.watcher.on('change', file => enqueue(async () => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\n\n // Re-register event handlers against the reloaded config (the config\n // object is replaced wholesale, so old handlers would be stale).\n events.clear()\n events.registerConfig(config)\n\n // Recreate the renderer so config changes (e.g. markdown.shikiTheme) take effect\n await renderer.close()\n renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n // Re-register the new renderer so user-land render() calls don't keep\n // reusing the closed one (see setActiveRenderer above).\n setActiveRenderer(renderer)\n\n /**\n * Push UI-relevant config bits so the dev UI reacts to live edits\n * without a page reload. Uses the same shape as the initial\n * inject.\n */\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n /**\n * Invalidate all renderer modules so component and config changes\n * are picked up on the next render (Tailwind recompiles with\n * fresh content).\n */\n await renderer.invalidateAll()\n bumpGeneration()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(file)\n ) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n // API middleware (before Vite's middleware)\n server.middlewares.use(async (req: any, res: any, next: any) => {\n const url = req.url || '/'\n\n if (url === '/__maizzle/templates') {\n return serveTemplateList(config, res)\n }\n\n if (url.startsWith('/__maizzle/render/')) {\n return await serveRenderedTemplate(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/compatibility/')) {\n return await serveCompatibility(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/lint/')) {\n return await serveLint(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/vue-source/')) {\n return await serveVueSource(url, config, res)\n }\n\n if (url.startsWith('/__maizzle/plaintext/')) {\n return await servePlaintext(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer, events)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\n }\n\n next()\n })\n\n // Dev UI fallback (after Vite's middleware)\n return () => {\n server.middlewares.use(async (req: any, res: any, next: any) => {\n if (isNavigationRequest(req)) {\n return await serveDevUI(server, res, req.url || '/', config)\n }\n\n next()\n })\n }\n },\n }\n}\n\nfunction isTemplateFile(file: string): boolean {\n return (file.endsWith('.vue') || file.endsWith('.md')) && !file.includes('server/ui')\n}\n\nfunction isNavigationRequest(req: any): boolean {\n const accept = req.headers?.accept || ''\n return req.method === 'GET' && accept.includes('text/html')\n}\n\n/**\n * Shape exposed to the dev UI both at initial HTML load (as\n * `window.__MAIZZLE_CONFIG__`) and on the `maizzle:config-updated` HMR event.\n * Add UI-visible config bits here; consumers on both ends pick up automatically.\n */\nfunction buildUiConfig(config: MaizzleConfig) {\n return {\n checks: config.server?.checks ?? true,\n }\n}\n\nasync function serveDevUI(server: ViteDevServer, res: any, url: string, config: MaizzleConfig) {\n let indexHtml = readFileSync(resolve(devUIDir, 'index.html'), 'utf-8')\n\n indexHtml = indexHtml.replace('./main.ts', `/@fs/${resolve(devUIDir, 'main.ts')}`)\n indexHtml = indexHtml.replace('./favicon.svg', `/@fs/${resolve(devUIDir, 'favicon.svg')}`)\n\n const configScript = `<script>window.__MAIZZLE_CONFIG__ = ${JSON.stringify(buildUiConfig(config))};</script>`\n indexHtml = indexHtml.replace('</head>', `${configScript}</head>`)\n\n const transformed = await server.transformIndexHtml(url, indexHtml)\n\n res.setHeader('Content-Type', 'text/html')\n res.end(transformed)\n}\n\nasync function serveTemplateList(config: MaizzleConfig, res: any) {\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n\n const data = templates.map(t => ({\n name: basename(t).replace(/\\.(vue|md)$/, ''),\n path: t,\n href: '/' + t.replace(/\\.(vue|md)$/, ''),\n }))\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(data))\n}\n\ninterface DedupedRender {\n /** Transformer output — before doctype prepend / stripForHtml / stripForPlaintext. */\n rawHtml: string\n doctype: string\n templateConfig: MaizzleConfig\n rendered: RenderedTemplate\n}\n\n/**\n * Render-result memo for the dev server. A single template save makes the\n * browser fire several endpoint requests in parallel (render, source, stats,\n * plaintext, email) that each need the same SSR render + transformer output.\n * Keying the in-flight Promise by `${generation}:${path}` collapses those into\n * one render and dedupes concurrent requests. The watcher bumps the generation\n * (and clears the cache) on every file/config change, so results never go\n * stale. Each endpoint applies its own tail step (doctype prepend, strip,\n * highlight, …) on top of `rawHtml`, keeping output byte-identical.\n */\nlet renderGeneration = 0\nconst renderCache = new Map<string, Promise<DedupedRender>>()\n\nfunction bumpGeneration() {\n renderGeneration++\n renderCache.clear()\n}\n\nfunction getRendered(absolutePath: string, config: MaizzleConfig, renderer: Renderer, events: EventManager): Promise<DedupedRender> {\n const key = `${renderGeneration}:${absolutePath}`\n let promise = renderCache.get(key)\n if (!promise) {\n promise = (async () => {\n _setCurrentTemplate(parsePath(absolutePath))\n try {\n /**\n * Mirror the build's per-template event pipeline (see buildTemplate)\n * so dev preview fires the same beforeRender / afterRender /\n * afterTransform hooks and matches production output. Clone config so\n * beforeRender mutations stay scoped to this render.\n */\n const renderConfig = cloneConfig(config)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsePath(absolutePath) }\n const originalSource = template.source\n\n await events.fireBeforeRender({ config: renderConfig, template })\n\n const rendered = await renderer.render(\n absolutePath,\n renderConfig,\n template.source !== originalSource ? { source: template.source } : undefined,\n )\n\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n const templateConfig = rendered.templateConfig\n let html = await events.fireAfterRender({ config: templateConfig, template, html: rendered.html })\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n }\n\n const rawHtml = await events.fireAfterTransform({ config: templateConfig, template, html })\n\n return { rawHtml, doctype, templateConfig, rendered }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n })()\n renderCache.set(key, promise)\n }\n return promise\n}\n\n/**\n * SSR render a .vue template using the Renderer (not the dev UI server).\n */\nasync function serveRenderedTemplate(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/render/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n let html = rawHtml\n if (doctype) html = `${doctype}\\n${html}`\n\n res.setHeader('Content-Type', 'text/html')\n res.end(stripForHtml(html))\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['laserwave'],\n langs: ['html', 'vue'],\n })\n }\n return highlighter\n}\n\nasync function serveHighlightedSource(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(doctype ? `${doctype}\\n${rawHtml}` : rawHtml)\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(html, {\n lang: 'html',\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function serveVueSource(url: string, config: MaizzleConfig, res: any) {\n const templateSlug = url.replace('/__maizzle/vue-source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n try {\n const source = readFileSync(resolve(match), 'utf-8')\n const lang = match.endsWith('.md') ? 'html' : 'vue'\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(source, {\n lang,\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function servePlaintext(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/plaintext/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const plaintext = createPlaintext(stripForPlaintext(rawHtml))\n\n res.setHeader('Content-Type', 'text/plain')\n res.end(plaintext)\n } catch (error: any) {\n res.statusCode = 500\n res.end(error.message)\n }\n}\n\nfunction humanFileSize(bytes: number, si = false, dp = 2) {\n const threshold = si ? 1000 : 1024\n\n if (Math.abs(bytes) < threshold) {\n return bytes + ' B'\n }\n\n const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n let u = -1\n const r = 10 ** dp\n\n do {\n bytes /= threshold\n ++u\n } while (Math.round(Math.abs(bytes) * r) / r >= threshold && u < units.length - 1)\n\n return bytes.toFixed(dp) + ' ' + units[u]\n}\n\nasync function serveStats(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/stats/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ error: 'Template not found' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(rawHtml)\n\n const sizeBytes = new TextEncoder().encode(html).length\n\n // Count images: <img> tags and CSS background images\n const imgTags = (html.match(/<img\\b[^>]*>/gi) || []).length\n const bgImages = (html.match(/url\\s*\\([^)]+\\)/gi) || []).length\n const totalImages = imgTags + bgImages\n\n // Count links\n const links = (html.match(/<a\\b[^>]*href\\s*=/gi) || []).length\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n size: {\n bytes: sizeBytes,\n formatted: humanFileSize(sizeBytes),\n },\n images: totalImages,\n links,\n }))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ error: error.message }))\n }\n}\n\nasync function serveEmailEndpoint(url: string, req: any, res: any, config: MaizzleConfig, renderer: Renderer, events: EventManager) {\n const templateSlug = url.replace('/__maizzle/email/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ success: false, message: 'Template not found' }))\n return\n }\n\n let body = ''\n for await (const chunk of req) body += chunk\n\n let payload: { to: string[]; subject: string }\n\n try {\n payload = JSON.parse(body)\n } catch {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Invalid JSON' }))\n return\n }\n\n if (!payload.to?.length) {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Missing recipients' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype, templateConfig } = await getRendered(absolutePath, config, renderer, events)\n let html = doctype ? `${doctype}\\n${rawHtml}` : rawHtml\n\n const text = createPlaintext(stripForPlaintext(html))\n html = stripForHtml(html)\n\n const result = await sendEmail(\n { to: payload.to, subject: payload.subject, html, text },\n config,\n templateConfig,\n )\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ success: false, message: error.message }))\n }\n}\n\nfunction serveEmailConfig(config: MaizzleConfig, res: any) {\n const emailConfig = config.server?.email\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n to: emailConfig?.to ? (Array.isArray(emailConfig.to) ? emailConfig.to : [emailConfig.to]) : [],\n from: emailConfig?.from ?? '',\n subject: emailConfig?.subject ?? '',\n hasTransport: !!emailConfig?.transport,\n }))\n}\n\nexport function printBanner(server: ViteDevServer, startupTime?: number) {\n const info = server.config.logger.info\n const time = startupTime ?? (server as any)._maizzleStartupTime\n\n const networkUrl = server.resolvedUrls?.network[0]\n if (networkUrl) {\n const qr = renderUnicodeCompact(networkUrl, { border: 1 })\n info('')\n info(qr.split('\\n').map(line => ` ${line}`).join('\\n'))\n }\n\n info('')\n info(` \\x1b[32m\\x1b[1mMAIZZLE\\x1b[0m\\x1b[32m v${version}\\x1b[0m \\x1b[2mready in\\x1b[0m \\x1b[1m${time}\\x1b[0m ms`)\n info('')\n server.printUrls()\n info('')\n}\n\nfunction customLogger() {\n const logger = createLogger('info')\n const warn = logger.warn\n\n logger.warn = (message, options) => {\n if (typeof message === 'string' && message.includes('<tr> cannot be child of <table>')) {\n return\n }\n\n warn(message, options)\n }\n\n return logger\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,MAAM,WAAW,QAAQ,WAAW,WAAW;AAE/C,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,MAAM,UAAU,KAAK,MACnB,aAAa,QAAQ,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,iBAAiB,GAAG,OAAO,CAC3F,CAAC,CAAC;AAEF,MAAM,OAAO,SAAiB;CAC5B,MAAM,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,QAAQ,OAAO,GAAG;CACzD,MAAM,SAAS,gBAAgB;CAC/B,MAAM,MAAM,SAAS,YAAY,MAAM;CAEvC,OAAO,SAAS,MAAM,GAAG,MAAM,OAAO,MAAM;AAC9C;;;;;;;;;AAUA,MAAM,eAAe,SAAiB;CACpC,MAAM,MAAM,IAAI,IAAI;CACpB,MAAM,KAAK,KAAK,MAAM,aAAa,QAAQ,KAAK,cAAc,GAAG,OAAO,CAAC;CACzE,MAAM,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,OAAO,OAAO,OAAO;CAClC,MAAM,OAAO,eAAgB,OAAe;CAE5C,MAAM,aAAa,OAAO,cAAc,QAAQ;CAChD,IAAI,YAAY;EACd,MAAM,KAAK,qBAAqB,YAAY,EAAE,QAAQ,EAAE,CAAC;EACzD,KAAK,EAAE;EACP,KAAK,GAAG,MAAM,IAAI,CAAC,CAAC,KAAI,SAAQ,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC;CACzD;CAEA,KAAK,EAAE;CACP,KAAK,4CAA4C,QAAQ,yCAAyC,KAAK,WAAW;CAClH,KAAK,EAAE;CACP,OAAO,UAAU;CACjB,KAAK,EAAE;AACT;AAEA,SAAS,eAAe;CACtB,MAAM,SAAS,aAAa,MAAM;CAClC,MAAM,OAAO,OAAO;CAEpB,OAAO,QAAQ,SAAS,YAAY;EAClC,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,iCAAiC,GACnF;EAGF,KAAK,SAAS,OAAO;CACvB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"serve.js","names":["parsePath"],"sources":["../src/serve.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve, basename, parse as parsePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { createServer, createLogger, type ViteDevServer } from 'vite'\nimport { renderUnicodeCompact } from 'uqr'\nimport vue from '@vitejs/plugin-vue'\nimport tailwindcss from '@tailwindcss/vite'\nimport { glob } from 'tinyglobby'\nimport { createHighlighter, type Highlighter } from 'shiki'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { resolveConfig } from './config/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { cloneConfig } from './utils/cloneConfig.ts'\nimport { createRenderer, type Renderer, type RenderedTemplate } from './render/createRenderer.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport { setActiveRenderer } from './render/active.ts'\nimport { serveCompatibility } from './server/compatibility.ts'\nimport { serveLint } from './server/linter.ts'\nimport { sendEmail } from './server/email.ts'\nimport { 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)\n\nconst version = JSON.parse(\n readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf-8'),\n).version\n\nconst pkg = (name: string) => {\n const resolved = require.resolve(name).replace(/\\\\/g, '/')\n const marker = `node_modules/${name}`\n const idx = resolved.lastIndexOf(marker)\n\n return resolved.slice(0, idx + marker.length)\n}\n\n/**\n * Resolve a package's ESM entry via its `exports` map. Aliasing to the\n * package directory bypasses `exports` (it only keys off the bare name),\n * so directory resolution can fall back to a UMD/CJS bundle — which Vite 8\n * flags `needsInterop` and then default-imports, breaking ESM-only deps\n * like culori (named exports, no default). Point the alias at the real\n * ESM entry instead.\n */\nconst pkgEsmEntry = (name: string) => {\n const dir = pkg(name)\n const pj = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8'))\n const entry = pj.exports?.['.']?.import ?? pj.module ?? pj.main\n return resolve(dir, entry)\n}\n\nexport interface ServeOptions {\n config?: Partial<MaizzleConfig> | string\n /** Override the dev server port (takes precedence over config.server.port) */\n port?: number\n /** Expose the server on the network (e.g. --host) */\n host?: boolean | string\n /** When true, suppresses the startup banner/URL output. */\n silent?: boolean\n}\n\n/**\n * Start the Maizzle dev server.\n *\n * Creates two things:\n * 1. A Vite dev server for the dev UI (sidebar + preview, with Vue + Tailwind for the UI itself)\n * 2. A Renderer instance for SSR rendering email templates\n *\n * Template rendering goes through the Renderer, not the Vite dev server.\n */\nexport async function serve(options: ServeOptions = {}) {\n const start = performance.now()\n\n let config = await resolveConfig(options.config)\n const port = options.port ?? config.server?.port ?? 3000\n const host = options.host ?? config.server?.host\n\n // Create a renderer for SSR rendering email templates (with dts for dev)\n let renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n /**\n * Register so user-land render() calls reuse this renderer instead of\n * spinning up another Vite SSR server (which collides when the host\n * app is itself a Vite dev process — e.g. TanStack Start).\n */\n setActiveRenderer(renderer)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const server = await createServer({\n configFile: false,\n plugins: [\n // Vue and Tailwind are only for the dev UI SPA, not for email templates\n vue(),\n tailwindcss(),\n maizzleDevPlugin(config, renderer, events, options.config),\n ],\n resolve: {\n dedupe: ['vue'],\n alias: [\n { find: '@', replacement: devUIDir },\n { find: 'vue', replacement: resolve(pkg('vue'), 'dist/vue.runtime.esm-bundler.js') },\n // culori is ESM-only — alias to its ESM entry, not the package dir (see pkgEsmEntry)\n { find: 'culori', replacement: pkgEsmEntry('culori') },\n ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge']\n .map(name => ({ find: name, replacement: pkg(name) })),\n ],\n },\n cacheDir: resolve(devUIDir, '.vite'),\n optimizeDeps: {\n noDiscovery: true,\n include: [\n 'vue',\n 'vue-router',\n '@lucide/vue',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n ],\n },\n server: {\n // Cherry-pick Vite's `server` options (e.g. watch.ignored) from the\n // user's `vite` config; Maizzle's required keys below take precedence.\n ...config.vite?.server,\n port,\n host,\n fs: {\n ...config.vite?.server?.fs,\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori'].map(pkg), ...(config.vite?.server?.fs?.allow ?? [])],\n },\n },\n customLogger: customLogger(),\n })\n\n // Store renderer ref on server for cleanup\n const originalClose = server.close.bind(server)\n server.close = async () => {\n setActiveRenderer(null)\n await renderer.close()\n return originalClose()\n }\n\n await server.listen()\n\n const startupTime = Math.round(performance.now() - start)\n\n if (!options.silent) {\n printBanner(server, startupTime)\n }\n\n // Expose startup time so the plugin can print it later\n ; (server as any)._maizzleStartupTime = startupTime\n\n return server\n}\n\n/**\n * Internal Vite plugin that adds Maizzle middleware and file watching to the dev UI server.\n */\nfunction maizzleDevPlugin(\n config: MaizzleConfig,\n renderer: Renderer,\n events: EventManager,\n configInput: Partial<MaizzleConfig> | string | undefined,\n) {\n return {\n name: 'maizzle:dev',\n enforce: 'pre' as const,\n\n hotUpdate: {\n order: 'pre' as const,\n handler({ file }: { file: string }) {\n /**\n * Prevent Tailwind/Vue from triggering a full reload for email template\n * files. Maizzle handles these via custom HMR events in the\n * watcher below.\n */\n if (isTemplateFile(file)) {\n return []\n }\n },\n },\n\n configureServer(server: ViteDevServer) {\n // File watching\n const defaultWatchPaths = [\n 'maizzle.config.js',\n 'maizzle.config.ts',\n 'tailwind.config.js',\n 'tailwind.config.ts',\n 'locales/**',\n ]\n\n const userWatchPaths = config.server?.watch ?? []\n const watchPaths = [...defaultWatchPaths, ...userWatchPaths]\n // Match against cwd, not config.root: the watched paths (maizzle/tailwind\n // configs, locales) are project-root relative, and `watcher.add` below\n // resolves them against cwd too. Using config.root would break matching\n // when root points at a subdirectory (e.g. the Vite-plugin setup).\n const isWatchedFile = createWatchedFileMatcher(watchPaths, process.cwd())\n\n for (const watchPath of watchPaths) {\n server.watcher.add(watchPath)\n }\n\n /**\n * Serialize watcher work onto one chain. The change handler closes and\n * recreates the renderer across awaits; without serialization a second\n * event firing mid-reload closes a stale renderer and leaks the new one.\n * Errors are caught so one failed task doesn't break the chain.\n */\n let watcherChain: Promise<void> = Promise.resolve()\n const enqueue = (task: () => Promise<void>): Promise<void> => {\n watcherChain = watcherChain.then(task).catch((err) => {\n console.error('[maizzle] watcher task failed:', err)\n })\n return watcherChain\n }\n\n server.watcher.on('add', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n }))\n\n server.watcher.on('unlink', file => enqueue(async () => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n bumpGeneration()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n }))\n\n server.watcher.on('change', file => enqueue(async () => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\n\n // Re-register event handlers against the reloaded config (the config\n // object is replaced wholesale, so old handlers would be stale).\n events.clear()\n events.registerConfig(config)\n\n // Recreate the renderer so config changes (e.g. markdown.shikiTheme) take effect\n await renderer.close()\n renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n // Re-register the new renderer so user-land render() calls don't keep\n // reusing the closed one (see setActiveRenderer above).\n setActiveRenderer(renderer)\n\n /**\n * Push UI-relevant config bits so the dev UI reacts to live edits\n * without a page reload. Uses the same shape as the initial\n * inject.\n */\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n /**\n * Invalidate all renderer modules so component and config changes\n * are picked up on the next render (Tailwind recompiles with\n * fresh content).\n */\n await renderer.invalidateAll()\n bumpGeneration()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(file)\n ) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n }))\n\n // API middleware (before Vite's middleware)\n server.middlewares.use(async (req: any, res: any, next: any) => {\n const url = req.url || '/'\n\n if (url === '/__maizzle/templates') {\n return serveTemplateList(config, res)\n }\n\n if (url.startsWith('/__maizzle/render/')) {\n return await serveRenderedTemplate(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/compatibility/')) {\n return await serveCompatibility(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/lint/')) {\n return await serveLint(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/vue-source/')) {\n return await serveVueSource(url, config, res)\n }\n\n if (url.startsWith('/__maizzle/plaintext/')) {\n return await servePlaintext(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, events, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer, events)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\n }\n\n next()\n })\n\n // Dev UI fallback (after Vite's middleware)\n return () => {\n server.middlewares.use(async (req: any, res: any, next: any) => {\n if (isNavigationRequest(req)) {\n return await serveDevUI(server, res, req.url || '/', config)\n }\n\n next()\n })\n }\n },\n }\n}\n\nfunction isTemplateFile(file: string): boolean {\n return (file.endsWith('.vue') || file.endsWith('.md')) && !file.includes('server/ui')\n}\n\nfunction isNavigationRequest(req: any): boolean {\n const accept = req.headers?.accept || ''\n return req.method === 'GET' && accept.includes('text/html')\n}\n\n/**\n * Shape exposed to the dev UI both at initial HTML load (as\n * `window.__MAIZZLE_CONFIG__`) and on the `maizzle:config-updated` HMR event.\n * Add UI-visible config bits here; consumers on both ends pick up automatically.\n */\nfunction buildUiConfig(config: MaizzleConfig) {\n return {\n checks: config.server?.checks ?? true,\n }\n}\n\nasync function serveDevUI(server: ViteDevServer, res: any, url: string, config: MaizzleConfig) {\n let indexHtml = readFileSync(resolve(devUIDir, 'index.html'), 'utf-8')\n\n indexHtml = indexHtml.replace('./main.ts', `/@fs/${resolve(devUIDir, 'main.ts')}`)\n indexHtml = indexHtml.replace('./favicon.svg', `/@fs/${resolve(devUIDir, 'favicon.svg')}`)\n\n const configScript = `<script>window.__MAIZZLE_CONFIG__ = ${JSON.stringify(buildUiConfig(config))};</script>`\n indexHtml = indexHtml.replace('</head>', `${configScript}</head>`)\n\n const transformed = await server.transformIndexHtml(url, indexHtml)\n\n res.setHeader('Content-Type', 'text/html')\n res.end(transformed)\n}\n\nasync function serveTemplateList(config: MaizzleConfig, res: any) {\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n\n const data = templates.map(t => ({\n name: basename(t).replace(/\\.(vue|md)$/, ''),\n path: t,\n href: '/' + t.replace(/\\.(vue|md)$/, ''),\n }))\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(data))\n}\n\ninterface DedupedRender {\n /** Transformer output — before doctype prepend / stripForHtml / stripForPlaintext. */\n rawHtml: string\n doctype: string\n templateConfig: MaizzleConfig\n rendered: RenderedTemplate\n}\n\n/**\n * Render-result memo for the dev server. A single template save makes the\n * browser fire several endpoint requests in parallel (render, source, stats,\n * plaintext, email) that each need the same SSR render + transformer output.\n * Keying the in-flight Promise by `${generation}:${path}` collapses those into\n * one render and dedupes concurrent requests. The watcher bumps the generation\n * (and clears the cache) on every file/config change, so results never go\n * stale. Each endpoint applies its own tail step (doctype prepend, strip,\n * highlight, …) on top of `rawHtml`, keeping output byte-identical.\n */\nlet renderGeneration = 0\nconst renderCache = new Map<string, Promise<DedupedRender>>()\n\nfunction bumpGeneration() {\n renderGeneration++\n renderCache.clear()\n}\n\nfunction getRendered(absolutePath: string, config: MaizzleConfig, renderer: Renderer, events: EventManager): Promise<DedupedRender> {\n const key = `${renderGeneration}:${absolutePath}`\n let promise = renderCache.get(key)\n if (!promise) {\n promise = (async () => {\n _setCurrentTemplate(parsePath(absolutePath))\n try {\n /**\n * Mirror the build's per-template event pipeline (see buildTemplate)\n * so dev preview fires the same beforeRender / afterRender /\n * afterTransform hooks and matches production output. Clone config so\n * beforeRender mutations stay scoped to this render.\n */\n const renderConfig = cloneConfig(config)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsePath(absolutePath) }\n const originalSource = template.source\n\n await events.fireBeforeRender({ config: renderConfig, template })\n\n const rendered = await renderer.render(\n absolutePath,\n renderConfig,\n template.source !== originalSource ? { source: template.source } : undefined,\n )\n\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n const templateConfig = rendered.templateConfig\n let html = await events.fireAfterRender({ config: templateConfig, template, html: rendered.html })\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks, rendered.sourceFiles)\n }\n\n const rawHtml = await events.fireAfterTransform({ config: templateConfig, template, html })\n\n return { rawHtml, doctype, templateConfig, rendered }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n })()\n renderCache.set(key, promise)\n }\n return promise\n}\n\n/**\n * SSR render a .vue template using the Renderer (not the dev UI server).\n */\nasync function serveRenderedTemplate(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/render/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n let html = rawHtml\n if (doctype) html = `${doctype}\\n${html}`\n\n res.setHeader('Content-Type', 'text/html')\n res.end(stripForHtml(html))\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['laserwave'],\n langs: ['html', 'vue'],\n })\n }\n return highlighter\n}\n\nasync function serveHighlightedSource(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(doctype ? `${doctype}\\n${rawHtml}` : rawHtml)\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(html, {\n lang: 'html',\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function serveVueSource(url: string, config: MaizzleConfig, res: any) {\n const templateSlug = url.replace('/__maizzle/vue-source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n try {\n const source = readFileSync(resolve(match), 'utf-8')\n const lang = match.endsWith('.md') ? 'html' : 'vue'\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(source, {\n lang,\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function servePlaintext(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/plaintext/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const plaintext = createPlaintext(stripForPlaintext(rawHtml))\n\n res.setHeader('Content-Type', 'text/plain')\n res.end(plaintext)\n } catch (error: any) {\n res.statusCode = 500\n res.end(error.message)\n }\n}\n\nfunction humanFileSize(bytes: number, si = false, dp = 2) {\n const threshold = si ? 1000 : 1024\n\n if (Math.abs(bytes) < threshold) {\n return bytes + ' B'\n }\n\n const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n let u = -1\n const r = 10 ** dp\n\n do {\n bytes /= threshold\n ++u\n } while (Math.round(Math.abs(bytes) * r) / r >= threshold && u < units.length - 1)\n\n return bytes.toFixed(dp) + ' ' + units[u]\n}\n\nasync function serveStats(url: string, config: MaizzleConfig, renderer: Renderer, events: EventManager, res: any) {\n const templateSlug = url.replace('/__maizzle/stats/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ error: 'Template not found' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml } = await getRendered(absolutePath, config, renderer, events)\n const html = stripForHtml(rawHtml)\n\n const sizeBytes = new TextEncoder().encode(html).length\n\n // Count images: <img> tags and CSS background images\n const imgTags = (html.match(/<img\\b[^>]*>/gi) || []).length\n const bgImages = (html.match(/url\\s*\\([^)]+\\)/gi) || []).length\n const totalImages = imgTags + bgImages\n\n // Count links\n const links = (html.match(/<a\\b[^>]*href\\s*=/gi) || []).length\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n size: {\n bytes: sizeBytes,\n formatted: humanFileSize(sizeBytes),\n },\n images: totalImages,\n links,\n }))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ error: error.message }))\n }\n}\n\nasync function serveEmailEndpoint(url: string, req: any, res: any, config: MaizzleConfig, renderer: Renderer, events: EventManager) {\n const templateSlug = url.replace('/__maizzle/email/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ success: false, message: 'Template not found' }))\n return\n }\n\n let body = ''\n for await (const chunk of req) body += chunk\n\n let payload: { to: string[]; subject: string }\n\n try {\n payload = JSON.parse(body)\n } catch {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Invalid JSON' }))\n return\n }\n\n if (!payload.to?.length) {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Missing recipients' }))\n return\n }\n\n const absolutePath = resolve(match)\n\n try {\n const { rawHtml, doctype, templateConfig } = await getRendered(absolutePath, config, renderer, events)\n let html = doctype ? `${doctype}\\n${rawHtml}` : rawHtml\n\n const text = createPlaintext(stripForPlaintext(html))\n html = stripForHtml(html)\n\n const result = await sendEmail(\n { to: payload.to, subject: payload.subject, html, text },\n config,\n templateConfig,\n )\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ success: false, message: error.message }))\n }\n}\n\nfunction serveEmailConfig(config: MaizzleConfig, res: any) {\n const emailConfig = config.server?.email\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n to: emailConfig?.to ? (Array.isArray(emailConfig.to) ? emailConfig.to : [emailConfig.to]) : [],\n from: emailConfig?.from ?? '',\n subject: emailConfig?.subject ?? '',\n hasTransport: !!emailConfig?.transport,\n }))\n}\n\nexport function printBanner(server: ViteDevServer, startupTime?: number) {\n const info = server.config.logger.info\n const time = startupTime ?? (server as any)._maizzleStartupTime\n\n const networkUrl = server.resolvedUrls?.network[0]\n if (networkUrl) {\n const qr = renderUnicodeCompact(networkUrl, { border: 1 })\n info('')\n info(qr.split('\\n').map(line => ` ${line}`).join('\\n'))\n }\n\n info('')\n info(` \\x1b[32m\\x1b[1mMAIZZLE\\x1b[0m\\x1b[32m v${version}\\x1b[0m \\x1b[2mready in\\x1b[0m \\x1b[1m${time}\\x1b[0m ms`)\n info('')\n server.printUrls()\n info('')\n}\n\nfunction customLogger() {\n const logger = createLogger('info')\n const warn = logger.warn\n\n logger.warn = (message, options) => {\n if (typeof message === 'string' && message.includes('<tr> cannot be child of <table>')) {\n return\n }\n\n warn(message, options)\n }\n\n return logger\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,MAAM,WAAW,QAAQ,WAAW,WAAW;AAE/C,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,MAAM,UAAU,KAAK,MACnB,aAAa,QAAQ,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,iBAAiB,GAAG,OAAO,CAC3F,CAAC,CAAC;AAEF,MAAM,OAAO,SAAiB;CAC5B,MAAM,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,QAAQ,OAAO,GAAG;CACzD,MAAM,SAAS,gBAAgB;CAC/B,MAAM,MAAM,SAAS,YAAY,MAAM;CAEvC,OAAO,SAAS,MAAM,GAAG,MAAM,OAAO,MAAM;AAC9C;;;;;;;;;AAUA,MAAM,eAAe,SAAiB;CACpC,MAAM,MAAM,IAAI,IAAI;CACpB,MAAM,KAAK,KAAK,MAAM,aAAa,QAAQ,KAAK,cAAc,GAAG,OAAO,CAAC;CACzE,MAAM,QAAQ,GAAG,UAAU,IAAI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AO,OAAO;CAClC,MAAM,OAAO,eAAgB,OAAe;CAE5C,MAAM,aAAa,OAAO,cAAc,QAAQ;CAChD,IAAI,YAAY;EACd,MAAM,KAAK,qBAAqB,YAAY,EAAE,QAAQ,EAAE,CAAC;EACzD,KAAK,EAAE;EACP,KAAK,GAAG,MAAM,IAAI,CAAC,CAAC,KAAI,SAAQ,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC;CACzD;CAEA,KAAK,EAAE;CACP,KAAK,4CAA4C,QAAQ,yCAAyC,KAAK,WAAW;CAClH,KAAK,EAAE;CACP,OAAO,UAAU;CACjB,KAAK,EAAE;AACT;AAEA,SAAS,eAAe;CACtB,MAAM,SAAS,aAAa,MAAM;CAClC,MAAM,OAAO,OAAO;CAEpB,OAAO,QAAQ,SAAS,YAAY;EAClC,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,iCAAiC,GACnF;EAGF,KAAK,SAAS,OAAO;CACvB;CAEA,OAAO;AACT"}
@@ -1,67 +1,67 @@
1
1
  {
2
- "hash": "4f8faf39",
3
- "configHash": "de0500f7",
2
+ "hash": "b0abb34b",
3
+ "configHash": "59abb408",
4
4
  "lockfileHash": "e3b0c442",
5
- "browserHash": "740a3b25",
5
+ "browserHash": "9153981c",
6
6
  "optimized": {
7
7
  "@lucide/vue": {
8
8
  "src": "../../../../../node_modules/@lucide/vue/dist/esm/lucide-vue.mjs",
9
9
  "file": "@lucide_vue.js",
10
- "fileHash": "f3cebbfd",
10
+ "fileHash": "32820ddd",
11
11
  "needsInterop": false
12
12
  },
13
13
  "@vueuse/core": {
14
14
  "src": "../../../../../node_modules/@vueuse/core/dist/index.js",
15
15
  "file": "@vueuse_core.js",
16
- "fileHash": "cd56e60a",
16
+ "fileHash": "02e18158",
17
17
  "needsInterop": false
18
18
  },
19
19
  "@vueuse/shared": {
20
20
  "src": "../../../../../node_modules/@vueuse/shared/dist/index.js",
21
21
  "file": "@vueuse_shared.js",
22
- "fileHash": "a40d441f",
22
+ "fileHash": "2a5e9744",
23
23
  "needsInterop": false
24
24
  },
25
25
  "class-variance-authority": {
26
26
  "src": "../../../../../node_modules/class-variance-authority/dist/index.mjs",
27
27
  "file": "class-variance-authority.js",
28
- "fileHash": "16877a9b",
28
+ "fileHash": "36b7dcc6",
29
29
  "needsInterop": false
30
30
  },
31
31
  "clsx": {
32
32
  "src": "../../../../../node_modules/clsx/dist/clsx.mjs",
33
33
  "file": "clsx.js",
34
- "fileHash": "9caf1bc1",
34
+ "fileHash": "559e2efa",
35
35
  "needsInterop": false
36
36
  },
37
37
  "culori": {
38
38
  "src": "../../../../../node_modules/culori/src/index.js",
39
39
  "file": "culori.js",
40
- "fileHash": "4c49a97e",
40
+ "fileHash": "d7e716eb",
41
41
  "needsInterop": false
42
42
  },
43
43
  "reka-ui": {
44
44
  "src": "../../../../../node_modules/reka-ui/dist/index.js",
45
45
  "file": "reka-ui.js",
46
- "fileHash": "f58c930b",
46
+ "fileHash": "fa6e4028",
47
47
  "needsInterop": false
48
48
  },
49
49
  "tailwind-merge": {
50
50
  "src": "../../../../../node_modules/tailwind-merge/dist/bundle-cjs.js",
51
51
  "file": "tailwind-merge.js",
52
- "fileHash": "c4b233fe",
52
+ "fileHash": "86c50c5c",
53
53
  "needsInterop": true
54
54
  },
55
55
  "vue-router": {
56
56
  "src": "../../../../../node_modules/vue-router/dist/vue-router.js",
57
57
  "file": "vue-router.js",
58
- "fileHash": "447de3dc",
58
+ "fileHash": "1de2cb0f",
59
59
  "needsInterop": false
60
60
  },
61
61
  "vue": {
62
62
  "src": "../../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
63
63
  "file": "vue.js",
64
- "fileHash": "0d7c3706",
64
+ "fileHash": "8c4f30a5",
65
65
  "needsInterop": false
66
66
  }
67
67
  },
@@ -32,7 +32,7 @@ import { TailwindBlock } from "../composables/renderContext.js";
32
32
  * 15. Prettify
33
33
  * 16. Minify
34
34
  */
35
- declare function runTransformers(html: string, config: MaizzleConfig, filePath?: string, doctype?: string, tailwindBlocks?: TailwindBlock[]): Promise<string>;
35
+ declare function runTransformers(html: string, config: MaizzleConfig, filePath?: string, doctype?: string, tailwindBlocks?: TailwindBlock[], sourceFiles?: string[]): Promise<string>;
36
36
  //#endregion
37
37
  export { runTransformers };
38
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/transformers/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyDsB,gBACpB,cACA,QAAQ,eACR,mBACA,kBACA,iBAAiB,kBAChB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/transformers/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyDsB,gBACpB,cACA,QAAQ,eACR,mBACA,kBACA,iBAAiB,iBACjB,yBACC"}
@@ -2,8 +2,8 @@ import { parse } from "../utils/ast/parser.js";
2
2
  import { serialize } from "../utils/ast/serializer.js";
3
3
  import "../utils/ast/index.js";
4
4
  import { inlineLinkDom } from "./inlineLink.js";
5
- import { tailwindComponent } from "./tailwindComponent.js";
6
5
  import { tailwindcss } from "./tailwindcss.js";
6
+ import { tailwindComponent } from "./tailwindComponent.js";
7
7
  import { safeSelectorsDom } from "./safeSelectors.js";
8
8
  import { attributeToStyleDom } from "./attributeToStyle.js";
9
9
  import { inlineCssDom } from "./inlineCss.js";
@@ -55,7 +55,7 @@ import { minify } from "./minify.js";
55
55
  * 15. Prettify
56
56
  * 16. Minify
57
57
  */
58
- async function runTransformers(html, config, filePath, doctype, tailwindBlocks) {
58
+ async function runTransformers(html, config, filePath, doctype, tailwindBlocks, sourceFiles) {
59
59
  /**
60
60
  * Per-transformer skip map — only honored when useTransformers is an object.
61
61
  * Whole-pipeline opt-out (`useTransformers === false`) is handled upstream
@@ -96,8 +96,8 @@ async function runTransformers(html, config, filePath, doctype, tailwindBlocks)
96
96
  }
97
97
  let dom = parse(html);
98
98
  dom = await inlineLinkDom(dom, filePath);
99
- if (tailwindBlocks?.length) dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath);
100
- dom = await tailwindcss(dom, effective, filePath);
99
+ if (tailwindBlocks?.length) dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath, sourceFiles);
100
+ dom = await tailwindcss(dom, effective, filePath, sourceFiles);
101
101
  if (enabled("safeSelectors")) dom = safeSelectorsDom(dom, effective.css);
102
102
  if (enabled("attributeToStyle") && typeof effective.css?.inline === "object" && effective.css.inline.attributeToStyle) dom = attributeToStyleDom(dom, effective.css.inline.attributeToStyle);
103
103
  if (enabled("inlineCss") && effective.css?.inline) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLinkDom } from './inlineLink.ts'\nimport { tailwindComponent } from './tailwindComponent.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeSelectorsDom } from './safeSelectors.ts'\nimport { attributeToStyleDom } from './attributeToStyle.ts'\nimport { inlineCssDom } from './inlineCss.ts'\nimport { msoPlaceholders } from './msoPlaceholders.ts'\nimport { columnWidth } from './columnWidth.ts'\nimport { imgWidthDom } from './imgWidth.ts'\nimport { removeAttributesDom } from './removeAttributes.ts'\nimport { shorthandCssDom } from './shorthandCss.ts'\nimport { sixHexDom } from './sixHex.ts'\nimport { addAttributesDom } from './addAttributes.ts'\nimport { filtersDom } from './filters/index.ts'\nimport { baseDom } from './base.ts'\nimport { entitiesDom } from './entities.ts'\nimport { urlQueryDom } from './urlQuery.ts'\nimport { purgeCssDom } from './purgeCss.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minifyCodeInline } from './minifyCodeInline.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Six-digit HEX\n * 8. Add attributes\n * 9. Filters\n * 10. Base URL\n * 11. URL query\n * 11.5 Entities in comment nodes (before purge — protects MSO conditionals)\n * 12. Purge CSS (serializes/parses internally around email-comb)\n * 13. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 14. Replace strings\n * 15. Prettify\n * 16. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n doctype?: string,\n tailwindBlocks?: TailwindBlock[],\n): Promise<string> {\n /**\n * Per-transformer skip map — only honored when useTransformers is an object.\n * Whole-pipeline opt-out (`useTransformers === false`) is handled upstream\n * in build.ts / render so we never reach this function in that case.\n *\n * A toggle set to `true` *force-enables* its transformer for this run\n * by layering on the matching config slice (e.g. `prettify: true`\n * sets `html.format = true`). This only applies to transformers\n * whose enable flag is a plain boolean — data-driven ones\n * (filters, baseURL, urlQuery, etc.) need actual config\n * values, so a bare `true` for those is a no-op.\n */\n const toggles = typeof config.useTransformers === 'object' ? config.useTransformers : null\n const enabled = (key: keyof NonNullable<typeof toggles>) => toggles?.[key] !== false\n\n let effective = config\n if (toggles) {\n const cssOver: Record<string, unknown> = {}\n const htmlOver: Record<string, unknown> = {}\n if (toggles.inlineCss === true) cssOver.inline = true\n if (toggles.purgeCss === true) cssOver.purge = true\n if (toggles.safeSelectors === true) cssOver.safe = true\n if (toggles.shorthandCss === true) cssOver.shorthand = true\n if (toggles.sixHex === true) cssOver.sixHex = true\n if (toggles.prettify === true) htmlOver.format = true\n if (toggles.minify === true) htmlOver.minify = true\n if (toggles.entities === true) htmlOver.decodeEntities = true\n\n if (Object.keys(cssOver).length || Object.keys(htmlOver).length) {\n effective = {\n ...config,\n css: { ...config.css, ...cssOver },\n html: { ...config.html, ...htmlOver },\n }\n }\n }\n\n // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLinkDom(dom, filePath)\n\n // 0.5. <Tailwind> component — compile per-block scoped CSS, inject into <head>\n if (tailwindBlocks?.length) {\n dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath)\n }\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, effective, filePath)\n\n // 2. Safe class names\n if (enabled('safeSelectors')) dom = safeSelectorsDom(dom, effective.css)\n\n // 3. Attribute to style\n if (enabled('attributeToStyle') && typeof effective.css?.inline === 'object' && effective.css.inline.attributeToStyle) {\n dom = attributeToStyleDom(dom, effective.css.inline.attributeToStyle)\n }\n\n // 4. CSS inliner (serializes/parses internally around juice)\n if (enabled('inlineCss') && effective.css?.inline) {\n const inlineOptions = typeof effective.css.inline === 'object' ? effective.css.inline : {}\n dom = inlineCssDom(dom, inlineOptions)\n }\n\n // 4.5. Resolve MSO placeholders (table width + td style) from inlined CSS\n dom = msoPlaceholders(dom)\n\n // 4.6. Resolve Column min-width placeholders from nearest sized ancestor\n dom = columnWidth(dom)\n\n // 4.7. Backfill width on <Img> images that inherit their parent's width\n dom = imgWidthDom(dom)\n\n // 5. Remove attributes\n if (enabled('removeAttributes')) {\n const removeRules = effective.html?.attributes?.remove\n dom = removeAttributesDom(dom, Array.isArray(removeRules) ? removeRules : [])\n }\n\n // 6. Shorthand CSS\n if (enabled('shorthandCss') && effective.css?.shorthand) {\n const shorthandOptions = typeof effective.css.shorthand === 'object' ? effective.css.shorthand : {}\n dom = shorthandCssDom(dom, shorthandOptions)\n }\n\n // 7. Six-digit HEX\n if (enabled('sixHex') && effective.css?.sixHex !== false) dom = sixHexDom(dom)\n\n // 8. Add attributes\n if (enabled('addAttributes')) dom = addAttributesDom(dom, effective.html?.attributes)\n\n // 9. Filters\n if (enabled('filters')) dom = filtersDom(dom, effective.filters)\n\n // 10. Base URL (serializes/parses internally for VML/MSO regex passes)\n if (enabled('baseURL') && effective.url?.base) dom = baseDom(dom, effective.url.base)\n\n // 11. URL query\n if (enabled('urlQuery') && effective.url?.query && Object.keys(effective.url.query).length > 0) {\n const { _options: queryOptions, ...queryParams } = effective.url.query as Record<string, unknown>\n dom = urlQueryDom(dom, queryParams, (queryOptions ?? {}) as import('../types/config.ts').UrlQueryOptions)\n }\n\n /**\n * 11.5. Encode entities in comment nodes before purge/minify. Raw\n * invisible chars (e.g. U+00A0 from Vue decoding &nbsp; at compile\n * time) inside MSO conditionals make email-comb remove the whole\n * \"whitespace-only\" conditional and html-crush collapse the chars.\n * Text nodes are skipped here — purge's internal parse round-trip\n * would decode them again — comment data survives un-decoded.\n */\n if (enabled('entities')) dom = entitiesDom(dom, effective.html?.decodeEntities, { text: false })\n\n // 12. Remove unused CSS (serializes/parses internally around email-comb)\n if (enabled('purgeCss') && effective.css?.purge) {\n const purgeOptions = typeof effective.css.purge === 'object' ? effective.css.purge : {}\n dom = purgeCssDom(dom, purgeOptions)\n }\n\n // 13. Entities\n if (enabled('entities')) dom = entitiesDom(dom, effective.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n const isXhtml = doctype ? /xhtml/i.test(doctype) : false\n let result = serialize(dom, { selfClosingTags: isXhtml })\n\n // 14. Replace strings\n if (enabled('replaceStrings')) result = replaceStrings(result, effective)\n\n // 15. Format — skipped when `minify` is enabled\n const minifyWillRun = enabled('minify') && !!effective.html?.minify\n if (enabled('prettify') && !minifyWillRun && effective.html?.format) {\n const formatOptions = typeof effective.html.format === 'object' ? effective.html.format : {}\n result = await format(result, formatOptions)\n }\n\n // 16. Minify\n if (enabled('minify') && effective.html?.minify) {\n const minifyOptions = typeof effective.html.minify === 'object' ? effective.html.minify : {}\n result = minify(result, minifyOptions)\n }\n\n /**\n * Strip self-closing slashes for HTML5 doctypes, but preserve content\n * inside MSO conditional comments (XML-ish, case/syntax sensitive).\n * MUST run BEFORE minifyCodeInline: at this point, CodeInline's\n * shiki output is still marker-encoded (§MZLT§/§MZGT§), so any\n * ` />` in the highlighted source code (e.g. a Vue self-close\n * tag) hasn't materialized yet and can't be mistakenly\n * stripped from inside a `<code>` element.\n */\n if (!isXhtml) {\n result = result.replace(\n /<!--\\[if [^\\]]*\\]>[\\s\\S]*?<!\\[endif\\]-->|( \\/>)/g,\n (match, selfClose) => selfClose ? '>' : match,\n )\n }\n\n /**\n * 16.5. Strip whitespace inside `data-minify-inline` markers (CodeInline's\n * Shiki output, etc.). Runs after format/minify so it cleans up the\n * pretty-printer's indentation between sibling tags.\n */\n result = minifyCodeInline(result)\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,eAAsB,gBACpB,MACA,QACA,UACA,SACA,gBACiB;;;;;;;;;;;;;CAajB,MAAM,UAAU,OAAO,OAAO,oBAAoB,WAAW,OAAO,kBAAkB;CACtF,MAAM,WAAW,QAA2C,UAAU,SAAS;CAE/E,IAAI,YAAY;CAChB,IAAI,SAAS;EACX,MAAM,UAAmC,CAAC;EAC1C,MAAM,WAAoC,CAAC;EAC3C,IAAI,QAAQ,cAAc,MAAM,QAAQ,SAAS;EACjD,IAAI,QAAQ,aAAa,MAAM,QAAQ,QAAQ;EAC/C,IAAI,QAAQ,kBAAkB,MAAM,QAAQ,OAAO;EACnD,IAAI,QAAQ,iBAAiB,MAAM,QAAQ,YAAY;EACvD,IAAI,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC9C,IAAI,QAAQ,aAAa,MAAM,SAAS,SAAS;EACjD,IAAI,QAAQ,WAAW,MAAM,SAAS,SAAS;EAC/C,IAAI,QAAQ,aAAa,MAA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AAQ,KAAK,UAAU,MAAM,QAAQ;EAC/C,MAAM,gBAAgB,OAAO,UAAU,KAAK,WAAW,WAAW,UAAU,KAAK,SAAS,CAAC;EAC3F,SAAS,OAAO,QAAQ,aAAa;CACvC;;;;;;;;;;CAWA,IAAI,CAAC,SACH,SAAS,OAAO,QACd,qDACC,OAAO,cAAc,YAAY,MAAM,KAC1C;;;;;;CAQF,SAAS,iBAAiB,MAAM;CAEhC,OAAO;AACT"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLinkDom } from './inlineLink.ts'\nimport { tailwindComponent } from './tailwindComponent.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeSelectorsDom } from './safeSelectors.ts'\nimport { attributeToStyleDom } from './attributeToStyle.ts'\nimport { inlineCssDom } from './inlineCss.ts'\nimport { msoPlaceholders } from './msoPlaceholders.ts'\nimport { columnWidth } from './columnWidth.ts'\nimport { imgWidthDom } from './imgWidth.ts'\nimport { removeAttributesDom } from './removeAttributes.ts'\nimport { shorthandCssDom } from './shorthandCss.ts'\nimport { sixHexDom } from './sixHex.ts'\nimport { addAttributesDom } from './addAttributes.ts'\nimport { filtersDom } from './filters/index.ts'\nimport { baseDom } from './base.ts'\nimport { entitiesDom } from './entities.ts'\nimport { urlQueryDom } from './urlQuery.ts'\nimport { purgeCssDom } from './purgeCss.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minifyCodeInline } from './minifyCodeInline.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Six-digit HEX\n * 8. Add attributes\n * 9. Filters\n * 10. Base URL\n * 11. URL query\n * 11.5 Entities in comment nodes (before purge — protects MSO conditionals)\n * 12. Purge CSS (serializes/parses internally around email-comb)\n * 13. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 14. Replace strings\n * 15. Prettify\n * 16. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n doctype?: string,\n tailwindBlocks?: TailwindBlock[],\n sourceFiles?: string[],\n): Promise<string> {\n /**\n * Per-transformer skip map — only honored when useTransformers is an object.\n * Whole-pipeline opt-out (`useTransformers === false`) is handled upstream\n * in build.ts / render so we never reach this function in that case.\n *\n * A toggle set to `true` *force-enables* its transformer for this run\n * by layering on the matching config slice (e.g. `prettify: true`\n * sets `html.format = true`). This only applies to transformers\n * whose enable flag is a plain boolean — data-driven ones\n * (filters, baseURL, urlQuery, etc.) need actual config\n * values, so a bare `true` for those is a no-op.\n */\n const toggles = typeof config.useTransformers === 'object' ? config.useTransformers : null\n const enabled = (key: keyof NonNullable<typeof toggles>) => toggles?.[key] !== false\n\n let effective = config\n if (toggles) {\n const cssOver: Record<string, unknown> = {}\n const htmlOver: Record<string, unknown> = {}\n if (toggles.inlineCss === true) cssOver.inline = true\n if (toggles.purgeCss === true) cssOver.purge = true\n if (toggles.safeSelectors === true) cssOver.safe = true\n if (toggles.shorthandCss === true) cssOver.shorthand = true\n if (toggles.sixHex === true) cssOver.sixHex = true\n if (toggles.prettify === true) htmlOver.format = true\n if (toggles.minify === true) htmlOver.minify = true\n if (toggles.entities === true) htmlOver.decodeEntities = true\n\n if (Object.keys(cssOver).length || Object.keys(htmlOver).length) {\n effective = {\n ...config,\n css: { ...config.css, ...cssOver },\n html: { ...config.html, ...htmlOver },\n }\n }\n }\n\n // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLinkDom(dom, filePath)\n\n // 0.5. <Tailwind> component — compile per-block scoped CSS, inject into <head>\n if (tailwindBlocks?.length) {\n dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath, sourceFiles)\n }\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, effective, filePath, sourceFiles)\n\n // 2. Safe class names\n if (enabled('safeSelectors')) dom = safeSelectorsDom(dom, effective.css)\n\n // 3. Attribute to style\n if (enabled('attributeToStyle') && typeof effective.css?.inline === 'object' && effective.css.inline.attributeToStyle) {\n dom = attributeToStyleDom(dom, effective.css.inline.attributeToStyle)\n }\n\n // 4. CSS inliner (serializes/parses internally around juice)\n if (enabled('inlineCss') && effective.css?.inline) {\n const inlineOptions = typeof effective.css.inline === 'object' ? effective.css.inline : {}\n dom = inlineCssDom(dom, inlineOptions)\n }\n\n // 4.5. Resolve MSO placeholders (table width + td style) from inlined CSS\n dom = msoPlaceholders(dom)\n\n // 4.6. Resolve Column min-width placeholders from nearest sized ancestor\n dom = columnWidth(dom)\n\n // 4.7. Backfill width on <Img> images that inherit their parent's width\n dom = imgWidthDom(dom)\n\n // 5. Remove attributes\n if (enabled('removeAttributes')) {\n const removeRules = effective.html?.attributes?.remove\n dom = removeAttributesDom(dom, Array.isArray(removeRules) ? removeRules : [])\n }\n\n // 6. Shorthand CSS\n if (enabled('shorthandCss') && effective.css?.shorthand) {\n const shorthandOptions = typeof effective.css.shorthand === 'object' ? effective.css.shorthand : {}\n dom = shorthandCssDom(dom, shorthandOptions)\n }\n\n // 7. Six-digit HEX\n if (enabled('sixHex') && effective.css?.sixHex !== false) dom = sixHexDom(dom)\n\n // 8. Add attributes\n if (enabled('addAttributes')) dom = addAttributesDom(dom, effective.html?.attributes)\n\n // 9. Filters\n if (enabled('filters')) dom = filtersDom(dom, effective.filters)\n\n // 10. Base URL (serializes/parses internally for VML/MSO regex passes)\n if (enabled('baseURL') && effective.url?.base) dom = baseDom(dom, effective.url.base)\n\n // 11. URL query\n if (enabled('urlQuery') && effective.url?.query && Object.keys(effective.url.query).length > 0) {\n const { _options: queryOptions, ...queryParams } = effective.url.query as Record<string, unknown>\n dom = urlQueryDom(dom, queryParams, (queryOptions ?? {}) as import('../types/config.ts').UrlQueryOptions)\n }\n\n /**\n * 11.5. Encode entities in comment nodes before purge/minify. Raw\n * invisible chars (e.g. U+00A0 from Vue decoding &nbsp; at compile\n * time) inside MSO conditionals make email-comb remove the whole\n * \"whitespace-only\" conditional and html-crush collapse the chars.\n * Text nodes are skipped here — purge's internal parse round-trip\n * would decode them again — comment data survives un-decoded.\n */\n if (enabled('entities')) dom = entitiesDom(dom, effective.html?.decodeEntities, { text: false })\n\n // 12. Remove unused CSS (serializes/parses internally around email-comb)\n if (enabled('purgeCss') && effective.css?.purge) {\n const purgeOptions = typeof effective.css.purge === 'object' ? effective.css.purge : {}\n dom = purgeCssDom(dom, purgeOptions)\n }\n\n // 13. Entities\n if (enabled('entities')) dom = entitiesDom(dom, effective.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n const isXhtml = doctype ? /xhtml/i.test(doctype) : false\n let result = serialize(dom, { selfClosingTags: isXhtml })\n\n // 14. Replace strings\n if (enabled('replaceStrings')) result = replaceStrings(result, effective)\n\n // 15. Format — skipped when `minify` is enabled\n const minifyWillRun = enabled('minify') && !!effective.html?.minify\n if (enabled('prettify') && !minifyWillRun && effective.html?.format) {\n const formatOptions = typeof effective.html.format === 'object' ? effective.html.format : {}\n result = await format(result, formatOptions)\n }\n\n // 16. Minify\n if (enabled('minify') && effective.html?.minify) {\n const minifyOptions = typeof effective.html.minify === 'object' ? effective.html.minify : {}\n result = minify(result, minifyOptions)\n }\n\n /**\n * Strip self-closing slashes for HTML5 doctypes, but preserve content\n * inside MSO conditional comments (XML-ish, case/syntax sensitive).\n * MUST run BEFORE minifyCodeInline: at this point, CodeInline's\n * shiki output is still marker-encoded (§MZLT§/§MZGT§), so any\n * ` />` in the highlighted source code (e.g. a Vue self-close\n * tag) hasn't materialized yet and can't be mistakenly\n * stripped from inside a `<code>` element.\n */\n if (!isXhtml) {\n result = result.replace(\n /<!--\\[if [^\\]]*\\]>[\\s\\S]*?<!\\[endif\\]-->|( \\/>)/g,\n (match, selfClose) => selfClose ? '>' : match,\n )\n }\n\n /**\n * 16.5. Strip whitespace inside `data-minify-inline` markers (CodeInline's\n * Shiki output, etc.). Runs after format/minify so it cleans up the\n * pretty-printer's indentation between sibling tags.\n */\n result = minifyCodeInline(result)\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,eAAsB,gBACpB,MACA,QACA,UACA,SACA,gBACA,aACiB;;;;;;;;;;;;;CAajB,MAAM,UAAU,OAAO,OAAO,oBAAoB,WAAW,OAAO,kBAAkB;CACtF,MAAM,WAAW,QAA2C,UAAU,SAAS;CAE/E,IAAI,YAAY;CAChB,IAAI,SAAS;EACX,MAAM,UAAmC,CAAC;EAC1C,MAAM,WAAoC,CAAC;EAC3C,IAAI,QAAQ,cAAc,MAAM,QAAQ,SAAS;EACjD,IAAI,QAAQ,aAAa,MAAM,QAAQ,QAAQ;EAC/C,IAAI,QAAQ,kBAAkB,MAAM,QAAQ,OAAO;EACnD,IAAI,QAAQ,iBAAiB,MAAM,QAAQ,YAAY;EACvD,IAAI,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC9C,IAAI,QAAQ,aAAa,MAAM,SAAS,SAAS;EACjD,IAAI,QAAQ,WAAW,MAAM,SAAS,SAAS;EAC/C,IAAI,QAAQ,aAAa,MAAM,SAAS,iBAAiB;EAEzD,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,UAAU,OAAO,KAAK,QAAQ,CAAC,C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UAAU,KAAK,SAAS,CAAC;EAC3F,SAAS,OAAO,QAAQ,aAAa;CACvC;;;;;;;;;;CAWA,IAAI,CAAC,SACH,SAAS,OAAO,QACd,qDACC,OAAO,cAAc,YAAY,MAAM,KAC1C;;;;;;CAQF,SAAS,iBAAiB,MAAM;CAEhC,OAAO;AACT"}
@@ -9,7 +9,7 @@ import { ChildNode } from "domhandler";
9
9
  * One <style> per outermost block is appended to <head>; marker comments
10
10
  * are stripped after.
11
11
  */
12
- declare function tailwindComponent(dom: ChildNode[], blocks: TailwindBlock[], config: MaizzleConfig, filePath?: string): Promise<ChildNode[]>;
12
+ declare function tailwindComponent(dom: ChildNode[], blocks: TailwindBlock[], config: MaizzleConfig, filePath?: string, sourceFiles?: string[]): Promise<ChildNode[]>;
13
13
  //#endregion
14
14
  export { tailwindComponent };
15
15
  //# sourceMappingURL=tailwindComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tailwindComponent.d.ts","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"mappings":";;;;;;;;;;;iBA0BsB,kBACpB,KAAK,aACL,QAAQ,iBACR,QAAQ,eACR,oBACC,QAAQ"}
1
+ {"version":3,"file":"tailwindComponent.d.ts","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"mappings":";;;;;;;;;;;iBA2BsB,kBACpB,KAAK,aACL,QAAQ,iBACR,QAAQ,eACR,mBACA,yBACC,QAAQ"}
@@ -1,7 +1,8 @@
1
1
  import { walk } from "../utils/ast/walker.js";
2
2
  import "../utils/ast/index.js";
3
3
  import { compileTailwindCss } from "../utils/compileTailwindCss.js";
4
- import { resolve } from "pathe";
4
+ import { rewriteImportsSourceNone } from "./tailwindcss.js";
5
+ import { dirname, relative, resolve } from "pathe";
5
6
  //#region src/transformers/tailwindComponent.ts
6
7
  const DEFAULT_SEED = "@import \"@maizzle/tailwindcss\" source(none);";
7
8
  const OPEN_RE = /^mz-tw:(\S+)$/;
@@ -13,7 +14,7 @@ const CLOSE_RE = /^\/mz-tw:(\S+)$/;
13
14
  * One <style> per outermost block is appended to <head>; marker comments
14
15
  * are stripped after.
15
16
  */
16
- async function tailwindComponent(dom, blocks, config, filePath) {
17
+ async function tailwindComponent(dom, blocks, config, filePath, sourceFiles) {
17
18
  if (!blocks.length) return dom;
18
19
  const map = /* @__PURE__ */ new Map();
19
20
  for (const b of blocks) map.set(b.id, {
@@ -60,9 +61,13 @@ async function tailwindComponent(dom, blocks, config, filePath) {
60
61
  * the existing tailwindcss transformer out of recompiling
61
62
  * already-compiled CSS.
62
63
  */
64
+ const scoped = config.css?.scopedSources !== false && !!sourceFiles?.length;
63
65
  for (const meta of map.values()) {
64
66
  if (meta.nested) continue;
65
- const cssInput = buildCssInput(meta.configCss, meta.classes);
67
+ const cssInput = buildCssInput(meta.configCss, meta.classes, scoped ? {
68
+ sourceFiles,
69
+ fromDir: dirname(fromPath)
70
+ } : void 0);
66
71
  const css = (await compileTailwindCss(cssInput, config, `${fromPath}?tw=${meta.id}`)).trim();
67
72
  if (!css) continue;
68
73
  const styleNode = {
@@ -91,10 +96,23 @@ async function tailwindComponent(dom, blocks, config, filePath) {
91
96
  }
92
97
  return dom;
93
98
  }
94
- function buildCssInput(configCss, classes) {
95
- const seed = configCss ?? DEFAULT_SEED;
96
- if (!classes.size) return seed;
97
- return `${seed}\n@source inline("${[...classes].join(" ").replace(/"/g, "\\\"")}");`;
99
+ function buildCssInput(configCss, classes, scope) {
100
+ let seed = configCss ?? DEFAULT_SEED;
101
+ const parts = [];
102
+ /**
103
+ * Scoped mode: disable auto source detection in the user's config
104
+ * CSS and point the scanner at the template's import closure
105
+ * instead, mirroring the main tailwindcss transformer.
106
+ */
107
+ if (scope) {
108
+ seed = rewriteImportsSourceNone(seed);
109
+ for (const file of scope.sourceFiles) parts.push(`@source "${relative(scope.fromDir, file)}";`);
110
+ }
111
+ if (classes.size) {
112
+ const inline = [...classes].join(" ").replace(/"/g, "\\\"");
113
+ parts.push(`@source inline("${inline}");`);
114
+ }
115
+ return parts.length ? `${seed}\n${parts.join("\n")}` : seed;
98
116
  }
99
117
  //#endregion
100
118
  export { tailwindComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"tailwindComponent.js","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"sourcesContent":["import { resolve } from 'pathe'\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 /**\n * Always assign to the OUTERMOST active marker (stack[0]) so nested\n * <Tailwind> blocks merge their classes into the parent's scope.\n */\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 /**\n * Compile + inject one <style raw> per outermost block. `raw` opts\n * the existing tailwindcss transformer out of recompiling\n * already-compiled CSS.\n */\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,IAAuB;CACvC,KAAK,MAAM,KAAK,QACd,IAAI,IAAI,EAAE,IAAI;EAAE,IAAI,EAAE;EAAI,WAAW,EAAE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N,MAAM;GACN,SAAS,EAAE,KAAK,GAAG;GACnB,UAAU,CAAC;GACX,QAAQ;GACR,MAAM;GACN,MAAM;EACR;EAUA,UAAU,WAAW,CAAC;GAPpB,MAAM;GACN,MAAM;GACN,QAAQ;GACR,MAAM;GACN,MAAM;EAGqB,CAAC;EAC9B,KAAK,SAAS,KAAK,SAAS;CAC9B;CAGA,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,SAAS,EAAE;EACjB,IAAI,CAAC,QAAQ,UAAU;EACvB,MAAM,IAAI,OAAO,SAAS,QAAQ,CAAC;EACnC,IAAI,KAAK,GAAG,OAAO,SAAS,OAAO,GAAG,CAAC;CACzC;CAEA,OAAO;AACT;AAEA,SAAS,cAAc,WAA+B,SAA8B;CAClF,MAAM,OAAO,aAAa;CAE1B,IAAI,CAAC,QAAQ,MAAM,OAAO;CAG1B,OAAO,GAAG,KAAK,oBADA,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,QAAQ,MAAM,MACZ,EAAE;AAC5C"}
1
+ {"version":3,"file":"tailwindComponent.js","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"sourcesContent":["import { resolve, relative, dirname } from 'pathe'\nimport type { ChildNode, Element, Comment } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport { rewriteImportsSourceNone } from './tailwindcss.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 sourceFiles?: 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 /**\n * Always assign to the OUTERMOST active marker (stack[0]) so nested\n * <Tailwind> blocks merge their classes into the parent's scope.\n */\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 /**\n * Compile + inject one <style raw> per outermost block. `raw` opts\n * the existing tailwindcss transformer out of recompiling\n * already-compiled CSS.\n */\n const scoped = config.css?.scopedSources !== false && !!sourceFiles?.length\n\n for (const meta of map.values()) {\n if (meta.nested) continue\n\n const cssInput = buildCssInput(meta.configCss, meta.classes, scoped ? { sourceFiles: sourceFiles!, fromDir: dirname(fromPath) } : undefined)\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(\n configCss: string | undefined,\n classes: Set<string>,\n scope?: { sourceFiles: string[]; fromDir: string },\n): string {\n let seed = configCss ?? DEFAULT_SEED\n\n const parts: string[] = []\n\n /**\n * Scoped mode: disable auto source detection in the user's config\n * CSS and point the scanner at the template's import closure\n * instead, mirroring the main tailwindcss transformer.\n */\n if (scope) {\n seed = rewriteImportsSourceNone(seed)\n for (const file of scope.sourceFiles) {\n parts.push(`@source \"${relative(scope.fromDir, file)}\";`)\n }\n }\n\n if (classes.size) {\n const inline = [...classes].join(' ').replace(/\"/g, '\\\\\"')\n parts.push(`@source inline(\"${inline}\");`)\n }\n\n return parts.length ? `${seed}\\n${parts.join('\\n')}` : seed\n}\n"],"mappings":";;;;;;AAQA,MAAM,eAAe;AASrB,MAAM,UAAU;AAChB,MAAM,WAAW;;;;;;;;AASjB,eAAsB,kBACpB,KACA,QACA,QACA,UACA,aACsB;CACtB,IAAI,CAAC,OAAO,QAAQ,OAAO;CAE3B,MAAM,sBAAM,IAAI,IAAuB;CACvC,KAAK,MAAM,KAAK,QACd,IAAI,IAAI,EAAE,IAAI;EAAE,IAAI,EAAE;EAAI,WAAW,EAAE;EAAK,QAAQ;EAAO,yBAAS,IAAI,IAAI;CAAE,CAAC;CAGjF,MAAM,QAAkB,CAAC;CACzB,MAAM,UAAqB,CAAC;CAE5B,KAAK,MAAM,SAAS;EAClB,IAAI,KAAK,SAAS,WAAW;GAC3B,MAAM,OAAQ,KAAiB;GAC/B,MAAM,OAAO,KAAK,MAAM,OAAO;GAC/B,MAAM,QAAQ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GAPpB,MAAM;GACN,MAAM;GACN,QAAQ;GACR,MAAM;GACN,MAAM;EAGqB,CAAC;EAC9B,KAAK,SAAS,KAAK,SAAS;CAC9B;CAGA,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,SAAS,EAAE;EACjB,IAAI,CAAC,QAAQ,UAAU;EACvB,MAAM,IAAI,OAAO,SAAS,QAAQ,CAAC;EACnC,IAAI,KAAK,GAAG,OAAO,SAAS,OAAO,GAAG,CAAC;CACzC;CAEA,OAAO;AACT;AAEA,SAAS,cACP,WACA,SACA,OACQ;CACR,IAAI,OAAO,aAAa;CAExB,MAAM,QAAkB,CAAC;;;;;;CAOzB,IAAI,OAAO;EACT,OAAO,yBAAyB,IAAI;EACpC,KAAK,MAAM,QAAQ,MAAM,aACvB,MAAM,KAAK,YAAY,SAAS,MAAM,SAAS,IAAI,EAAE,GAAG;CAE5D;CAEA,IAAI,QAAQ,MAAM;EAChB,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,QAAQ,MAAM,MAAK;EACzD,MAAM,KAAK,mBAAmB,OAAO,IAAI;CAC3C;CAEA,OAAO,MAAM,SAAS,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM;AACzD"}
@@ -1,6 +1,12 @@
1
1
  import { MaizzleConfig } from "../types/config.js";
2
2
  import { ChildNode } from "domhandler";
3
3
  //#region src/transformers/tailwindcss.d.ts
4
+ /**
5
+ * Append ` source(none)` to Tailwind imports so auto source detection
6
+ * is off and only our explicit `@source` directives apply. Skips
7
+ * imports that already carry a `source(...)` modifier.
8
+ */
9
+ declare function rewriteImportsSourceNone(css: string): string;
4
10
  /**
5
11
  * Tailwind CSS transformer.
6
12
  *
@@ -9,7 +15,8 @@ import { ChildNode } from "domhandler";
9
15
  *
10
16
  * Configures Tailwind sources to scan:
11
17
  * - Rendered class attributes (via `@source inline`) for all classes from all components
12
- * - User project files (via Tailwind's auto-detection from base/from path)
18
+ * - The template's module import closure (via `@source` directives), or user
19
+ * project files (via Tailwind's auto-detection) when `css.scopedSources` is off
13
20
  *
14
21
  * User `@source` and `@source not directives` in style tags are preserved.
15
22
  * Source directives are only added to style tags that import Tailwind.
@@ -17,7 +24,7 @@ import { ChildNode } from "domhandler";
17
24
  * Runs as the first transformer in the pipeline so that subsequent
18
25
  * transformers (inliner, purge, etc.) work with fully compiled CSS.
19
26
  */
20
- declare function tailwindcss(dom: ChildNode[], config: MaizzleConfig, filePath?: string): Promise<ChildNode[]>;
27
+ declare function tailwindcss(dom: ChildNode[], config: MaizzleConfig, filePath?: string, sourceFiles?: string[]): Promise<ChildNode[]>;
21
28
  //#endregion
22
- export { tailwindcss };
29
+ export { rewriteImportsSourceNone, tailwindcss };
23
30
  //# sourceMappingURL=tailwindcss.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tailwindcss.d.ts","names":[],"sources":["../../src/transformers/tailwindcss.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBA4JsB,YAAY,KAAK,aAAa,QAAQ,eAAe,oBAAoB,QAAQ"}
1
+ {"version":3,"file":"tailwindcss.d.ts","names":[],"sources":["../../src/transformers/tailwindcss.ts"],"mappings":";;;;;;;;iBAgKgB,yBAAyB;;;;;;;;;;;;;;;;;;iBAwBnB,YAAY,KAAK,aAAa,QAAQ,eAAe,mBAAmB,yBAAyB,QAAQ"}
@@ -1,7 +1,7 @@
1
1
  import { walk } from "../utils/ast/walker.js";
2
2
  import "../utils/ast/index.js";
3
- import { compileTailwindCss } from "../utils/compileTailwindCss.js";
4
3
  import { decodeStyleEntities } from "../utils/decodeStyleEntities.js";
4
+ import { compileTailwindCss } from "../utils/compileTailwindCss.js";
5
5
  import { dirname, relative, resolve } from "pathe";
6
6
  //#region src/transformers/tailwindcss.ts
7
7
  /**
@@ -24,10 +24,21 @@ function usesTailwind(css) {
24
24
  * expressions, and the template itself — Tailwind's scanner handles
25
25
  * the actual class extraction from these raw values
26
26
  */
27
- function buildSourceDirectives(dom, config, fromDir) {
27
+ function buildSourceDirectives(dom, config, fromDir, sourceFiles) {
28
28
  const directives = [];
29
- const excludePaths = [resolve(config.output?.path ?? "dist"), ...(config.css?.exclude ?? []).map((p) => resolve(p))];
30
- for (const p of excludePaths) directives.push(`@source not "${relative(fromDir, resolve(p))}";`);
29
+ if (config.css?.scopedSources !== false && !!sourceFiles?.length)
30
+ /**
31
+ * Scoped mode: point Tailwind's scanner at exactly the files in
32
+ * this template's import closure instead of auto-detecting from
33
+ * the project root. Auto-detection is disabled by appending
34
+ * `source(none)` to the Tailwind import (see
35
+ * rewriteImportsSourceNone below).
36
+ */
37
+ for (const file of sourceFiles) directives.push(`@source "${relative(fromDir, file)}";`);
38
+ else {
39
+ const excludePaths = [resolve(config.output?.path ?? "dist"), ...(config.css?.exclude ?? []).map((p) => resolve(p))];
40
+ for (const p of excludePaths) directives.push(`@source not "${relative(fromDir, resolve(p))}";`);
41
+ }
31
42
  /**
32
43
  * Inline source: collect all class attribute values from the rendered DOM.
33
44
  * After Vue SSR, the DOM contains every class from every component
@@ -104,6 +115,14 @@ function collectGradientCombos(dom) {
104
115
  return [...bySignature.values()];
105
116
  }
106
117
  /**
118
+ * Append ` source(none)` to Tailwind imports so auto source detection
119
+ * is off and only our explicit `@source` directives apply. Skips
120
+ * imports that already carry a `source(...)` modifier.
121
+ */
122
+ function rewriteImportsSourceNone(css) {
123
+ return css.replace(/(@import\s+["'](?:@maizzle\/)?tailwindcss(?:\/[^"']*)?["'][^;]*);/g, (match, stmt) => stmt.includes("source(") ? match : `${stmt} source(none);`);
124
+ }
125
+ /**
107
126
  * Tailwind CSS transformer.
108
127
  *
109
128
  * Compiles CSS inside <style> tags in the DOM using
@@ -111,7 +130,8 @@ function collectGradientCombos(dom) {
111
130
  *
112
131
  * Configures Tailwind sources to scan:
113
132
  * - Rendered class attributes (via `@source inline`) for all classes from all components
114
- * - User project files (via Tailwind's auto-detection from base/from path)
133
+ * - The template's module import closure (via `@source` directives), or user
134
+ * project files (via Tailwind's auto-detection) when `css.scopedSources` is off
115
135
  *
116
136
  * User `@source` and `@source not directives` in style tags are preserved.
117
137
  * Source directives are only added to style tags that import Tailwind.
@@ -119,7 +139,7 @@ function collectGradientCombos(dom) {
119
139
  * Runs as the first transformer in the pipeline so that subsequent
120
140
  * transformers (inliner, purge, etc.) work with fully compiled CSS.
121
141
  */
122
- async function tailwindcss(dom, config, filePath) {
142
+ async function tailwindcss(dom, config, filePath, sourceFiles) {
123
143
  const styleTags = [];
124
144
  walk(dom, (node) => {
125
145
  if (node.name !== "style") return;
@@ -145,7 +165,8 @@ async function tailwindcss(dom, config, filePath) {
145
165
  const fromPath = filePath ?? resolve(process.cwd(), "template.vue");
146
166
  const fromDir = dirname(fromPath);
147
167
  const hasTailwindStyles = styleTags.some(({ cssContent }) => usesTailwind(cssContent));
148
- const sourceDirectives = hasTailwindStyles ? buildSourceDirectives(dom, config, fromDir) : "";
168
+ const sourceDirectives = hasTailwindStyles ? buildSourceDirectives(dom, config, fromDir, sourceFiles) : "";
169
+ const scoped = config.css?.scopedSources !== false && !!sourceFiles?.length;
149
170
  /**
150
171
  * Collect gradient combos and rewrite elements to single classes.
151
172
  * Runs after source directives are built (so the utility classes are
@@ -156,12 +177,7 @@ async function tailwindcss(dom, config, filePath) {
156
177
  const firstTailwindStyle = styleTags.findIndex(({ cssContent }) => usesTailwind(cssContent));
157
178
  for (let i = 0; i < styleTags.length; i++) {
158
179
  const { node, cssContent } = styleTags[i];
159
- /**
160
- * Only add source directives to style tags that import Tailwind —
161
- * plain CSS doesn't need them and @tailwindcss/postcss would
162
- * leave the directives unconsumed in the output.
163
- */
164
- const fullCss = usesTailwind(cssContent) ? `${cssContent}\n${sourceDirectives}` : cssContent;
180
+ const fullCss = usesTailwind(cssContent) ? `${scoped ? rewriteImportsSourceNone(cssContent) : cssContent}\n${sourceDirectives}` : cssContent;
165
181
  const combos = i === firstTailwindStyle ? gradientCombos : [];
166
182
  try {
167
183
  node.children = [{
@@ -184,6 +200,6 @@ async function tailwindcss(dom, config, filePath) {
184
200
  return dom;
185
201
  }
186
202
  //#endregion
187
- export { tailwindcss };
203
+ export { rewriteImportsSourceNone, tailwindcss };
188
204
 
189
205
  //# sourceMappingURL=tailwindcss.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tailwindcss.js","names":[],"sources":["../../src/transformers/tailwindcss.ts"],"sourcesContent":["import { resolve, dirname, relative } from 'pathe'\nimport type { ChildNode, Element } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport { decodeStyleEntities } from '../utils/decodeStyleEntities.ts'\nimport { compileTailwindCss } from '../utils/compileTailwindCss.ts'\nimport type { GradientCombo } from '../plugins/postcss/flattenGradients.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\n/**\n * Check if CSS content uses Tailwind features that require source scanning.\n *\n * Only CSS that imports Tailwind (or @maizzle/tailwindcss) needs @source\n * directives. Plain CSS without Tailwind imports doesn't need scanning\n * and would pass through @source directives unconsumed.\n */\nfunction usesTailwind(css: string): boolean {\n return /((@import|@reference)\\s+[\"'](tailwindcss|@maizzle\\/tailwindcss)|@tailwind\\s)/.test(css)\n}\n\n/**\n * Build @source directives for Tailwind CSS scanning.\n *\n * Configures two types of sources:\n * 1. Exclusions for output dir and user-configured paths\n * 2. Inline source with all class attribute values from the rendered DOM,\n * capturing classes from all components (built-in + user), dynamic\n * expressions, and the template itself — Tailwind's scanner handles\n * the actual class extraction from these raw values\n */\nfunction buildSourceDirectives(dom: ChildNode[], config: MaizzleConfig, fromDir: string): string {\n const directives: string[] = []\n\n // Exclude output dir and user-configured paths\n const excludePaths = [\n resolve(config.output?.path ?? 'dist'),\n ...(config.css?.exclude ?? []).map(p => resolve(p)),\n ]\n\n for (const p of excludePaths) {\n directives.push(`@source not \"${relative(fromDir, resolve(p))}\";`)\n }\n\n /**\n * Inline source: collect all class attribute values from the rendered DOM.\n * After Vue SSR, the DOM contains every class from every component\n * (built-in framework components, user components, dynamic\n * bindings). We pass these raw values to Tailwind's\n * scanner via @source inline().\n */\n const classes: string[] = []\n walk(dom, (n) => {\n const cls = (n as Element).attribs?.class\n if (cls) classes.push(cls)\n })\n\n if (classes.length) {\n directives.push(`@source inline(\"${classes.join(' ')}\");`)\n }\n\n return directives.join('\\n')\n}\n\nconst GRADIENT_FN_RE = /^bg-(linear|radial|conic)\\b/\nconst GRADIENT_GENERATED_RE = /^bg-(linear|radial|conic)-gradient-/\nconst GRADIENT_STOP_RE = /^(from|via|to)-/\n\n/** Rank a stop class so generated names are stable regardless of author order. */\nfunction stopRank(cls: string): number {\n const prefix = cls.startsWith('from-') ? 0 : cls.startsWith('via-') ? 1 : 2\n const isPosition = /^(from|via|to)-\\d+%$/.test(cls) ? 1 : 0\n return prefix * 2 + isPosition\n}\n\n/** Sanitize a class token into a valid, readable CSS class name fragment. */\nfunction sanitize(token: string): string {\n return token\n .replace(/[[\\]#()]/g, '')\n .replace(/[/,.%\\s]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n}\n\n/**\n * Detect Tailwind gradient class combinations on DOM elements.\n *\n * A gradient only works once its `bg-linear/radial/conic` direction class\n * combines with `from-*`/`via-*`/`to-*` stops on the same element. This\n * collects those per-element combos, rewrites each element to a single\n * readable class (e.g. `bg-linear-gradient-to-bl-from-indigo-50-to-indigo-600`),\n * and returns the combos so the flattenGradients plugin can emit one flat\n * `background-image` rule per unique combo.\n */\nfunction collectGradientCombos(dom: ChildNode[]): GradientCombo[] {\n const bySignature = new Map<string, GradientCombo>()\n const usedNames = new Map<string, string>()\n\n walk(dom, (node) => {\n const el = node as Element\n const cls = el.attribs?.class\n if (!cls) return\n\n const tokens = cls.split(/\\s+/).filter(Boolean)\n const fnClass = tokens.find(t => GRADIENT_FN_RE.test(t) && !GRADIENT_GENERATED_RE.test(t))\n if (!fnClass) return\n\n const gradientClasses = tokens.filter(\n t => (GRADIENT_FN_RE.test(t) && !GRADIENT_GENERATED_RE.test(t)) || GRADIENT_STOP_RE.test(t),\n )\n const stops = gradientClasses.filter(t => t !== fnClass).sort((a, b) => stopRank(a) - stopRank(b) || a.localeCompare(b))\n const ordered = [fnClass, ...stops]\n const signature = ordered.join(' ')\n\n let combo = bySignature.get(signature)\n if (!combo) {\n const fn = fnClass.match(GRADIENT_FN_RE)![1]\n const dirRemainder = fnClass.replace(new RegExp(`^bg-${fn}-?`), '')\n const parts = [dirRemainder, ...stops].filter(Boolean).map(sanitize)\n let name = `bg-${fn}-gradient${parts.length ? `-${parts.join('-')}` : ''}`\n\n // Guard against sanitize collisions from distinct combos.\n const existing = usedNames.get(name)\n if (existing && existing !== signature) {\n let n = 2\n while (usedNames.has(`${name}-${n}`)) n++\n name = `${name}-${n}`\n }\n usedNames.set(name, signature)\n\n combo = { className: name, classes: ordered }\n bySignature.set(signature, combo)\n }\n\n // Replace the gradient utilities with the single generated class.\n const rest = tokens.filter(t => !gradientClasses.includes(t))\n el.attribs.class = [...rest, combo.className].join(' ')\n })\n\n return [...bySignature.values()]\n}\n\n/**\n * Tailwind CSS transformer.\n *\n * Compiles CSS inside <style> tags in the DOM using\n * @tailwindcss/postcss, then lowers modern CSS syntax with lightningcss.\n *\n * Configures Tailwind sources to scan:\n * - Rendered class attributes (via `@source inline`) for all classes from all components\n * - User project files (via Tailwind's auto-detection from base/from path)\n *\n * User `@source` and `@source not directives` in style tags are preserved.\n * Source directives are only added to style tags that import Tailwind.\n *\n * Runs as the first transformer in the pipeline so that subsequent\n * transformers (inliner, purge, etc.) work with fully compiled CSS.\n */\nexport async function tailwindcss(dom: ChildNode[], config: MaizzleConfig, filePath?: string): Promise<ChildNode[]> {\n const styleTags: { node: Element; cssContent: string }[] = []\n\n walk(dom, (node) => {\n if ((node as Element).name !== 'style') return\n\n const el = node as Element\n const attrs = el.attribs\n\n /**\n * `raw` opts out of compilation entirely (marker is consumed here).\n * `embed`/`data-embed` only signal \"preserve tag after inlining\"\n * — they still need to go through compile so Tailwind/@apply\n * resolves.\n */\n if ('raw' in attrs) {\n delete el.attribs.raw\n return\n }\n\n // Get text content from children and decode HTML entities\n const rawContent = el.children\n .filter(child => child.type === 'text')\n .map(child => (child as any).data)\n .join('')\n\n if (!rawContent.trim()) return\n\n styleTags.push({ node: el, cssContent: decodeStyleEntities(rawContent) })\n })\n\n if (!styleTags.length) return dom\n\n const fromPath = filePath ?? resolve(process.cwd(), 'template.vue')\n const fromDir = dirname(fromPath)\n\n // Only compute source directives if at least one style tag uses Tailwind\n const hasTailwindStyles = styleTags.some(({ cssContent }) => usesTailwind(cssContent))\n const sourceDirectives = hasTailwindStyles\n ? buildSourceDirectives(dom, config, fromDir)\n : ''\n\n /**\n * Collect gradient combos and rewrite elements to single classes.\n * Runs after source directives are built (so the utility classes are\n * still scanned) and only feeds the first Tailwind style tag, whose\n * `:root` holds the theme colors the flat rules reference.\n */\n const gradientCombos = hasTailwindStyles ? collectGradientCombos(dom) : []\n const firstTailwindStyle = styleTags.findIndex(({ cssContent }) => usesTailwind(cssContent))\n\n for (let i = 0; i < styleTags.length; i++) {\n const { node, cssContent } = styleTags[i]\n\n /**\n * Only add source directives to style tags that import Tailwind —\n * plain CSS doesn't need them and @tailwindcss/postcss would\n * leave the directives unconsumed in the output.\n */\n const fullCss = usesTailwind(cssContent)\n ? `${cssContent}\\n${sourceDirectives}`\n : cssContent\n\n const combos = i === firstTailwindStyle ? gradientCombos : []\n\n try {\n const optimized = await compileTailwindCss(fullCss, config, `${fromPath}?style=${i}`, combos)\n\n // Replace the style tag's children with the compiled CSS\n node.children = [{\n type: 'text',\n data: optimized,\n parent: node,\n } as any]\n } catch {\n /**\n * If CSS processing fails, still replace with decoded content\n * so HTML entities don't break the CSS.\n */\n node.children = [{\n type: 'text',\n data: cssContent,\n parent: node,\n } as any]\n }\n }\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAS,aAAa,KAAsB;CAC1C,OAAO,+EAA+E,KAAK,GAAG;AAChG;;;;;;;;;;;AAYA,SAAS,sBAAsB,KAAkB,QAAuB,SAAyB;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ACV,QAAQ;;;;;GAKN,KAAK,WAAW,CAAC;IACf,MAAM;IACN,MAAM;IACN,QAAQ;GACV,CAAQ;EACV;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"tailwindcss.js","names":[],"sources":["../../src/transformers/tailwindcss.ts"],"sourcesContent":["import { resolve, dirname, relative } from 'pathe'\nimport type { ChildNode, Element } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport { decodeStyleEntities } from '../utils/decodeStyleEntities.ts'\nimport { compileTailwindCss } from '../utils/compileTailwindCss.ts'\nimport type { GradientCombo } from '../plugins/postcss/flattenGradients.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\n/**\n * Check if CSS content uses Tailwind features that require source scanning.\n *\n * Only CSS that imports Tailwind (or @maizzle/tailwindcss) needs @source\n * directives. Plain CSS without Tailwind imports doesn't need scanning\n * and would pass through @source directives unconsumed.\n */\nfunction usesTailwind(css: string): boolean {\n return /((@import|@reference)\\s+[\"'](tailwindcss|@maizzle\\/tailwindcss)|@tailwind\\s)/.test(css)\n}\n\n/**\n * Build @source directives for Tailwind CSS scanning.\n *\n * Configures two types of sources:\n * 1. Exclusions for output dir and user-configured paths\n * 2. Inline source with all class attribute values from the rendered DOM,\n * capturing classes from all components (built-in + user), dynamic\n * expressions, and the template itself — Tailwind's scanner handles\n * the actual class extraction from these raw values\n */\nfunction buildSourceDirectives(dom: ChildNode[], config: MaizzleConfig, fromDir: string, sourceFiles?: string[]): string {\n const directives: string[] = []\n\n const scoped = config.css?.scopedSources !== false && !!sourceFiles?.length\n\n if (scoped) {\n /**\n * Scoped mode: point Tailwind's scanner at exactly the files in\n * this template's import closure instead of auto-detecting from\n * the project root. Auto-detection is disabled by appending\n * `source(none)` to the Tailwind import (see\n * rewriteImportsSourceNone below).\n */\n for (const file of sourceFiles!) {\n directives.push(`@source \"${relative(fromDir, file)}\";`)\n }\n } else {\n // Exclude output dir and user-configured paths\n const excludePaths = [\n resolve(config.output?.path ?? 'dist'),\n ...(config.css?.exclude ?? []).map(p => resolve(p)),\n ]\n\n for (const p of excludePaths) {\n directives.push(`@source not \"${relative(fromDir, resolve(p))}\";`)\n }\n }\n\n /**\n * Inline source: collect all class attribute values from the rendered DOM.\n * After Vue SSR, the DOM contains every class from every component\n * (built-in framework components, user components, dynamic\n * bindings). We pass these raw values to Tailwind's\n * scanner via @source inline().\n */\n const classes: string[] = []\n walk(dom, (n) => {\n const cls = (n as Element).attribs?.class\n if (cls) classes.push(cls)\n })\n\n if (classes.length) {\n directives.push(`@source inline(\"${classes.join(' ')}\");`)\n }\n\n return directives.join('\\n')\n}\n\nconst GRADIENT_FN_RE = /^bg-(linear|radial|conic)\\b/\nconst GRADIENT_GENERATED_RE = /^bg-(linear|radial|conic)-gradient-/\nconst GRADIENT_STOP_RE = /^(from|via|to)-/\n\n/** Rank a stop class so generated names are stable regardless of author order. */\nfunction stopRank(cls: string): number {\n const prefix = cls.startsWith('from-') ? 0 : cls.startsWith('via-') ? 1 : 2\n const isPosition = /^(from|via|to)-\\d+%$/.test(cls) ? 1 : 0\n return prefix * 2 + isPosition\n}\n\n/** Sanitize a class token into a valid, readable CSS class name fragment. */\nfunction sanitize(token: string): string {\n return token\n .replace(/[[\\]#()]/g, '')\n .replace(/[/,.%\\s]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n}\n\n/**\n * Detect Tailwind gradient class combinations on DOM elements.\n *\n * A gradient only works once its `bg-linear/radial/conic` direction class\n * combines with `from-*`/`via-*`/`to-*` stops on the same element. This\n * collects those per-element combos, rewrites each element to a single\n * readable class (e.g. `bg-linear-gradient-to-bl-from-indigo-50-to-indigo-600`),\n * and returns the combos so the flattenGradients plugin can emit one flat\n * `background-image` rule per unique combo.\n */\nfunction collectGradientCombos(dom: ChildNode[]): GradientCombo[] {\n const bySignature = new Map<string, GradientCombo>()\n const usedNames = new Map<string, string>()\n\n walk(dom, (node) => {\n const el = node as Element\n const cls = el.attribs?.class\n if (!cls) return\n\n const tokens = cls.split(/\\s+/).filter(Boolean)\n const fnClass = tokens.find(t => GRADIENT_FN_RE.test(t) && !GRADIENT_GENERATED_RE.test(t))\n if (!fnClass) return\n\n const gradientClasses = tokens.filter(\n t => (GRADIENT_FN_RE.test(t) && !GRADIENT_GENERATED_RE.test(t)) || GRADIENT_STOP_RE.test(t),\n )\n const stops = gradientClasses.filter(t => t !== fnClass).sort((a, b) => stopRank(a) - stopRank(b) || a.localeCompare(b))\n const ordered = [fnClass, ...stops]\n const signature = ordered.join(' ')\n\n let combo = bySignature.get(signature)\n if (!combo) {\n const fn = fnClass.match(GRADIENT_FN_RE)![1]\n const dirRemainder = fnClass.replace(new RegExp(`^bg-${fn}-?`), '')\n const parts = [dirRemainder, ...stops].filter(Boolean).map(sanitize)\n let name = `bg-${fn}-gradient${parts.length ? `-${parts.join('-')}` : ''}`\n\n // Guard against sanitize collisions from distinct combos.\n const existing = usedNames.get(name)\n if (existing && existing !== signature) {\n let n = 2\n while (usedNames.has(`${name}-${n}`)) n++\n name = `${name}-${n}`\n }\n usedNames.set(name, signature)\n\n combo = { className: name, classes: ordered }\n bySignature.set(signature, combo)\n }\n\n // Replace the gradient utilities with the single generated class.\n const rest = tokens.filter(t => !gradientClasses.includes(t))\n el.attribs.class = [...rest, combo.className].join(' ')\n })\n\n return [...bySignature.values()]\n}\n\n/**\n * Append ` source(none)` to Tailwind imports so auto source detection\n * is off and only our explicit `@source` directives apply. Skips\n * imports that already carry a `source(...)` modifier.\n */\nexport function rewriteImportsSourceNone(css: string): string {\n return css.replace(\n /(@import\\s+[\"'](?:@maizzle\\/)?tailwindcss(?:\\/[^\"']*)?[\"'][^;]*);/g,\n (match, stmt) => stmt.includes('source(') ? match : `${stmt} source(none);`,\n )\n}\n\n/**\n * Tailwind CSS transformer.\n *\n * Compiles CSS inside <style> tags in the DOM using\n * @tailwindcss/postcss, then lowers modern CSS syntax with lightningcss.\n *\n * Configures Tailwind sources to scan:\n * - Rendered class attributes (via `@source inline`) for all classes from all components\n * - The template's module import closure (via `@source` directives), or user\n * project files (via Tailwind's auto-detection) when `css.scopedSources` is off\n *\n * User `@source` and `@source not directives` in style tags are preserved.\n * Source directives are only added to style tags that import Tailwind.\n *\n * Runs as the first transformer in the pipeline so that subsequent\n * transformers (inliner, purge, etc.) work with fully compiled CSS.\n */\nexport async function tailwindcss(dom: ChildNode[], config: MaizzleConfig, filePath?: string, sourceFiles?: string[]): Promise<ChildNode[]> {\n const styleTags: { node: Element; cssContent: string }[] = []\n\n walk(dom, (node) => {\n if ((node as Element).name !== 'style') return\n\n const el = node as Element\n const attrs = el.attribs\n\n /**\n * `raw` opts out of compilation entirely (marker is consumed here).\n * `embed`/`data-embed` only signal \"preserve tag after inlining\"\n * — they still need to go through compile so Tailwind/@apply\n * resolves.\n */\n if ('raw' in attrs) {\n delete el.attribs.raw\n return\n }\n\n // Get text content from children and decode HTML entities\n const rawContent = el.children\n .filter(child => child.type === 'text')\n .map(child => (child as any).data)\n .join('')\n\n if (!rawContent.trim()) return\n\n styleTags.push({ node: el, cssContent: decodeStyleEntities(rawContent) })\n })\n\n if (!styleTags.length) return dom\n\n const fromPath = filePath ?? resolve(process.cwd(), 'template.vue')\n const fromDir = dirname(fromPath)\n\n // Only compute source directives if at least one style tag uses Tailwind\n const hasTailwindStyles = styleTags.some(({ cssContent }) => usesTailwind(cssContent))\n const sourceDirectives = hasTailwindStyles\n ? buildSourceDirectives(dom, config, fromDir, sourceFiles)\n : ''\n\n const scoped = config.css?.scopedSources !== false && !!sourceFiles?.length\n\n /**\n * Collect gradient combos and rewrite elements to single classes.\n * Runs after source directives are built (so the utility classes are\n * still scanned) and only feeds the first Tailwind style tag, whose\n * `:root` holds the theme colors the flat rules reference.\n */\n const gradientCombos = hasTailwindStyles ? collectGradientCombos(dom) : []\n const firstTailwindStyle = styleTags.findIndex(({ cssContent }) => usesTailwind(cssContent))\n\n for (let i = 0; i < styleTags.length; i++) {\n const { node, cssContent } = styleTags[i]\n\n /**\n * Only add source directives to style tags that import Tailwind —\n * plain CSS doesn't need them and @tailwindcss/postcss would\n * leave the directives unconsumed in the output.\n */\n const usesTw = usesTailwind(cssContent)\n const fullCss = usesTw\n ? `${scoped ? rewriteImportsSourceNone(cssContent) : cssContent}\\n${sourceDirectives}`\n : cssContent\n\n const combos = i === firstTailwindStyle ? gradientCombos : []\n\n try {\n const optimized = await compileTailwindCss(fullCss, config, `${fromPath}?style=${i}`, combos)\n\n // Replace the style tag's children with the compiled CSS\n node.children = [{\n type: 'text',\n data: optimized,\n parent: node,\n } as any]\n } catch {\n /**\n * If CSS processing fails, still replace with decoded content\n * so HTML entities don't break the CSS.\n */\n node.children = [{\n type: 'text',\n data: cssContent,\n parent: node,\n } as any]\n }\n }\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAS,aAAa,KAAsB;CAC1C,OAAO,+EAA+E,KAAK,GAAG;AAChG;;;;;;;;;;;AAYA,SAAS,sBAAsB,KAAkB,QAAuB,SAAiB,aAAgC;CACvH,MAAM,aAAuB,CAAC;CAI9B,IAFe,OAAO,KAAK,kBAAkB,SAAS,CAAC,CAAC,aAAa;;;;;;;;CAUnE,KAAK,MAAM,QAAQ,aACjB,WAAW,KAAK,YAAY,SAAS,SAAS,IAAI,EAAE,GAAG;MAEpD;EAEL,MAAM,eAAe,CACnB,QAAQ,OAAO,QAAQ,QAAQ,MAAM,GACrC,IAAI,OAAO,KAAK,WAAW,CAAC,EAAA,CAAG,KAAI,MAAK,QAAQ,CAAC,CAAC,CACpD;EAEA,KAAK,MAAM,KAAK,cACd,WAAW,KAAK,gBAAgB,SAAS,SAAS,QAAQ,CAAC,CAAC,EAAE,GAAG;CAErE;;;;;;;;CASA,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,MAAM;EACf,MAAM,MAAO,EAAc,SAAS;EACpC,IAAI,KAAK,QAAQ,KAAK,GAAG;CAC3B,CAAC;CAED,IAAI,QAAQ,QACV,WAAW,KAAK,mBAAmB,QAAQ,KAAK,G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AC,CACtC,KAAI,UAAU,MAAc,IAAI,CAAC,CACjC,KAAK,EAAE;EAEV,IAAI,CAAC,WAAW,KAAK,GAAG;EAExB,UAAU,KAAK;GAAE,MAAM;GAAI,YAAY,oBAAoB,UAAU;EAAE,CAAC;CAC1E,CAAC;CAED,IAAI,CAAC,UAAU,QAAQ,OAAO;CAE9B,MAAM,WAAW,YAAY,QAAQ,QAAQ,IAAI,GAAG,cAAc;CAClE,MAAM,UAAU,QAAQ,QAAQ;CAGhC,MAAM,oBAAoB,UAAU,MAAM,EAAE,iBAAiB,aAAa,UAAU,CAAC;CACrF,MAAM,mBAAmB,oBACrB,sBAAsB,KAAK,QAAQ,SAAS,WAAW,IACvD;CAEJ,MAAM,SAAS,OAAO,KAAK,kBAAkB,SAAS,CAAC,CAAC,aAAa;;;;;;;CAQrE,MAAM,iBAAiB,oBAAoB,sBAAsB,GAAG,IAAI,CAAC;CACzE,MAAM,qBAAqB,UAAU,WAAW,EAAE,iBAAiB,aAAa,UAAU,CAAC;CAE3F,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EACzC,MAAM,EAAE,MAAM,eAAe,UAAU;EAQvC,MAAM,UADS,aAAa,UACP,IACjB,GAAG,SAAS,yBAAyB,UAAU,IAAI,WAAW,IAAI,qBAClE;EAEJ,MAAM,SAAS,MAAM,qBAAqB,iBAAiB,CAAC;EAE5D,IAAI;GAIF,KAAK,WAAW,CAAC;IACf,MAAM;IACN,MAAM,MALgB,mBAAmB,SAAS,QAAQ,GAAG,SAAS,SAAS,KAAK,MAAM;IAM1F,QAAQ;GACV,CAAQ;EACV,QAAQ;;;;;GAKN,KAAK,WAAW,CAAC;IACf,MAAM;IACN,MAAM;IACN,QAAQ;GACV,CAAQ;EACV;CACF;CAEA,OAAO;AACT"}
@@ -78,6 +78,17 @@ interface CssConfig {
78
78
  * Automatically set to `root` when `root` is configured.
79
79
  */
80
80
  base?: string;
81
+ /**
82
+ * Scope Tailwind source scanning to each template's module import
83
+ * closure (the template file plus every component/module it actually
84
+ * uses) instead of scanning the whole project for every template.
85
+ *
86
+ * Set to `false` to restore whole-project scanning, e.g. when classes
87
+ * live in files Maizzle can't trace through imports.
88
+ *
89
+ * @default true
90
+ */
91
+ scopedSources?: boolean;
81
92
  /**
82
93
  * Remove unused CSS.
83
94
  *
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/types/config.ts"],"mappings":";;;;;;;KAKK,eAAe,YAAY,kBAAkB;UAGjC;;;;;;EAMf;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,KAAK;;KAGK,WAAW;EACrB,WAAW;;UAGI;;;;;;;;;;;;EAYf,QAAQ;;;;;;;;;;;EAWR;;IAEE;;IAEA,kBAAkB,eAAe;;IAEjC,aAAa;;IAEb;;IAEA;;;UAIa;;;;;;EAMf;;;;;;;;EAQA,kBAAkB;;;;;;;;;;;;;;EAclB,mBAAmB;;;;;;;IAOjB;;;;;;IAMA;;;;;;;IAOA;;;;;;;;;;;;IAYA,mBAAmB;;;;;;;IAOnB;;;;;;;IAOA;;;;;;;IAOA;;;;;;;IAOA,aAAa;MAAiB;MAAe;;;;;;IAK7C;;;;;;;;;;;;;;EAcF;;;;;;IAME,4CAA4C,WAAW;;;;;;;;;EASzD;;;;;;EAMA,iBAAiB;;;;;;;;EAQjB;IAAwB;;;;;;;;;EAQxB;;;;;;;;;;;EAWA,qBAAqB,eA3BJ;;;;;;;;;;;;;EAwCjB;;UAGe;;;;;;;;;;;;;;;;;;EAkBf,cAAc,uBAAuB;;;;;;;;;;;;;;;;;;;;;;EAsBrC,SAAS;IAAiB;IAAc,iBAAiB;;;KAG/C,2BAA2B;;;;;;KAO3B;UAOK;;;;;;EAMf,UAAU;;;;;;;;EAQV;;UAGe;;;;;;;;;;;EAWf;;;;;;;;;;;EAWA;;UAGe;;EAEf,aAAa;;;;;;;;EAQb,iBAAiB;;;;;;EAMjB,mCAAmC;;;;;;;;;EASnC,mBAAmB,6BAA6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2
  "name": "@maizzle/framework",
3
- "version": "6.1.1",
3
+ "version": "6.1.2",
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",