@maizzle/framework 6.1.0 → 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.
Files changed (63) hide show
  1. package/dist/build.js +2 -1
  2. package/dist/build.js.map +1 -1
  3. package/dist/config/index.js.map +1 -1
  4. package/dist/plugins/postcss/mergeMediaQueries.js +2 -1
  5. package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -1
  6. package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -1
  7. package/dist/render/buildTemplate.js +4 -2
  8. package/dist/render/buildTemplate.js.map +1 -1
  9. package/dist/render/createRenderer.d.ts +7 -0
  10. package/dist/render/createRenderer.d.ts.map +1 -1
  11. package/dist/render/createRenderer.js +46 -3
  12. package/dist/render/createRenderer.js.map +1 -1
  13. package/dist/serve.js +19 -10
  14. package/dist/serve.js.map +1 -1
  15. package/dist/server/compatibility.js +2 -1
  16. package/dist/server/compatibility.js.map +1 -1
  17. package/dist/server/linter.js +2 -1
  18. package/dist/server/linter.js.map +1 -1
  19. package/dist/server/sfc-utils.js.map +1 -1
  20. package/dist/server/ui/.vite/deps/@lucide_vue.js +6845 -6285
  21. package/dist/server/ui/.vite/deps/@lucide_vue.js.map +1 -1
  22. package/dist/server/ui/.vite/deps/@vueuse_core.js +2 -6
  23. package/dist/server/ui/.vite/deps/@vueuse_core.js.map +1 -1
  24. package/dist/server/ui/.vite/deps/@vueuse_shared.js +1 -1
  25. package/dist/server/ui/.vite/deps/@vueuse_shared.js.map +1 -1
  26. package/dist/server/ui/.vite/deps/_metadata.json +15 -15
  27. package/dist/server/ui/.vite/deps/culori.js +8 -6
  28. package/dist/server/ui/.vite/deps/culori.js.map +1 -1
  29. package/dist/server/ui/.vite/deps/reka-ui.js +63 -73
  30. package/dist/server/ui/.vite/deps/reka-ui.js.map +1 -1
  31. package/dist/server/ui/.vite/deps/tailwind-merge.js.map +1 -1
  32. package/dist/server/ui/.vite/deps/vue-router.js +5 -13
  33. package/dist/server/ui/.vite/deps/vue-router.js.map +1 -1
  34. package/dist/server/ui/.vite/deps/vue.js +1 -1
  35. package/dist/server/ui/.vite/deps/{vue.runtime.esm-bundler-BHD3r-bP.js → vue.runtime.esm-bundler-S54atuNJ.js} +323 -259
  36. package/dist/server/ui/.vite/deps/{vue.runtime.esm-bundler-BHD3r-bP.js.map → vue.runtime.esm-bundler-S54atuNJ.js.map} +1 -1
  37. package/dist/transformers/format.js +2 -1
  38. package/dist/transformers/format.js.map +1 -1
  39. package/dist/transformers/index.d.ts +1 -1
  40. package/dist/transformers/index.d.ts.map +1 -1
  41. package/dist/transformers/index.js +4 -4
  42. package/dist/transformers/index.js.map +1 -1
  43. package/dist/transformers/inlineCss.js +3 -2
  44. package/dist/transformers/inlineCss.js.map +1 -1
  45. package/dist/transformers/inlineLink.js +2 -1
  46. package/dist/transformers/inlineLink.js.map +1 -1
  47. package/dist/transformers/minify.js +2 -1
  48. package/dist/transformers/minify.js.map +1 -1
  49. package/dist/transformers/tailwindComponent.d.ts +1 -1
  50. package/dist/transformers/tailwindComponent.d.ts.map +1 -1
  51. package/dist/transformers/tailwindComponent.js +26 -7
  52. package/dist/transformers/tailwindComponent.js.map +1 -1
  53. package/dist/transformers/tailwindcss.d.ts +10 -3
  54. package/dist/transformers/tailwindcss.d.ts.map +1 -1
  55. package/dist/transformers/tailwindcss.js +30 -14
  56. package/dist/transformers/tailwindcss.js.map +1 -1
  57. package/dist/transformers/urlQuery.js +2 -1
  58. package/dist/transformers/urlQuery.js.map +1 -1
  59. package/dist/types/config.d.ts +11 -0
  60. package/dist/types/config.d.ts.map +1 -1
  61. package/dist/utils/cssBox.js +2 -6
  62. package/dist/utils/cssBox.js.map +1 -1
  63. package/package.json +2 -2
