@maizzle/framework 6.0.0-rc.23 → 6.0.0-rc.24
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.
- package/dist/build.js +11 -2
- package/dist/build.js.map +1 -1
- package/dist/components/Markdown.vue +48 -16
- package/dist/composables/renderContext.d.ts +1 -0
- package/dist/composables/renderContext.d.ts.map +1 -1
- package/dist/composables/renderContext.js +1 -1
- package/dist/composables/renderContext.js.map +1 -1
- package/dist/composables/useConfig.d.ts +7 -0
- package/dist/composables/useConfig.d.ts.map +1 -1
- package/dist/composables/useConfig.js +8 -1
- package/dist/composables/useConfig.js.map +1 -1
- package/dist/composables/useOutputPath.d.ts +17 -0
- package/dist/composables/useOutputPath.d.ts.map +1 -0
- package/dist/composables/useOutputPath.js +23 -0
- package/dist/composables/useOutputPath.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/render/createRenderer.d.ts +1 -0
- package/dist/render/createRenderer.d.ts.map +1 -1
- package/dist/render/createRenderer.js +16 -0
- package/dist/render/createRenderer.js.map +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/index.js.map +1 -1
- package/dist/serve.js +3 -3
- package/dist/serve.js.map +1 -1
- package/dist/server/ui/App.vue +3 -4
- package/dist/server/ui/main.css +25 -0
- package/dist/server/ui/pages/Preview.vue +5 -1
- package/package.json +1 -1
- package/dist/server/ui/components/Markdown.vue +0 -17
package/dist/build.js
CHANGED
|
@@ -95,9 +95,15 @@ async function build(configInput) {
|
|
|
95
95
|
template,
|
|
96
96
|
html
|
|
97
97
|
});
|
|
98
|
-
html = `${doctype}\n${html}`;
|
|
98
|
+
if (doctype) html = `${doctype}\n${html}`;
|
|
99
99
|
const htmlOut = stripForHtml(html);
|
|
100
|
-
const
|
|
100
|
+
const sfcOutputPath = rendered.outputPath;
|
|
101
|
+
let outputFilePath;
|
|
102
|
+
if (sfcOutputPath) {
|
|
103
|
+
const parsed = parse(resolve(sfcOutputPath));
|
|
104
|
+
const ext = parsed.ext ? parsed.ext.slice(1) : outputExtension;
|
|
105
|
+
outputFilePath = join(parsed.dir, `${parsed.name}.${ext}`);
|
|
106
|
+
} else outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase);
|
|
101
107
|
mkdirSync(dirname(outputFilePath), { recursive: true });
|
|
102
108
|
writeFileSync(outputFilePath, htmlOut);
|
|
103
109
|
outputFiles.push(outputFilePath);
|
|
@@ -112,6 +118,9 @@ async function build(configInput) {
|
|
|
112
118
|
if (sfcPlaintext?.destination) {
|
|
113
119
|
const name = basename(templatePath).replace(/\.(vue|md)$/, "");
|
|
114
120
|
ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`);
|
|
121
|
+
} else if (sfcOutputPath) {
|
|
122
|
+
const parsed = parse(outputFilePath);
|
|
123
|
+
ptOutputPath = join(parsed.dir, `${parsed.name}.${ptExtension}`);
|
|
115
124
|
} else if (globalCfg.destination) ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase);
|
|
116
125
|
else ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase);
|
|
117
126
|
mkdirSync(dirname(ptOutputPath), { recursive: true });
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","names":["parsePath"],"sources":["../src/build.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join, parse as parsePath } from 'node:path'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport defu from 'defu'\nimport type { MaizzleConfig } from './types/index.ts'\n\nexport interface BuildResult {\n files: string[]\n config: MaizzleConfig\n}\n\n/**\n * Build all SFC email templates to HTML files.\n *\n * Creates a single Renderer instance, then loops through each template\n * calling render → transformers → write to disk.\n *\n * Pass a `Partial<MaizzleConfig>` to override config inline, or a string\n * to load config from a specific file path. Omit to load `maizzle.config`\n * from the working directory.\n */\nexport async function build(configInput?: Partial<MaizzleConfig> | string): Promise<BuildResult> {\n const start = Date.now()\n const spinner = ora({ text: 'Building templates...', spinner: 'circleHalves' }).start()\n\n const config = await resolveConfig(configInput)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const outputPath = resolve(config.output?.path ?? 'dist')\n const outputExtension = config.output?.extension ?? 'html'\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const contentBase = computeContentBase(contentPatterns)\n const templateFiles = await glob(contentPatterns)\n\n if (templateFiles.length === 0) {\n spinner.succeed('No templates found')\n return { files: [], config }\n }\n\n // Clear the output directory before writing fresh output\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true })\n }\n\n const renderer = await createRenderer({ markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n const outputFiles: string[] = []\n\n try {\n for (const templatePath of templateFiles) {\n const absolutePath = resolve(templatePath)\n const parsedPath = parsePath(absolutePath)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsedPath }\n\n _setCurrentTemplate(parsedPath)\n\n try {\n await events.fireBeforeRender({ config, template })\n\n const rendered = await renderer.render(absolutePath, config)\n\n /**\n * Register SFC event handlers collected during render so they take\n * part in the post-render events (afterRender / afterTransform).\n * They're cleared at the end of the iteration so they don't\n * leak into the next template.\n */\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n let html = await events.fireAfterRender({ config, template, html: rendered.html })\n\n /**\n * Use the per-template merged config (from defineConfig() in the SFC) so\n * that template-level overrides like css.safe: false are respected\n * by transformers.\n */\n const templateConfig = rendered.templateConfig\n\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n }\n\n html = await events.fireAfterTransform({ config, template, html })\n html = `${doctype}\\n${html}`\n\n const htmlOut = stripForHtml(html)\n const outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase)\n mkdirSync(dirname(outputFilePath), { recursive: true })\n writeFileSync(outputFilePath, htmlOut)\n outputFiles.push(outputFilePath)\n\n // Generate plaintext version if configured\n const globalPlaintext = templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n const plaintext = createPlaintext(stripForPlaintext(html), stripOptions)\n const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? 'txt'\n\n let ptOutputPath: string\n\n if (sfcPlaintext?.destination) {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`)\n } else if (globalCfg.destination) {\n ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase)\n } else {\n ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase)\n }\n\n mkdirSync(dirname(ptOutputPath), { recursive: true })\n writeFileSync(ptOutputPath, plaintext)\n }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n}\n\n/**\n * Extract the static (non-glob) prefix from content patterns.\n *\n * For example, `['/abs/path/emails/**\\/*.vue']` → `'/abs/path/emails'`\n *\n * This is used to strip the content base from template paths\n * so the output preserves only the subdirectory structure.\n */\nfunction computeContentBase(patterns: string[]): string {\n // Use the first non-negated pattern\n const pattern = patterns.find(p => !p.startsWith('!')) ?? patterns[0]\n\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n}\n\nfunction resolveOutputPath(templatePath: string, outputDir: string, extension: string, contentBase: string): string {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n const absTemplate = resolve(templatePath)\n const rel = relative(contentBase, dirname(absTemplate))\n\n return join(outputDir, rel, `${name}.${extension}`)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n const files = await glob(sources)\n\n for (const file of files) {\n const destPath = join(outputPath, destination, relative(dirname(sources[0]).replace(/\\*.*$/, ''), file))\n const destDir = dirname(destPath)\n\n if (!existsSync(destDir)) {\n mkdirSync(destDir, { recursive: true })\n }\n\n cpSync(file, destPath)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAsB,MAAM,aAAqE;CAC/F,MAAM,QAAQ,KAAK,IAAI;CACvB,MAAM,UAAU,IAAI;EAAE,MAAM;EAAyB,SAAS;CAAe,CAAC,EAAE,MAAM;CAEtF,MAAM,SAAS,MAAM,cAAc,WAAW;CAE9C,MAAM,SAAS,IAAI,aAAa;CAChC,OAAO,eAAe,MAAM;CAC5B,MAAM,OAAO,iBAAiB,EAAE,OAAO,CAAC;CAExC,MAAM,aAAa,QAAQ,OAAO,QAAQ,QAAQ,MAAM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AM,WAAW,UAAU,IAAI,MAAM,GAAG,MAAM,SAAS;CACxE,CAAC;CAED,OAAO;EAAE,OAAO;EAAa;CAAO;AACtC;;;;;;;;;AAUA,SAAS,mBAAmB,UAA4B;CAKtD,MAAM,cAHU,SAAS,MAAK,MAAK,CAAC,EAAE,WAAW,GAAG,CAAC,KAAK,SAAS,IAGxC,MAAM,QAAQ,EAAE;CAG3C,OAAO,QAAQ,WAAW,SAAS,GAAG,IAAI,aAAa,QAAQ,UAAU,CAAC;AAC5E;AAEA,SAAS,kBAAkB,cAAsB,WAAmB,WAAmB,aAA6B;CAClH,MAAM,OAAO,SAAS,YAAY,EAAE,QAAQ,eAAe,EAAE;CAI7D,OAAO,KAAK,WAFA,SAAS,aAAa,QADd,QAAQ,YACwB,CAAC,CAE5B,GAAG,GAAG,KAAK,GAAG,WAAW;AACpD;AAEA,eAAe,WAAW,QAAuB,YAAmC;CAClF,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,eAAe;CACzD,MAAM,cAAc,OAAO,QAAQ,eAAe;CAElD,MAAM,QAAQ,MAAM,KAAK,OAAO;CAEhC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,YAAY,aAAa,SAAS,QAAQ,QAAQ,EAAE,EAAE,QAAQ,SAAS,EAAE,GAAG,IAAI,CAAC;EACvG,MAAM,UAAU,QAAQ,QAAQ;EAEhC,IAAI,CAAC,WAAW,OAAO,GACrB,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAGxC,OAAO,MAAM,QAAQ;CACvB;AACF"}
|
|
1
|
+
{"version":3,"file":"build.js","names":["parsePath"],"sources":["../src/build.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join, parse as parsePath } from 'node:path'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport defu from 'defu'\nimport type { MaizzleConfig } from './types/index.ts'\n\nexport interface BuildResult {\n files: string[]\n config: MaizzleConfig\n}\n\n/**\n * Build all SFC email templates to HTML files.\n *\n * Creates a single Renderer instance, then loops through each template\n * calling render → transformers → write to disk.\n *\n * Pass a `Partial<MaizzleConfig>` to override config inline, or a string\n * to load config from a specific file path. Omit to load `maizzle.config`\n * from the working directory.\n */\nexport async function build(configInput?: Partial<MaizzleConfig> | string): Promise<BuildResult> {\n const start = Date.now()\n const spinner = ora({ text: 'Building templates...', spinner: 'circleHalves' }).start()\n\n const config = await resolveConfig(configInput)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const outputPath = resolve(config.output?.path ?? 'dist')\n const outputExtension = config.output?.extension ?? 'html'\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const contentBase = computeContentBase(contentPatterns)\n const templateFiles = await glob(contentPatterns)\n\n if (templateFiles.length === 0) {\n spinner.succeed('No templates found')\n return { files: [], config }\n }\n\n // Clear the output directory before writing fresh output\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true })\n }\n\n const renderer = await createRenderer({ markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n const outputFiles: string[] = []\n\n try {\n for (const templatePath of templateFiles) {\n const absolutePath = resolve(templatePath)\n const parsedPath = parsePath(absolutePath)\n const template = { source: readFileSync(absolutePath, 'utf-8'), path: parsedPath }\n\n _setCurrentTemplate(parsedPath)\n\n try {\n await events.fireBeforeRender({ config, template })\n\n const rendered = await renderer.render(absolutePath, config)\n\n /**\n * Register SFC event handlers collected during render so they take\n * part in the post-render events (afterRender / afterTransform).\n * They're cleared at the end of the iteration so they don't\n * leak into the next template.\n */\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n let html = await events.fireAfterRender({ config, template, html: rendered.html })\n\n /**\n * Use the per-template merged config (from defineConfig() in the SFC) so\n * that template-level overrides like css.safe: false are respected\n * by transformers.\n */\n const templateConfig = rendered.templateConfig\n\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n }\n\n html = await events.fireAfterTransform({ config, template, html })\n 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 outputFiles.push(outputFilePath)\n\n // Generate plaintext version if configured\n const globalPlaintext = templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n const plaintext = createPlaintext(stripForPlaintext(html), stripOptions)\n const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? 'txt'\n\n let ptOutputPath: string\n\n if (sfcPlaintext?.destination) {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`)\n } else if (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 }\n } finally {\n _setCurrentTemplate(undefined)\n events.clearSfcHandlers()\n }\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n}\n\n/**\n * Extract the static (non-glob) prefix from content patterns.\n *\n * For example, `['/abs/path/emails/**\\/*.vue']` → `'/abs/path/emails'`\n *\n * This is used to strip the content base from template paths\n * so the output preserves only the subdirectory structure.\n */\nfunction computeContentBase(patterns: string[]): string {\n // Use the first non-negated pattern\n const pattern = patterns.find(p => !p.startsWith('!')) ?? patterns[0]\n\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n}\n\nfunction resolveOutputPath(templatePath: string, outputDir: string, extension: string, contentBase: string): string {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n const absTemplate = resolve(templatePath)\n const rel = relative(contentBase, dirname(absTemplate))\n\n return join(outputDir, rel, `${name}.${extension}`)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n const files = await glob(sources)\n\n for (const file of files) {\n const destPath = join(outputPath, destination, relative(dirname(sources[0]).replace(/\\*.*$/, ''), file))\n const destDir = dirname(destPath)\n\n if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,SAAS,aAAa,QADd,QAAQ,YACwB,CAAC,CAE5B,GAAG,GAAG,KAAK,GAAG,WAAW;AACpD;AAEA,eAAe,WAAW,QAAuB,YAAmC;CAClF,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,eAAe;CACzD,MAAM,cAAc,OAAO,QAAQ,eAAe;CAElD,MAAM,QAAQ,MAAM,KAAK,OAAO;CAEhC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,YAAY,aAAa,SAAS,QAAQ,QAAQ,EAAE,EAAE,QAAQ,SAAS,EAAE,GAAG,IAAI,CAAC;EACvG,MAAM,UAAU,QAAQ,QAAQ;EAEhC,IAAI,CAAC,WAAW,OAAO,GACrB,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAGxC,OAAO,MAAM,QAAQ;CACvB;AACF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { createStaticVNode, type PropType } from 'vue'
|
|
2
|
+
import { createStaticVNode, inject, type PropType } from 'vue'
|
|
3
3
|
import { createMarkdownExit, type MarkdownExitOptions } from 'markdown-exit'
|
|
4
4
|
import { codeToHtml, type BundledTheme } from 'shiki'
|
|
5
|
+
import { defu } from 'defu'
|
|
6
|
+
import { MaizzleConfigKey } from '../composables/useConfig.ts'
|
|
5
7
|
|
|
6
8
|
export default {
|
|
7
9
|
props: {
|
|
@@ -15,17 +17,21 @@ export default {
|
|
|
15
17
|
type: String,
|
|
16
18
|
default: ''
|
|
17
19
|
},
|
|
18
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Shiki theme for fenced code blocks. Falls back to
|
|
22
|
+
* `markdown.shikiTheme` from the config, then to
|
|
23
|
+
* `'github-dark-high-contrast'`.
|
|
24
|
+
*/
|
|
19
25
|
shikiTheme: {
|
|
20
26
|
type: String as PropType<BundledTheme>,
|
|
21
|
-
default:
|
|
27
|
+
default: undefined
|
|
22
28
|
},
|
|
23
29
|
/** Wrap output in a div element. @default false */
|
|
24
30
|
wrapper: {
|
|
25
31
|
type: Boolean,
|
|
26
32
|
default: false
|
|
27
33
|
},
|
|
28
|
-
/** markdown-exit configuration options.
|
|
34
|
+
/** markdown-exit configuration options. Takes precedence over `markdown.markdownOptions` from the config. */
|
|
29
35
|
config: {
|
|
30
36
|
type: Object as PropType<MarkdownExitOptions>,
|
|
31
37
|
default: () => ({})
|
|
@@ -48,19 +54,45 @@ export default {
|
|
|
48
54
|
return () => createStaticVNode('', 0)
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Pull the global `markdown` config (when rendered inside a Maizzle
|
|
59
|
+
* build) so the component honors the same options and plugins as
|
|
60
|
+
* `.md` templates. Props override the config; both fall back to the
|
|
61
|
+
* component defaults. `inject` over `useConfig()` so the component
|
|
62
|
+
* still works standalone, when no config is provided.
|
|
63
|
+
*/
|
|
64
|
+
const mdConfig = inject(MaizzleConfigKey, undefined)?.markdown ?? {}
|
|
65
|
+
const markdownOptions = mdConfig.markdownOptions ?? mdConfig.markdownItOptions
|
|
66
|
+
const markdownUses = mdConfig.markdownUses ?? mdConfig.markdownItUses
|
|
67
|
+
const markdownSetup = mdConfig.markdownSetup ?? mdConfig.markdownItSetup
|
|
68
|
+
const theme = props.shikiTheme ?? mdConfig.shikiTheme ?? 'github-dark-high-contrast'
|
|
69
|
+
|
|
70
|
+
const md = createMarkdownExit(defu(
|
|
71
|
+
props.config,
|
|
72
|
+
markdownOptions ?? {},
|
|
73
|
+
{
|
|
74
|
+
html: true,
|
|
75
|
+
linkify: true,
|
|
76
|
+
typographer: true,
|
|
77
|
+
highlight: async (code: string, lang: string) => {
|
|
78
|
+
try {
|
|
79
|
+
return await codeToHtml(code, { lang, theme })
|
|
80
|
+
} catch {
|
|
81
|
+
return ''
|
|
82
|
+
}
|
|
83
|
+
},
|
|
61
84
|
},
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
))
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Apply config plugins before overriding the fence rules, so the
|
|
89
|
+
* code-block wrapping below composes over whatever they emit.
|
|
90
|
+
*/
|
|
91
|
+
for (const use of markdownUses ?? []) {
|
|
92
|
+
if (Array.isArray(use)) md.use(...use)
|
|
93
|
+
else md.use(use)
|
|
94
|
+
}
|
|
95
|
+
await markdownSetup?.(md)
|
|
64
96
|
|
|
65
97
|
const wrapPre = (html: string) =>
|
|
66
98
|
`<table class="w-full"><tr><td class="max-w-0 mso-padding-alt-4">${html}</td></tr></table>\n`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderContext.d.ts","names":[],"sources":["../../src/composables/renderContext.ts"],"mappings":";;;;;;UAKiB,gBAAA;EACf,MAAA;EACA,IAAA;EACA,WAAA;EACA,GAAA;AAAA;AAAA,UAGe,aAAA;EACf,EAAA;EANA;EAQA,GAAG;AAAA;AAAA,UAGY,aAAA;EACf,OAAA;EACA,SAAA;IAAc,IAAA;IAAc,WAAA;EAAA;EAC5B,SAAA,GAAY,aAAA;EACZ,gBAAA,EAAkB,KAAA;IAAQ,IAAA,EAAM,SAAA;IAAW,OAAA,EAAS,QAAA,CAAS,SAAA;EAAA;EAC7D,SAAA,GAAY,mBAAA;EACZ,KAAA,GAAQ,gBAAA;EACR,cAAA,GAAiB,aAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"renderContext.d.ts","names":[],"sources":["../../src/composables/renderContext.ts"],"mappings":";;;;;;UAKiB,gBAAA;EACf,MAAA;EACA,IAAA;EACA,WAAA;EACA,GAAA;AAAA;AAAA,UAGe,aAAA;EACf,EAAA;EANA;EAQA,GAAG;AAAA;AAAA,UAGY,aAAA;EACf,OAAA;EACA,SAAA;IAAc,IAAA;IAAc,WAAA;EAAA;EAC5B,SAAA,GAAY,aAAA;EACZ,gBAAA,EAAkB,KAAA;IAAQ,IAAA,EAAM,SAAA;IAAW,OAAA,EAAS,QAAA,CAAS,SAAA;EAAA;EAC7D,SAAA,GAAY,mBAAA;EACZ,UAAA;EACA,KAAA,GAAQ,gBAAA;EACR,cAAA,GAAiB,aAAA;AAAA;AAAA,cAIN,gBAAA,EAAkB,YAAY,CAAC,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderContext.js","names":[],"sources":["../../src/composables/renderContext.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\nimport type { UsePlaintextOptions } from './usePlaintext.ts'\n\nexport interface FontRegistration {\n family: string\n slug: string\n declaration: string\n url: string\n}\n\nexport interface TailwindBlock {\n id: string\n /** Optional raw CSS from the component's `#config` slot. */\n css?: string\n}\n\nexport interface RenderContext {\n doctype?: string\n preheader?: { text: string; fillerCount: number }\n sfcConfig?: MaizzleConfig\n sfcEventHandlers: Array<{ name: EventName; handler: EventMap[EventName] }>\n plaintext?: UsePlaintextOptions\n fonts?: FontRegistration[]\n tailwindBlocks?: TailwindBlock[]\n}\n\nexport const RenderContextKey: InjectionKey<RenderContext> = Symbol('
|
|
1
|
+
{"version":3,"file":"renderContext.js","names":[],"sources":["../../src/composables/renderContext.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\nimport type { UsePlaintextOptions } from './usePlaintext.ts'\n\nexport interface FontRegistration {\n family: string\n slug: string\n declaration: string\n url: string\n}\n\nexport interface TailwindBlock {\n id: string\n /** Optional raw CSS from the component's `#config` slot. */\n css?: string\n}\n\nexport interface RenderContext {\n doctype?: string\n preheader?: { text: string; fillerCount: number }\n sfcConfig?: MaizzleConfig\n sfcEventHandlers: Array<{ name: EventName; handler: EventMap[EventName] }>\n plaintext?: UsePlaintextOptions\n outputPath?: string\n fonts?: FontRegistration[]\n tailwindBlocks?: TailwindBlock[]\n}\n\n// Global symbol registry — same rationale as MaizzleConfigKey in useConfig.ts.\nexport const RenderContextKey: InjectionKey<RenderContext> = Symbol.for('maizzle.renderContext')\n"],"mappings":";AA8BA,MAAa,mBAAgD,OAAO,IAAI,uBAAuB"}
|
|
@@ -2,6 +2,13 @@ import { MaizzleConfig } from "../types/config.js";
|
|
|
2
2
|
import { InjectionKey } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/composables/useConfig.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Use the global symbol registry so the key is identical across every
|
|
7
|
+
* module instance. In dev, `render()` (Node) and the SFC's auto-imported
|
|
8
|
+
* composables can resolve to two separate instances of this module; a plain
|
|
9
|
+
* `Symbol()` would differ between them, so `app.provide()` and the SFC's
|
|
10
|
+
* `inject()` would miss each other and `useConfig()` would throw.
|
|
11
|
+
*/
|
|
5
12
|
declare const MaizzleConfigKey: InjectionKey<MaizzleConfig>;
|
|
6
13
|
declare function useConfig(): MaizzleConfig;
|
|
7
14
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.d.ts","names":[],"sources":["../../src/composables/useConfig.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useConfig.d.ts","names":[],"sources":["../../src/composables/useConfig.ts"],"mappings":";;;;;;;AAWA;;;;cAAa,gBAAA,EAAkB,YAAY,CAAC,aAAA;AAAA,iBAE5B,SAAA,CAAA,GAAa,aAAa"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { inject } from "vue";
|
|
2
2
|
//#region src/composables/useConfig.ts
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Use the global symbol registry so the key is identical across every
|
|
5
|
+
* module instance. In dev, `render()` (Node) and the SFC's auto-imported
|
|
6
|
+
* composables can resolve to two separate instances of this module; a plain
|
|
7
|
+
* `Symbol()` would differ between them, so `app.provide()` and the SFC's
|
|
8
|
+
* `inject()` would miss each other and `useConfig()` would throw.
|
|
9
|
+
*/
|
|
10
|
+
const MaizzleConfigKey = Symbol.for("maizzle.config");
|
|
4
11
|
function useConfig() {
|
|
5
12
|
const config = inject(MaizzleConfigKey);
|
|
6
13
|
if (!config) throw new Error("useConfig() requires the Maizzle plugin to provide config. Make sure you are using it inside a Maizzle template.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.js","names":[],"sources":["../../src/composables/useConfig.ts"],"sourcesContent":["import { inject } from 'vue'\nimport type { InjectionKey } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport const MaizzleConfigKey: InjectionKey<MaizzleConfig> = Symbol('
|
|
1
|
+
{"version":3,"file":"useConfig.js","names":[],"sources":["../../src/composables/useConfig.ts"],"sourcesContent":["import { inject } from 'vue'\nimport type { InjectionKey } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\n\n/**\n * Use the global symbol registry so the key is identical across every\n * module instance. In dev, `render()` (Node) and the SFC's auto-imported\n * composables can resolve to two separate instances of this module; a plain\n * `Symbol()` would differ between them, so `app.provide()` and the SFC's\n * `inject()` would miss each other and `useConfig()` would throw.\n */\nexport const MaizzleConfigKey: InjectionKey<MaizzleConfig> = Symbol.for('maizzle.config')\n\nexport function useConfig(): MaizzleConfig {\n const config = inject(MaizzleConfigKey)\n\n if (!config) {\n throw new Error('useConfig() requires the Maizzle plugin to provide config. Make sure you are using it inside a Maizzle template.')\n }\n\n return config\n}\n"],"mappings":";;;;;;;;;AAWA,MAAa,mBAAgD,OAAO,IAAI,gBAAgB;AAExF,SAAgB,YAA2B;CACzC,MAAM,SAAS,OAAO,gBAAgB;CAEtC,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,kHAAkH;CAGpI,OAAO;AACT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/composables/useOutputPath.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Override the output file path for the current template.
|
|
4
|
+
*
|
|
5
|
+
* The path is relative to the project root (cwd); it may be
|
|
6
|
+
* absolute or escape the output directory with `../`. If it
|
|
7
|
+
* has no extension, `output.extension` is appended.
|
|
8
|
+
*
|
|
9
|
+
* Usage in SFC <script setup>:
|
|
10
|
+
* ```ts
|
|
11
|
+
* useOutputPath('dist/promos/black-friday.html')
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare function useOutputPath(path: string): void;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { useOutputPath };
|
|
17
|
+
//# sourceMappingURL=useOutputPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOutputPath.d.ts","names":[],"sources":["../../src/composables/useOutputPath.ts"],"mappings":";;AAeA;;;;AAA0C;;;;;;;iBAA1B,aAAA,CAAc,IAAY"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RenderContextKey } from "./renderContext.js";
|
|
2
|
+
import { inject } from "vue";
|
|
3
|
+
//#region src/composables/useOutputPath.ts
|
|
4
|
+
/**
|
|
5
|
+
* Override the output file path for the current template.
|
|
6
|
+
*
|
|
7
|
+
* The path is relative to the project root (cwd); it may be
|
|
8
|
+
* absolute or escape the output directory with `../`. If it
|
|
9
|
+
* has no extension, `output.extension` is appended.
|
|
10
|
+
*
|
|
11
|
+
* Usage in SFC <script setup>:
|
|
12
|
+
* ```ts
|
|
13
|
+
* useOutputPath('dist/promos/black-friday.html')
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function useOutputPath(path) {
|
|
17
|
+
const ctx = inject(RenderContextKey);
|
|
18
|
+
if (ctx) ctx.outputPath = path;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useOutputPath };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=useOutputPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOutputPath.js","names":[],"sources":["../../src/composables/useOutputPath.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { RenderContextKey } from './renderContext.ts'\n\n/**\n * Override the output file path for the current template.\n *\n * The path is relative to the project root (cwd); it may be\n * absolute or escape the output directory with `../`. If it\n * has no extension, `output.extension` is appended.\n *\n * Usage in SFC <script setup>:\n * ```ts\n * useOutputPath('dist/promos/black-friday.html')\n * ```\n */\nexport function useOutputPath(path: string): void {\n const ctx = inject(RenderContextKey)\n if (ctx) ctx.outputPath = path\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,cAAc,MAAoB;CAChD,MAAM,MAAM,OAAO,gBAAgB;CACnC,IAAI,KAAK,IAAI,aAAa;AAC5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { useDoctype } from "./composables/useDoctype.js";
|
|
|
9
9
|
import { useEvent } from "./composables/useEvent.js";
|
|
10
10
|
import { useFont } from "./composables/useFont.js";
|
|
11
11
|
import { useOutlookFallback } from "./composables/useOutlookFallback.js";
|
|
12
|
+
import { useOutputPath } from "./composables/useOutputPath.js";
|
|
12
13
|
import { useTransformers } from "./composables/useTransformers.js";
|
|
13
14
|
import { useUrlQuery } from "./composables/useUrlQuery.js";
|
|
14
15
|
import { resolveConfig } from "./config/index.js";
|
|
@@ -36,4 +37,4 @@ import { replaceStrings } from "./transformers/replaceStrings.js";
|
|
|
36
37
|
import { FormatOptions, format } from "./transformers/format.js";
|
|
37
38
|
import { MinifyOptions, minify } from "./transformers/minify.js";
|
|
38
39
|
import { useHead } from "@unhead/vue";
|
|
39
|
-
export { type AttributesConfig, type BaseUrlOptions, type ComponentSource, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, type NormalizedComponentSource, type PlaintextConfig, type PrepareOptions, type PurgeCssOptions, type RemoveAttributeOption, type RemoveAttributeRule, type RenderResult, type RenderedTemplate, type Renderer, type ShorthandCssOptions, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeSelectors, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
|
40
|
+
export { type AttributesConfig, type BaseUrlOptions, type ComponentSource, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, type NormalizedComponentSource, type PlaintextConfig, type PrepareOptions, type PurgeCssOptions, type RemoveAttributeOption, type RemoveAttributeRule, type RenderResult, type RenderedTemplate, type Renderer, type ShorthandCssOptions, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeSelectors, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, useOutputPath, usePlaintext, useTransformers, useUrlQuery };
|
package/dist/index.js
CHANGED
|
@@ -30,9 +30,10 @@ import { useDoctype } from "./composables/useDoctype.js";
|
|
|
30
30
|
import { useEvent } from "./composables/useEvent.js";
|
|
31
31
|
import { useFont } from "./composables/useFont.js";
|
|
32
32
|
import { useOutlookFallback } from "./composables/useOutlookFallback.js";
|
|
33
|
+
import { useOutputPath } from "./composables/useOutputPath.js";
|
|
33
34
|
import { usePlaintext } from "./composables/usePlaintext.js";
|
|
34
35
|
import { useTransformers } from "./composables/useTransformers.js";
|
|
35
36
|
import { useBaseUrl } from "./composables/useBaseUrl.js";
|
|
36
37
|
import { useUrlQuery } from "./composables/useUrlQuery.js";
|
|
37
38
|
import { useHead } from "@unhead/vue";
|
|
38
|
-
export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeSelectors, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
|
39
|
+
export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeSelectors, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, useOutputPath, usePlaintext, useTransformers, useUrlQuery };
|
|
@@ -11,6 +11,7 @@ interface RenderedTemplate {
|
|
|
11
11
|
templateConfig: MaizzleConfig;
|
|
12
12
|
sfcEventHandlers: RenderContext['sfcEventHandlers'];
|
|
13
13
|
plaintext?: RenderContext['plaintext'];
|
|
14
|
+
outputPath?: RenderContext['outputPath'];
|
|
14
15
|
tailwindBlocks?: RenderContext['tailwindBlocks'];
|
|
15
16
|
}
|
|
16
17
|
interface Renderer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRenderer.d.ts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":";;;;;;;UAkCiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,cAAA,EAAgB,aAAA;EAChB,gBAAA,EAAkB,aAAA;EAClB,SAAA,GAAY,aAAA;EACZ,cAAA,GAAiB,aAAA;AAAA;AAAA,UAGF,QAAA;EACf,MAAA,CAAO,KAAA,WAAgB,SAAA,EAAW,MAAA,EAAQ,aAAA,GAAgB,OAAA,CAAQ,gBAAA;EAClE,UAAA,CAAW,QAAA,WAAmB,OAAA;EAC9B,aAAA,IAAiB,OAAA;EACjB,KAAA,IAAS,OAAA;AAAA;AAAA,UAGM,qBAAA;
|
|
1
|
+
{"version":3,"file":"createRenderer.d.ts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":";;;;;;;UAkCiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,cAAA,EAAgB,aAAA;EAChB,gBAAA,EAAkB,aAAA;EAClB,SAAA,GAAY,aAAA;EACZ,UAAA,GAAa,aAAA;EACb,cAAA,GAAiB,aAAA;AAAA;AAAA,UAGF,QAAA;EACf,MAAA,CAAO,KAAA,WAAgB,SAAA,EAAW,MAAA,EAAQ,aAAA,GAAgB,OAAA,CAAQ,gBAAA;EAClE,UAAA,CAAW,QAAA,WAAmB,OAAA;EAC9B,aAAA,IAAiB,OAAA;EACjB,KAAA,IAAS,OAAA;AAAA;AAAA,UAGM,qBAAA;EAdC;EAgBhB,GAAA;EAfkB;EAiBlB,QAAA,GAAW,cAAA;EAhBC;EAkBZ,IAAA;EAjBa;;;;EAsBb,aAAA,GAAgB,yBAAA;EAlBD;EAoBf,IAAA,GAAO,YAAA;AAAA;;;;;;;iBASa,cAAA,CACpB,OAAA,GAAS,qBAAA,GACR,OAAA,CAAQ,QAAA"}
|
|
@@ -217,6 +217,21 @@ isCustomElement: (tag) => tag.startsWith("amp-") }
|
|
|
217
217
|
AutoImport({
|
|
218
218
|
dirs: [resolve(__dirname, "../composables"), resolve(__dirname, "../filters")],
|
|
219
219
|
imports: ["vue", unheadVueComposablesImports],
|
|
220
|
+
/**
|
|
221
|
+
* unplugin-auto-import's default `include` doesn't match `.md`, so
|
|
222
|
+
* auto-imports (Vue, unhead and Maizzle composables/filters) were
|
|
223
|
+
* never injected into Markdown templates — `useConfig()` and friends
|
|
224
|
+
* threw at runtime. Extend the default list with `.md` (and its
|
|
225
|
+
* `?vue` script sub-requests) to mirror the `.md` coverage the
|
|
226
|
+
* Components plugin already declares below.
|
|
227
|
+
*/
|
|
228
|
+
include: [
|
|
229
|
+
/\.[jt]sx?$/,
|
|
230
|
+
/\.vue$/,
|
|
231
|
+
/\.vue\?vue/,
|
|
232
|
+
/\.md$/,
|
|
233
|
+
/\.md\?vue/
|
|
234
|
+
],
|
|
220
235
|
dts: dts ? resolve(dtsDir, "auto-imports.d.ts") : false
|
|
221
236
|
}),
|
|
222
237
|
Components({
|
|
@@ -377,6 +392,7 @@ isCustomElement: (tag) => tag.startsWith("amp-") }
|
|
|
377
392
|
templateConfig: renderContext.sfcConfig ? defu$1(renderContext.sfcConfig, config) : config,
|
|
378
393
|
sfcEventHandlers: renderContext.sfcEventHandlers,
|
|
379
394
|
plaintext: renderContext.plaintext,
|
|
395
|
+
outputPath: renderContext.outputPath,
|
|
380
396
|
tailwindBlocks: renderContext.tailwindBlocks
|
|
381
397
|
};
|
|
382
398
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRenderer.js","names":["relPath","merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, relative as relPath, resolve } from 'node:path'\nimport { mkdirSync, writeFileSync, existsSync, rmSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { isLaravel } from '../utils/detect.ts'\nimport { rowSourceLocation } from './plugins/rowSourceLocation.ts'\nimport { rawExtract } from './plugins/rawExtract.ts'\nimport { codeBlockExtract } from './plugins/codeBlockExtract.ts'\nimport { markdownExtract } from './plugins/markdownExtract.ts'\nimport { createServer, mergeConfig, type InlineConfig, type Plugin } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport Markdown from 'unplugin-vue-markdown/vite'\nimport AutoImport from 'unplugin-auto-import/vite'\nimport Components from 'unplugin-vue-components/vite'\nimport { unheadVueComposablesImports } from '@unhead/vue'\nimport { defu as merge } from 'defu'\nimport { glob, globSync } from 'tinyglobby'\nimport { createSSRApp } from 'vue'\nimport { renderToString } from 'vue/server-renderer'\nimport { createHead } from '@unhead/vue/server'\nimport { MaizzleConfigKey } from '../composables/useConfig.ts'\nimport { RenderContextKey } from '../composables/renderContext.ts'\nimport { componentNameFromPath, type NormalizedComponentSource } from '../utils/componentSources.ts'\nimport type { Component, InjectionKey } from 'vue'\nimport type { MaizzleConfig, MarkdownConfig } from '../types/index.ts'\nimport type { MarkdownExit } from 'markdown-exit'\nimport type { RenderContext } from '../composables/renderContext.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nconst vuePkgDir = dirname(fileURLToPath(import.meta.resolve('vue/package.json')))\nconst vueServerRendererPkgDir = dirname(fileURLToPath(import.meta.resolve('@vue/server-renderer/package.json')))\nconst unheadVuePkgDir = resolve(dirname(fileURLToPath(import.meta.resolve('@unhead/vue'))), '..')\nconst vueRouterPkgDir = dirname(fileURLToPath(import.meta.resolve('vue-router/package.json')))\n\nexport interface RenderedTemplate {\n html: string\n doctype?: string\n templateConfig: MaizzleConfig\n sfcEventHandlers: RenderContext['sfcEventHandlers']\n plaintext?: RenderContext['plaintext']\n tailwindBlocks?: RenderContext['tailwindBlocks']\n}\n\nexport interface Renderer {\n render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate>\n invalidate(filePath: string): Promise<void>\n invalidateAll(): Promise<void>\n close(): Promise<void>\n}\n\nexport interface CreateRendererOptions {\n /** Generate .d.ts files for auto-imports and components (default: false) */\n dts?: boolean\n /** Options passed to unplugin-vue-markdown */\n markdown?: MarkdownConfig\n /** Root directory for resolving user component dirs and .d.ts output */\n root?: string\n /**\n * Additional component sources to register for auto-import. Already\n * normalized — pass through `normalizeComponentSources()` first.\n */\n componentDirs?: NormalizedComponentSource[]\n /** User Vite config options to merge into the internal SSR server */\n vite?: InlineConfig\n}\n\n/**\n * Lightweight Vite SSR loader for rendering Vue SFC email templates.\n *\n * Uses only Vue + unplugin for component/auto-import resolution.\n * Tailwind CSS compilation is handled by the transformer pipeline.\n */\nexport async function createRenderer(\n options: CreateRendererOptions = {},\n): Promise<Renderer> {\n const { dts = false, markdown: markdownOptionsRaw, root = process.cwd(), componentDirs = [], vite: userViteConfig } = options\n const { shikiTheme = 'github-light', ...markdownOptions } = markdownOptionsRaw ?? {}\n\n /**\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 * 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 vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n compilerOptions: {\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 isCustomElement: (tag: string) => tag.startsWith('amp-'),\n },\n },\n }),\n Markdown(merge(markdownOptions ?? {}, {\n headEnabled: true,\n wrapperDiv: false,\n wrapperClasses: 'prose',\n wrapperComponent: (id: string, raw: string) => {\n const fm = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1]\n const layout = fm?.match(/^[ \\t]*layout[ \\t]*:[ \\t]*['\"]?([A-Za-z][\\w-]*|false|none)['\"]?[ \\t]*$/m)?.[1]\n if (layout === 'false' || layout === 'none') return null\n if (layout) return layout\n /**\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 return codeToHtml(code, { lang, theme: shikiTheme })\n },\n },\n markdownSetup(md: MarkdownExit) {\n const wrapPre = (html: string) =>\n `<table class=\"w-full\"><tr><td class=\"max-w-0 mso-padding-alt-4\">${html}</td></tr></table>\\n`\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) => {\n const result = defaultFence(...args)\n if (typeof result === 'string') return wrapPre(result)\n return result.then(wrapPre)\n }\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => wrapPre(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n dts: dts ? resolve(dtsDir, 'auto-imports.d.ts') : false,\n }),\n Components({\n extensions: ['vue', 'md'],\n include: [/\\.vue$/, /\\.vue\\?vue/, /\\.md$/],\n dirs: [\n frameworkComponentsDir,\n resolve(root, 'components'),\n ...dirSources.map(s => s.path),\n ],\n /**\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): 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 component = (await server.ssrLoadModule(input)).default\n }\n } else {\n // Pre-compiled component — use directly imported keys\n component = input\n configKey = MaizzleConfigKey\n contextKey = RenderContextKey\n }\n\n const renderContext: RenderContext = {\n doctype: undefined,\n sfcConfig: undefined,\n sfcEventHandlers: [],\n }\n\n const head = createHead({ disableDefaults: true })\n const app = createSSRApp(component)\n app.use(head)\n\n // Register user Vue plugins, directives, and global properties\n if (config.vue) {\n const plugins = typeof config.vue.plugins === 'function'\n ? config.vue.plugins()\n : config.vue.plugins ?? []\n for (const plugin of plugins) {\n app.use(plugin)\n }\n for (const [name, directive] of Object.entries(config.vue.directives ?? {})) {\n app.directive(name, directive)\n }\n Object.assign(app.config.globalProperties, config.vue.globalProperties)\n }\n\n app.provide(configKey, config)\n app.provide(contextKey, renderContext)\n\n const ssrContext: Record<string, any> = {}\n let html: string = await renderToString(app, ssrContext)\n\n const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = head.render()\n\n // Inject head entries into the rendered HTML\n if (htmlAttrs) {\n html = html.replace(/<html([^>]*)>/, `<html$1 ${htmlAttrs}>`)\n }\n if (headTags) {\n html = html.replace('</head>', `${headTags}\\n</head>`)\n }\n if (bodyAttrs) {\n html = html.replace(/<body([^>]*)>/, `<body$1 ${bodyAttrs}>`)\n }\n if (bodyTagsOpen) {\n html = html.replace(/<body([^>]*)>/, `<body$1>\\n${bodyTagsOpen}`)\n }\n if (bodyTags) {\n html = html.replace('</body>', `${bodyTags}\\n</body>`)\n }\n\n // Inject SSR teleport content into their target elements\n const hasTeleports = ssrContext.teleports && Object.keys(ssrContext.teleports).length > 0\n const hasFonts = (renderContext.fonts?.length ?? 0) > 0\n\n if (hasTeleports || hasFonts) {\n const { parse: parseDom, serialize: serializeDom, walk } = await import('../utils/ast/index.ts')\n let dom = parseDom(html)\n\n if (hasTeleports) {\n for (const [rawTarget, content] of Object.entries(ssrContext.teleports) as [string, string][]) {\n if (!content) continue\n\n const prepend = rawTarget.endsWith(':start')\n const target = prepend ? rawTarget.slice(0, -6) : rawTarget\n const targetChildren = parseDom(content)\n\n walk(dom, (node) => {\n const el = node as import('domhandler').Element\n\n if (!el.name) return\n\n const matched\n = target === el.name\n || (target.startsWith('#') && el.attribs?.id === target.slice(1))\n || (target.startsWith('.') && el.attribs?.class?.split(/\\s+/).includes(target.slice(1)))\n\n if (matched) {\n for (const child of targetChildren) {\n child.parent = el as any\n }\n\n el.children = prepend\n ? [...targetChildren, ...(el.children || [])] as any\n : [...(el.children || []), ...targetChildren] as any\n }\n })\n }\n }\n\n if (hasFonts) {\n const { injectFonts } = await import('./injectFonts.ts')\n injectFonts(dom, renderContext.fonts!, parseDom, walk)\n }\n\n html = serializeDom(dom)\n }\n\n // Inject preheader text from usePreheader() composable\n if (renderContext.preheader) {\n const { text, fillerCount } = 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 /**\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.\n */\n html = html\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n return {\n html,\n doctype: renderContext.doctype,\n /**\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 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":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,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;;;;;;;AAwC7F,eAAsB,eACpB,UAAiC,CAAC,GACf;CACn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A,MAAM,WAAW,UAAiC;GAChD,MAAM,MAAM,MAAM,OAAO,YAAY,eAAe,QAAQ;GAC5D,IAAI,KACF,OAAO,YAAY,iBAAiB,GAAG;EAE3C;EAEA,MAAM,gBAA+B;GACnC,KAAK,MAAM,OAAO,OAAO,YAAY,cAAc,OAAO,GACxD,OAAO,YAAY,iBAAiB,GAAG;EAE3C;EAEA,MAAM,QAAuB;GAC3B,MAAM,OAAO,MAAM;;;;;;;;;;GAUnB,IAAI,KACF,MAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC;EAEzD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"createRenderer.js","names":["relPath","merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, relative as relPath, resolve } from 'node:path'\nimport { mkdirSync, writeFileSync, existsSync, rmSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { isLaravel } from '../utils/detect.ts'\nimport { rowSourceLocation } from './plugins/rowSourceLocation.ts'\nimport { rawExtract } from './plugins/rawExtract.ts'\nimport { codeBlockExtract } from './plugins/codeBlockExtract.ts'\nimport { markdownExtract } from './plugins/markdownExtract.ts'\nimport { createServer, mergeConfig, type InlineConfig, type Plugin } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport Markdown from 'unplugin-vue-markdown/vite'\nimport AutoImport from 'unplugin-auto-import/vite'\nimport Components from 'unplugin-vue-components/vite'\nimport { unheadVueComposablesImports } from '@unhead/vue'\nimport { defu as merge } from 'defu'\nimport { glob, globSync } from 'tinyglobby'\nimport { createSSRApp } from 'vue'\nimport { renderToString } from 'vue/server-renderer'\nimport { createHead } from '@unhead/vue/server'\nimport { MaizzleConfigKey } from '../composables/useConfig.ts'\nimport { RenderContextKey } from '../composables/renderContext.ts'\nimport { componentNameFromPath, type NormalizedComponentSource } from '../utils/componentSources.ts'\nimport type { Component, InjectionKey } from 'vue'\nimport type { MaizzleConfig, MarkdownConfig } from '../types/index.ts'\nimport type { MarkdownExit } from 'markdown-exit'\nimport type { RenderContext } from '../composables/renderContext.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nconst vuePkgDir = dirname(fileURLToPath(import.meta.resolve('vue/package.json')))\nconst vueServerRendererPkgDir = dirname(fileURLToPath(import.meta.resolve('@vue/server-renderer/package.json')))\nconst unheadVuePkgDir = resolve(dirname(fileURLToPath(import.meta.resolve('@unhead/vue'))), '..')\nconst vueRouterPkgDir = dirname(fileURLToPath(import.meta.resolve('vue-router/package.json')))\n\nexport interface RenderedTemplate {\n html: string\n doctype?: string\n templateConfig: MaizzleConfig\n sfcEventHandlers: RenderContext['sfcEventHandlers']\n plaintext?: RenderContext['plaintext']\n outputPath?: RenderContext['outputPath']\n tailwindBlocks?: RenderContext['tailwindBlocks']\n}\n\nexport interface Renderer {\n render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate>\n invalidate(filePath: string): Promise<void>\n invalidateAll(): Promise<void>\n close(): Promise<void>\n}\n\nexport interface CreateRendererOptions {\n /** Generate .d.ts files for auto-imports and components (default: false) */\n dts?: boolean\n /** Options passed to unplugin-vue-markdown */\n markdown?: MarkdownConfig\n /** Root directory for resolving user component dirs and .d.ts output */\n root?: string\n /**\n * Additional component sources to register for auto-import. Already\n * normalized — pass through `normalizeComponentSources()` first.\n */\n componentDirs?: NormalizedComponentSource[]\n /** User Vite config options to merge into the internal SSR server */\n vite?: InlineConfig\n}\n\n/**\n * Lightweight Vite SSR loader for rendering Vue SFC email templates.\n *\n * Uses only Vue + unplugin for component/auto-import resolution.\n * Tailwind CSS compilation is handled by the transformer pipeline.\n */\nexport async function createRenderer(\n options: CreateRendererOptions = {},\n): Promise<Renderer> {\n const { dts = false, markdown: markdownOptionsRaw, root = process.cwd(), componentDirs = [], vite: userViteConfig } = options\n const { shikiTheme = 'github-light', ...markdownOptions } = markdownOptionsRaw ?? {}\n\n /**\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 * 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 vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n compilerOptions: {\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 isCustomElement: (tag: string) => tag.startsWith('amp-'),\n },\n },\n }),\n Markdown(merge(markdownOptions ?? {}, {\n headEnabled: true,\n wrapperDiv: false,\n wrapperClasses: 'prose',\n wrapperComponent: (id: string, raw: string) => {\n const fm = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1]\n const layout = fm?.match(/^[ \\t]*layout[ \\t]*:[ \\t]*['\"]?([A-Za-z][\\w-]*|false|none)['\"]?[ \\t]*$/m)?.[1]\n if (layout === 'false' || layout === 'none') return null\n if (layout) return layout\n /**\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 return codeToHtml(code, { lang, theme: shikiTheme })\n },\n },\n markdownSetup(md: MarkdownExit) {\n const wrapPre = (html: string) =>\n `<table class=\"w-full\"><tr><td class=\"max-w-0 mso-padding-alt-4\">${html}</td></tr></table>\\n`\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) => {\n const result = defaultFence(...args)\n if (typeof result === 'string') return wrapPre(result)\n return result.then(wrapPre)\n }\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => wrapPre(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n /**\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): 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 component = (await server.ssrLoadModule(input)).default\n }\n } else {\n // Pre-compiled component — use directly imported keys\n component = input\n configKey = MaizzleConfigKey\n contextKey = RenderContextKey\n }\n\n const renderContext: RenderContext = {\n doctype: undefined,\n sfcConfig: undefined,\n sfcEventHandlers: [],\n }\n\n const head = createHead({ disableDefaults: true })\n const app = createSSRApp(component)\n app.use(head)\n\n // Register user Vue plugins, directives, and global properties\n if (config.vue) {\n const plugins = typeof config.vue.plugins === 'function'\n ? config.vue.plugins()\n : config.vue.plugins ?? []\n for (const plugin of plugins) {\n app.use(plugin)\n }\n for (const [name, directive] of Object.entries(config.vue.directives ?? {})) {\n app.directive(name, directive)\n }\n Object.assign(app.config.globalProperties, config.vue.globalProperties)\n }\n\n app.provide(configKey, config)\n app.provide(contextKey, renderContext)\n\n const ssrContext: Record<string, any> = {}\n let html: string = await renderToString(app, ssrContext)\n\n const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = head.render()\n\n // Inject head entries into the rendered HTML\n if (htmlAttrs) {\n html = html.replace(/<html([^>]*)>/, `<html$1 ${htmlAttrs}>`)\n }\n if (headTags) {\n html = html.replace('</head>', `${headTags}\\n</head>`)\n }\n if (bodyAttrs) {\n html = html.replace(/<body([^>]*)>/, `<body$1 ${bodyAttrs}>`)\n }\n if (bodyTagsOpen) {\n html = html.replace(/<body([^>]*)>/, `<body$1>\\n${bodyTagsOpen}`)\n }\n if (bodyTags) {\n html = html.replace('</body>', `${bodyTags}\\n</body>`)\n }\n\n // Inject SSR teleport content into their target elements\n const hasTeleports = ssrContext.teleports && Object.keys(ssrContext.teleports).length > 0\n const hasFonts = (renderContext.fonts?.length ?? 0) > 0\n\n if (hasTeleports || hasFonts) {\n const { parse: parseDom, serialize: serializeDom, walk } = await import('../utils/ast/index.ts')\n let dom = parseDom(html)\n\n if (hasTeleports) {\n for (const [rawTarget, content] of Object.entries(ssrContext.teleports) as [string, string][]) {\n if (!content) continue\n\n const prepend = rawTarget.endsWith(':start')\n const target = prepend ? rawTarget.slice(0, -6) : rawTarget\n const targetChildren = parseDom(content)\n\n walk(dom, (node) => {\n const el = node as import('domhandler').Element\n\n if (!el.name) return\n\n const matched\n = target === el.name\n || (target.startsWith('#') && el.attribs?.id === target.slice(1))\n || (target.startsWith('.') && el.attribs?.class?.split(/\\s+/).includes(target.slice(1)))\n\n if (matched) {\n for (const child of targetChildren) {\n child.parent = el as any\n }\n\n el.children = prepend\n ? [...targetChildren, ...(el.children || [])] as any\n : [...(el.children || []), ...targetChildren] as any\n }\n })\n }\n }\n\n if (hasFonts) {\n const { injectFonts } = await import('./injectFonts.ts')\n injectFonts(dom, renderContext.fonts!, parseDom, walk)\n }\n\n html = serializeDom(dom)\n }\n\n // Inject preheader text from usePreheader() composable\n if (renderContext.preheader) {\n const { text, fillerCount } = 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 /**\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.\n */\n html = html\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n return {\n html,\n doctype: renderContext.doctype,\n /**\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":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,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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,uBAAuB,EAAE;GAEvC,OAAO;IACL;IACA,SAAS,cAAc;;;;;;;;;;;IAWvB,gBAAgB,cAAc,YAAYA,OAAM,cAAc,WAAW,MAAM,IAAI;IACnF,kBAAkB,cAAc;IAChC,WAAW,cAAc;IACzB,YAAY,cAAc;IAC1B,gBAAgB,cAAc;GAChC;EACF;EAEA,MAAM,WAAW,UAAiC;GAChD,MAAM,MAAM,MAAM,OAAO,YAAY,eAAe,QAAQ;GAC5D,IAAI,KACF,OAAO,YAAY,iBAAiB,GAAG;EAE3C;EAEA,MAAM,gBAA+B;GACnC,KAAK,MAAM,OAAO,OAAO,YAAY,cAAc,OAAO,GACxD,OAAO,YAAY,iBAAiB,GAAG;EAE3C;EAEA,MAAM,QAAuB;GAC3B,MAAM,OAAO,MAAM;;;;;;;;;;GAUnB,IAAI,KACF,MAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC;EAEzD;CACF;AACF"}
|
package/dist/render/index.js
CHANGED
|
@@ -35,7 +35,7 @@ async function render(template, config) {
|
|
|
35
35
|
let html = rendered.html;
|
|
36
36
|
const doctype = rendered.doctype ?? rendered.templateConfig.doctype ?? "<!DOCTYPE html>";
|
|
37
37
|
if (rendered.templateConfig.useTransformers !== false) html = await runTransformers(html, rendered.templateConfig, isFile ? resolve(template) : void 0, doctype, rendered.tailwindBlocks);
|
|
38
|
-
html = `${doctype}\n${html}`;
|
|
38
|
+
if (doctype) html = `${doctype}\n${html}`;
|
|
39
39
|
const globalPlaintext = rendered.templateConfig.plaintext;
|
|
40
40
|
const sfcPlaintext = rendered.plaintext;
|
|
41
41
|
let plaintextResult;
|
package/dist/render/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/render/index.ts"],"sourcesContent":["import { resolve, extname } from 'node:path'\nimport { resolveConfig } from '../config/index.ts'\nimport { runTransformers } from '../transformers/index.ts'\nimport { createPlaintext } from '../plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from '../utils/output-markers.ts'\nimport defu from 'defu'\nimport type { Component } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport { createRenderer } from './createRenderer.ts'\nimport { getActiveRenderer } from './active.ts'\nimport { normalizeComponentSources } from '../utils/componentSources.ts'\n\nexport type { Renderer, RenderedTemplate, CreateRendererOptions } from './createRenderer.ts'\nexport { createRenderer } from './createRenderer.ts'\n\nexport interface RenderResult {\n html: string\n config: MaizzleConfig\n plaintext?: string\n}\n\n/**\n * Render a Vue SFC email template to a fully-transformed HTML string.\n * Accepts a file path or a raw SFC source string.\n */\nexport async function render(\n template: string | Component,\n config?: Partial<MaizzleConfig>,\n): Promise<RenderResult> {\n if (template == null) {\n throw new Error(\n `render() received ${template}. If you used \\`import X from './x.vue'\\`, Node cannot load .vue files natively — pass the path string instead: render('./x.vue').`,\n )\n }\n if (typeof template !== 'string' && typeof template !== 'object' && typeof template !== 'function') {\n throw new TypeError(\n `render() expected a file path or SFC source string, got ${typeof template}.`,\n )\n }\n\n const resolvedConfig = await resolveConfig(config)\n\n /**\n * Reuse a renderer started by the Vite plugin when one is active.\n * Spinning up a fresh Vite SSR server inside a host Vite dev process\n * (e.g. TanStack Start) collides on env wiring and throws\n * \"outsideEmitter undefined\".\n */\n const active = getActiveRenderer()\n const renderer = active ?? await createRenderer({\n markdown: resolvedConfig.markdown,\n root: resolvedConfig.root,\n componentDirs: normalizeComponentSources(resolvedConfig.components?.source, process.cwd()),\n vite: resolvedConfig.vite,\n })\n\n try {\n const isFile = typeof template === 'string'\n && ['.vue', '.md'].includes(extname(template))\n && !template.includes('\\n')\n\n const rendered = await renderer.render(isFile ? resolve(template) : template, resolvedConfig)\n let html = rendered.html\n\n const doctype = rendered.doctype ?? rendered.templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (rendered.templateConfig.useTransformers !== false) {\n html = await runTransformers(html, rendered.templateConfig, isFile ? resolve(template) : undefined, doctype, rendered.tailwindBlocks)\n }\n html = `${doctype}\\n${html}`\n\n const globalPlaintext = rendered.templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n let plaintextResult: string | undefined\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n plaintextResult = createPlaintext(stripForPlaintext(html), stripOptions)\n }\n\n return { html: stripForHtml(html), config: rendered.templateConfig, plaintext: plaintextResult }\n } finally {\n if (!active) await renderer.close()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAyBA,eAAsB,OACpB,UACA,QACuB;CACvB,IAAI,YAAY,MACd,MAAM,IAAI,MACR,qBAAqB,SAAS,mIAChC;CAEF,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,YAAY,OAAO,aAAa,YACtF,MAAM,IAAI,UACR,2DAA2D,OAAO,SAAS,EAC7E;CAGF,MAAM,iBAAiB,MAAM,cAAc,MAAM;;;;;;;CAQjD,MAAM,SAAS,kBAAkB;CACjC,MAAM,WAAW,UAAU,MAAM,eAAe;EAC9C,UAAU,eAAe;EACzB,MAAM,eAAe;EACrB,eAAe,0BAA0B,eAAe,YAAY,QAAQ,QAAQ,IAAI,CAAC;EACzF,MAAM,eAAe;CACvB,CAAC;CAED,IAAI;EACF,MAAM,SAAS,OAAO,aAAa,YAC9B,CAAC,QAAQ,KAAK,EAAE,SAAS,QAAQ,QAAQ,CAAC,KAC1C,CAAC,SAAS,SAAS,IAAI;EAE5B,MAAM,WAAW,MAAM,SAAS,OAAO,SAAS,QAAQ,QAAQ,IAAI,UAAU,cAAc;EAC5F,IAAI,OAAO,SAAS;EAEpB,MAAM,UAAU,SAAS,WAAW,SAAS,eAAe,WAAW;EAEvE,IAAI,SAAS,eAAe,oBAAoB,OAC9C,OAAO,MAAM,gBAAgB,MAAM,SAAS,gBAAgB,SAAS,QAAQ,QAAQ,IAAI,KAAA,GAAW,SAAS,SAAS,cAAc;EAEtI,OAAO,GAAG,QAAQ,IAAI;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/render/index.ts"],"sourcesContent":["import { resolve, extname } from 'node:path'\nimport { resolveConfig } from '../config/index.ts'\nimport { runTransformers } from '../transformers/index.ts'\nimport { createPlaintext } from '../plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from '../utils/output-markers.ts'\nimport defu from 'defu'\nimport type { Component } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport { createRenderer } from './createRenderer.ts'\nimport { getActiveRenderer } from './active.ts'\nimport { normalizeComponentSources } from '../utils/componentSources.ts'\n\nexport type { Renderer, RenderedTemplate, CreateRendererOptions } from './createRenderer.ts'\nexport { createRenderer } from './createRenderer.ts'\n\nexport interface RenderResult {\n html: string\n config: MaizzleConfig\n plaintext?: string\n}\n\n/**\n * Render a Vue SFC email template to a fully-transformed HTML string.\n * Accepts a file path or a raw SFC source string.\n */\nexport async function render(\n template: string | Component,\n config?: Partial<MaizzleConfig>,\n): Promise<RenderResult> {\n if (template == null) {\n throw new Error(\n `render() received ${template}. If you used \\`import X from './x.vue'\\`, Node cannot load .vue files natively — pass the path string instead: render('./x.vue').`,\n )\n }\n if (typeof template !== 'string' && typeof template !== 'object' && typeof template !== 'function') {\n throw new TypeError(\n `render() expected a file path or SFC source string, got ${typeof template}.`,\n )\n }\n\n const resolvedConfig = await resolveConfig(config)\n\n /**\n * Reuse a renderer started by the Vite plugin when one is active.\n * Spinning up a fresh Vite SSR server inside a host Vite dev process\n * (e.g. TanStack Start) collides on env wiring and throws\n * \"outsideEmitter undefined\".\n */\n const active = getActiveRenderer()\n const renderer = active ?? await createRenderer({\n markdown: resolvedConfig.markdown,\n root: resolvedConfig.root,\n componentDirs: normalizeComponentSources(resolvedConfig.components?.source, process.cwd()),\n vite: resolvedConfig.vite,\n })\n\n try {\n const isFile = typeof template === 'string'\n && ['.vue', '.md'].includes(extname(template))\n && !template.includes('\\n')\n\n const rendered = await renderer.render(isFile ? resolve(template) : template, resolvedConfig)\n let html = rendered.html\n\n const doctype = rendered.doctype ?? rendered.templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (rendered.templateConfig.useTransformers !== false) {\n html = await runTransformers(html, rendered.templateConfig, isFile ? resolve(template) : undefined, doctype, rendered.tailwindBlocks)\n }\n if (doctype) html = `${doctype}\\n${html}`\n\n const globalPlaintext = rendered.templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n let plaintextResult: string | undefined\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n plaintextResult = createPlaintext(stripForPlaintext(html), stripOptions)\n }\n\n return { html: stripForHtml(html), config: rendered.templateConfig, plaintext: plaintextResult }\n } finally {\n if (!active) await renderer.close()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAyBA,eAAsB,OACpB,UACA,QACuB;CACvB,IAAI,YAAY,MACd,MAAM,IAAI,MACR,qBAAqB,SAAS,mIAChC;CAEF,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,YAAY,OAAO,aAAa,YACtF,MAAM,IAAI,UACR,2DAA2D,OAAO,SAAS,EAC7E;CAGF,MAAM,iBAAiB,MAAM,cAAc,MAAM;;;;;;;CAQjD,MAAM,SAAS,kBAAkB;CACjC,MAAM,WAAW,UAAU,MAAM,eAAe;EAC9C,UAAU,eAAe;EACzB,MAAM,eAAe;EACrB,eAAe,0BAA0B,eAAe,YAAY,QAAQ,QAAQ,IAAI,CAAC;EACzF,MAAM,eAAe;CACvB,CAAC;CAED,IAAI;EACF,MAAM,SAAS,OAAO,aAAa,YAC9B,CAAC,QAAQ,KAAK,EAAE,SAAS,QAAQ,QAAQ,CAAC,KAC1C,CAAC,SAAS,SAAS,IAAI;EAE5B,MAAM,WAAW,MAAM,SAAS,OAAO,SAAS,QAAQ,QAAQ,IAAI,UAAU,cAAc;EAC5F,IAAI,OAAO,SAAS;EAEpB,MAAM,UAAU,SAAS,WAAW,SAAS,eAAe,WAAW;EAEvE,IAAI,SAAS,eAAe,oBAAoB,OAC9C,OAAO,MAAM,gBAAgB,MAAM,SAAS,gBAAgB,SAAS,QAAQ,QAAQ,IAAI,KAAA,GAAW,SAAS,SAAS,cAAc;EAEtI,IAAI,SAAS,OAAO,GAAG,QAAQ,IAAI;EAEnC,MAAM,kBAAkB,SAAS,eAAe;EAChD,MAAM,eAAe,SAAS;EAE9B,IAAI;EAEJ,IAAI,mBAAmB,cAAc;GACnC,MAAM,YAAY,OAAO,oBAAoB,WAAW,kBAAkB,CAAC;GAC3E,MAAM,eAAe,KAAK,cAAc,SAAS,UAAU,OAAO;GAClE,kBAAkB,gBAAgB,kBAAkB,IAAI,GAAG,YAAY;EACzE;EAEA,OAAO;GAAE,MAAM,aAAa,IAAI;GAAG,QAAQ,SAAS;GAAgB,WAAW;EAAgB;CACjG,UAAU;EACR,IAAI,CAAC,QAAQ,MAAM,SAAS,MAAM;CACpC;AACF"}
|
package/dist/serve.js
CHANGED
|
@@ -299,7 +299,7 @@ async function serveRenderedTemplate(url, config, renderer, res) {
|
|
|
299
299
|
const templateConfig = rendered.templateConfig;
|
|
300
300
|
const doctype = rendered.doctype ?? templateConfig.doctype ?? "<!DOCTYPE html>";
|
|
301
301
|
html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks);
|
|
302
|
-
html = `${doctype}\n${html}`;
|
|
302
|
+
if (doctype) html = `${doctype}\n${html}`;
|
|
303
303
|
res.setHeader("Content-Type", "text/html");
|
|
304
304
|
res.end(stripForHtml(html));
|
|
305
305
|
} catch (error) {
|
|
@@ -334,7 +334,7 @@ async function serveHighlightedSource(url, config, renderer, res) {
|
|
|
334
334
|
const templateConfig = rendered.templateConfig;
|
|
335
335
|
const doctype = rendered.doctype ?? templateConfig.doctype ?? "<!DOCTYPE html>";
|
|
336
336
|
html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks);
|
|
337
|
-
html = stripForHtml(`${doctype}\n${html}`);
|
|
337
|
+
html = stripForHtml(doctype ? `${doctype}\n${html}` : html);
|
|
338
338
|
const highlighted = (await getHighlighter()).codeToHtml(html, {
|
|
339
339
|
lang: "html",
|
|
340
340
|
theme: "laserwave",
|
|
@@ -502,7 +502,7 @@ async function serveEmailEndpoint(url, req, res, config, renderer) {
|
|
|
502
502
|
const templateConfig = rendered.templateConfig;
|
|
503
503
|
const doctype = rendered.doctype ?? templateConfig.doctype ?? "<!DOCTYPE html>";
|
|
504
504
|
html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks);
|
|
505
|
-
html = `${doctype}\n${html}`;
|
|
505
|
+
if (doctype) html = `${doctype}\n${html}`;
|
|
506
506
|
const text = createPlaintext(stripForPlaintext(html));
|
|
507
507
|
html = stripForHtml(html);
|
|
508
508
|
const result = await sendEmail({
|
package/dist/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","names":["parsePath"],"sources":["../src/serve.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve, basename, parse as parsePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { createServer, createLogger, type ViteDevServer } from 'vite'\nimport { renderUnicodeCompact } from 'uqr'\nimport vue from '@vitejs/plugin-vue'\nimport tailwindcss from '@tailwindcss/vite'\nimport { glob } from 'tinyglobby'\nimport { createHighlighter, type Highlighter } from 'shiki'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { resolveConfig } from './config/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer, type Renderer } from './render/createRenderer.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport { setActiveRenderer } from './render/active.ts'\nimport { serveCompatibility } from './server/compatibility.ts'\nimport { serveLint } from './server/linter.ts'\nimport { sendEmail } from './server/email.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { createWatchedFileMatcher } from './utils/watchPaths.ts'\nimport type { MaizzleConfig } from './types/index.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst devUIDir = resolve(__dirname, 'server/ui')\n\nconst require = createRequire(import.meta.url)\nconst pkg = (name: string) => {\n const resolved = require.resolve(name).replace(/\\\\/g, '/')\n const marker = `node_modules/${name}`\n const idx = resolved.lastIndexOf(marker)\n\n return resolved.slice(0, idx + marker.length)\n}\n\nexport interface ServeOptions {\n config?: Partial<MaizzleConfig> | string\n /** Override the dev server port (takes precedence over config.server.port) */\n port?: number\n /** Expose the server on the network (e.g. --host) */\n host?: boolean | string\n /** When true, suppresses the banner/URL output (used by the Vite plugin, which prints its own) */\n silent?: boolean\n}\n\n/**\n * Start the Maizzle dev server.\n *\n * Creates two things:\n * 1. A Vite dev server for the dev UI (sidebar + preview, with Vue + Tailwind for the UI itself)\n * 2. A Renderer instance for SSR rendering email templates\n *\n * Template rendering goes through the Renderer, not the Vite dev server.\n */\nexport async function serve(options: ServeOptions = {}) {\n const start = performance.now()\n\n let config = await resolveConfig(options.config)\n const port = options.port ?? config.server?.port ?? 3000\n\n // Create a renderer for SSR rendering email templates (with dts for dev)\n let renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n\n /**\n * Register so user-land render() calls reuse this renderer instead of\n * spinning up another Vite SSR server (which collides when the host\n * app is itself a Vite dev process — e.g. TanStack Start).\n */\n setActiveRenderer(renderer)\n\n const server = await createServer({\n configFile: false,\n plugins: [\n // Vue and Tailwind are only for the dev UI SPA, not for email templates\n vue(),\n tailwindcss(),\n maizzleDevPlugin(config, renderer, options.config),\n ],\n resolve: {\n dedupe: ['vue'],\n alias: [\n { find: '@', replacement: devUIDir },\n { find: 'vue', replacement: resolve(pkg('vue'), 'dist/vue.runtime.esm-bundler.js') },\n ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori']\n .map(name => ({ find: name, replacement: pkg(name) })),\n ],\n },\n cacheDir: resolve(devUIDir, '.vite'),\n optimizeDeps: {\n noDiscovery: true,\n include: [\n 'vue',\n 'vue-router',\n '@lucide/vue',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n ],\n },\n server: {\n port,\n host: options.host,\n fs: {\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori'].map(pkg)],\n },\n },\n customLogger: customLogger(),\n })\n\n // Store renderer ref on server for cleanup\n const originalClose = server.close.bind(server)\n server.close = async () => {\n setActiveRenderer(null)\n await renderer.close()\n return originalClose()\n }\n\n await server.listen()\n\n const startupTime = Math.round(performance.now() - start)\n\n if (!options.silent) {\n printBanner(server, startupTime)\n }\n\n // Expose startup time so the plugin can print it later\n ; (server as any)._maizzleStartupTime = startupTime\n\n return server\n}\n\n/**\n * Internal Vite plugin that adds Maizzle middleware and file watching to the dev UI server.\n */\nfunction maizzleDevPlugin(\n config: MaizzleConfig,\n renderer: Renderer,\n configInput: Partial<MaizzleConfig> | string | undefined,\n) {\n return {\n name: 'maizzle:dev',\n enforce: 'pre' as const,\n\n hotUpdate: {\n order: 'pre' as const,\n handler({ file }: { file: string }) {\n /**\n * Prevent Tailwind/Vue from triggering a full reload for email template\n * files. Maizzle handles these via custom HMR events in the\n * watcher below.\n */\n if (isTemplateFile(file)) {\n return []\n }\n },\n },\n\n configureServer(server: ViteDevServer) {\n // File watching\n const defaultWatchPaths = [\n 'maizzle.config.js',\n 'maizzle.config.ts',\n 'tailwind.config.js',\n 'tailwind.config.ts',\n 'locales/**',\n ]\n\n const userWatchPaths = config.server?.watch ?? []\n const watchPaths = [...defaultWatchPaths, ...userWatchPaths]\n const isWatchedFile = createWatchedFileMatcher(watchPaths, config.root ?? process.cwd())\n\n for (const watchPath of watchPaths) {\n server.watcher.add(watchPath)\n }\n\n server.watcher.on('add', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('unlink', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('change', async (file) => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\n\n // Recreate the renderer so config changes (e.g. markdown.shikiTheme) take effect\n await renderer.close()\n renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n\n /**\n * Push UI-relevant config bits so the dev UI reacts to live edits\n * without a page reload. Uses the same shape as the initial\n * inject.\n */\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n /**\n * Invalidate all renderer modules so component and config changes\n * are picked up on the next render (Tailwind recompiles with\n * fresh content).\n */\n await renderer.invalidateAll()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(file)\n ) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n })\n\n // API middleware (before Vite's middleware)\n server.middlewares.use(async (req: any, res: any, next: any) => {\n const url = req.url || '/'\n\n if (url === '/__maizzle/templates') {\n return serveTemplateList(config, res)\n }\n\n if (url.startsWith('/__maizzle/render/')) {\n return await serveRenderedTemplate(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/compatibility/')) {\n return await serveCompatibility(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/lint/')) {\n return await serveLint(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/vue-source/')) {\n return await serveVueSource(url, config, res)\n }\n\n if (url.startsWith('/__maizzle/plaintext/')) {\n return await servePlaintext(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\n }\n\n next()\n })\n\n // Dev UI fallback (after Vite's middleware)\n return () => {\n server.middlewares.use(async (req: any, res: any, next: any) => {\n if (isNavigationRequest(req)) {\n return await serveDevUI(server, res, req.url || '/', config)\n }\n\n next()\n })\n }\n },\n }\n}\n\nfunction isTemplateFile(file: string): boolean {\n return (file.endsWith('.vue') || file.endsWith('.md')) && !file.includes('server/ui')\n}\n\nfunction isNavigationRequest(req: any): boolean {\n const accept = req.headers?.accept || ''\n return req.method === 'GET' && accept.includes('text/html')\n}\n\n/**\n * Shape exposed to the dev UI both at initial HTML load (as\n * `window.__MAIZZLE_CONFIG__`) and on the `maizzle:config-updated` HMR event.\n * Add UI-visible config bits here; consumers on both ends pick up automatically.\n */\nfunction buildUiConfig(config: MaizzleConfig) {\n return {\n checks: config.server?.checks ?? true,\n }\n}\n\nasync function serveDevUI(server: ViteDevServer, res: any, url: string, config: MaizzleConfig) {\n let indexHtml = readFileSync(resolve(devUIDir, 'index.html'), 'utf-8')\n\n indexHtml = indexHtml.replace('./main.ts', `/@fs/${resolve(devUIDir, 'main.ts')}`)\n indexHtml = indexHtml.replace('./favicon.svg', `/@fs/${resolve(devUIDir, 'favicon.svg')}`)\n\n const configScript = `<script>window.__MAIZZLE_CONFIG__ = ${JSON.stringify(buildUiConfig(config))};</script>`\n indexHtml = indexHtml.replace('</head>', `${configScript}</head>`)\n\n const transformed = await server.transformIndexHtml(url, indexHtml)\n\n res.setHeader('Content-Type', 'text/html')\n res.end(transformed)\n}\n\nasync function serveTemplateList(config: MaizzleConfig, res: any) {\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n\n const data = templates.map(t => ({\n name: basename(t).replace(/\\.(vue|md)$/, ''),\n path: t,\n href: '/' + t.replace(/\\.(vue|md)$/, ''),\n }))\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(data))\n}\n\n/**\n * SSR render a .vue template using the Renderer (not the dev UI server).\n */\nasync function serveRenderedTemplate(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/render/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n // Invalidate all modules so template + component changes are picked up\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = `${doctype}\\n${html}`\n\n res.setHeader('Content-Type', 'text/html')\n res.end(stripForHtml(html))\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['laserwave'],\n langs: ['html', 'vue'],\n })\n }\n return highlighter\n}\n\nasync function serveHighlightedSource(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n html = stripForHtml(`${doctype}\\n${html}`)\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(html, {\n lang: 'html',\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nasync function serveVueSource(url: string, config: MaizzleConfig, res: any) {\n const templateSlug = url.replace('/__maizzle/vue-source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n try {\n const source = readFileSync(resolve(match), 'utf-8')\n const lang = match.endsWith('.md') ? 'html' : 'vue'\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(source, {\n lang,\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function servePlaintext(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/plaintext/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n const plaintext = createPlaintext(stripForPlaintext(html))\n\n res.setHeader('Content-Type', 'text/plain')\n res.end(plaintext)\n } catch (error: any) {\n res.statusCode = 500\n res.end(error.message)\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nfunction humanFileSize(bytes: number, si = false, dp = 2) {\n const threshold = si ? 1000 : 1024\n\n if (Math.abs(bytes) < threshold) {\n return bytes + ' B'\n }\n\n const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n let u = -1\n const r = 10 ** dp\n\n do {\n bytes /= threshold\n ++u\n } while (Math.round(Math.abs(bytes) * r) / r >= threshold && u < units.length - 1)\n\n return bytes.toFixed(dp) + ' ' + units[u]\n}\n\nasync function serveStats(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/stats/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ error: 'Template not found' }))\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = stripForHtml(html)\n\n const sizeBytes = Buffer.byteLength(html, 'utf-8')\n\n // Count images: <img> tags and CSS background images\n const imgTags = (html.match(/<img\\b[^>]*>/gi) || []).length\n const bgImages = (html.match(/url\\s*\\([^)]+\\)/gi) || []).length\n const totalImages = imgTags + bgImages\n\n // Count links\n const links = (html.match(/<a\\b[^>]*href\\s*=/gi) || []).length\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n size: {\n bytes: sizeBytes,\n formatted: humanFileSize(sizeBytes),\n },\n images: totalImages,\n links,\n }))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ error: error.message }))\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nasync function serveEmailEndpoint(url: string, req: any, res: any, config: MaizzleConfig, renderer: Renderer) {\n const templateSlug = url.replace('/__maizzle/email/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ success: false, message: 'Template not found' }))\n return\n }\n\n let body = ''\n for await (const chunk of req) body += chunk\n\n let payload: { to: string[]; subject: string }\n\n try {\n payload = JSON.parse(body)\n } catch {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Invalid JSON' }))\n return\n }\n\n if (!payload.to?.length) {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Missing recipients' }))\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = `${doctype}\\n${html}`\n\n const text = createPlaintext(stripForPlaintext(html))\n html = stripForHtml(html)\n\n const result = await sendEmail(\n { to: payload.to, subject: payload.subject, html, text },\n config,\n templateConfig,\n )\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ success: false, message: error.message }))\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nfunction serveEmailConfig(config: MaizzleConfig, res: any) {\n const emailConfig = config.server?.email\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n to: emailConfig?.to ? (Array.isArray(emailConfig.to) ? emailConfig.to : [emailConfig.to]) : [],\n from: emailConfig?.from ?? '',\n subject: emailConfig?.subject ?? '',\n hasTransport: !!emailConfig?.transport,\n }))\n}\n\nexport function printBanner(server: ViteDevServer, startupTime?: number) {\n const info = server.config.logger.info\n const time = startupTime ?? (server as any)._maizzleStartupTime\n\n const networkUrl = server.resolvedUrls?.network[0]\n if (networkUrl) {\n const qr = renderUnicodeCompact(networkUrl, { border: 1 })\n info('')\n info(qr.split('\\n').map(line => ` ${line}`).join('\\n'))\n }\n\n info('')\n info(` \\x1b[32m\\x1b[1mMAIZZLE\\x1b[0m\\x1b[32m v6.0.0\\x1b[0m \\x1b[2mready in\\x1b[0m \\x1b[1m${time}\\x1b[0m ms`)\n info('')\n server.printUrls()\n info('')\n}\n\nfunction customLogger() {\n const logger = createLogger('info')\n const warn = logger.warn\n\n logger.warn = (message, options) => {\n if (typeof message === 'string' && message.includes('<tr> cannot be child of <table>')) {\n return\n }\n\n warn(message, options)\n }\n\n return logger\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,WAAW,QADC,QAAQ,cAAc,OAAO,KAAK,GAAG,CACtB,GAAG,WAAW;AA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IAAI,KAAK,UAAU;EACrB,IAAI,aAAa,KAAM,MAAM,QAAQ,YAAY,EAAE,IAAI,YAAY,KAAK,CAAC,YAAY,EAAE,IAAK,CAAC;EAC7F,MAAM,aAAa,QAAQ;EAC3B,SAAS,aAAa,WAAW;EACjC,cAAc,CAAC,CAAC,aAAa;CAC/B,CAAC,CAAC;AACJ;AAEA,SAAgB,YAAY,QAAuB,aAAsB;CACvE,MAAM,OAAO,OAAO,OAAO,OAAO;CAClC,MAAM,OAAO,eAAgB,OAAe;CAE5C,MAAM,aAAa,OAAO,cAAc,QAAQ;CAChD,IAAI,YAAY;EACd,MAAM,KAAK,qBAAqB,YAAY,EAAE,QAAQ,EAAE,CAAC;EACzD,KAAK,EAAE;EACP,KAAK,GAAG,MAAM,IAAI,EAAE,KAAI,SAAQ,KAAK,MAAM,EAAE,KAAK,IAAI,CAAC;CACzD;CAEA,KAAK,EAAE;CACP,KAAK,wFAAwF,KAAK,WAAW;CAC7G,KAAK,EAAE;CACP,OAAO,UAAU;CACjB,KAAK,EAAE;AACT;AAEA,SAAS,eAAe;CACtB,MAAM,SAAS,aAAa,MAAM;CAClC,MAAM,OAAO,OAAO;CAEpB,OAAO,QAAQ,SAAS,YAAY;EAClC,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,iCAAiC,GACnF;EAGF,KAAK,SAAS,OAAO;CACvB;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"serve.js","names":["parsePath"],"sources":["../src/serve.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { dirname, resolve, basename, parse as parsePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { createServer, createLogger, type ViteDevServer } from 'vite'\nimport { renderUnicodeCompact } from 'uqr'\nimport vue from '@vitejs/plugin-vue'\nimport tailwindcss from '@tailwindcss/vite'\nimport { glob } from 'tinyglobby'\nimport { createHighlighter, type Highlighter } from 'shiki'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { resolveConfig } from './config/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer, type Renderer } from './render/createRenderer.ts'\nimport { _setCurrentTemplate } from './composables/useCurrentTemplate.ts'\nimport { setActiveRenderer } from './render/active.ts'\nimport { serveCompatibility } from './server/compatibility.ts'\nimport { serveLint } from './server/linter.ts'\nimport { sendEmail } from './server/email.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport { createWatchedFileMatcher } from './utils/watchPaths.ts'\nimport type { MaizzleConfig } from './types/index.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst devUIDir = resolve(__dirname, 'server/ui')\n\nconst require = createRequire(import.meta.url)\nconst pkg = (name: string) => {\n const resolved = require.resolve(name).replace(/\\\\/g, '/')\n const marker = `node_modules/${name}`\n const idx = resolved.lastIndexOf(marker)\n\n return resolved.slice(0, idx + marker.length)\n}\n\nexport interface ServeOptions {\n config?: Partial<MaizzleConfig> | string\n /** Override the dev server port (takes precedence over config.server.port) */\n port?: number\n /** Expose the server on the network (e.g. --host) */\n host?: boolean | string\n /** When true, suppresses the banner/URL output (used by the Vite plugin, which prints its own) */\n silent?: boolean\n}\n\n/**\n * Start the Maizzle dev server.\n *\n * Creates two things:\n * 1. A Vite dev server for the dev UI (sidebar + preview, with Vue + Tailwind for the UI itself)\n * 2. A Renderer instance for SSR rendering email templates\n *\n * Template rendering goes through the Renderer, not the Vite dev server.\n */\nexport async function serve(options: ServeOptions = {}) {\n const start = performance.now()\n\n let config = await resolveConfig(options.config)\n const port = options.port ?? config.server?.port ?? 3000\n\n // Create a renderer for SSR rendering email templates (with dts for dev)\n let renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n\n /**\n * Register so user-land render() calls reuse this renderer instead of\n * spinning up another Vite SSR server (which collides when the host\n * app is itself a Vite dev process — e.g. TanStack Start).\n */\n setActiveRenderer(renderer)\n\n const server = await createServer({\n configFile: false,\n plugins: [\n // Vue and Tailwind are only for the dev UI SPA, not for email templates\n vue(),\n tailwindcss(),\n maizzleDevPlugin(config, renderer, options.config),\n ],\n resolve: {\n dedupe: ['vue'],\n alias: [\n { find: '@', replacement: devUIDir },\n { find: 'vue', replacement: resolve(pkg('vue'), 'dist/vue.runtime.esm-bundler.js') },\n ...['vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori']\n .map(name => ({ find: name, replacement: pkg(name) })),\n ],\n },\n cacheDir: resolve(devUIDir, '.vite'),\n optimizeDeps: {\n noDiscovery: true,\n include: [\n 'vue',\n 'vue-router',\n '@lucide/vue',\n '@vueuse/core',\n '@vueuse/shared',\n 'reka-ui',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'culori',\n ],\n },\n server: {\n port,\n host: options.host,\n fs: {\n allow: [process.cwd(), config.root ?? process.cwd(), devUIDir, ...['vue', 'vue-router', 'reka-ui', '@vueuse/core', '@vueuse/shared', '@lucide/vue', 'class-variance-authority', 'clsx', 'tailwind-merge', 'culori'].map(pkg)],\n },\n },\n customLogger: customLogger(),\n })\n\n // Store renderer ref on server for cleanup\n const originalClose = server.close.bind(server)\n server.close = async () => {\n setActiveRenderer(null)\n await renderer.close()\n return originalClose()\n }\n\n await server.listen()\n\n const startupTime = Math.round(performance.now() - start)\n\n if (!options.silent) {\n printBanner(server, startupTime)\n }\n\n // Expose startup time so the plugin can print it later\n ; (server as any)._maizzleStartupTime = startupTime\n\n return server\n}\n\n/**\n * Internal Vite plugin that adds Maizzle middleware and file watching to the dev UI server.\n */\nfunction maizzleDevPlugin(\n config: MaizzleConfig,\n renderer: Renderer,\n configInput: Partial<MaizzleConfig> | string | undefined,\n) {\n return {\n name: 'maizzle:dev',\n enforce: 'pre' as const,\n\n hotUpdate: {\n order: 'pre' as const,\n handler({ file }: { file: string }) {\n /**\n * Prevent Tailwind/Vue from triggering a full reload for email template\n * files. Maizzle handles these via custom HMR events in the\n * watcher below.\n */\n if (isTemplateFile(file)) {\n return []\n }\n },\n },\n\n configureServer(server: ViteDevServer) {\n // File watching\n const defaultWatchPaths = [\n 'maizzle.config.js',\n 'maizzle.config.ts',\n 'tailwind.config.js',\n 'tailwind.config.ts',\n 'locales/**',\n ]\n\n const userWatchPaths = config.server?.watch ?? []\n const watchPaths = [...defaultWatchPaths, ...userWatchPaths]\n const isWatchedFile = createWatchedFileMatcher(watchPaths, config.root ?? process.cwd())\n\n for (const watchPath of watchPaths) {\n server.watcher.add(watchPath)\n }\n\n server.watcher.on('add', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('unlink', async (file) => {\n if (isTemplateFile(file)) {\n await renderer.invalidateAll()\n server.ws.send({ type: 'custom', event: 'maizzle:templates-changed' })\n }\n })\n\n server.watcher.on('change', async (file) => {\n if (isWatchedFile(file)) {\n config = await resolveConfig(configInput)\n\n // Recreate the renderer so config changes (e.g. markdown.shikiTheme) take effect\n await renderer.close()\n renderer = await createRenderer({ dts: true, markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n\n /**\n * Push UI-relevant config bits so the dev UI reacts to live edits\n * without a page reload. Uses the same shape as the initial\n * inject.\n */\n server.ws.send({ type: 'custom', event: 'maizzle:config-updated', data: buildUiConfig(config) })\n }\n\n /**\n * Invalidate all renderer modules so component and config changes\n * are picked up on the next render (Tailwind recompiles with\n * fresh content).\n */\n await renderer.invalidateAll()\n\n if (\n isTemplateFile(file)\n || isWatchedFile(file)\n ) {\n server.ws.send({ type: 'custom', event: 'maizzle:template-updated', data: { file } })\n }\n })\n\n // API middleware (before Vite's middleware)\n server.middlewares.use(async (req: any, res: any, next: any) => {\n const url = req.url || '/'\n\n if (url === '/__maizzle/templates') {\n return serveTemplateList(config, res)\n }\n\n if (url.startsWith('/__maizzle/render/')) {\n return await serveRenderedTemplate(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/source/')) {\n return await serveHighlightedSource(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/compatibility/')) {\n return await serveCompatibility(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/lint/')) {\n return await serveLint(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()))\n }\n\n if (url.startsWith('/__maizzle/vue-source/')) {\n return await serveVueSource(url, config, res)\n }\n\n if (url.startsWith('/__maizzle/plaintext/')) {\n return await servePlaintext(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/stats/')) {\n return await serveStats(url, config, renderer, res)\n }\n\n if (url.startsWith('/__maizzle/email/') && req.method === 'POST') {\n return await serveEmailEndpoint(url, req, res, config, renderer)\n }\n\n if (url === '/__maizzle/email-config') {\n return serveEmailConfig(config, res)\n }\n\n next()\n })\n\n // Dev UI fallback (after Vite's middleware)\n return () => {\n server.middlewares.use(async (req: any, res: any, next: any) => {\n if (isNavigationRequest(req)) {\n return await serveDevUI(server, res, req.url || '/', config)\n }\n\n next()\n })\n }\n },\n }\n}\n\nfunction isTemplateFile(file: string): boolean {\n return (file.endsWith('.vue') || file.endsWith('.md')) && !file.includes('server/ui')\n}\n\nfunction isNavigationRequest(req: any): boolean {\n const accept = req.headers?.accept || ''\n return req.method === 'GET' && accept.includes('text/html')\n}\n\n/**\n * Shape exposed to the dev UI both at initial HTML load (as\n * `window.__MAIZZLE_CONFIG__`) and on the `maizzle:config-updated` HMR event.\n * Add UI-visible config bits here; consumers on both ends pick up automatically.\n */\nfunction buildUiConfig(config: MaizzleConfig) {\n return {\n checks: config.server?.checks ?? true,\n }\n}\n\nasync function serveDevUI(server: ViteDevServer, res: any, url: string, config: MaizzleConfig) {\n let indexHtml = readFileSync(resolve(devUIDir, 'index.html'), 'utf-8')\n\n indexHtml = indexHtml.replace('./main.ts', `/@fs/${resolve(devUIDir, 'main.ts')}`)\n indexHtml = indexHtml.replace('./favicon.svg', `/@fs/${resolve(devUIDir, 'favicon.svg')}`)\n\n const configScript = `<script>window.__MAIZZLE_CONFIG__ = ${JSON.stringify(buildUiConfig(config))};</script>`\n indexHtml = indexHtml.replace('</head>', `${configScript}</head>`)\n\n const transformed = await server.transformIndexHtml(url, indexHtml)\n\n res.setHeader('Content-Type', 'text/html')\n res.end(transformed)\n}\n\nasync function serveTemplateList(config: MaizzleConfig, res: any) {\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n\n const data = templates.map(t => ({\n name: basename(t).replace(/\\.(vue|md)$/, ''),\n path: t,\n href: '/' + t.replace(/\\.(vue|md)$/, ''),\n }))\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(data))\n}\n\n/**\n * SSR render a .vue template using the Renderer (not the dev UI server).\n */\nasync function serveRenderedTemplate(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/render/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n // Invalidate all modules so template + component changes are picked up\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n if (doctype) html = `${doctype}\\n${html}`\n\n res.setHeader('Content-Type', 'text/html')\n res.end(stripForHtml(html))\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['laserwave'],\n langs: ['html', 'vue'],\n })\n }\n return highlighter\n}\n\nasync function serveHighlightedSource(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n html = stripForHtml(doctype ? `${doctype}\\n${html}` : html)\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(html, {\n lang: 'html',\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nasync function serveVueSource(url: string, config: MaizzleConfig, res: any) {\n const templateSlug = url.replace('/__maizzle/vue-source/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n try {\n const source = readFileSync(resolve(match), 'utf-8')\n const lang = match.endsWith('.md') ? 'html' : 'vue'\n\n const hl = await getHighlighter()\n const highlighted = hl.codeToHtml(source, {\n lang,\n theme: 'laserwave',\n transformers: [{\n line(node, line) {\n node.properties['data-line'] = line\n },\n }],\n })\n\n res.setHeader('Content-Type', 'text/html')\n res.end(highlighted)\n } catch (error: any) {\n res.statusCode = 500\n res.end(`<pre>${error.stack || error.message}</pre>`)\n }\n}\n\nasync function servePlaintext(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/plaintext/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end('Template not found')\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n\n const plaintext = createPlaintext(stripForPlaintext(html))\n\n res.setHeader('Content-Type', 'text/plain')\n res.end(plaintext)\n } catch (error: any) {\n res.statusCode = 500\n res.end(error.message)\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nfunction humanFileSize(bytes: number, si = false, dp = 2) {\n const threshold = si ? 1000 : 1024\n\n if (Math.abs(bytes) < threshold) {\n return bytes + ' B'\n }\n\n const units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n let u = -1\n const r = 10 ** dp\n\n do {\n bytes /= threshold\n ++u\n } while (Math.round(Math.abs(bytes) * r) / r >= threshold && u < units.length - 1)\n\n return bytes.toFixed(dp) + ' ' + units[u]\n}\n\nasync function serveStats(url: string, config: MaizzleConfig, renderer: Renderer, res: any) {\n const templateSlug = url.replace('/__maizzle/stats/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ error: 'Template not found' }))\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n html = stripForHtml(html)\n\n const sizeBytes = Buffer.byteLength(html, 'utf-8')\n\n // Count images: <img> tags and CSS background images\n const imgTags = (html.match(/<img\\b[^>]*>/gi) || []).length\n const bgImages = (html.match(/url\\s*\\([^)]+\\)/gi) || []).length\n const totalImages = imgTags + bgImages\n\n // Count links\n const links = (html.match(/<a\\b[^>]*href\\s*=/gi) || []).length\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n size: {\n bytes: sizeBytes,\n formatted: humanFileSize(sizeBytes),\n },\n images: totalImages,\n links,\n }))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ error: error.message }))\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nasync function serveEmailEndpoint(url: string, req: any, res: any, config: MaizzleConfig, renderer: Renderer) {\n const templateSlug = url.replace('/__maizzle/email/', '').replace(/\\?.*$/, '')\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const templates = await glob(contentPatterns)\n const match = templates.find(t => t.replace(/\\.(vue|md)$/, '') === templateSlug)\n\n if (!match) {\n res.statusCode = 404\n res.end(JSON.stringify({ success: false, message: 'Template not found' }))\n return\n }\n\n let body = ''\n for await (const chunk of req) body += chunk\n\n let payload: { to: string[]; subject: string }\n\n try {\n payload = JSON.parse(body)\n } catch {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Invalid JSON' }))\n return\n }\n\n if (!payload.to?.length) {\n res.statusCode = 400\n res.end(JSON.stringify({ success: false, message: 'Missing recipients' }))\n return\n }\n\n const absolutePath = resolve(match)\n _setCurrentTemplate(parsePath(absolutePath))\n\n try {\n await renderer.invalidateAll()\n\n const rendered = await renderer.render(absolutePath, config)\n let html = rendered.html\n const templateConfig = rendered.templateConfig\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n if (doctype) html = `${doctype}\\n${html}`\n\n const text = createPlaintext(stripForPlaintext(html))\n html = stripForHtml(html)\n\n const result = await sendEmail(\n { to: payload.to, subject: payload.subject, html, text },\n config,\n templateConfig,\n )\n\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(result))\n } catch (error: any) {\n res.statusCode = 500\n res.end(JSON.stringify({ success: false, message: error.message }))\n } finally {\n _setCurrentTemplate(undefined)\n }\n}\n\nfunction serveEmailConfig(config: MaizzleConfig, res: any) {\n const emailConfig = config.server?.email\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify({\n to: emailConfig?.to ? (Array.isArray(emailConfig.to) ? emailConfig.to : [emailConfig.to]) : [],\n from: emailConfig?.from ?? '',\n subject: emailConfig?.subject ?? '',\n hasTransport: !!emailConfig?.transport,\n }))\n}\n\nexport function printBanner(server: ViteDevServer, startupTime?: number) {\n const info = server.config.logger.info\n const time = startupTime ?? (server as any)._maizzleStartupTime\n\n const networkUrl = server.resolvedUrls?.network[0]\n if (networkUrl) {\n const qr = renderUnicodeCompact(networkUrl, { border: 1 })\n info('')\n info(qr.split('\\n').map(line => ` ${line}`).join('\\n'))\n }\n\n info('')\n info(` \\x1b[32m\\x1b[1mMAIZZLE\\x1b[0m\\x1b[32m v6.0.0\\x1b[0m \\x1b[2mready in\\x1b[0m \\x1b[1m${time}\\x1b[0m ms`)\n info('')\n server.printUrls()\n info('')\n}\n\nfunction customLogger() {\n const logger = createLogger('info')\n const warn = logger.warn\n\n logger.warn = (message, options) => {\n if (typeof message === 'string' && message.includes('<tr> cannot be child of <table>')) {\n return\n }\n\n warn(message, options)\n }\n\n return logger\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,WAAW,QADC,QAAQ,cAAc,OAAO,KAAK,GAAG,CACtB,GAAG,WAAW;AAE/C,MAAM,UAAU,cAAc,OAAO,KAAK,GAAG;AAC7C,MAAM,OAAO,SAAiB;CAC5B,MAAM,WAAW,QAAQ,QAAQ,IAAI,EAAE,QAAQ,OAAO,GAAG;CACzD,MAAM,SAAS,gBAAgB;CAC/B,MAAM,MAAM,SAAS,YAAY,MAAM;CAEvC,OAAO,SAAS,MAAM,GAAG,MAAM,OAAO,MAAM;AAC9C;;;;;;;;;;AAqBA,eAAsB,MAAM,UAAwB,CAAC,GAAG;CACtD,MAAM,QAAQ,YAAY,IAAI;CAE9B,IAAI,SAAS,MAAM,cAAc,QAAQ,MAAM;CAC/C,MAAM,OAAO,QAAQ,QAAQ,OAAO,QAAQ,QAAQ;CAGpD,IAAI,WAAW,MAAM,eAAe;EAAE,KAAK;EAAM,UAAU,OAAO;EAAU,MAAM,OAAO;EAAM,eAAe,0BAA0B,OAAO,YAAY,QAAQ,QAAQ,IAAI,CAAC;EAAG,MAAM,OAAO;CAAK,CAAC;;;;;;CAOtM,kBAAkB,QAAQ;CAE1B,MAAM,SAAS,MAAM,aAAa;EAChC,YAAY;EACZ,SAAS;GAEP,IAAI;GACJ,YAAY;GACZ,iBAAiB,QAAQ,UAAU,QAAQ,MAAM;EACnD;EACA,SAAS;GACP,QAAQ,CAAC,KAAK;GACd,OAAO;IACL;KAAE,MAAM;KAAK,aAAa;IAAS;IACnC;KAAE,MAAM;KAAO,aAAa,QAAQ,IAAI,KAAK,GAAG,iCAAiC;IAAE;IACnF,GAAG;K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
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, computed, onMounted, onUnmounted, watch, watchEffect } from 'vue'
|
|
3
3
|
import { RouterLink, RouterView, useRoute, useRouter } from 'vue-router'
|
|
4
|
-
import { Monitor, CodeXml, Smartphone, ChevronDown, ArrowUp, ArrowDown, CornerDownLeft, Check, Search,
|
|
4
|
+
import { Monitor, CodeXml, Smartphone, ChevronDown, ArrowUp, ArrowDown, CornerDownLeft, Check, Search, FileCode, FileText, Code, BookText, MailQuestion, Moon, Sun } from '@lucide/vue'
|
|
5
5
|
import SidebarClose from '@/components/SidebarClose.vue'
|
|
6
|
-
import Markdown from '@/components/Markdown.vue'
|
|
7
6
|
import logoUrl from '@/logo.svg'
|
|
8
7
|
import logoGradientUrl from '@/logo-gradient.svg'
|
|
9
8
|
import { Kbd } from '@/components/ui/kbd'
|
|
@@ -340,7 +339,7 @@ onUnmounted(() => {
|
|
|
340
339
|
:is-active="isActive(t.href)"
|
|
341
340
|
>
|
|
342
341
|
<RouterLink :to="t.href" class="truncate">
|
|
343
|
-
<
|
|
342
|
+
<span class="mz-tpl-icon size-4 shrink-0 opacity-70" :class="t.path.endsWith('.md') ? 'mz-tpl-icon-md' : 'mz-tpl-icon-vue'" />
|
|
344
343
|
<span class="truncate">{{ t.name }}</span>
|
|
345
344
|
</RouterLink>
|
|
346
345
|
</SidebarMenuButton>
|
|
@@ -507,7 +506,7 @@ onUnmounted(() => {
|
|
|
507
506
|
:value="t.path"
|
|
508
507
|
@select="onCommandSelect(t.href)"
|
|
509
508
|
>
|
|
510
|
-
<
|
|
509
|
+
<span class="mz-tpl-icon size-3 shrink-0 opacity-70" :class="t.path.endsWith('.md') ? 'mz-tpl-icon-md' : 'mz-tpl-icon-vue'" />
|
|
511
510
|
<span>{{ getFileName(t.path) }}</span>
|
|
512
511
|
<span class="sr-only">{{ ' ' + t.path.split('/').join(' ') }}</span>
|
|
513
512
|
</CommandItem>
|
package/dist/server/ui/main.css
CHANGED
|
@@ -127,3 +127,28 @@
|
|
|
127
127
|
border-left: 2px solid #f59e0b;
|
|
128
128
|
min-width: fit-content;
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Template list icons, painted as a CSS mask so the sidebar can render
|
|
133
|
+
* thousands of rows without a Vue component or inline <svg> per row. Each
|
|
134
|
+
* icon SVG is decoded once and reused; background-color: currentColor keeps
|
|
135
|
+
* the currentColor theming the old <svg> icons had.
|
|
136
|
+
*/
|
|
137
|
+
.mz-tpl-icon {
|
|
138
|
+
display: inline-block;
|
|
139
|
+
background-color: currentColor;
|
|
140
|
+
-webkit-mask-position: center;
|
|
141
|
+
mask-position: center;
|
|
142
|
+
-webkit-mask-size: contain;
|
|
143
|
+
mask-size: contain;
|
|
144
|
+
-webkit-mask-repeat: no-repeat;
|
|
145
|
+
mask-repeat: no-repeat;
|
|
146
|
+
}
|
|
147
|
+
.mz-tpl-icon-vue {
|
|
148
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%3Cpath d='m5 16-3 3 3 3'/%3E%3Cpath d='m9 22 3-3-3-3'/%3E%3C/svg%3E");
|
|
149
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%3Cpath d='m5 16-3 3 3 3'/%3E%3Cpath d='m9 22 3-3-3-3'/%3E%3C/svg%3E");
|
|
150
|
+
}
|
|
151
|
+
.mz-tpl-icon-md {
|
|
152
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22h6a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%3Cpath d='M3 22V14l4 4 4-4v8'/%3E%3C/svg%3E");
|
|
153
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22h6a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%3Cpath d='M3 22V14l4 4 4-4v8'/%3E%3C/svg%3E");
|
|
154
|
+
}
|
|
@@ -241,7 +241,11 @@ function updateIframeContentHeight() {
|
|
|
241
241
|
|
|
242
242
|
// Temporarily collapse to measure true content height
|
|
243
243
|
iframe.style.height = '0'
|
|
244
|
-
|
|
244
|
+
const contentHeight = doc.documentElement.scrollHeight
|
|
245
|
+
// Fill the preview viewport when the email is shorter than it; grow past it
|
|
246
|
+
// (and let the ScrollArea scroll) when the email is taller.
|
|
247
|
+
const availableHeight = viewport?.clientHeight ?? 0
|
|
248
|
+
iframeContentHeight.value = Math.max(contentHeight, availableHeight)
|
|
245
249
|
iframe.style.height = `${iframeContentHeight.value}px`
|
|
246
250
|
|
|
247
251
|
// Restore scroll position
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg
|
|
3
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
-
width="24"
|
|
5
|
-
height="24"
|
|
6
|
-
viewBox="0 0 24 24"
|
|
7
|
-
fill="none"
|
|
8
|
-
stroke="currentColor"
|
|
9
|
-
stroke-width="1"
|
|
10
|
-
stroke-linecap="round"
|
|
11
|
-
stroke-linejoin="round"
|
|
12
|
-
>
|
|
13
|
-
<path d="M12 22h6a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6" />
|
|
14
|
-
<path d="M14 2v5a1 1 0 0 0 1 1h5" />
|
|
15
|
-
<path d="M3 22V14l4 4 4-4v8" />
|
|
16
|
-
</svg>
|
|
17
|
-
</template>
|