package/dist/build.js CHANGED
@@ -218,7 +218,8 @@ async function copyStatic(config, outputPath) {
218
218
  const bases = sources.filter((s) => !s.startsWith("!")).map(staticBase);
219
219
  for (const file of files) {
220
220
  const abs = resolve(file);
221
- const destPath = join(outputPath, destination, relative(bases.filter((b) => abs === b || abs.startsWith(b + sep)).sort((a, b) => b.length - a.length)[0] ?? bases[0] ?? resolve("."), abs));
221
+ const base = bases.filter((b) => abs === b || abs.startsWith(b + sep)).sort((a, b) => b.length - a.length)[0] ?? bases[0] ?? resolve(".");
222
+ const destPath = join(outputPath, destination, relative(base, abs));
222
223
  const destDir = dirname(destPath);
223
224
  if (!existsSync(destDir)) mkdirSync(destDir, { recursive: true });
224
225
  cpSync(file, destPath);
package/dist/build.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","names":["parsePath"],"sources":["../src/build.ts"],"sourcesContent":["import { mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, relative, join, parse as parsePath, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { availableParallelism } from 'node:os'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { buildTemplate, computeContentBase } from './render/buildTemplate.ts'\nimport type { MaizzleConfig } from './types/index.ts'\n\nexport interface BuildResult {\n files: string[]\n config: MaizzleConfig\n}\n\n/**\n * Build all SFC email templates to HTML files.\n *\n * Creates a single Renderer instance, then loops through each template\n * calling render → transformers → write to disk.\n *\n * Pass a `Partial<MaizzleConfig>` to override config inline, or a string\n * to load config from a specific file path. Omit to load `maizzle.config`\n * from the working directory.\n */\nexport async function build(configInput?: Partial<MaizzleConfig> | string): Promise<BuildResult> {\n const start = Date.now()\n const spinner = ora({ text: 'Building templates...', spinner: 'circleHalves' }).start()\n\n try {\n const config = await resolveConfig(configInput)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const outputPath = resolve(config.output?.path ?? 'dist')\n const outputExtension = config.output?.extension ?? 'html'\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const contentBase = computeContentBase(contentPatterns)\n const templateFiles = await glob(contentPatterns)\n\n if (templateFiles.length === 0) {\n spinner.succeed('No templates found')\n return { files: [], config }\n }\n\n // Clear the output directory before writing fresh output. Guard against a\n // misconfigured output.path (e.g. '.', '', '../..') that resolves to the\n // project root or a parent of it — rmSync would wipe the whole project.\n const cwd = process.cwd()\n if (outputPath === parsePath(outputPath).root || outputPath === cwd || cwd.startsWith(outputPath + sep)) {\n throw new Error(`Refusing to clear output path \"${outputPath}\": it is the filesystem root, the current working directory, or a parent of it. Set output.path to a subdirectory like \"dist\".`)\n }\n\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true })\n }\n\n const outputFiles: string[] = []\n let droppedAfterBuild = 0\n\n const parallel = resolveParallel(config, templateFiles.length, configInput)\n\n if (parallel.enabled) {\n spinner.text = `Building ${templateFiles.length} templates across ${parallel.workers} workers...`\n\n const result = await runParallelBuild({\n templateFiles,\n workers: parallel.workers,\n config,\n configInput,\n outputPath,\n outputExtension,\n contentBase,\n })\n\n outputFiles.push(...result.files)\n droppedAfterBuild = result.sfcAfterBuildCount\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } else {\n const renderer = await createRenderer({ markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n try {\n for (const templatePath of templateFiles) {\n const { files } = await buildTemplate(templatePath, { config, renderer, events, outputPath, outputExtension, contentBase })\n outputFiles.push(...files)\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n }\n\n if (droppedAfterBuild > 0) {\n console.warn(`[maizzle] Skipped ${droppedAfterBuild} SFC-registered afterBuild handler(s): afterBuild can't run inside a parallel build worker. Move build-completion logic to the config's afterBuild hook.`)\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n } catch (err) {\n // Stop the spinner so a thrown error doesn't leave it spinning forever.\n if (spinner.isSpinning) spinner.fail('Build failed')\n throw err\n }\n}\n\n/**\n * Default template count above which parallel build turns on. Benchmarked\n * crossover (with the worker cap below) is ~25 templates; 50 leaves margin so\n * auto-parallel only kicks in where it's a reliable win across hardware.\n * Override per project with `parallel: { threshold }`.\n */\nconst DEFAULT_PARALLEL_THRESHOLD = 50\n\n/**\n * Default worker cap. Each worker runs a full Vite SSR renderer, so startup +\n * contention outweighs added parallelism past ~8 — benchmarks showed 8 beating\n * 12/16/23 at every size. Override with `parallel: { workers }`.\n */\nconst DEFAULT_MAX_WORKERS = 8\n\n/**\n * Decide whether to build in parallel and with how many workers.\n *\n * `config.parallel`:\n * - omitted → parallel when `count > 50`, min(CPU count − 1, 8) workers\n * - `true` → always parallel (ignores threshold), default workers\n * - `false` → always sequential\n * - `{ workers, threshold }` → parallel when `count > threshold` (default 50),\n * using `workers` threads (default min(CPU count − 1, 8))\n *\n * Workers reload the config file to recover function hooks, so parallel only\n * applies to file-based configs (a path or the default cwd config) — an inline\n * config object has no file to reload and always builds sequentially.\n */\nexport function resolveParallel(\n config: MaizzleConfig,\n count: number,\n configInput: Partial<MaizzleConfig> | string | undefined,\n): { enabled: boolean; workers: number } {\n const setting = config.parallel\n if (setting === false) return { enabled: false, workers: 0 }\n\n const fileBased = typeof configInput === 'string' || configInput == null\n if (!fileBased) return { enabled: false, workers: 0 }\n\n const cpus = availableParallelism()\n const defaultWorkers = Math.min(Math.max(1, cpus - 1), DEFAULT_MAX_WORKERS)\n\n let maxWorkers = defaultWorkers\n let threshold = DEFAULT_PARALLEL_THRESHOLD\n // `true` opts in regardless of count; object/omitted stay threshold-gated.\n const ignoreThreshold = setting === true\n\n if (typeof setting === 'object' && setting !== null) {\n if (typeof setting.workers === 'number' && setting.workers > 0) maxWorkers = Math.floor(setting.workers)\n if (typeof setting.threshold === 'number' && setting.threshold >= 0) threshold = Math.floor(setting.threshold)\n }\n\n if (!ignoreThreshold && count <= threshold) return { enabled: false, workers: 0 }\n\n const workers = Math.min(maxWorkers, count)\n return { enabled: workers >= 2 && count >= 2, workers }\n}\n\n/**\n * Run the build across worker threads. Each worker reloads the config (for its\n * function hooks), builds its batch via the same `buildTemplate` as the\n * sequential path, and returns the files it wrote. beforeCreate/afterBuild stay\n * on the main thread (handled by the caller).\n */\nasync function runParallelBuild(opts: {\n templateFiles: string[]\n workers: number\n config: MaizzleConfig\n configInput: Partial<MaizzleConfig> | string | undefined\n outputPath: string\n outputExtension: string\n contentBase: string\n}): Promise<{ files: string[]; sfcAfterBuildCount: number }> {\n const { templateFiles, workers, config, configInput, outputPath, outputExtension, contentBase } = opts\n\n const { default: Tinypool } = await import('tinypool')\n const workerPath = resolve(dirname(fileURLToPath(import.meta.url)), 'render/parallel/worker.mjs')\n\n const configPath = typeof configInput === 'string' ? configInput : undefined\n // Serializable snapshot of the post-beforeCreate config (functions dropped).\n const configData = JSON.parse(JSON.stringify(config)) as Partial<MaizzleConfig>\n\n const batches = shardEvenly(templateFiles, workers)\n\n const pool = new Tinypool({ filename: workerPath, minThreads: batches.length, maxThreads: batches.length })\n\n try {\n const results = await Promise.all(\n batches.map(templatePaths => pool.run({\n templatePaths,\n configPath,\n configData,\n outputPath,\n outputExtension,\n contentBase,\n })),\n )\n\n return {\n files: results.flatMap(r => r.files),\n sfcAfterBuildCount: results.reduce((n, r) => n + r.sfcAfterBuildCount, 0),\n }\n } finally {\n await pool.destroy()\n }\n}\n\n/** Round-robin items into up to `buckets` non-empty groups for even balance. */\nfunction shardEvenly<T>(items: T[], buckets: number): T[][] {\n const out: T[][] = Array.from({ length: buckets }, () => [])\n items.forEach((item, i) => out[i % buckets].push(item))\n return out.filter(b => b.length > 0)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n // One glob call so negation patterns still apply across the whole set.\n const files = await glob(sources)\n\n // Absolute base dir to strip, per positive source pattern. Each file keeps\n // the structure under its own pattern's base — using only sources[0] sends\n // files from other roots to the wrong place (or escaping the output dir).\n const bases = sources.filter(s => !s.startsWith('!')).map(staticBase)\n\n for (const file of files) {\n const abs = resolve(file)\n const base = bases\n .filter(b => abs === b || abs.startsWith(b + sep))\n .sort((a, b) => b.length - a.length)[0] ?? bases[0] ?? resolve('.')\n\n const destPath = join(outputPath, destination, relative(base, abs))\n const destDir = dirname(destPath)\n\n if (!existsSync(destDir)) {\n mkdirSync(destDir, { recursive: true })\n }\n\n cpSync(file, destPath)\n }\n}\n\n/** Absolute static (non-glob) prefix of a source pattern, used as the strip base. */\nfunction staticBase(pattern: string): string {\n const staticPart = pattern.split(/[*{?[]/)[0]\n // Treat both separators as trailing: resolved patterns use '\\' on Windows.\n return resolve(/[/\\\\]$/.test(staticPart) ? staticPart : dirname(staticPart))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,MAAM,aAAqE;CAC/F,MAAM,QAAQ,KAAK,IAAI;CACvB,MAAM,UAAU,IAAI;EAAE,MAAM;EAAyB,SAAS;CAAe,CAAC,CAAC,CAAC,MAAM;CAEtF,IAAI;EACF,MAAM,SAAS,MAAM,cAAc,WAAW;EAE9C,MAAM,SAAS,IAAI,aAAa;EAChC,OAAO,eAAe,MAAM;EAC5B,MAAM,OAAO,iBAAiB,EAAE,OAAO,CAAC;EAExC,MAAM,aAAa,QAAQ,OAAO,QAAQ,QAAQ,MAAM;EACxD,MAAM,kBAAkB,OAAO,QAAQ,aAAa;EAEpD,MAAM,kBAAkB,OAAO,WAAW,CAAC,iBAAiB;EAC5D,MAAM,cAAc,mBAAmB,eAAe;EACtD,MAAM,gBAAgB,MAAM,KAAK,eAAe;EAEhD,IAAI,cAAc,WAAW,GAAG;GAC9B,QAAQ,QAAQ,oBAAoB;GACpC,OAAO;IAA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AK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,QAAQ,IAAI;EAKxB,MAAM,WAAW,KAAK,YAAY,aAAa,SAJlC,MACV,QAAO,MAAK,QAAQ,KAAK,IAAI,WAAW,IAAI,GAAG,CAAC,CAAC,CACjD,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,MAAM,MAAM,QAAQ,GAAG,GAEN,GAAG,CAAC;EAClE,MAAM,UAAU,QAAQ,QAAQ;EAEhC,IAAI,CAAC,WAAW,OAAO,GACrB,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAGxC,OAAO,MAAM,QAAQ;CACvB;AACF;;AAGA,SAAS,WAAW,SAAyB;CAC3C,MAAM,aAAa,QAAQ,MAAM,QAAQ,CAAC,CAAC;CAE3C,OAAO,QAAQ,SAAS,KAAK,UAAU,IAAI,aAAa,QAAQ,UAAU,CAAC;AAC7E"}
1
+ {"version":3,"file":"build.js","names":["parsePath"],"sources":["../src/build.ts"],"sourcesContent":["import { mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, relative, join, parse as parsePath, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { availableParallelism } from 'node:os'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { buildTemplate, computeContentBase } from './render/buildTemplate.ts'\nimport type { MaizzleConfig } from './types/index.ts'\n\nexport interface BuildResult {\n files: string[]\n config: MaizzleConfig\n}\n\n/**\n * Build all SFC email templates to HTML files.\n *\n * Creates a single Renderer instance, then loops through each template\n * calling render → transformers → write to disk.\n *\n * Pass a `Partial<MaizzleConfig>` to override config inline, or a string\n * to load config from a specific file path. Omit to load `maizzle.config`\n * from the working directory.\n */\nexport async function build(configInput?: Partial<MaizzleConfig> | string): Promise<BuildResult> {\n const start = Date.now()\n const spinner = ora({ text: 'Building templates...', spinner: 'circleHalves' }).start()\n\n try {\n const config = await resolveConfig(configInput)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const outputPath = resolve(config.output?.path ?? 'dist')\n const outputExtension = config.output?.extension ?? 'html'\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const contentBase = computeContentBase(contentPatterns)\n const templateFiles = await glob(contentPatterns)\n\n if (templateFiles.length === 0) {\n spinner.succeed('No templates found')\n return { files: [], config }\n }\n\n // Clear the output directory before writing fresh output. Guard against a\n // misconfigured output.path (e.g. '.', '', '../..') that resolves to the\n // project root or a parent of it — rmSync would wipe the whole project.\n const cwd = process.cwd()\n if (outputPath === parsePath(outputPath).root || outputPath === cwd || cwd.startsWith(outputPath + sep)) {\n throw new Error(`Refusing to clear output path \"${outputPath}\": it is the filesystem root, the current working directory, or a parent of it. Set output.path to a subdirectory like \"dist\".`)\n }\n\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true })\n }\n\n const outputFiles: string[] = []\n let droppedAfterBuild = 0\n\n const parallel = resolveParallel(config, templateFiles.length, configInput)\n\n if (parallel.enabled) {\n spinner.text = `Building ${templateFiles.length} templates across ${parallel.workers} workers...`\n\n const result = await runParallelBuild({\n templateFiles,\n workers: parallel.workers,\n config,\n configInput,\n outputPath,\n outputExtension,\n contentBase,\n })\n\n outputFiles.push(...result.files)\n droppedAfterBuild = result.sfcAfterBuildCount\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } else {\n const renderer = await createRenderer({ markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite, customElements: config.vue?.customElements })\n\n try {\n for (const templatePath of templateFiles) {\n const { files } = await buildTemplate(templatePath, { config, renderer, events, outputPath, outputExtension, contentBase })\n outputFiles.push(...files)\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n }\n\n if (droppedAfterBuild > 0) {\n console.warn(`[maizzle] Skipped ${droppedAfterBuild} SFC-registered afterBuild handler(s): afterBuild can't run inside a parallel build worker. Move build-completion logic to the config's afterBuild hook.`)\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n } catch (err) {\n // Stop the spinner so a thrown error doesn't leave it spinning forever.\n if (spinner.isSpinning) spinner.fail('Build failed')\n throw err\n }\n}\n\n/**\n * Default template count above which parallel build turns on. Benchmarked\n * crossover (with the worker cap below) is ~25 templates; 50 leaves margin so\n * auto-parallel only kicks in where it's a reliable win across hardware.\n * Override per project with `parallel: { threshold }`.\n */\nconst DEFAULT_PARALLEL_THRESHOLD = 50\n\n/**\n * Default worker cap. Each worker runs a full Vite SSR renderer, so startup +\n * contention outweighs added parallelism past ~8 — benchmarks showed 8 beating\n * 12/16/23 at every size. Override with `parallel: { workers }`.\n */\nconst DEFAULT_MAX_WORKERS = 8\n\n/**\n * Decide whether to build in parallel and with how many workers.\n *\n * `config.parallel`:\n * - omitted → parallel when `count > 50`, min(CPU count − 1, 8) workers\n * - `true` → always parallel (ignores threshold), default workers\n * - `false` → always sequential\n * - `{ workers, threshold }` → parallel when `count > threshold` (default 50),\n * using `workers` threads (default min(CPU count − 1, 8))\n *\n * Workers reload the config file to recover function hooks, so parallel only\n * applies to file-based configs (a path or the default cwd config) — an inline\n * config object has no file to reload and always builds sequentially.\n */\nexport function resolveParallel(\n config: MaizzleConfig,\n count: number,\n configInput: Partial<MaizzleConfig> | string | undefined,\n): { enabled: boolean; workers: number } {\n const setting = config.parallel\n if (setting === false) return { enabled: false, workers: 0 }\n\n const fileBased = typeof configInput === 'string' || configInput == null\n if (!fileBased) return { enabled: false, workers: 0 }\n\n const cpus = availableParallelism()\n const defaultWorkers = Math.min(Math.max(1, cpus - 1), DEFAULT_MAX_WORKERS)\n\n let maxWorkers = defaultWorkers\n let threshold = DEFAULT_PARALLEL_THRESHOLD\n // `true` opts in regardless of count; object/omitted stay threshold-gated.\n const ignoreThreshold = setting === true\n\n if (typeof setting === 'object' && setting !== null) {\n if (typeof setting.workers === 'number' && setting.workers > 0) maxWorkers = Math.floor(setting.workers)\n if (typeof setting.threshold === 'number' && setting.threshold >= 0) threshold = Math.floor(setting.threshold)\n }\n\n if (!ignoreThreshold && count <= threshold) return { enabled: false, workers: 0 }\n\n const workers = Math.min(maxWorkers, count)\n return { enabled: workers >= 2 && count >= 2, workers }\n}\n\n/**\n * Run the build across worker threads. Each worker reloads the config (for its\n * function hooks), builds its batch via the same `buildTemplate` as the\n * sequential path, and returns the files it wrote. beforeCreate/afterBuild stay\n * on the main thread (handled by the caller).\n */\nasync function runParallelBuild(opts: {\n templateFiles: string[]\n workers: number\n config: MaizzleConfig\n configInput: Partial<MaizzleConfig> | string | undefined\n outputPath: string\n outputExtension: string\n contentBase: string\n}): Promise<{ files: string[]; sfcAfterBuildCount: number }> {\n const { templateFiles, workers, config, configInput, outputPath, outputExtension, contentBase } = opts\n\n const { default: Tinypool } = await import('tinypool')\n const workerPath = resolve(dirname(fileURLToPath(import.meta.url)), 'render/parallel/worker.mjs')\n\n const configPath = typeof configInput === 'string' ? configInput : undefined\n // Serializable snapshot of the post-beforeCreate config (functions dropped).\n const configData = JSON.parse(JSON.stringify(config)) as Partial<MaizzleConfig>\n\n const batches = shardEvenly(templateFiles, workers)\n\n const pool = new Tinypool({ filename: workerPath, minThreads: batches.length, maxThreads: batches.length })\n\n try {\n const results = await Promise.all(\n batches.map(templatePaths => pool.run({\n templatePaths,\n configPath,\n configData,\n outputPath,\n outputExtension,\n contentBase,\n })),\n )\n\n return {\n files: results.flatMap(r => r.files),\n sfcAfterBuildCount: results.reduce((n, r) => n + r.sfcAfterBuildCount, 0),\n }\n } finally {\n await pool.destroy()\n }\n}\n\n/** Round-robin items into up to `buckets` non-empty groups for even balance. */\nfunction shardEvenly<T>(items: T[], buckets: number): T[][] {\n const out: T[][] = Array.from({ length: buckets }, () => [])\n items.forEach((item, i) => out[i % buckets].push(item))\n return out.filter(b => b.length > 0)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n // One glob call so negation patterns still apply across the whole set.\n const files = await glob(sources)\n\n // Absolute base dir to strip, per positive source pattern. Each file keeps\n // the structure under its own pattern's base — using only sources[0] sends\n // files from other roots to the wrong place (or escaping the output dir).\n const bases = sources.filter(s => !s.startsWith('!')).map(staticBase)\n\n for (const file of files) {\n const abs = resolve(file)\n const base = bases\n .filter(b => abs === b || abs.startsWith(b + sep))\n .sort((a, b) => b.length - a.length)[0] ?? bases[0] ?? resolve('.')\n\n const destPath = join(outputPath, destination, relative(base, abs))\n const destDir = dirname(destPath)\n\n if (!existsSync(destDir)) {\n mkdirSync(destDir, { recursive: true })\n }\n\n cpSync(file, destPath)\n }\n}\n\n/** Absolute static (non-glob) prefix of a source pattern, used as the strip base. */\nfunction staticBase(pattern: string): string {\n const staticPart = pattern.split(/[*{?[]/)[0]\n // Treat both separators as trailing: resolved patterns use '\\' on Windows.\n return resolve(/[/\\\\]$/.test(staticPart) ? staticPart : dirname(staticPart))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,MAAM,aAAqE;CAC/F,MAAM,QAAQ,KAAK,IAAI;CACvB,MAAM,UAAU,IAAI;EAAE,MAAM;EAAyB,SAAS;CAAe,CAAC,CAAC,CAAC,MAAM;CAEtF,IAAI;EACF,MAAM,SAAS,MAAM,cAAc,WAAW;EAE9C,MAAM,SAAS,IAAI,aAAa;EAChC,OAAO,eAAe,MAAM;EAC5B,MAAM,OAAO,iBAAiB,EAAE,OAAO,CAAC;EAExC,MAAM,aAAa,QAAQ,OAAO,QAAQ,QAAQ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uB,YAAmC;CAClF,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,eAAe;CACzD,MAAM,cAAc,OAAO,QAAQ,eAAe;CAGlD,MAAM,QAAQ,MAAM,KAAK,OAAO;CAKhC,MAAM,QAAQ,QAAQ,QAAO,MAAK,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC,CAAC,IAAI,UAAU;CAEpE,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,QAAQ,IAAI;EACxB,MAAM,OAAO,MACV,QAAO,MAAK,QAAQ,KAAK,IAAI,WAAW,IAAI,GAAG,CAAC,CAAC,CACjD,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,MAAM,MAAM,QAAQ,GAAG;EAEpE,MAAM,WAAW,KAAK,YAAY,aAAa,SAAS,MAAM,GAAG,CAAC;EAClE,MAAM,UAAU,QAAQ,QAAQ;EAEhC,IAAI,CAAC,WAAW,OAAO,GACrB,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAGxC,OAAO,MAAM,QAAQ;CACvB;AACF;;AAGA,SAAS,WAAW,SAAyB;CAC3C,MAAM,aAAa,QAAQ,MAAM,QAAQ,CAAC,CAAC;CAE3C,OAAO,QAAQ,SAAS,KAAK,UAAU,IAAI,aAAa,QAAQ,UAAU,CAAC;AAC7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/config/index.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { resolve, dirname, extname, join } from 'pathe'\nimport { createJiti } from 'jiti'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { createDefu } from 'defu'\n\n// defu that replaces arrays: if user provides content: ['x'], it replaces the default, not appends\nconst merge = createDefu((obj, key, value) => {\n if (Array.isArray(obj[key])) {\n obj[key] = value\n return true\n }\n})\nimport { defaults } from './defaults.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport { defineConfig } from '../composables/defineConfig.ts'\nexport { defaults } from './defaults.ts'\n\nconst CONFIG_FILES = [\n 'maizzle.config.ts',\n 'maizzle.config.js',\n]\n\n/**\n * Resolve the Maizzle config.\n *\n * Always loads from the config file on disk (maizzle.config.{ts,js}),\n * then merges the programmatic config on top, then fills in defaults.\n */\nexport async function resolveConfig(\n config?: Partial<MaizzleConfig> | string,\n cwd: string = process.cwd(),\n): Promise<MaizzleConfig> {\n // If a string path was provided, load that specific file\n const fileConfig = await loadConfig(\n typeof config === 'string' ? config : undefined,\n cwd,\n )\n\n // Programmatic config (object) overrides file config, which overrides defaults\n const programmaticConfig = typeof config === 'object' && config !== null ? config : {}\n\n return normalizeConfig(programmaticConfig, fileConfig, cwd)\n}\n\n/**\n * Resolve config from a programmatic object only — never touches disk.\n *\n * `render()` uses this so a stray `maizzle.config.{ts,js}` in `cwd` can't\n * silently alter output: the config you pass is the config you get, layered\n * over defaults. Callers who want the project's file config load it\n * explicitly via {@link resolveConfig} and pass the result in.\n */\nexport function resolveConfigObject(\n config?: Partial<MaizzleConfig>,\n cwd: string = process.cwd(),\n): MaizzleConfig {\n const programmaticConfig = config && typeof config === 'object' ? config : {}\n return normalizeConfig(programmaticConfig, {}, cwd)\n}\n\n/**\n * Merge programmatic config over file config over defaults, then resolve\n * filesystem paths (root, content, static, components) relative to cwd/root.\n */\nfunction normalizeConfig(\n programmaticConfig: Partial<MaizzleConfig>,\n fileConfig: Partial<MaizzleConfig>,\n cwd: string,\n): MaizzleConfig {\n const merged = merge(programmaticConfig, fileConfig, defaults) as MaizzleConfig\n\n // Check if root was explicitly provided before resolving\n const hasExplicitRoot = !!(programmaticConfig.root ?? fileConfig.root)\n\n // Resolve root to an absolute path (defaults to cwd)\n const root = resolve(cwd, merged.root ?? '.')\n merged.root = root\n\n // Resolve content patterns relative to root\n if (merged.content) {\n merged.content = merged.content.map(p => {\n // Skip already-absolute or negated patterns\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p)\n })\n }\n\n // Resolve static source patterns relative to root\n if (merged.static?.source) {\n merged.static.source = merged.static.source.map(p => {\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p)\n })\n }\n\n /**\n * Resolve components.source paths relative to cwd (not root), since extra\n * component dirs often live outside the root directory. String\n * entries → resolve in-place. Object entries → resolve\n * `path`, preserve `prefix`/`pathPrefix`.\n */\n if (merged.components?.source) {\n const dirs = Array.isArray(merged.components.source)\n ? merged.components.source\n : [merged.components.source]\n\n merged.components.source = dirs.map(entry => {\n if (typeof entry === 'string') {\n return entry.startsWith('/') ? entry : resolve(cwd, entry)\n }\n return {\n ...entry,\n path: entry.path.startsWith('/') ? entry.path : resolve(cwd, entry.path),\n }\n })\n }\n\n /**\n * Default css.base to root when root is explicitly set, so Tailwind resolves\n * @source from the right directory. When root is not set, leave\n * css.base undefined so Tailwind uses its own default (the\n * template file's directory).\n */\n if (hasExplicitRoot && !merged.css?.base) {\n if (!merged.css) merged.css = {}\n merged.css.base = root\n }\n\n return merged\n}\n\n/**\n * Whether Node can natively `import()` this file as ESM — true for `.mjs`\n * and for `.js` whose nearest package.json declares `\"type\": \"module\"`.\n * jiti hands such files to Node's native loader, which caches them in the\n * (unbustable) module registry, so we import them ourselves with a fresh\n * query instead. Everything else (CJS, TS) goes through jiti, which already\n * re-evaluates per instance.\n */\nexport function isNativeESM(absolutePath: string): boolean {\n const ext = extname(absolutePath)\n if (ext === '.mjs') return true\n if (ext === '.cjs' || ext === '.ts' || ext === '.mts' || ext === '.cts') return false\n\n let dir = dirname(absolutePath)\n for (;;) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n return JSON.parse(readFileSync(pkgPath, 'utf-8')).type === 'module'\n } catch {\n return false\n }\n }\n const parent = dirname(dir)\n if (parent === dir) return false\n dir = parent\n }\n}\n\n/**\n * Monotonic nonce appended to native-import URLs so each load is fresh even\n * when two reloads land in the same millisecond.\n */\nlet configLoadNonce = 0\n\nasync function importConfig(absolutePath: string, jiti: ReturnType<typeof createJiti>): Promise<MaizzleConfig> {\n if (isNativeESM(absolutePath)) {\n const url = `${pathToFileURL(absolutePath).href}?t=${Date.now()}-${configLoadNonce++}`\n const mod = await import(url) as any\n return mod.default ?? mod\n }\n\n const mod = await jiti.import(absolutePath) as any\n return mod.default ?? mod\n}\n\nasync function loadConfig(\n configPath?: string,\n cwd: string = process.cwd(),\n): Promise<MaizzleConfig> {\n const jiti = createJiti(fileURLToPath(import.meta.url), { moduleCache: false })\n\n // If an explicit path was provided, use it directly\n if (configPath) {\n const absolutePath = resolve(cwd, configPath)\n\n if (!existsSync(absolutePath)) {\n throw new Error(`Config file not found: ${absolutePath}`)\n }\n\n return importConfig(absolutePath, jiti)\n }\n\n // Otherwise scan cwd for known config file names\n for (const filename of CONFIG_FILES) {\n const filepath = resolve(cwd, filename)\n\n if (existsSync(filepath)) {\n return importConfig(filepath, jiti)\n }\n }\n\n // No config file found, return empty (defaults will be applied by resolveConfig)\n return {}\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,QAAQ,YAAY,KAAK,KAAK,UAAU;CAC5C,IAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;EAC3B,IAAI,OAAO;EACX,OAAO;CACT;AACF,CAAC;AAOD,MAAM,eAAe,CACnB,qBACA,mBACF;;;;;;;AAQA,eAAsB,cACpB,QACA,MAAc,QAAQ,IAAI,GACF;CAExB,MAAM,aAAa,MAAM,WACvB,OAAO,WAAW,WAAW,SAAS,KAAA,GACtC,GACF;CAKA,OAAO,gBAFoB,OAAO,WAAW,YAAY,WAAW,OAAO,SAAS,CAAC,GAE1C,YAAY,GAAG;AAC5D;;;;;;;;;AAUA,SAAgB,oBACd,QACA,MAAc,QAAQ,IAAI,GACX;CAEf,OAAO,gBADoB,UAAU,OAAO,WAAW,WAAW,SAAS,CAAC,GACjC,CAAC,GAAG,GAAG;AACpD;;;;;AAMA,SAAS,gBACP,oBACA,YACA,KACe;CACf,MAAM,SAAS,MAAM,oBAAoB,YAAY,QAAQ;CAG7D,MAAM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;EACP,MAAM,UAAU,KAAK,KAAK,cAAc;EACxC,IAAI,WAAW,OAAO,GACpB,IAAI;GACF,OAAO,KAAK,MAAM,aAAa,SAAS,OAAO,CAAC,CAAC,CAAC,SAAS;EAC7D,QAAQ;GACN,OAAO;EACT;EAEF,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF;;;;;AAMA,IAAI,kBAAkB;AAEtB,eAAe,aAAa,cAAsB,MAA6D;CAC7G,IAAI,YAAY,YAAY,GAAG;EAE7B,MAAM,MAAM,MAAM,OAAO,GADV,cAAc,YAAY,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,EAAE,GAAG;EAEnE,OAAO,IAAI,WAAW;CACxB;CAEA,MAAM,MAAM,MAAM,KAAK,OAAO,YAAY;CAC1C,OAAO,IAAI,WAAW;AACxB;AAEA,eAAe,WACb,YACA,MAAc,QAAQ,IAAI,GACF;CACxB,MAAM,OAAO,WAAW,cAAc,OAAO,KAAK,GAAG,GAAG,EAAE,aAAa,MAAM,CAAC;CAG9E,IAAI,YAAY;EACd,MAAM,eAAe,QAAQ,KAAK,UAAU;EAE5C,IAAI,CAAC,WAAW,YAAY,GAC1B,MAAM,IAAI,MAAM,0BAA0B,cAAc;EAG1D,OAAO,aAAa,cAAc,IAAI;CACxC;CAGA,KAAK,MAAM,YAAY,cAAc;EACnC,MAAM,WAAW,QAAQ,KAAK,QAAQ;EAEtC,IAAI,WAAW,QAAQ,GACrB,OAAO,aAAa,UAAU,IAAI;CAEtC;CAGA,OAAO,CAAC;AACV"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/config/index.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { resolve, dirname, extname, join } from 'pathe'\nimport { createJiti } from 'jiti'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { createDefu } from 'defu'\n\n// defu that replaces arrays: if user provides content: ['x'], it replaces the default, not appends\nconst merge = createDefu((obj, key, value) => {\n if (Array.isArray(obj[key])) {\n obj[key] = value\n return true\n }\n})\nimport { defaults } from './defaults.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport { defineConfig } from '../composables/defineConfig.ts'\nexport { defaults } from './defaults.ts'\n\nconst CONFIG_FILES = [\n 'maizzle.config.ts',\n 'maizzle.config.js',\n]\n\n/**\n * Resolve the Maizzle config.\n *\n * Always loads from the config file on disk (maizzle.config.{ts,js}),\n * then merges the programmatic config on top, then fills in defaults.\n */\nexport async function resolveConfig(\n config?: Partial<MaizzleConfig> | string,\n cwd: string = process.cwd(),\n): Promise<MaizzleConfig> {\n // If a string path was provided, load that specific file\n const fileConfig = await loadConfig(\n typeof config === 'string' ? config : undefined,\n cwd,\n )\n\n // Programmatic config (object) overrides file config, which overrides defaults\n const programmaticConfig = typeof config === 'object' && config !== null ? config : {}\n\n return normalizeConfig(programmaticConfig, fileConfig, cwd)\n}\n\n/**\n * Resolve config from a programmatic object only — never touches disk.\n *\n * `render()` uses this so a stray `maizzle.config.{ts,js}` in `cwd` can't\n * silently alter output: the config you pass is the config you get, layered\n * over defaults. Callers who want the project's file config load it\n * explicitly via {@link resolveConfig} and pass the result in.\n */\nexport function resolveConfigObject(\n config?: Partial<MaizzleConfig>,\n cwd: string = process.cwd(),\n): MaizzleConfig {\n const programmaticConfig = config && typeof config === 'object' ? config : {}\n return normalizeConfig(programmaticConfig, {}, cwd)\n}\n\n/**\n * Merge programmatic config over file config over defaults, then resolve\n * filesystem paths (root, content, static, components) relative to cwd/root.\n */\nfunction normalizeConfig(\n programmaticConfig: Partial<MaizzleConfig>,\n fileConfig: Partial<MaizzleConfig>,\n cwd: string,\n): MaizzleConfig {\n const merged = merge(programmaticConfig, fileConfig, defaults) as MaizzleConfig\n\n // Check if root was explicitly provided before resolving\n const hasExplicitRoot = !!(programmaticConfig.root ?? fileConfig.root)\n\n // Resolve root to an absolute path (defaults to cwd)\n const root = resolve(cwd, merged.root ?? '.')\n merged.root = root\n\n // Resolve content patterns relative to root\n if (merged.content) {\n merged.content = merged.content.map(p => {\n // Skip already-absolute or negated patterns\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p)\n })\n }\n\n // Resolve static source patterns relative to root\n if (merged.static?.source) {\n merged.static.source = merged.static.source.map(p => {\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p)\n })\n }\n\n /**\n * Resolve components.source paths relative to cwd (not root), since extra\n * component dirs often live outside the root directory. String\n * entries → resolve in-place. Object entries → resolve\n * `path`, preserve `prefix`/`pathPrefix`.\n */\n if (merged.components?.source) {\n const dirs = Array.isArray(merged.components.source)\n ? merged.components.source\n : [merged.components.source]\n\n merged.components.source = dirs.map(entry => {\n if (typeof entry === 'string') {\n return entry.startsWith('/') ? entry : resolve(cwd, entry)\n }\n return {\n ...entry,\n path: entry.path.startsWith('/') ? entry.path : resolve(cwd, entry.path),\n }\n })\n }\n\n /**\n * Default css.base to root when root is explicitly set, so Tailwind resolves\n * @source from the right directory. When root is not set, leave\n * css.base undefined so Tailwind uses its own default (the\n * template file's directory).\n */\n if (hasExplicitRoot && !merged.css?.base) {\n if (!merged.css) merged.css = {}\n merged.css.base = root\n }\n\n return merged\n}\n\n/**\n * Whether Node can natively `import()` this file as ESM — true for `.mjs`\n * and for `.js` whose nearest package.json declares `\"type\": \"module\"`.\n * jiti hands such files to Node's native loader, which caches them in the\n * (unbustable) module registry, so we import them ourselves with a fresh\n * query instead. Everything else (CJS, TS) goes through jiti, which already\n * re-evaluates per instance.\n */\nexport function isNativeESM(absolutePath: string): boolean {\n const ext = extname(absolutePath)\n if (ext === '.mjs') return true\n if (ext === '.cjs' || ext === '.ts' || ext === '.mts' || ext === '.cts') return false\n\n let dir = dirname(absolutePath)\n for (;;) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n return JSON.parse(readFileSync(pkgPath, 'utf-8')).type === 'module'\n } catch {\n return false\n }\n }\n const parent = dirname(dir)\n if (parent === dir) return false\n dir = parent\n }\n}\n\n/**\n * Monotonic nonce appended to native-import URLs so each load is fresh even\n * when two reloads land in the same millisecond.\n */\nlet configLoadNonce = 0\n\nasync function importConfig(absolutePath: string, jiti: ReturnType<typeof createJiti>): Promise<MaizzleConfig> {\n if (isNativeESM(absolutePath)) {\n const url = `${pathToFileURL(absolutePath).href}?t=${Date.now()}-${configLoadNonce++}`\n const mod = await import(url) as any\n return mod.default ?? mod\n }\n\n const mod = await jiti.import(absolutePath) as any\n return mod.default ?? mod\n}\n\nasync function loadConfig(\n configPath?: string,\n cwd: string = process.cwd(),\n): Promise<MaizzleConfig> {\n const jiti = createJiti(fileURLToPath(import.meta.url), { moduleCache: false })\n\n // If an explicit path was provided, use it directly\n if (configPath) {\n const absolutePath = resolve(cwd, configPath)\n\n if (!existsSync(absolutePath)) {\n throw new Error(`Config file not found: ${absolutePath}`)\n }\n\n return importConfig(absolutePath, jiti)\n }\n\n // Otherwise scan cwd for known config file names\n for (const filename of CONFIG_FILES) {\n const filepath = resolve(cwd, filename)\n\n if (existsSync(filepath)) {\n return importConfig(filepath, jiti)\n }\n }\n\n // No config file found, return empty (defaults will be applied by resolveConfig)\n return {}\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,QAAQ,YAAY,KAAK,KAAK,UAAU;CAC5C,IAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;EAC3B,IAAI,OAAO;EACX,OAAO;CACT;AACF,CAAC;AAOD,MAAM,eAAe,CACnB,qBACA,mBACF;;;;;;;AAQA,eAAsB,cACpB,QACA,MAAc,QAAQ,IAAI,GACF;CAExB,MAAM,aAAa,MAAM,WACvB,OAAO,WAAW,WAAW,SAAS,KAAA,GACtC,GACF;CAKA,OAAO,gBAFoB,OAAO,WAAW,YAAY,WAAW,OAAO,SAAS,CAAC,GAE1C,YAAY,GAAG;AAC5D;;;;;;;;;AAUA,SAAgB,oBACd,QACA,MAAc,QAAQ,IAAI,GACX;CAEf,OAAO,gBADoB,UAAU,OAAO,WAAW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IAAI,QAAQ,QAAQ,OAAO;CAC3B,IAAI,QAAQ,UAAU,QAAQ,SAAS,QAAQ,UAAU,QAAQ,QAAQ,OAAO;CAEhF,IAAI,MAAM,QAAQ,YAAY;CAC9B,SAAS;EACP,MAAM,UAAU,KAAK,KAAK,cAAc;EACxC,IAAI,WAAW,OAAO,GACpB,IAAI;GACF,OAAO,KAAK,MAAM,aAAa,SAAS,OAAO,CAAC,CAAC,CAAC,SAAS;EAC7D,QAAQ;GACN,OAAO;EACT;EAEF,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF;;;;;AAMA,IAAI,kBAAkB;AAEtB,eAAe,aAAa,cAAsB,MAA6D;CAC7G,IAAI,YAAY,YAAY,GAAG;EAE7B,MAAM,MAAM,MAAM,OAAO,GADV,cAAc,YAAY,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,EAAE,GAAG;EAEnE,OAAO,IAAI,WAAW;CACxB;CAEA,MAAM,MAAM,MAAM,KAAK,OAAO,YAAY;CAC1C,OAAO,IAAI,WAAW;AACxB;AAEA,eAAe,WACb,YACA,MAAc,QAAQ,IAAI,GACF;CACxB,MAAM,OAAO,WAAW,cAAc,YAAY,GAAG,GAAG,EAAE,aAAa,MAAM,CAAC;CAG9E,IAAI,YAAY;EACd,MAAM,eAAe,QAAQ,KAAK,UAAU;EAE5C,IAAI,CAAC,WAAW,YAAY,GAC1B,MAAM,IAAI,MAAM,0BAA0B,cAAc;EAG1D,OAAO,aAAa,cAAc,IAAI;CACxC;CAGA,KAAK,MAAM,YAAY,cAAc;EACnC,MAAM,WAAW,QAAQ,KAAK,QAAQ;EAEtC,IAAI,WAAW,QAAQ,GACrB,OAAO,aAAa,UAAU,IAAI;CAEtC;CAGA,OAAO,CAAC;AACV"}
@@ -13,7 +13,8 @@ import sortMediaQueries from "postcss-sort-media-queries";
13
13
  function mergeMediaQueries(config) {
14
14
  const media = config.css?.media;
15
15
  if (media === false) return null;
16
- return sortMediaQueries({ sort: (typeof media === "object" ? media : {}).sort ?? "mobile-first" });
16
+ const sort = (typeof media === "object" ? media : {}).sort ?? "mobile-first";
17
+ return sortMediaQueries({ sort });
17
18
  }
18
19
  //#endregion
19
20
  export { mergeMediaQueries };
@@ -1 +1 @@
1
- {"version":3,"file":"mergeMediaQueries.js","names":[],"sources":["../../../src/plugins/postcss/mergeMediaQueries.ts"],"sourcesContent":["import sortMediaQueries from 'postcss-sort-media-queries'\nimport type postcss from 'postcss'\nimport type { MaizzleConfig } from '../../types/config.ts'\n\n/**\n * Sorts and merges CSS media queries using postcss-sort-media-queries.\n *\n * Enabled by default. Opt out with css: { media: false }.\n *\n * Config examples:\n * css: { media: true } // merge, mobile-first sort (default)\n * css: { media: { sort: 'desktop-first' } } // merge, desktop-first sort\n * css: { media: false } // disabled\n */\nexport function mergeMediaQueries(config: MaizzleConfig): postcss.Plugin | null {\n const media = config.css?.media\n\n if (media === false) return null\n\n const options = typeof media === 'object' ? media : {}\n const sort = options.sort ?? 'mobile-first'\n\n return sortMediaQueries({ sort }) as postcss.Plugin\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,kBAAkB,QAA8C;CAC9E,MAAM,QAAQ,OAAO,KAAK;CAE1B,IAAI,UAAU,OAAO,OAAO;CAK5B,OAAO,iBAAiB,EAAE,OAHV,OAAO,UAAU,WAAW,QAAQ,CAAC,EAAA,CAChC,QAAQ,eAEE,CAAC;AAClC"}
1
+ {"version":3,"file":"mergeMediaQueries.js","names":[],"sources":["../../../src/plugins/postcss/mergeMediaQueries.ts"],"sourcesContent":["import sortMediaQueries from 'postcss-sort-media-queries'\nimport type postcss from 'postcss'\nimport type { MaizzleConfig } from '../../types/config.ts'\n\n/**\n * Sorts and merges CSS media queries using postcss-sort-media-queries.\n *\n * Enabled by default. Opt out with css: { media: false }.\n *\n * Config examples:\n * css: { media: true } // merge, mobile-first sort (default)\n * css: { media: { sort: 'desktop-first' } } // merge, desktop-first sort\n * css: { media: false } // disabled\n */\nexport function mergeMediaQueries(config: MaizzleConfig): postcss.Plugin | null {\n const media = config.css?.media\n\n if (media === false) return null\n\n const options = typeof media === 'object' ? media : {}\n const sort = options.sort ?? 'mobile-first'\n\n return sortMediaQueries({ sort }) as postcss.Plugin\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,kBAAkB,QAA8C;CAC9E,MAAM,QAAQ,OAAO,KAAK;CAE1B,IAAI,UAAU,OAAO,OAAO;CAG5B,MAAM,QADU,OAAO,UAAU,WAAW,QAAQ,CAAC,EAAA,CAChC,QAAQ;CAE7B,OAAO,iBAAiB,EAAE,KAAK,CAAC;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveMaizzleImports.js","names":[],"sources":["../../../src/plugins/postcss/resolveMaizzleImports.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport type { Plugin } from 'postcss'\n\nconst PKG = '@maizzle/tailwindcss'\nconst SUBPATH_RE = new RegExp(`^${PKG}(?:/|$)`)\n\nconst requireFromFramework = createRequire(import.meta.url)\n\n/**\n * Rewrite `@import \"@maizzle/tailwindcss\"` (and subpaths like\n * `@maizzle/tailwindcss/mso`) to absolute file paths so postcss/Tailwind\n * can resolve them regardless of where the user's template lives or how\n * their package manager hoists dependencies.\n *\n * Resolution order: prefer the user's project copy (so explicit installs\n * win), then fall back to the copy bundled with the framework.\n */\nexport function resolveMaizzleImports(userRoot: string = process.cwd()): Plugin {\n const requireFromUser = createRequire(`${userRoot}/_maizzle.js`)\n\n function resolve(spec: string): string | undefined {\n try { return requireFromUser.resolve(spec) } catch {}\n try { return requireFromFramework.resolve(spec) } catch {}\n return undefined\n }\n\n return {\n postcssPlugin: 'maizzle:resolve-tw-imports',\n AtRule: {\n import(rule) {\n const m = rule.params.match(/^\\s*[\"']([^\"']+)[\"']/)\n if (!m) return\n const spec = m[1]\n if (!SUBPATH_RE.test(spec)) return\n\n const abs = resolve(spec)\n if (abs) rule.params = rule.params.replace(m[0], `\"${abs}\"`)\n },\n },\n }\n}\n"],"mappings":";;AAIA,MAAM,aAAa,IAAI,OAAO,8BAAgB;AAE9C,MAAM,uBAAuB,cAAc,OAAO,KAAK,GAAG;;;;;;;;;;AAW1D,SAAgB,sBAAsB,WAAmB,QAAQ,IAAI,GAAW;CAC9E,MAAM,kBAAkB,cAAc,GAAG,SAAS,aAAa;CAE/D,SAAS,QAAQ,MAAkC;EACjD,IAAI;GAAE,OAAO,gBAAgB,QAAQ,IAAI;EAAE,QAAQ,CAAC;EACpD,IAAI;GAAE,OAAO,qBAAqB,QAAQ,IAAI;EAAE,QAAQ,CAAC;CAE3D;CAEA,OAAO;EACL,eAAe;EACf,QAAQ,EACN,OAAO,MAAM;GACX,MAAM,IAAI,KAAK,OAAO,MAAM,sBAAsB;GAClD,IAAI,CAAC,GAAG;GACR,MAAM,OAAO,EAAE;GACf,IAAI,CAAC,WAAW,KAAK,IAAI,GAAG;GAE5B,MAAM,MAAM,QAAQ,IAAI;GACxB,IAAI,KAAK,KAAK,SAAS,KAAK,OAAO,QAAQ,EAAE,IAAI,IAAI,IAAI,EAAE;EAC7D,EACF;CACF;AACF"}
1
+ {"version":3,"file":"resolveMaizzleImports.js","names":[],"sources":["../../../src/plugins/postcss/resolveMaizzleImports.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport type { Plugin } from 'postcss'\n\nconst PKG = '@maizzle/tailwindcss'\nconst SUBPATH_RE = new RegExp(`^${PKG}(?:/|$)`)\n\nconst requireFromFramework = createRequire(import.meta.url)\n\n/**\n * Rewrite `@import \"@maizzle/tailwindcss\"` (and subpaths like\n * `@maizzle/tailwindcss/mso`) to absolute file paths so postcss/Tailwind\n * can resolve them regardless of where the user's template lives or how\n * their package manager hoists dependencies.\n *\n * Resolution order: prefer the user's project copy (so explicit installs\n * win), then fall back to the copy bundled with the framework.\n */\nexport function resolveMaizzleImports(userRoot: string = process.cwd()): Plugin {\n const requireFromUser = createRequire(`${userRoot}/_maizzle.js`)\n\n function resolve(spec: string): string | undefined {\n try { return requireFromUser.resolve(spec) } catch {}\n try { return requireFromFramework.resolve(spec) } catch {}\n return undefined\n }\n\n return {\n postcssPlugin: 'maizzle:resolve-tw-imports',\n AtRule: {\n import(rule) {\n const m = rule.params.match(/^\\s*[\"']([^\"']+)[\"']/)\n if (!m) return\n const spec = m[1]\n if (!SUBPATH_RE.test(spec)) return\n\n const abs = resolve(spec)\n if (abs) rule.params = rule.params.replace(m[0], `\"${abs}\"`)\n },\n },\n }\n}\n"],"mappings":";;AAIA,MAAM,aAAa,IAAI,OAAO,8BAAgB;AAE9C,MAAM,uBAAuB,cAAc,YAAY,GAAG;;;;;;;;;;AAW1D,SAAgB,sBAAsB,WAAmB,QAAQ,IAAI,GAAW;CAC9E,MAAM,kBAAkB,cAAc,GAAG,SAAS,aAAa;CAE/D,SAAS,QAAQ,MAAkC;EACjD,IAAI;GAAE,OAAO,gBAAgB,QAAQ,IAAI;EAAE,QAAQ,CAAC;EACpD,IAAI;GAAE,OAAO,qBAAqB,QAAQ,IAAI;EAAE,QAAQ,CAAC;CAE3D;CAEA,OAAO;EACL,eAAe;EACf,QAAQ,EACN,OAAO,MAAM;GACX,MAAM,IAAI,KAAK,OAAO,MAAM,sBAAsB;GAClD,IAAI,CAAC,GAAG;GACR,MAAM,OAAO,EAAE;GACf,IAAI,CAAC,WAAW,KAAK,IAAI,GAAG;GAE5B,MAAM,MAAM,QAAQ,IAAI;GACxB,IAAI,KAAK,KAAK,SAAS,KAAK,OAAO,QAAQ,EAAE,IAAI,IAAI,IAAI,EAAE;EAC7D,EACF;CACF;AACF"}
@@ -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,
@@ -133,7 +133,9 @@ function commonPath(a, b) {
133
133
  }
134
134
  function resolveOutputPath(templatePath, outputDir, extension, contentBase) {
135
135
  const name = basename(templatePath).replace(/\.(vue|md)$/, "");
136
- return join(outputDir, relative(contentBase, dirname(resolve(templatePath))), `${name}.${extension}`);
136
+ const absTemplate = resolve(templatePath);
137
+ const rel = relative(contentBase, dirname(absTemplate));
138
+ return join(outputDir, rel, `${name}.${extension}`);
137
139
  }
138
140
  //#endregion
139
141
  export { buildTemplate, computeContentBase, resolveOutputPath };
@@ -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,iBAAiB,SAAS;EAEhC,IAAI,O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}
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,MAAM,UAAU,aAAa,IAAI;EACjC,MAAM,gBAAgB,SAAS;EAC/B,IAAI;EA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AAY,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";
@@ -343,7 +343,48 @@ async function createRenderer(options = {}) {
343
343
  logLevel: "silent",
344
344
  optimizeDeps: { noDiscovery: true }
345
345
  };
346
- const server = await createServer(userViteConfig ? mergeConfig(userViteConfig, maizzleConfig) : maizzleConfig);
346
+ /**
347
+ * Merge user's vite config (from config.vite) under Maizzle's config.
348
+ * mergeConfig(a, b) → b overrides a for scalars, arrays concatenate.
349
+ * This ensures Maizzle's critical settings (middlewareMode, appType,
350
+ * etc.) always win, while user plugins and other options remain.
351
+ */
352
+ const finalConfig = userViteConfig ? mergeConfig(userViteConfig, maizzleConfig) : maizzleConfig;
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
+ }
347
388
  return {
348
389
  async render(input, config, opts) {
349
390
  let component;
@@ -456,9 +497,11 @@ async function createRenderer(options = {}) {
456
497
  const previewHtml = `<div style="display:none">${text}${" ͏ ".repeat(fillerCount)}\u00A0</div>`;
457
498
  html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`);
458
499
  }
500
+ const sourceFiles = typeof input === "string" && !input.includes("<template") && !input.includes("<script") ? collectSourceFiles(input) : void 0;
459
501
  return {
460
502
  html,
461
503
  doctype: renderContext.doctype,
504
+ sourceFiles,
462
505
  /**
463
506
  * Layer sfcConfig over config — sfcConfig is a partial override
464
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,OAAO,KAAK,GAAG,CAAC;AAExD,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,QAAQ,kBAAkB,CAAC,CAAC;AAChF,MAAM,0BAA0B,QAAQ,cAAc,OAAO,KAAK,QAAQ,mCAAmC,CAAC,CAAC;AAC/G,MAAM,kBAAkB,QAAQ,QAAQ,cAAc,OAAO,KAAK,QAAQ,aAAa,CAAC,CAAC,GAAG,IAAI;AAChG,MAAM,kBAAkB,QAAQ,cAAc,OAAO,KAAK,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,G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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"}
1
+ {"version":3,"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,kBA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