@maizzle/framework 6.0.0-rc.19 → 6.0.0-rc.20
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.d.ts.map +1 -1
- package/dist/build.js +2 -1
- package/dist/build.js.map +1 -1
- package/dist/config/index.js +6 -3
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/prepare.d.ts.map +1 -1
- package/dist/prepare.js +2 -1
- package/dist/prepare.js.map +1 -1
- package/dist/render/createRenderer.d.ts +6 -2
- package/dist/render/createRenderer.d.ts.map +1 -1
- package/dist/render/createRenderer.js +93 -6
- package/dist/render/createRenderer.js.map +1 -1
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +2 -1
- package/dist/render/index.js.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +5 -4
- package/dist/serve.js.map +1 -1
- package/dist/server/compatibility.d.ts +3 -1
- package/dist/server/compatibility.d.ts.map +1 -1
- package/dist/server/compatibility.js +2 -1
- package/dist/server/compatibility.js.map +1 -1
- package/dist/server/linter.d.ts +4 -2
- package/dist/server/linter.d.ts.map +1 -1
- package/dist/server/linter.js +2 -2
- package/dist/server/linter.js.map +1 -1
- package/dist/server/sfc-utils.d.ts +5 -2
- package/dist/server/sfc-utils.d.ts.map +1 -1
- package/dist/server/sfc-utils.js +25 -10
- package/dist/server/sfc-utils.js.map +1 -1
- package/dist/types/config.d.ts +38 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/componentSources.d.ts +50 -0
- package/dist/utils/componentSources.d.ts.map +1 -0
- package/dist/utils/componentSources.js +50 -0
- package/dist/utils/componentSources.js.map +1 -0
- package/package.json +1 -1
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","names":[],"sources":["../src/build.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"build.d.ts","names":[],"sources":["../src/build.ts"],"mappings":";;UAciB,WAAA;EACf,KAAA;EACA,MAAA,EAAQ,aAAA;AAAA;;;;;;;;;AAaV;;iBAAsB,KAAA,CAAM,WAAA,GAAc,OAAA,CAAQ,aAAA,aAA0B,OAAA,CAAQ,WAAA"}
|
package/dist/build.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveConfig } from "./config/index.js";
|
|
2
2
|
import { EventManager } from "./events/index.js";
|
|
3
3
|
import { runTransformers } from "./transformers/index.js";
|
|
4
|
+
import { normalizeComponentSources } from "./utils/componentSources.js";
|
|
4
5
|
import { createRenderer } from "./render/createRenderer.js";
|
|
5
6
|
import { createPlaintext } from "./plaintext.js";
|
|
6
7
|
import { stripForHtml, stripForPlaintext } from "./utils/output-markers.js";
|
|
@@ -49,7 +50,7 @@ async function build(configInput) {
|
|
|
49
50
|
const renderer = await createRenderer({
|
|
50
51
|
markdown: config.markdown,
|
|
51
52
|
root: config.root,
|
|
52
|
-
componentDirs:
|
|
53
|
+
componentDirs: normalizeComponentSources(config.components?.source, process.cwd()),
|
|
53
54
|
vite: config.vite
|
|
54
55
|
});
|
|
55
56
|
const outputFiles = [];
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","names":[],"sources":["../src/build.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join } from 'node:path'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport 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: [config.components?.source ?? []].flat(), vite: config.vite })\n const outputFiles: string[] = []\n\n try {\n for (const templatePath of templateFiles) {\n const absolutePath = resolve(templatePath)\n let template = readFileSync(absolutePath, 'utf-8')\n\n template = await events.fireBeforeRender({ config, template })\n\n const rendered = await renderer.render(absolutePath, config)\n\n // Register SFC event handlers collected during render so they participate\n // in the post-render events (afterRender / afterTransform). They're cleared\n // at the end of the iteration so they don't leak into the next template.\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n let html = await events.fireAfterRender({ config, template, html: rendered.html })\n\n // Use the per-template merged config (from defineConfig() in the SFC) so that\n // template-level overrides like css.safe: false are respected by transformers.\n const templateConfig = rendered.templateConfig\n\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n }\n\n html = await events.fireAfterTransform({ config, template, html })\n html = `${doctype}\\n${html}`\n\n const htmlOut = stripForHtml(html)\n const outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase)\n mkdirSync(dirname(outputFilePath), { recursive: true })\n writeFileSync(outputFilePath, htmlOut)\n outputFiles.push(outputFilePath)\n\n // Generate plaintext version if configured\n const globalPlaintext = templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n const plaintext = createPlaintext(stripForPlaintext(html), stripOptions)\n const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? 'txt'\n\n let ptOutputPath: string\n\n if (sfcPlaintext?.destination) {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`)\n } else if (globalCfg.destination) {\n ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase)\n } else {\n ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase)\n }\n\n mkdirSync(dirname(ptOutputPath), { recursive: true })\n writeFileSync(ptOutputPath, plaintext)\n }\n\n events.clearSfcHandlers()\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n}\n\n/**\n * Extract the static (non-glob) prefix from content patterns.\n *\n * For example, `['/abs/path/emails/**\\/*.vue']` → `'/abs/path/emails'`\n *\n * This is used to strip the content base from template paths\n * so the output preserves only the subdirectory structure.\n */\nfunction computeContentBase(patterns: string[]): string {\n // Use the first non-negated pattern\n const pattern = patterns.find(p => !p.startsWith('!')) ?? patterns[0]\n\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n}\n\nfunction resolveOutputPath(templatePath: string, outputDir: string, extension: string, contentBase: string): string {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n const absTemplate = resolve(templatePath)\n const rel = relative(contentBase, dirname(absTemplate))\n\n return join(outputDir, rel, `${name}.${extension}`)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n const files = await glob(sources)\n\n for (const file of files) {\n const destPath = join(outputPath, destination, relative(dirname(sources[0]).replace(/\\*.*$/, ''), file))\n const destDir = dirname(destPath)\n\n if (!existsSync(destDir)) {\n mkdirSync(destDir, { recursive: true })\n }\n\n cpSync(file, destPath)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,MAAM,aAAqE;CAC/F,MAAM,QAAQ,KAAK,KAAK;CACxB,MAAM,UAAU,IAAI;EAAE,MAAM;EAAyB,SAAS;EAAgB,CAAC,CAAC,OAAO;CAEvF,MAAM,SAAS,MAAM,cAAc,YAAY;CAE/C,MAAM,SAAS,IAAI,cAAc;CACjC,OAAO,eAAe,OAAO;CAC7B,MAAM,OAAO,iBAAiB,EAAE,QAAQ,CAAC;CAEzC,MAAM,aAAa,QAAQ,OAAO,QAAQ,QAAQ,OAAO;CACzD,MAAM,kBAAkB,OAAO,QAAQ,aAAa;CAEpD,MAAM,kBAAkB,OAAO,WAAW,CAAC,kBAAkB;CAC7D,MAAM,cAAc,mBAAmB,gBAAgB;CACvD,MAAM,gBAAgB,MAAM,KAAK,gBAAgB;CAEjD,IAAI,cAAc,WAAW,GAAG;EAC9B,QAAQ,QAAQ,qBA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AAa,CAAC,QAAQ,eAAe,GAAG;CAI9D,OAAO,KAAK,WAFA,SAAS,aAAa,QADd,QAAQ,aACyB,CAAC,CAE5B,EAAE,GAAG,KAAK,GAAG,YAAY;;AAGrD,eAAe,WAAW,QAAuB,YAAmC;CAClF,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,gBAAgB;CAC1D,MAAM,cAAc,OAAO,QAAQ,eAAe;CAElD,MAAM,QAAQ,MAAM,KAAK,QAAQ;CAEjC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,YAAY,aAAa,SAAS,QAAQ,QAAQ,GAAG,CAAC,QAAQ,SAAS,GAAG,EAAE,KAAK,CAAC;EACxG,MAAM,UAAU,QAAQ,SAAS;EAEjC,IAAI,CAAC,WAAW,QAAQ,EACtB,UAAU,SAAS,EAAE,WAAW,MAAM,CAAC;EAGzC,OAAO,MAAM,SAAS"}
|
|
1
|
+
{"version":3,"file":"build.js","names":[],"sources":["../src/build.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, cpSync, existsSync, rmSync } from 'node:fs'\nimport { resolve, dirname, basename, relative, join } from 'node:path'\nimport { glob } from 'tinyglobby'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { EventManager } from './events/index.ts'\nimport { runTransformers } from './transformers/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { createPlaintext } from './plaintext.ts'\nimport { stripForHtml, stripForPlaintext } from './utils/output-markers.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\nimport defu from 'defu'\nimport type { MaizzleConfig } from './types/index.ts'\n\nexport interface BuildResult {\n files: string[]\n config: MaizzleConfig\n}\n\n/**\n * Build all SFC email templates to HTML files.\n *\n * Creates a single Renderer instance, then loops through each template\n * calling render → transformers → write to disk.\n *\n * Pass a `Partial<MaizzleConfig>` to override config inline, or a string\n * to load config from a specific file path. Omit to load `maizzle.config`\n * from the working directory.\n */\nexport async function build(configInput?: Partial<MaizzleConfig> | string): Promise<BuildResult> {\n const start = Date.now()\n const spinner = ora({ text: 'Building templates...', spinner: 'circleHalves' }).start()\n\n const config = await resolveConfig(configInput)\n\n const events = new EventManager()\n events.registerConfig(config)\n await events.fireBeforeCreate({ config })\n\n const outputPath = resolve(config.output?.path ?? 'dist')\n const outputExtension = config.output?.extension ?? 'html'\n\n const contentPatterns = config.content ?? ['emails/**/*.vue']\n const contentBase = computeContentBase(contentPatterns)\n const templateFiles = await glob(contentPatterns)\n\n if (templateFiles.length === 0) {\n spinner.succeed('No templates found')\n return { files: [], config }\n }\n\n // Clear the output directory before writing fresh output\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true })\n }\n\n const renderer = await createRenderer({ markdown: config.markdown, root: config.root, componentDirs: normalizeComponentSources(config.components?.source, process.cwd()), vite: config.vite })\n const outputFiles: string[] = []\n\n try {\n for (const templatePath of templateFiles) {\n const absolutePath = resolve(templatePath)\n let template = readFileSync(absolutePath, 'utf-8')\n\n template = await events.fireBeforeRender({ config, template })\n\n const rendered = await renderer.render(absolutePath, config)\n\n // Register SFC event handlers collected during render so they participate\n // in the post-render events (afterRender / afterTransform). They're cleared\n // at the end of the iteration so they don't leak into the next template.\n for (const { name, handler } of rendered.sfcEventHandlers) {\n events.on(name, handler)\n }\n\n let html = await events.fireAfterRender({ config, template, html: rendered.html })\n\n // Use the per-template merged config (from defineConfig() in the SFC) so that\n // template-level overrides like css.safe: false are respected by transformers.\n const templateConfig = rendered.templateConfig\n\n const doctype = rendered.doctype ?? templateConfig.doctype ?? '<!DOCTYPE html>'\n\n if (templateConfig.useTransformers !== false) {\n html = await runTransformers(html, templateConfig, absolutePath, doctype, rendered.tailwindBlocks)\n }\n\n html = await events.fireAfterTransform({ config, template, html })\n html = `${doctype}\\n${html}`\n\n const htmlOut = stripForHtml(html)\n const outputFilePath = resolveOutputPath(templatePath, outputPath, outputExtension, contentBase)\n mkdirSync(dirname(outputFilePath), { recursive: true })\n writeFileSync(outputFilePath, htmlOut)\n outputFiles.push(outputFilePath)\n\n // Generate plaintext version if configured\n const globalPlaintext = templateConfig.plaintext\n const sfcPlaintext = rendered.plaintext\n\n if (globalPlaintext || sfcPlaintext) {\n const globalCfg = typeof globalPlaintext === 'object' ? globalPlaintext : {}\n const stripOptions = defu(sfcPlaintext?.options, globalCfg.options)\n const plaintext = createPlaintext(stripForPlaintext(html), stripOptions)\n const ptExtension = sfcPlaintext?.extension ?? globalCfg.extension ?? 'txt'\n\n let ptOutputPath: string\n\n if (sfcPlaintext?.destination) {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n ptOutputPath = join(resolve(sfcPlaintext.destination), `${name}.${ptExtension}`)\n } else if (globalCfg.destination) {\n ptOutputPath = resolveOutputPath(templatePath, resolve(globalCfg.destination), ptExtension, contentBase)\n } else {\n ptOutputPath = resolveOutputPath(templatePath, outputPath, ptExtension, contentBase)\n }\n\n mkdirSync(dirname(ptOutputPath), { recursive: true })\n writeFileSync(ptOutputPath, plaintext)\n }\n\n events.clearSfcHandlers()\n }\n\n await copyStatic(config, outputPath)\n await events.fireAfterBuild({ files: outputFiles, config })\n } finally {\n await renderer.close()\n }\n\n const duration = ((Date.now() - start) / 1000).toFixed(2)\n const count = outputFiles.length\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Built ${count} template${count !== 1 ? 's' : ''} in ${duration}s`,\n })\n\n return { files: outputFiles, config }\n}\n\n/**\n * Extract the static (non-glob) prefix from content patterns.\n *\n * For example, `['/abs/path/emails/**\\/*.vue']` → `'/abs/path/emails'`\n *\n * This is used to strip the content base from template paths\n * so the output preserves only the subdirectory structure.\n */\nfunction computeContentBase(patterns: string[]): string {\n // Use the first non-negated pattern\n const pattern = patterns.find(p => !p.startsWith('!')) ?? patterns[0]\n\n // Split on first glob character (* { ? [) and take the directory part\n const staticPart = pattern.split(/[*{?[]/)[0]\n\n // Ensure we have a clean directory path (not a partial segment)\n return resolve(staticPart.endsWith('/') ? staticPart : dirname(staticPart))\n}\n\nfunction resolveOutputPath(templatePath: string, outputDir: string, extension: string, contentBase: string): string {\n const name = basename(templatePath).replace(/\\.(vue|md)$/, '')\n const absTemplate = resolve(templatePath)\n const rel = relative(contentBase, dirname(absTemplate))\n\n return join(outputDir, rel, `${name}.${extension}`)\n}\n\nasync function copyStatic(config: MaizzleConfig, outputPath: string): Promise<void> {\n const sources = config.static?.source ?? ['public/**/*.*']\n const destination = config.static?.destination ?? 'public'\n\n const files = await glob(sources)\n\n for (const file of files) {\n const destPath = join(outputPath, destination, relative(dirname(sources[0]).replace(/\\*.*$/, ''), file))\n const destDir = dirname(destPath)\n\n if (!existsSync(destDir)) {\n mkdirSync(destDir, { recursive: true })\n }\n\n cpSync(file, destPath)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,MAAM,aAAqE;CAC/F,MAAM,QAAQ,KAAK,KAAK;CACxB,MAAM,UAAU,IAAI;EAAE,MAAM;EAAyB,SAAS;EAAgB,CAAC,CAAC,OAAO;CAEvF,MAAM,SAAS,MAAM,cAAc,YAAY;CAE/C,MAAM,SAAS,IAAI,cAAc;CACjC,OAAO,eAAe,OAAO;CAC7B,MAAM,OAAO,iBAAiB,EAAE,QAAQ,CAAC;CAEzC,MAAM,aAAa,QAAQ,OAAO,QAAQ,QAAQ,OAAO;CACzD,MAAM,kBAAkB,OAAO,QAAQ,aAAa;CAEpD,MAAM,kBAAkB,OAAO,WAAW,CAAC,kBAAkB;CAC7D,MAAM,cAAc,mBAAmB,gBAAgB;CACvD,MAAM,gBAAgB,MAAM,KAAK,gBAAgB;CAEjD,IAAI,cAAc,WAAW,GAAG;EAC9B,QAAQ,QAAQ,qBAAqB;EACrC,OAAO;GAAE,OAAO,EAAE;GAAE;GAAQ;;CAI9B,IAAI,WAAW,WAAW,EACxB,OAAO,YAAY;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC;CAGtD,MAAM,WAAW,MAAM,eAAe;EAAE,UAAU,OAAO;EAAU,MAAM,OAA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,UAAU,CAAC,gBAAgB;CAC1D,MAAM,cAAc,OAAO,QAAQ,eAAe;CAElD,MAAM,QAAQ,MAAM,KAAK,QAAQ;CAEjC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,YAAY,aAAa,SAAS,QAAQ,QAAQ,GAAG,CAAC,QAAQ,SAAS,GAAG,EAAE,KAAK,CAAC;EACxG,MAAM,UAAU,QAAQ,SAAS;EAEjC,IAAI,CAAC,WAAW,QAAQ,EACtB,UAAU,SAAS,EAAE,WAAW,MAAM,CAAC;EAGzC,OAAO,MAAM,SAAS"}
|
package/dist/config/index.js
CHANGED
|
@@ -36,9 +36,12 @@ async function resolveConfig(config, cwd = process.cwd()) {
|
|
|
36
36
|
});
|
|
37
37
|
if (merged.components?.source) {
|
|
38
38
|
const dirs = Array.isArray(merged.components.source) ? merged.components.source : [merged.components.source];
|
|
39
|
-
merged.components.source = dirs.map((
|
|
40
|
-
if (
|
|
41
|
-
return
|
|
39
|
+
merged.components.source = dirs.map((entry) => {
|
|
40
|
+
if (typeof entry === "string") return entry.startsWith("/") ? entry : resolve(cwd, entry);
|
|
41
|
+
return {
|
|
42
|
+
...entry,
|
|
43
|
+
path: entry.path.startsWith("/") ? entry.path : resolve(cwd, entry.path)
|
|
44
|
+
};
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
if (hasExplicitRoot && !merged.css?.base) {
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/config/index.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { createJiti } from 'jiti'\nimport { fileURLToPath } from 'node:url'\nimport { createDefu } from 'defu'\n\n// defu that replaces arrays: if user provides content: ['x'], it replaces the default, not appends\nconst merge = createDefu((obj, key, value) => {\n if (Array.isArray(obj[key])) {\n obj[key] = value\n return true\n }\n})\nimport { defaults } from './defaults.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport { defineConfig } from '../composables/defineConfig.ts'\nexport { defaults } from './defaults.ts'\n\nconst CONFIG_FILES = [\n 'maizzle.config.ts',\n 'maizzle.config.js',\n]\n\n/**\n * Resolve the Maizzle config.\n *\n * Always loads from the config file on disk (maizzle.config.{ts,js}),\n * then merges the programmatic config on top, then fills in defaults.\n */\nexport async function resolveConfig(\n config?: Partial<MaizzleConfig> | string,\n cwd: string = process.cwd(),\n): Promise<MaizzleConfig> {\n // If a string path was provided, load that specific file\n const fileConfig = await loadConfig(\n typeof config === 'string' ? config : undefined,\n cwd,\n )\n\n // Programmatic config (object) overrides file config, which overrides defaults\n const programmaticConfig = typeof config === 'object' && config !== null ? config : {}\n\n const merged = merge(programmaticConfig, fileConfig, defaults) as MaizzleConfig\n\n // Check if root was explicitly provided before resolving\n const hasExplicitRoot = !!(programmaticConfig.root ?? fileConfig.root)\n\n // Resolve root to an absolute path (defaults to cwd)\n const root = resolve(cwd, merged.root ?? '.')\n merged.root = root\n\n // Resolve content patterns relative to root\n if (merged.content) {\n merged.content = merged.content.map(p => {\n // Skip already-absolute or negated patterns\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p).replace(/\\\\/g, '/')\n })\n }\n\n // Resolve static source patterns relative to root\n if (merged.static?.source) {\n merged.static.source = merged.static.source.map(p => {\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p).replace(/\\\\/g, '/')\n })\n }\n\n // Resolve components.source paths relative to cwd (not root),\n // since extra component dirs often live outside the root directory
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/config/index.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { createJiti } from 'jiti'\nimport { fileURLToPath } from 'node:url'\nimport { createDefu } from 'defu'\n\n// defu that replaces arrays: if user provides content: ['x'], it replaces the default, not appends\nconst merge = createDefu((obj, key, value) => {\n if (Array.isArray(obj[key])) {\n obj[key] = value\n return true\n }\n})\nimport { defaults } from './defaults.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport { defineConfig } from '../composables/defineConfig.ts'\nexport { defaults } from './defaults.ts'\n\nconst CONFIG_FILES = [\n 'maizzle.config.ts',\n 'maizzle.config.js',\n]\n\n/**\n * Resolve the Maizzle config.\n *\n * Always loads from the config file on disk (maizzle.config.{ts,js}),\n * then merges the programmatic config on top, then fills in defaults.\n */\nexport async function resolveConfig(\n config?: Partial<MaizzleConfig> | string,\n cwd: string = process.cwd(),\n): Promise<MaizzleConfig> {\n // If a string path was provided, load that specific file\n const fileConfig = await loadConfig(\n typeof config === 'string' ? config : undefined,\n cwd,\n )\n\n // Programmatic config (object) overrides file config, which overrides defaults\n const programmaticConfig = typeof config === 'object' && config !== null ? config : {}\n\n const merged = merge(programmaticConfig, fileConfig, defaults) as MaizzleConfig\n\n // Check if root was explicitly provided before resolving\n const hasExplicitRoot = !!(programmaticConfig.root ?? fileConfig.root)\n\n // Resolve root to an absolute path (defaults to cwd)\n const root = resolve(cwd, merged.root ?? '.')\n merged.root = root\n\n // Resolve content patterns relative to root\n if (merged.content) {\n merged.content = merged.content.map(p => {\n // Skip already-absolute or negated patterns\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p).replace(/\\\\/g, '/')\n })\n }\n\n // Resolve static source patterns relative to root\n if (merged.static?.source) {\n merged.static.source = merged.static.source.map(p => {\n if (p.startsWith('/') || p.startsWith('!')) return p\n return resolve(root, p).replace(/\\\\/g, '/')\n })\n }\n\n // Resolve components.source paths relative to cwd (not root),\n // since extra component dirs often live outside the root directory.\n // String entries → resolve in-place. Object entries → resolve `path`,\n // preserve `prefix`/`pathPrefix`.\n if (merged.components?.source) {\n const dirs = Array.isArray(merged.components.source)\n ? merged.components.source\n : [merged.components.source]\n\n merged.components.source = dirs.map(entry => {\n if (typeof entry === 'string') {\n return entry.startsWith('/') ? entry : resolve(cwd, entry)\n }\n return {\n ...entry,\n path: entry.path.startsWith('/') ? entry.path : resolve(cwd, entry.path),\n }\n })\n }\n\n // Default css.base to root when root is explicitly set,\n // so Tailwind resolves @source from the right directory.\n // When root is not set, leave css.base undefined so Tailwind\n // uses its own default (the template file's directory).\n if (hasExplicitRoot && !merged.css?.base) {\n if (!merged.css) merged.css = {}\n merged.css.base = root\n }\n\n return merged\n}\n\nasync function loadConfig(\n configPath?: string,\n cwd: string = process.cwd(),\n): Promise<MaizzleConfig> {\n const jiti = createJiti(fileURLToPath(import.meta.url), { moduleCache: false })\n\n // If an explicit path was provided, use it directly\n if (configPath) {\n const absolutePath = resolve(cwd, configPath)\n\n if (!existsSync(absolutePath)) {\n throw new Error(`Config file not found: ${absolutePath}`)\n }\n\n const mod = await jiti.import(absolutePath) as any\n return mod.default ?? mod\n }\n\n // Otherwise scan cwd for known config file names\n for (const filename of CONFIG_FILES) {\n const filepath = resolve(cwd, filename)\n\n if (existsSync(filepath)) {\n const mod = await jiti.import(filepath) as any\n return mod.default ?? mod\n }\n }\n\n // No config file found, return empty (defaults will be applied by resolveConfig)\n return {}\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,QAAQ,YAAY,KAAK,KAAK,UAAU;CAC5C,IAAI,MAAM,QAAQ,IAAI,KAAK,EAAE;EAC3B,IAAI,OAAO;EACX,OAAO;;EAET;AAOF,MAAM,eAAe,CACnB,qBACA,oBACD;;;;;;;AAQD,eAAsB,cACpB,QACA,MAAc,QAAQ,KAAK,EACH;CAExB,MAAM,aAAa,MAAM,WACvB,OAAO,WAAW,WAAW,SAAS,KAAA,GACtC,IACD;CAGD,MAAM,qBAAqB,OAAO,WAAW,YAAY,WAAW,OAAO,SAAS,EAAE;CAEtF,MAAM,SAAS,MAAM,oBAAoB,YAAY,SAAS;CAG9D,MAAM,kBAAkB,CAAC,EAAE,mBAAmB,QAAQ,WAAW;CAGjE,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;CAC7C,OAAO,OAAO;CAGd,IAAI,OAAO,SACT,OAAO,UAAU,OAAO,QAAQ,KAA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AQ,KAAK,SAAS;EAEvC,IAAI,WAAW,SAAS,EAAE;GACxB,MAAM,MAAM,MAAM,KAAK,OAAO,SAAS;GACvC,OAAO,IAAI,WAAW;;;CAK1B,OAAO,EAAE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttributesConfig, CssConfig, EntitiesConfig, FilterFunction, FiltersConfig, HtmlConfig, MaizzleConfig, PlaintextConfig, UrlConfig, UrlQuery, UrlQueryOptions } from "./types/config.js";
|
|
1
|
+
import { AttributesConfig, ComponentSource, CssConfig, EntitiesConfig, FilterFunction, FiltersConfig, HtmlConfig, MaizzleConfig, PlaintextConfig, UrlConfig, UrlQuery, UrlQueryOptions } from "./types/config.js";
|
|
2
2
|
import { build } from "./build.js";
|
|
3
3
|
import { defineConfig } from "./composables/defineConfig.js";
|
|
4
4
|
import { usePlaintext } from "./composables/usePlaintext.js";
|
|
@@ -12,6 +12,7 @@ import { useTransformers } from "./composables/useTransformers.js";
|
|
|
12
12
|
import { useUrlQuery } from "./composables/useUrlQuery.js";
|
|
13
13
|
import { resolveConfig } from "./config/index.js";
|
|
14
14
|
import { maizzle } from "./plugin.js";
|
|
15
|
+
import { NormalizedComponentSource, normalizeComponentSources } from "./utils/componentSources.js";
|
|
15
16
|
import { CreateRendererOptions, RenderedTemplate, Renderer, createRenderer } from "./render/createRenderer.js";
|
|
16
17
|
import { RenderResult, render } from "./render/index.js";
|
|
17
18
|
import { serve } from "./serve.js";
|
|
@@ -34,4 +35,4 @@ import { replaceStrings } from "./transformers/replaceStrings.js";
|
|
|
34
35
|
import { FormatOptions, format } from "./transformers/format.js";
|
|
35
36
|
import { MinifyOptions, minify } from "./transformers/minify.js";
|
|
36
37
|
import { useHead } from "@unhead/vue";
|
|
37
|
-
export { type AttributesConfig, type BaseUrlOptions, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, 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, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
|
38
|
+
export { type AttributesConfig, type BaseUrlOptions, type ComponentSource, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, type NormalizedComponentSource, type PlaintextConfig, type PrepareOptions, type PurgeCssOptions, type RemoveAttributeOption, type RemoveAttributeRule, type RenderResult, type RenderedTemplate, type Renderer, type ShorthandCssOptions, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { purgeCss } from "./transformers/purgeCss.js";
|
|
|
17
17
|
import { replaceStrings } from "./transformers/replaceStrings.js";
|
|
18
18
|
import { format } from "./transformers/format.js";
|
|
19
19
|
import { minify } from "./transformers/minify.js";
|
|
20
|
+
import { normalizeComponentSources } from "./utils/componentSources.js";
|
|
20
21
|
import { createRenderer } from "./render/createRenderer.js";
|
|
21
22
|
import { createPlaintext } from "./plaintext.js";
|
|
22
23
|
import { build } from "./build.js";
|
|
@@ -33,4 +34,4 @@ import { useTransformers } from "./composables/useTransformers.js";
|
|
|
33
34
|
import { useBaseUrl } from "./composables/useBaseUrl.js";
|
|
34
35
|
import { useUrlQuery } from "./composables/useUrlQuery.js";
|
|
35
36
|
import { useHead } from "@unhead/vue";
|
|
36
|
-
export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
|
37
|
+
export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
package/dist/prepare.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.d.ts","names":[],"sources":["../src/prepare.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","names":[],"sources":["../src/prepare.ts"],"mappings":";UAOiB,cAAA;EAAA;EAEf,MAAA;AAAA;;;AAWF;;;;;;iBAAsB,OAAA,CAAQ,OAAA,GAAS,cAAA,GAAsB,OAAA"}
|
package/dist/prepare.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveConfig } from "./config/index.js";
|
|
2
2
|
import { isLaravel } from "./utils/detect.js";
|
|
3
|
+
import { normalizeComponentSources } from "./utils/componentSources.js";
|
|
3
4
|
import { createRenderer } from "./render/createRenderer.js";
|
|
4
5
|
import { relative, resolve } from "node:path";
|
|
5
6
|
import ora from "ora";
|
|
@@ -22,7 +23,7 @@ async function prepare(options = {}) {
|
|
|
22
23
|
dts: true,
|
|
23
24
|
markdown: config.markdown,
|
|
24
25
|
root: config.root,
|
|
25
|
-
componentDirs:
|
|
26
|
+
componentDirs: normalizeComponentSources(config.components?.source, process.cwd()),
|
|
26
27
|
vite: config.vite
|
|
27
28
|
});
|
|
28
29
|
try {
|
package/dist/prepare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","names":[],"sources":["../src/prepare.ts"],"sourcesContent":["import { relative, resolve } from 'node:path'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { isLaravel } from './utils/detect.ts'\n\nexport interface PrepareOptions {\n /** Path to a Maizzle config file. */\n config?: string\n}\n\n/**\n * Generate IDE type definitions in `.maizzle/`\n * (`auto-imports.d.ts` and `components.d.ts`).\n *\n * Intended as a `postinstall` step so editors get autocompletion before the\n * user runs `dev` or `build`. Spins up the renderer with `dts: true`, runs\n * a trivial render to trigger the unplugin scans, then shuts down.\n */\nexport async function prepare(options: PrepareOptions = {}): Promise<void> {\n const spinner = ora({ text: 'Generating types...', spinner: 'circleHalves' }).start()\n\n const config = await resolveConfig(options.config)\n\n const renderer = await createRenderer({\n dts: true,\n markdown: config.markdown,\n root: config.root,\n componentDirs:
|
|
1
|
+
{"version":3,"file":"prepare.js","names":[],"sources":["../src/prepare.ts"],"sourcesContent":["import { relative, resolve } from 'node:path'\nimport ora from 'ora'\nimport { resolveConfig } from './config/index.ts'\nimport { createRenderer } from './render/createRenderer.ts'\nimport { isLaravel } from './utils/detect.ts'\nimport { normalizeComponentSources } from './utils/componentSources.ts'\n\nexport interface PrepareOptions {\n /** Path to a Maizzle config file. */\n config?: string\n}\n\n/**\n * Generate IDE type definitions in `.maizzle/`\n * (`auto-imports.d.ts` and `components.d.ts`).\n *\n * Intended as a `postinstall` step so editors get autocompletion before the\n * user runs `dev` or `build`. Spins up the renderer with `dts: true`, runs\n * a trivial render to trigger the unplugin scans, then shuts down.\n */\nexport async function prepare(options: PrepareOptions = {}): Promise<void> {\n const spinner = ora({ text: 'Generating types...', spinner: 'circleHalves' }).start()\n\n const config = await resolveConfig(options.config)\n\n const renderer = await createRenderer({\n dts: true,\n markdown: config.markdown,\n root: config.root,\n componentDirs: normalizeComponentSources(config.components?.source, process.cwd()),\n vite: config.vite,\n })\n\n try {\n await renderer.render('<template><div></div></template>', config)\n } finally {\n await renderer.close()\n }\n\n const dtsDir = isLaravel()\n ? resolve(process.cwd(), 'resources/js/types/maizzle')\n : resolve(config.root, '.maizzle')\n const displayPath = relative(process.cwd(), dtsDir) || dtsDir\n\n spinner.stopAndPersist({\n symbol: '✅',\n text: `Types generated in ${displayPath}`,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eAAsB,QAAQ,UAA0B,EAAE,EAAiB;CACzE,MAAM,UAAU,IAAI;EAAE,MAAM;EAAuB,SAAS;EAAgB,CAAC,CAAC,OAAO;CAErF,MAAM,SAAS,MAAM,cAAc,QAAQ,OAAO;CAElD,MAAM,WAAW,MAAM,eAAe;EACpC,KAAK;EACL,UAAU,OAAO;EACjB,MAAM,OAAO;EACb,eAAe,0BAA0B,OAAO,YAAY,QAAQ,QAAQ,KAAK,CAAC;EAClF,MAAM,OAAO;EACd,CAAC;CAEF,IAAI;EACF,MAAM,SAAS,OAAO,oCAAoC,OAAO;WACzD;EACR,MAAM,SAAS,OAAO;;CAGxB,MAAM,SAAS,WAAW,GACtB,QAAQ,QAAQ,KAAK,EAAE,6BAA6B,GACpD,QAAQ,OAAO,MAAM,WAAW;CACpC,MAAM,cAAc,SAAS,QAAQ,KAAK,EAAE,OAAO,IAAI;CAEvD,QAAQ,eAAe;EACrB,QAAQ;EACR,MAAM,sBAAsB;EAC7B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MaizzleConfig, MarkdownConfig } from "../types/config.js";
|
|
2
2
|
import { RenderContext } from "../composables/renderContext.js";
|
|
3
|
+
import { NormalizedComponentSource } from "../utils/componentSources.js";
|
|
3
4
|
import { Component } from "vue";
|
|
4
5
|
import { InlineConfig } from "vite";
|
|
5
6
|
|
|
@@ -25,8 +26,11 @@ interface CreateRendererOptions {
|
|
|
25
26
|
markdown?: MarkdownConfig;
|
|
26
27
|
/** Root directory for resolving user component dirs and .d.ts output */
|
|
27
28
|
root?: string;
|
|
28
|
-
/**
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Additional component sources to register for auto-import. Already
|
|
31
|
+
* normalized — pass through `normalizeComponentSources()` first.
|
|
32
|
+
*/
|
|
33
|
+
componentDirs?: NormalizedComponentSource[];
|
|
30
34
|
/** User Vite config options to merge into the internal SSR server */
|
|
31
35
|
vite?: InlineConfig;
|
|
32
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRenderer.d.ts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":"
|
|
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;EAbC;EAehB,GAAA;EAdkB;EAgBlB,QAAA,GAAW,cAAA;EAfC;EAiBZ,IAAA;EAhBiB;;;AAGnB;EAkBE,aAAA,GAAgB,yBAAA;;EAEhB,IAAA,GAAO,YAAA;AAAA;;;;;;;iBASa,cAAA,CACpB,OAAA,GAAS,qBAAA,GACR,OAAA,CAAQ,QAAA"}
|
|
@@ -5,7 +5,10 @@ import { rowSourceLocation } from "./plugins/rowSourceLocation.js";
|
|
|
5
5
|
import { rawExtract } from "./plugins/rawExtract.js";
|
|
6
6
|
import { codeBlockExtract } from "./plugins/codeBlockExtract.js";
|
|
7
7
|
import { markdownExtract } from "./plugins/markdownExtract.js";
|
|
8
|
-
import {
|
|
8
|
+
import { componentNameFromPath } from "../utils/componentSources.js";
|
|
9
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { dirname, relative, resolve } from "node:path";
|
|
11
|
+
import { glob, globSync } from "tinyglobby";
|
|
9
12
|
import { fileURLToPath } from "node:url";
|
|
10
13
|
import { defu as defu$1 } from "defu";
|
|
11
14
|
import { createSSRApp } from "vue";
|
|
@@ -32,8 +35,86 @@ const vueRouterPkgDir = dirname(fileURLToPath(import.meta.resolve("vue-router/pa
|
|
|
32
35
|
async function createRenderer(options = {}) {
|
|
33
36
|
const { dts = false, markdown: markdownOptionsRaw, root = process.cwd(), componentDirs = [], vite: userViteConfig } = options;
|
|
34
37
|
const { shikiTheme = "github-light", ...markdownOptions } = markdownOptionsRaw ?? {};
|
|
35
|
-
const
|
|
38
|
+
const dirSources = componentDirs.filter((s) => s.prefix === void 0);
|
|
39
|
+
const prefixedSources = componentDirs.filter((s) => s.prefix !== void 0);
|
|
40
|
+
const componentDirsAbs = [resolve(root, "components"), ...componentDirs.map((s) => s.path)];
|
|
36
41
|
const dtsDir = isLaravel() ? resolve(process.cwd(), "resources/js/types/maizzle") : resolve(root, ".maizzle");
|
|
42
|
+
const frameworkComponentsDir = resolve(__dirname, "../components");
|
|
43
|
+
function topLevelBasenamesLower(dir) {
|
|
44
|
+
if (!existsSync(dir)) return /* @__PURE__ */ new Set();
|
|
45
|
+
const files = globSync(["*.vue", "*.md"], {
|
|
46
|
+
cwd: dir,
|
|
47
|
+
absolute: false
|
|
48
|
+
});
|
|
49
|
+
return new Set(files.map((f) => f.replace(/\.(vue|md)$/, "").toLowerCase()));
|
|
50
|
+
}
|
|
51
|
+
const frameworkFiles = globSync(["*.vue", "*.md"], {
|
|
52
|
+
cwd: frameworkComponentsDir,
|
|
53
|
+
absolute: false
|
|
54
|
+
});
|
|
55
|
+
const frameworkByLower = new Map(frameworkFiles.map((f) => [f.replace(/\.(vue|md)$/, "").toLowerCase(), f]));
|
|
56
|
+
const shadowedNames = /* @__PURE__ */ new Set();
|
|
57
|
+
for (const dir of [resolve(root, "components"), ...dirSources.map((s) => s.path)]) for (const lower of topLevelBasenamesLower(dir)) if (frameworkByLower.has(lower)) shadowedNames.add(lower);
|
|
58
|
+
const frameworkExcludes = [...shadowedNames].map((lower) => `${frameworkComponentsDir}/${frameworkByLower.get(lower)}`);
|
|
59
|
+
const prefixedNameMap = /* @__PURE__ */ new Map();
|
|
60
|
+
async function scanPrefixedSources() {
|
|
61
|
+
prefixedNameMap.clear();
|
|
62
|
+
const seen = /* @__PURE__ */ new Map();
|
|
63
|
+
for (const source of prefixedSources) {
|
|
64
|
+
const files = await glob(["**/*.vue", "**/*.md"], {
|
|
65
|
+
cwd: source.path,
|
|
66
|
+
absolute: true
|
|
67
|
+
});
|
|
68
|
+
for (const file of files) {
|
|
69
|
+
const name = componentNameFromPath({
|
|
70
|
+
filePath: file,
|
|
71
|
+
dirRoot: source.path,
|
|
72
|
+
prefix: source.prefix,
|
|
73
|
+
pathPrefix: source.pathPrefix
|
|
74
|
+
});
|
|
75
|
+
const existing = seen.get(name);
|
|
76
|
+
if (existing && existing !== file) throw new Error(`[maizzle] Component name collision: "${name}" resolved from both "${existing}" and "${file}". Rename one of the files or split them into separate sources with distinct prefixes.`);
|
|
77
|
+
seen.set(name, file);
|
|
78
|
+
prefixedNameMap.set(name, file);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
await scanPrefixedSources();
|
|
83
|
+
const prefixedResolver = (name) => prefixedNameMap.get(name);
|
|
84
|
+
const prefixedDtsPath = resolve(dtsDir, "prefixed-components.d.ts");
|
|
85
|
+
function writePrefixedDts() {
|
|
86
|
+
if (!dts) return;
|
|
87
|
+
if (prefixedNameMap.size === 0) {
|
|
88
|
+
if (existsSync(prefixedDtsPath)) rmSync(prefixedDtsPath);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const dtsBase = dirname(prefixedDtsPath);
|
|
92
|
+
mkdirSync(dtsBase, { recursive: true });
|
|
93
|
+
writeFileSync(prefixedDtsPath, `/* 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${Array.from(prefixedNameMap.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([name, file]) => {
|
|
94
|
+
const relativePath = relative(dtsBase, file).replace(/\\/g, "/");
|
|
95
|
+
return ` ${name}: typeof import('${relativePath.startsWith(".") ? relativePath : `./${relativePath}`}')['default']`;
|
|
96
|
+
}).join("\n")}\n }\n}\n`);
|
|
97
|
+
}
|
|
98
|
+
writePrefixedDts();
|
|
99
|
+
/**
|
|
100
|
+
* Watches prefixed source dirs and rebuilds {@link prefixedNameMap} when
|
|
101
|
+
* files are added/removed. Vite's watcher already covers `dirSources`
|
|
102
|
+
* via unplugin-vue-components' own filesystem hooks.
|
|
103
|
+
*/
|
|
104
|
+
const prefixedSourceWatcher = prefixedSources.length > 0 ? {
|
|
105
|
+
name: "maizzle:prefixed-component-watcher",
|
|
106
|
+
configureServer(server) {
|
|
107
|
+
for (const source of prefixedSources) server.watcher.add(source.path);
|
|
108
|
+
const refresh = async (file) => {
|
|
109
|
+
if (!prefixedSources.some((s) => file.startsWith(`${s.path}/`))) return;
|
|
110
|
+
if (!/\.(vue|md)$/.test(file)) return;
|
|
111
|
+
await scanPrefixedSources();
|
|
112
|
+
writePrefixedDts();
|
|
113
|
+
};
|
|
114
|
+
server.watcher.on("add", refresh);
|
|
115
|
+
server.watcher.on("unlink", refresh);
|
|
116
|
+
}
|
|
117
|
+
} : null;
|
|
37
118
|
const VIRTUAL_SFC_ID = "virtual:maizzle-sfc.vue";
|
|
38
119
|
let virtualSfcSource = "";
|
|
39
120
|
const maizzleConfig = {
|
|
@@ -98,12 +179,17 @@ async function createRenderer(options = {}) {
|
|
|
98
179
|
/\.md$/
|
|
99
180
|
],
|
|
100
181
|
dirs: [
|
|
101
|
-
|
|
182
|
+
frameworkComponentsDir,
|
|
102
183
|
resolve(root, "components"),
|
|
103
|
-
...
|
|
184
|
+
...dirSources.map((s) => s.path)
|
|
104
185
|
],
|
|
186
|
+
globsExclude: frameworkExcludes,
|
|
187
|
+
directoryAsNamespace: true,
|
|
188
|
+
collapseSamePrefixes: true,
|
|
189
|
+
resolvers: prefixedSources.length > 0 ? [prefixedResolver] : void 0,
|
|
105
190
|
dts: dts ? resolve(dtsDir, "components.d.ts") : false
|
|
106
|
-
})
|
|
191
|
+
}),
|
|
192
|
+
...prefixedSourceWatcher ? [prefixedSourceWatcher] : []
|
|
107
193
|
],
|
|
108
194
|
resolve: { alias: {
|
|
109
195
|
"vue/server-renderer": resolve(vueServerRendererPkgDir, "dist/server-renderer.esm-bundler.js"),
|
|
@@ -118,7 +204,7 @@ async function createRenderer(options = {}) {
|
|
|
118
204
|
fs: { allow: [
|
|
119
205
|
process.cwd(),
|
|
120
206
|
root,
|
|
121
|
-
...componentDirs,
|
|
207
|
+
...componentDirs.map((s) => s.path),
|
|
122
208
|
vuePkgDir,
|
|
123
209
|
vueServerRendererPkgDir,
|
|
124
210
|
unheadVuePkgDir,
|
|
@@ -223,6 +309,7 @@ async function createRenderer(options = {}) {
|
|
|
223
309
|
},
|
|
224
310
|
async close() {
|
|
225
311
|
await server.close();
|
|
312
|
+
if (dts) await new Promise((resolve) => setTimeout(resolve, 600));
|
|
226
313
|
}
|
|
227
314
|
};
|
|
228
315
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRenderer.js","names":["merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, resolve } from 'node:path'\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 } 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 { 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 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 /** Additional component directories to register for auto-import */\n componentDirs?: string[]\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 // Absolute component dirs — used to skip auto-wrapping `.md` files that are\n // imported as reusable components (vs. entry-point email templates).\n const componentDirsAbs = [resolve(root, 'components'), ...componentDirs.map(d => resolve(root, d))]\n\n const dtsDir = isLaravel()\n ? resolve(process.cwd(), 'resources/js/types/maizzle')\n : resolve(root, '.maizzle')\n\n const VIRTUAL_SFC_ID = 'virtual:maizzle-sfc.vue'\n let virtualSfcSource = ''\n\n // Never load the host project's vite.config.ts here. Doing so pulls every\n // host plugin (Nitro, TanStack Start, the Maizzle plugin itself, …) into\n // this isolated SSR pipeline, where they override env factories, re-trigger\n // configureServer hooks, and break Vite's hot channel wiring. Users that\n // need extra Vite plugins for SSR pass them explicitly via the `vite` option.\n const maizzleConfig: InlineConfig = {\n configFile: false,\n plugins: [\n rawExtract(),\n codeBlockExtract(),\n markdownExtract(),\n rowSourceLocation(),\n {\n name: 'maizzle:virtual-sfc',\n resolveId(id) {\n if (id === VIRTUAL_SFC_ID) return id\n },\n load(id) {\n if (id === VIRTUAL_SFC_ID) return virtualSfcSource\n },\n },\n vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n },\n }),\n Markdown(merge(markdownOptions ?? {}, {\n headEnabled: true,\n wrapperDiv: false,\n wrapperClasses: 'prose',\n wrapperComponent: (id: string, raw: string) => {\n const fm = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1]\n const layout = fm?.match(/^[ \\t]*layout[ \\t]*:[ \\t]*['\"]?([A-Za-z][\\w-]*|false|none)['\"]?[ \\t]*$/m)?.[1]\n if (layout === 'false' || layout === 'none') return null\n if (layout) return layout\n // No `layout:` set — default to the built-in `MarkdownLayout` for\n // entry-template `.md` files. Skip for `.md` files inside component\n // dirs, which are reusable fragments imported into other templates.\n const inComponentDir = componentDirsAbs.some(d => id === d || id.startsWith(`${d}/`))\n return inComponentDir ? null : 'MarkdownLayout'\n },\n markdownOptions: {\n async highlight(code: string, lang: string) {\n const { codeToHtml } = await import('shiki')\n return codeToHtml(code, { lang, theme: shikiTheme })\n },\n },\n markdownSetup(md: MarkdownExit) {\n const wrapPre = (html: string) =>\n `<table class=\"w-full\"><tr><td class=\"max-w-0 mso-padding-alt-4\">${html}</td></tr></table>\\n`\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) => {\n const result = defaultFence(...args)\n if (typeof result === 'string') return wrapPre(result)\n return result.then(wrapPre)\n }\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => wrapPre(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n dts: dts ? resolve(dtsDir, 'auto-imports.d.ts') : false,\n }),\n Components({\n extensions: ['vue', 'md'],\n include: [/\\.vue$/, /\\.vue\\?vue/, /\\.md$/],\n dirs: [\n resolve(__dirname, '../components'),\n resolve(root, 'components'),\n ...componentDirs,\n ],\n dts: dts ? resolve(dtsDir, 'components.d.ts') : false,\n }),\n ],\n resolve: {\n alias: {\n 'vue/server-renderer': resolve(vueServerRendererPkgDir, 'dist/server-renderer.esm-bundler.js'),\n 'vue': resolve(vuePkgDir, 'dist/vue.runtime.esm-bundler.js'),\n 'vue-router': vueRouterPkgDir,\n '@unhead/vue/server': resolve(unheadVuePkgDir, 'dist/server.mjs'),\n '@unhead/vue': resolve(unheadVuePkgDir, 'dist/index.mjs'),\n },\n },\n server: {\n middlewareMode: true,\n hmr: false,\n // Watcher is required so unplugin-vue-components and unplugin-auto-import\n // detect added/removed component files and rewrite their .d.ts on the fly.\n // (We only render via SSR — HMR is off, but chokidar still drives the plugins.)\n fs: {\n allow: [process.cwd(), root, ...componentDirs, vuePkgDir, vueServerRendererPkgDir, unheadVuePkgDir, vueRouterPkgDir],\n },\n },\n appType: 'custom',\n logLevel: 'silent',\n optimizeDeps: {\n noDiscovery: true,\n },\n }\n\n // Merge user's vite config (from config.vite) under Maizzle's config.\n // mergeConfig(a, b) → b overrides a for scalars, arrays are concatenated.\n // This ensures Maizzle's critical settings (middlewareMode, appType, etc.) always win,\n // while user plugins and other options are included.\n const finalConfig = userViteConfig\n ? mergeConfig(userViteConfig, maizzleConfig)\n : maizzleConfig\n\n const server = await createServer(finalConfig)\n\n return {\n async render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate> {\n let component: Component\n let configKey: InjectionKey<MaizzleConfig>\n let contextKey: InjectionKey<RenderContext>\n\n if (typeof input === 'string') {\n // String input goes through Vite — must use ssrLoadModule for injection keys\n // so they share the same module instance as the SFC\n const configModule = await server.ssrLoadModule(resolve(__dirname, '../composables/useConfig'))\n const contextModule = await server.ssrLoadModule(resolve(__dirname, '../composables/renderContext'))\n configKey = configModule.MaizzleConfigKey\n contextKey = contextModule.RenderContextKey\n\n if (input.includes('<template') || input.includes('<script')) {\n virtualSfcSource = input\n const mod = server.moduleGraph.getModuleById(VIRTUAL_SFC_ID)\n if (mod) server.moduleGraph.invalidateModule(mod)\n component = (await server.ssrLoadModule(VIRTUAL_SFC_ID)).default\n } else {\n component = (await server.ssrLoadModule(input)).default\n }\n } else {\n // Pre-compiled component — use directly imported keys\n component = input\n configKey = MaizzleConfigKey\n contextKey = RenderContextKey\n }\n\n const renderContext: RenderContext = {\n doctype: undefined,\n sfcConfig: undefined,\n sfcEventHandlers: [],\n }\n\n const head = createHead({ disableDefaults: true })\n const app = createSSRApp(component)\n app.use(head)\n\n // Register user Vue plugins, directives, and global properties\n if (config.vue) {\n for (const plugin of config.vue.plugins ?? []) {\n app.use(plugin)\n }\n for (const [name, directive] of Object.entries(config.vue.directives ?? {})) {\n app.directive(name, directive)\n }\n Object.assign(app.config.globalProperties, config.vue.globalProperties)\n }\n\n app.provide(configKey, config)\n app.provide(contextKey, renderContext)\n\n const ssrContext: Record<string, any> = {}\n let html: string = await renderToString(app, ssrContext)\n\n const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = head.render()\n\n // Inject head entries into the rendered HTML\n if (htmlAttrs) {\n html = html.replace(/<html([^>]*)>/, `<html$1 ${htmlAttrs}>`)\n }\n if (headTags) {\n html = html.replace('</head>', `${headTags}\\n</head>`)\n }\n if (bodyAttrs) {\n html = html.replace(/<body([^>]*)>/, `<body$1 ${bodyAttrs}>`)\n }\n if (bodyTagsOpen) {\n html = html.replace(/<body([^>]*)>/, `<body$1>\\n${bodyTagsOpen}`)\n }\n if (bodyTags) {\n html = html.replace('</body>', `${bodyTags}\\n</body>`)\n }\n\n // Inject SSR teleport content into their target elements\n const hasTeleports = ssrContext.teleports && Object.keys(ssrContext.teleports).length > 0\n const hasFonts = (renderContext.fonts?.length ?? 0) > 0\n\n if (hasTeleports || hasFonts) {\n const { parse: parseDom, serialize: serializeDom, walk } = await import('../utils/ast/index.ts')\n let dom = parseDom(html)\n\n if (hasTeleports) {\n for (const [rawTarget, content] of Object.entries(ssrContext.teleports) as [string, string][]) {\n if (!content) continue\n\n const prepend = rawTarget.endsWith(':start')\n const target = prepend ? rawTarget.slice(0, -6) : rawTarget\n const targetChildren = parseDom(content)\n\n walk(dom, (node) => {\n const el = node as import('domhandler').Element\n\n if (!el.name) return\n\n const matched\n = target === el.name\n || (target.startsWith('#') && el.attribs?.id === target.slice(1))\n || (target.startsWith('.') && el.attribs?.class?.split(/\\s+/).includes(target.slice(1)))\n\n if (matched) {\n for (const child of targetChildren) {\n child.parent = el as any\n }\n\n el.children = prepend\n ? [...targetChildren, ...(el.children || [])] as any\n : [...(el.children || []), ...targetChildren] as any\n }\n })\n }\n }\n\n if (hasFonts) {\n const { injectFonts } = await import('./injectFonts.ts')\n injectFonts(dom, renderContext.fonts!, parseDom, walk)\n }\n\n html = serializeDom(dom)\n }\n\n // Inject preheader text from usePreheader() composable\n if (renderContext.preheader) {\n const { text, fillerCount, shyCount } = renderContext.preheader\n const filler = '\\u2007\\u034F '.repeat(fillerCount)\n const shys = '\\u00AD '.repeat(shyCount)\n const previewHtml = `<div style=\"display:none\">${text}${filler}${shys}\\u00A0</div>`\n html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`)\n }\n\n // Strip Vue SSR fragment markers + teleport anchor comments. These are\n // rendering hygiene, not transformer concerns — must run regardless of\n // `useTransformers` state. Fragment markers contain `-->`, which would\n // prematurely terminate MSO conditional comments downstream.\n html = html\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n return {\n html,\n doctype: renderContext.doctype,\n // Layer sfcConfig over config — sfcConfig is a partial override\n // emitted by composables (defineConfig, useTransformers, etc.).\n // A naive replacement (`sfcConfig ?? config`) drops defaults from\n // the resolved config when the SFC only sets a single key, since\n // the composables' inject() of globalConfig can return `{}` in\n // dev when ssrLoadModule and the SFC's auto-imported module\n // resolve to different module instances (different Symbols).\n templateConfig: renderContext.sfcConfig ? merge(renderContext.sfcConfig, config) : config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\n tailwindBlocks: renderContext.tailwindBlocks,\n }\n },\n\n async invalidate(filePath: string): Promise<void> {\n const mod = await server.moduleGraph.getModuleByUrl(filePath)\n if (mod) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async invalidateAll(): Promise<void> {\n for (const mod of server.moduleGraph.idToModuleMap.values()) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async close(): Promise<void> {\n await server.close()\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,QAAQ,mBAAmB,CAAC,CAAC;AACjF,MAAM,0BAA0B,QAAQ,cAAc,OAAO,KAAK,QAAQ,oCAAoC,CAAC,CAAC;AAChH,MAAM,kBAAkB,QAAQ,QAAQ,cAAc,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,EAAE,KAAK;AACjG,MAAM,kBAAkB,QAAQ,cAAc,OAAO,KAAK,QAAQ,0BAA0B,CAAC,CAAC;;;;;;;AAqC9F,eAAsB,eACpB,UAAiC,EAAE,EAChB;CACnB,MAAM,EAAE,MAAM,OAAO,UAAU,oBAAoB,OAAO,QAAQ,KAAK,EAAE,gBAAgB,EAAE,EAAE,MAAM,mBAAmB;CACtH,MAAM,EAAE,aAAa,gBAAgB,GAAG,oBAAoB,sBAAsB,EAAE;CAIpF,MAAM,mBAAmB,CAAC,QAAQ,MAAM,aAAa,EAAE,GAAG,cAAc,KAAI,MAAK,QAAQ,MAAM,EAAE,CAAC,CAAC;CAEnG,MAAM,SAAS,WAAW,GACtB,QAAQ,QAAQ,KAAK,EAAE,6BAA6B,GACpD,QAAQ,MAAM,WAAW;CAE7B,MAAM,iBAAiB;CACvB,IAAI,mBAAmB;CAOvB,MAAM,gBAA8B;EAClC,YAAY;EACZ,SAAS;GACP,YAAY;GACZ,k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;IACA,SAAS,cAAc;IAQvB,gBAAgB,cAAc,YAAYA,OAAM,cAAc,WAAW,OAAO,GAAG;IACnF,kBAAkB,cAAc;IAChC,WAAW,cAAc;IACzB,gBAAgB,cAAc;IAC/B;;EAGH,MAAM,WAAW,UAAiC;GAChD,MAAM,MAAM,MAAM,OAAO,YAAY,eAAe,SAAS;GAC7D,IAAI,KACF,OAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,gBAA+B;GACnC,KAAK,MAAM,OAAO,OAAO,YAAY,cAAc,QAAQ,EACzD,OAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,QAAuB;GAC3B,MAAM,OAAO,OAAO;;EAEvB"}
|
|
1
|
+
{"version":3,"file":"createRenderer.js","names":["relPath","merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, relative as relPath, resolve } from 'node:path'\nimport { mkdirSync, writeFileSync, existsSync, rmSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { isLaravel } from '../utils/detect.ts'\nimport { rowSourceLocation } from './plugins/rowSourceLocation.ts'\nimport { rawExtract } from './plugins/rawExtract.ts'\nimport { codeBlockExtract } from './plugins/codeBlockExtract.ts'\nimport { markdownExtract } from './plugins/markdownExtract.ts'\nimport { createServer, mergeConfig, type InlineConfig, type Plugin } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport Markdown from 'unplugin-vue-markdown/vite'\nimport AutoImport from 'unplugin-auto-import/vite'\nimport Components from 'unplugin-vue-components/vite'\nimport { unheadVueComposablesImports } from '@unhead/vue'\nimport { defu as merge } from 'defu'\nimport { glob, globSync } from 'tinyglobby'\nimport { createSSRApp } from 'vue'\nimport { renderToString } from 'vue/server-renderer'\nimport { createHead } from '@unhead/vue/server'\nimport { MaizzleConfigKey } from '../composables/useConfig.ts'\nimport { RenderContextKey } from '../composables/renderContext.ts'\nimport { componentNameFromPath, type NormalizedComponentSource } from '../utils/componentSources.ts'\nimport type { Component, InjectionKey } from 'vue'\nimport type { MaizzleConfig, MarkdownConfig } from '../types/index.ts'\nimport type { MarkdownExit } from 'markdown-exit'\nimport type { RenderContext } from '../composables/renderContext.ts'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nconst vuePkgDir = dirname(fileURLToPath(import.meta.resolve('vue/package.json')))\nconst vueServerRendererPkgDir = dirname(fileURLToPath(import.meta.resolve('@vue/server-renderer/package.json')))\nconst unheadVuePkgDir = resolve(dirname(fileURLToPath(import.meta.resolve('@unhead/vue'))), '..')\nconst vueRouterPkgDir = dirname(fileURLToPath(import.meta.resolve('vue-router/package.json')))\n\nexport interface RenderedTemplate {\n html: string\n doctype?: string\n templateConfig: MaizzleConfig\n sfcEventHandlers: RenderContext['sfcEventHandlers']\n plaintext?: RenderContext['plaintext']\n tailwindBlocks?: RenderContext['tailwindBlocks']\n}\n\nexport interface Renderer {\n render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate>\n invalidate(filePath: string): Promise<void>\n invalidateAll(): Promise<void>\n close(): Promise<void>\n}\n\nexport interface CreateRendererOptions {\n /** Generate .d.ts files for auto-imports and components (default: false) */\n dts?: boolean\n /** Options passed to unplugin-vue-markdown */\n markdown?: MarkdownConfig\n /** Root directory for resolving user component dirs and .d.ts output */\n root?: string\n /**\n * Additional component sources to register for auto-import. Already\n * normalized — pass through `normalizeComponentSources()` first.\n */\n componentDirs?: NormalizedComponentSource[]\n /** User Vite config options to merge into the internal SSR server */\n vite?: InlineConfig\n}\n\n/**\n * Lightweight Vite SSR loader for rendering Vue SFC email templates.\n *\n * Uses only Vue + unplugin for component/auto-import resolution.\n * Tailwind CSS compilation is handled by the transformer pipeline.\n */\nexport async function createRenderer(\n options: CreateRendererOptions = {},\n): Promise<Renderer> {\n const { dts = false, markdown: markdownOptionsRaw, root = process.cwd(), componentDirs = [], vite: userViteConfig } = options\n const { shikiTheme = 'github-light', ...markdownOptions } = markdownOptionsRaw ?? {}\n\n // Sources without an explicit prefix get registered via unplugin's `dirs`\n // (folder name auto-namespaces). Sources with an explicit `prefix` are\n // registered through a custom resolver below so we can fully control naming.\n const dirSources = componentDirs.filter(s => s.prefix === undefined)\n const prefixedSources = componentDirs.filter(s => s.prefix !== undefined)\n\n // Absolute component dirs — used to skip auto-wrapping `.md` files that are\n // imported as reusable components (vs. entry-point email templates).\n const componentDirsAbs = [resolve(root, 'components'), ...componentDirs.map(s => s.path)]\n\n const dtsDir = isLaravel()\n ? resolve(process.cwd(), 'resources/js/types/maizzle')\n : resolve(root, '.maizzle')\n\n // Built-in framework components live at this path. When a user provides a\n // top-level file with the same (PascalCased) basename, drop the built-in\n // from unplugin's scan so the user's component is the only candidate. This\n // avoids the \"naming conflicts\" warning and the alphabetical-glob ordering\n // pitfall that decides who wins when both are present in `dirs`.\n const frameworkComponentsDir = resolve(__dirname, '../components')\n\n function topLevelBasenamesLower(dir: string): Set<string> {\n if (!existsSync(dir)) return new Set()\n const files = globSync(['*.vue', '*.md'], { cwd: dir, absolute: false })\n return new Set(files.map(f => f.replace(/\\.(vue|md)$/, '').toLowerCase()))\n }\n\n const frameworkFiles = globSync(['*.vue', '*.md'], { cwd: frameworkComponentsDir, absolute: false })\n const frameworkByLower = new Map(\n frameworkFiles.map(f => [f.replace(/\\.(vue|md)$/, '').toLowerCase(), f]),\n )\n\n const shadowedNames = new Set<string>()\n for (const dir of [resolve(root, 'components'), ...dirSources.map(s => s.path)]) {\n for (const lower of topLevelBasenamesLower(dir)) {\n if (frameworkByLower.has(lower)) shadowedNames.add(lower)\n }\n }\n\n const frameworkExcludes = [...shadowedNames]\n .map(lower => `${frameworkComponentsDir}/${frameworkByLower.get(lower)}`)\n\n // Pre-scanned name → absolute-path map for prefixed sources. Rebuilt on\n // file add/unlink via the watcher hook plugin further down. Powers the\n // runtime resolver and the d.ts file we write for IDE autocompletion.\n const prefixedNameMap = new Map<string, string>()\n\n async function scanPrefixedSources(): Promise<void> {\n prefixedNameMap.clear()\n const seen = new Map<string, string>()\n for (const source of prefixedSources) {\n const files = await glob(['**/*.vue', '**/*.md'], { cwd: source.path, absolute: true })\n for (const file of files) {\n const name = componentNameFromPath({\n filePath: file,\n dirRoot: source.path,\n prefix: source.prefix,\n pathPrefix: source.pathPrefix,\n })\n const existing = seen.get(name)\n if (existing && existing !== file) {\n throw new Error(\n `[maizzle] Component name collision: \"${name}\" resolved from both \"${existing}\" and \"${file}\". `\n + 'Rename one of the files or split them into separate sources with distinct prefixes.',\n )\n }\n seen.set(name, file)\n prefixedNameMap.set(name, file)\n }\n }\n }\n\n await scanPrefixedSources()\n\n const prefixedResolver = (name: string) => prefixedNameMap.get(name)\n\n // unplugin-vue-components' own d.ts only covers components found via `dirs`;\n // its `types` option emits named-import entries which break for SFC `default`\n // exports. Write a sibling d.ts for prefixed sources so editors get correct\n // autocompletion via TypeScript interface merging on `vue.GlobalComponents`.\n const prefixedDtsPath = resolve(dtsDir, 'prefixed-components.d.ts')\n\n function writePrefixedDts(): void {\n if (!dts) return\n if (prefixedNameMap.size === 0) {\n if (existsSync(prefixedDtsPath)) rmSync(prefixedDtsPath)\n return\n }\n const dtsBase = dirname(prefixedDtsPath)\n mkdirSync(dtsBase, { recursive: true })\n const lines = Array.from(prefixedNameMap.entries())\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, file]) => {\n const relativePath = relPath(dtsBase, file).replace(/\\\\/g, '/')\n const importPath = relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n return ` ${name}: typeof import('${importPath}')['default']`\n })\n .join('\\n')\n writeFileSync(\n prefixedDtsPath,\n `/* eslint-disable */\\n// @ts-nocheck\\n// biome-ignore lint: disable\\n// oxlint-disable\\n// Generated by Maizzle for prefixed component sources\\n\\nexport {}\\n\\n/* prettier-ignore */\\ndeclare module 'vue' {\\n export interface GlobalComponents {\\n${lines}\\n }\\n}\\n`,\n )\n }\n\n writePrefixedDts()\n\n /**\n * Watches prefixed source dirs and rebuilds {@link prefixedNameMap} when\n * files are added/removed. Vite's watcher already covers `dirSources`\n * via unplugin-vue-components' own filesystem hooks.\n */\n const prefixedSourceWatcher: Plugin | null = prefixedSources.length > 0\n ? {\n name: 'maizzle:prefixed-component-watcher',\n configureServer(server) {\n for (const source of prefixedSources) {\n server.watcher.add(source.path)\n }\n const refresh = async (file: string) => {\n if (!prefixedSources.some(s => file.startsWith(`${s.path}/`))) return\n if (!/\\.(vue|md)$/.test(file)) return\n await scanPrefixedSources()\n writePrefixedDts()\n }\n server.watcher.on('add', refresh)\n server.watcher.on('unlink', refresh)\n },\n }\n : null\n\n const VIRTUAL_SFC_ID = 'virtual:maizzle-sfc.vue'\n let virtualSfcSource = ''\n\n // Never load the host project's vite.config.ts here. Doing so pulls every\n // host plugin (Nitro, TanStack Start, the Maizzle plugin itself, …) into\n // this isolated SSR pipeline, where they override env factories, re-trigger\n // configureServer hooks, and break Vite's hot channel wiring. Users that\n // need extra Vite plugins for SSR pass them explicitly via the `vite` option.\n const maizzleConfig: InlineConfig = {\n configFile: false,\n plugins: [\n rawExtract(),\n codeBlockExtract(),\n markdownExtract(),\n rowSourceLocation(),\n {\n name: 'maizzle:virtual-sfc',\n resolveId(id) {\n if (id === VIRTUAL_SFC_ID) return id\n },\n load(id) {\n if (id === VIRTUAL_SFC_ID) return virtualSfcSource\n },\n },\n vue({\n include: [/\\.vue$/, /\\.md$/],\n template: {\n transformAssetUrls: false,\n },\n }),\n Markdown(merge(markdownOptions ?? {}, {\n headEnabled: true,\n wrapperDiv: false,\n wrapperClasses: 'prose',\n wrapperComponent: (id: string, raw: string) => {\n const fm = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1]\n const layout = fm?.match(/^[ \\t]*layout[ \\t]*:[ \\t]*['\"]?([A-Za-z][\\w-]*|false|none)['\"]?[ \\t]*$/m)?.[1]\n if (layout === 'false' || layout === 'none') return null\n if (layout) return layout\n // No `layout:` set — default to the built-in `MarkdownLayout` for\n // entry-template `.md` files. Skip for `.md` files inside component\n // dirs, which are reusable fragments imported into other templates.\n const inComponentDir = componentDirsAbs.some(d => id === d || id.startsWith(`${d}/`))\n return inComponentDir ? null : 'MarkdownLayout'\n },\n markdownOptions: {\n async highlight(code: string, lang: string) {\n const { codeToHtml } = await import('shiki')\n return codeToHtml(code, { lang, theme: shikiTheme })\n },\n },\n markdownSetup(md: MarkdownExit) {\n const wrapPre = (html: string) =>\n `<table class=\"w-full\"><tr><td class=\"max-w-0 mso-padding-alt-4\">${html}</td></tr></table>\\n`\n\n const defaultFence = md.renderer.rules.fence!\n md.renderer.rules.fence = (...args) => {\n const result = defaultFence(...args)\n if (typeof result === 'string') return wrapPre(result)\n return result.then(wrapPre)\n }\n\n const defaultCodeBlock = md.renderer.rules.code_block!\n md.renderer.rules.code_block = (...args) => wrapPre(defaultCodeBlock(...args) as string)\n },\n })),\n AutoImport({\n dirs: [\n resolve(__dirname, '../composables'),\n resolve(__dirname, '../filters'),\n ],\n imports: ['vue', unheadVueComposablesImports],\n dts: dts ? resolve(dtsDir, 'auto-imports.d.ts') : false,\n }),\n Components({\n extensions: ['vue', 'md'],\n include: [/\\.vue$/, /\\.vue\\?vue/, /\\.md$/],\n dirs: [\n frameworkComponentsDir,\n resolve(root, 'components'),\n ...dirSources.map(s => s.path),\n ],\n // Drop built-in component files whose name the user has shadowed.\n // This makes the user's version the only match — no \"naming\n // conflicts\" warning, no glob-ordering games.\n globsExclude: frameworkExcludes,\n directoryAsNamespace: true,\n collapseSamePrefixes: true,\n resolvers: prefixedSources.length > 0 ? [prefixedResolver] : undefined,\n dts: dts ? resolve(dtsDir, 'components.d.ts') : false,\n }),\n ...(prefixedSourceWatcher ? [prefixedSourceWatcher] : []),\n ],\n resolve: {\n alias: {\n 'vue/server-renderer': resolve(vueServerRendererPkgDir, 'dist/server-renderer.esm-bundler.js'),\n 'vue': resolve(vuePkgDir, 'dist/vue.runtime.esm-bundler.js'),\n 'vue-router': vueRouterPkgDir,\n '@unhead/vue/server': resolve(unheadVuePkgDir, 'dist/server.mjs'),\n '@unhead/vue': resolve(unheadVuePkgDir, 'dist/index.mjs'),\n },\n },\n server: {\n middlewareMode: true,\n hmr: false,\n // Watcher is required so unplugin-vue-components and unplugin-auto-import\n // detect added/removed component files and rewrite their .d.ts on the fly.\n // (We only render via SSR — HMR is off, but chokidar still drives the plugins.)\n fs: {\n allow: [process.cwd(), root, ...componentDirs.map(s => s.path), vuePkgDir, vueServerRendererPkgDir, unheadVuePkgDir, vueRouterPkgDir],\n },\n },\n appType: 'custom',\n logLevel: 'silent',\n optimizeDeps: {\n noDiscovery: true,\n },\n }\n\n // Merge user's vite config (from config.vite) under Maizzle's config.\n // mergeConfig(a, b) → b overrides a for scalars, arrays are concatenated.\n // This ensures Maizzle's critical settings (middlewareMode, appType, etc.) always win,\n // while user plugins and other options are included.\n const finalConfig = userViteConfig\n ? mergeConfig(userViteConfig, maizzleConfig)\n : maizzleConfig\n\n const server = await createServer(finalConfig)\n\n return {\n async render(input: string | Component, config: MaizzleConfig): Promise<RenderedTemplate> {\n let component: Component\n let configKey: InjectionKey<MaizzleConfig>\n let contextKey: InjectionKey<RenderContext>\n\n if (typeof input === 'string') {\n // String input goes through Vite — must use ssrLoadModule for injection keys\n // so they share the same module instance as the SFC\n const configModule = await server.ssrLoadModule(resolve(__dirname, '../composables/useConfig'))\n const contextModule = await server.ssrLoadModule(resolve(__dirname, '../composables/renderContext'))\n configKey = configModule.MaizzleConfigKey\n contextKey = contextModule.RenderContextKey\n\n if (input.includes('<template') || input.includes('<script')) {\n virtualSfcSource = input\n const mod = server.moduleGraph.getModuleById(VIRTUAL_SFC_ID)\n if (mod) server.moduleGraph.invalidateModule(mod)\n component = (await server.ssrLoadModule(VIRTUAL_SFC_ID)).default\n } else {\n component = (await server.ssrLoadModule(input)).default\n }\n } else {\n // Pre-compiled component — use directly imported keys\n component = input\n configKey = MaizzleConfigKey\n contextKey = RenderContextKey\n }\n\n const renderContext: RenderContext = {\n doctype: undefined,\n sfcConfig: undefined,\n sfcEventHandlers: [],\n }\n\n const head = createHead({ disableDefaults: true })\n const app = createSSRApp(component)\n app.use(head)\n\n // Register user Vue plugins, directives, and global properties\n if (config.vue) {\n for (const plugin of config.vue.plugins ?? []) {\n app.use(plugin)\n }\n for (const [name, directive] of Object.entries(config.vue.directives ?? {})) {\n app.directive(name, directive)\n }\n Object.assign(app.config.globalProperties, config.vue.globalProperties)\n }\n\n app.provide(configKey, config)\n app.provide(contextKey, renderContext)\n\n const ssrContext: Record<string, any> = {}\n let html: string = await renderToString(app, ssrContext)\n\n const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = head.render()\n\n // Inject head entries into the rendered HTML\n if (htmlAttrs) {\n html = html.replace(/<html([^>]*)>/, `<html$1 ${htmlAttrs}>`)\n }\n if (headTags) {\n html = html.replace('</head>', `${headTags}\\n</head>`)\n }\n if (bodyAttrs) {\n html = html.replace(/<body([^>]*)>/, `<body$1 ${bodyAttrs}>`)\n }\n if (bodyTagsOpen) {\n html = html.replace(/<body([^>]*)>/, `<body$1>\\n${bodyTagsOpen}`)\n }\n if (bodyTags) {\n html = html.replace('</body>', `${bodyTags}\\n</body>`)\n }\n\n // Inject SSR teleport content into their target elements\n const hasTeleports = ssrContext.teleports && Object.keys(ssrContext.teleports).length > 0\n const hasFonts = (renderContext.fonts?.length ?? 0) > 0\n\n if (hasTeleports || hasFonts) {\n const { parse: parseDom, serialize: serializeDom, walk } = await import('../utils/ast/index.ts')\n let dom = parseDom(html)\n\n if (hasTeleports) {\n for (const [rawTarget, content] of Object.entries(ssrContext.teleports) as [string, string][]) {\n if (!content) continue\n\n const prepend = rawTarget.endsWith(':start')\n const target = prepend ? rawTarget.slice(0, -6) : rawTarget\n const targetChildren = parseDom(content)\n\n walk(dom, (node) => {\n const el = node as import('domhandler').Element\n\n if (!el.name) return\n\n const matched\n = target === el.name\n || (target.startsWith('#') && el.attribs?.id === target.slice(1))\n || (target.startsWith('.') && el.attribs?.class?.split(/\\s+/).includes(target.slice(1)))\n\n if (matched) {\n for (const child of targetChildren) {\n child.parent = el as any\n }\n\n el.children = prepend\n ? [...targetChildren, ...(el.children || [])] as any\n : [...(el.children || []), ...targetChildren] as any\n }\n })\n }\n }\n\n if (hasFonts) {\n const { injectFonts } = await import('./injectFonts.ts')\n injectFonts(dom, renderContext.fonts!, parseDom, walk)\n }\n\n html = serializeDom(dom)\n }\n\n // Inject preheader text from usePreheader() composable\n if (renderContext.preheader) {\n const { text, fillerCount, shyCount } = renderContext.preheader\n const filler = '\\u2007\\u034F '.repeat(fillerCount)\n const shys = '\\u00AD '.repeat(shyCount)\n const previewHtml = `<div style=\"display:none\">${text}${filler}${shys}\\u00A0</div>`\n html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`)\n }\n\n // Strip Vue SSR fragment markers + teleport anchor comments. These are\n // rendering hygiene, not transformer concerns — must run regardless of\n // `useTransformers` state. Fragment markers contain `-->`, which would\n // prematurely terminate MSO conditional comments downstream.\n html = html\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n return {\n html,\n doctype: renderContext.doctype,\n // Layer sfcConfig over config — sfcConfig is a partial override\n // emitted by composables (defineConfig, useTransformers, etc.).\n // A naive replacement (`sfcConfig ?? config`) drops defaults from\n // the resolved config when the SFC only sets a single key, since\n // the composables' inject() of globalConfig can return `{}` in\n // dev when ssrLoadModule and the SFC's auto-imported module\n // resolve to different module instances (different Symbols).\n templateConfig: renderContext.sfcConfig ? merge(renderContext.sfcConfig, config) : config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\n tailwindBlocks: renderContext.tailwindBlocks,\n }\n },\n\n async invalidate(filePath: string): Promise<void> {\n const mod = await server.moduleGraph.getModuleByUrl(filePath)\n if (mod) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async invalidateAll(): Promise<void> {\n for (const mod of server.moduleGraph.idToModuleMap.values()) {\n server.moduleGraph.invalidateModule(mod)\n }\n },\n\n async close(): Promise<void> {\n await server.close()\n // unplugin-auto-import schedules a 500ms-throttled, fire-and-forget\n // d.ts write on its first scan. server.close() doesn't drain that\n // pending write, so callers tearing down the working dir right after\n // close (tests, ephemeral build pipelines) can race the mkdir against\n // a missing parent directory. Wait one throttle window past close so\n // that lingering write resolves while the dir still exists.\n if (dts) {\n await new Promise(resolve => setTimeout(resolve, 600))\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,QAAQ,mBAAmB,CAAC,CAAC;AACjF,MAAM,0BAA0B,QAAQ,cAAc,OAAO,KAAK,QAAQ,oCAAoC,CAAC,CAAC;AAChH,MAAM,kBAAkB,QAAQ,QAAQ,cAAc,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,EAAE,KAAK;AACjG,MAAM,kBAAkB,QAAQ,cAAc,OAAO,KAAK,QAAQ,0BAA0B,CAAC,CAAC;;;;;;;AAwC9F,eAAsB,eACpB,UAAiC,EAAE,EAChB;CACnB,MAAM,EAAE,MAAM,OAAO,UAAU,oBAAoB,OAAO,QAAQ,KAAK,EAAE,gBAAgB,EAAE,EAAE,MAAM,mBAAmB;CACtH,MAAM,EAAE,aAAa,gBAAgB,GAAG,oBAAoB,sBAAsB,EAAE;CAKpF,MAAM,aAAa,cAAc,QAAO,MAAK,EAAE,WAAW,KAAA,EAAU;CACpE,MAAM,kBAAkB,cAAc,QAAO,MAAK,EAAE,WAAW,KAAA,EAAU;CAIzE,MAAM,mBAAmB,CAAC,QAAQ,MAAM,aAAa,EAAE,GAAG,cAAc,KAAI,MAAK,EAAE,KAAK,CAAC;CAEzF,MAAM,SAAS,WAAW,GACtB,QAAQ,QAAQ,KAAK,EAAE,6BAA6B,GACpD,QAAQ,MAAM,WAAW;CAO7B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a,aAAa,cAAc;IAGtD,MAAM,cAAc,6BAA6B,OAFlC,MAAgB,OAAO,YAEwB,GADjD,KAAU,OAAO,SACuC,CAAC;IACtE,OAAO,KAAK,QAAQ,iBAAiB,WAAW,cAAc;;GAOhE,OAAO,KACJ,WAAW,YAAY,GAAG,CAC1B,WAAW,YAAY,GAAG,CAC1B,WAAW,gCAAgC,GAAG,CAC9C,WAAW,0BAA0B,GAAG,CACxC,WAAW,yBAAyB,GAAG,CACvC,WAAW,uBAAuB,GAAG;GAExC,OAAO;IACL;IACA,SAAS,cAAc;IAQvB,gBAAgB,cAAc,YAAYA,OAAM,cAAc,WAAW,OAAO,GAAG;IACnF,kBAAkB,cAAc;IAChC,WAAW,cAAc;IACzB,gBAAgB,cAAc;IAC/B;;EAGH,MAAM,WAAW,UAAiC;GAChD,MAAM,MAAM,MAAM,OAAO,YAAY,eAAe,SAAS;GAC7D,IAAI,KACF,OAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,gBAA+B;GACnC,KAAK,MAAM,OAAO,OAAO,YAAY,cAAc,QAAQ,EACzD,OAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,QAAuB;GAC3B,MAAM,OAAO,OAAO;GAOpB,IAAI,KACF,MAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,IAAI,CAAC;;EAG3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/render/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/render/index.ts"],"mappings":";;;;;UAeiB,YAAA;EACf,IAAA;EACA,MAAA,EAAQ,aAAA;EACR,SAAA;AAAA;;;;;iBAOoB,MAAA,CACpB,QAAA,WAAmB,SAAA,EACnB,MAAA,GAAS,OAAA,CAAQ,aAAA,IAChB,OAAA,CAAQ,YAAA"}
|
package/dist/render/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveConfig } from "../config/index.js";
|
|
2
2
|
import { runTransformers } from "../transformers/index.js";
|
|
3
|
+
import { normalizeComponentSources } from "../utils/componentSources.js";
|
|
3
4
|
import { createRenderer } from "./createRenderer.js";
|
|
4
5
|
import { createPlaintext } from "../plaintext.js";
|
|
5
6
|
import { stripForHtml, stripForPlaintext } from "../utils/output-markers.js";
|
|
@@ -19,7 +20,7 @@ async function render(template, config) {
|
|
|
19
20
|
const renderer = active ?? await createRenderer({
|
|
20
21
|
markdown: resolvedConfig.markdown,
|
|
21
22
|
root: resolvedConfig.root,
|
|
22
|
-
componentDirs:
|
|
23
|
+
componentDirs: normalizeComponentSources(resolvedConfig.components?.source, process.cwd()),
|
|
23
24
|
vite: resolvedConfig.vite
|
|
24
25
|
});
|
|
25
26
|
try {
|
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'\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 // Reuse a renderer started by the Vite plugin when one is active. Spinning\n // up a fresh Vite SSR server inside a host Vite dev process (e.g. TanStack\n // Start) collides on env wiring and throws \"outsideEmitter undefined\".\n const active = getActiveRenderer()\n const renderer = active ?? await createRenderer({\n markdown: resolvedConfig.markdown,\n root: resolvedConfig.root,\n componentDirs:
|
|
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 // Reuse a renderer started by the Vite plugin when one is active. Spinning\n // up a fresh Vite SSR server inside a host Vite dev process (e.g. TanStack\n // Start) collides on env wiring and throws \"outsideEmitter undefined\".\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,oIAC/B;CAEH,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,YAAY,OAAO,aAAa,YACtF,MAAM,IAAI,UACR,2DAA2D,OAAO,SAAS,GAC5E;CAGH,MAAM,iBAAiB,MAAM,cAAc,OAAO;CAKlD,MAAM,SAAS,mBAAmB;CAClC,MAAM,WAAW,UAAU,MAAM,eAAe;EAC9C,UAAU,eAAe;EACzB,MAAM,eAAe;EACrB,eAAe,0BAA0B,eAAe,YAAY,QAAQ,QAAQ,KAAK,CAAC;EAC1F,MAAM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+jBtC,WAAA,CAAY,MAAA,EAAQ,aAAA,EAAe,WAAA"}
|
package/dist/serve.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveConfig } from "./config/index.js";
|
|
2
2
|
import { runTransformers } from "./transformers/index.js";
|
|
3
|
+
import { normalizeComponentSources } from "./utils/componentSources.js";
|
|
3
4
|
import { createRenderer } from "./render/createRenderer.js";
|
|
4
5
|
import { createPlaintext } from "./plaintext.js";
|
|
5
6
|
import { stripForHtml, stripForPlaintext } from "./utils/output-markers.js";
|
|
@@ -43,7 +44,7 @@ async function serve(options = {}) {
|
|
|
43
44
|
dts: true,
|
|
44
45
|
markdown: config.markdown,
|
|
45
46
|
root: config.root,
|
|
46
|
-
componentDirs:
|
|
47
|
+
componentDirs: normalizeComponentSources(config.components?.source, process.cwd()),
|
|
47
48
|
vite: config.vite
|
|
48
49
|
});
|
|
49
50
|
setActiveRenderer(renderer);
|
|
@@ -186,7 +187,7 @@ function maizzleDevPlugin(config, renderer, configInput) {
|
|
|
186
187
|
dts: true,
|
|
187
188
|
markdown: config.markdown,
|
|
188
189
|
root: config.root,
|
|
189
|
-
componentDirs:
|
|
190
|
+
componentDirs: normalizeComponentSources(config.components?.source, process.cwd()),
|
|
190
191
|
vite: config.vite
|
|
191
192
|
});
|
|
192
193
|
server.ws.send({
|
|
@@ -207,8 +208,8 @@ function maizzleDevPlugin(config, renderer, configInput) {
|
|
|
207
208
|
if (url === "/__maizzle/templates") return serveTemplateList(config, res);
|
|
208
209
|
if (url.startsWith("/__maizzle/render/")) return await serveRenderedTemplate(url, config, renderer, res);
|
|
209
210
|
if (url.startsWith("/__maizzle/source/")) return await serveHighlightedSource(url, config, renderer, res);
|
|
210
|
-
if (url.startsWith("/__maizzle/compatibility/")) return await serveCompatibility(url, res, config,
|
|
211
|
-
if (url.startsWith("/__maizzle/lint/")) return await serveLint(url, res, config,
|
|
211
|
+
if (url.startsWith("/__maizzle/compatibility/")) return await serveCompatibility(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()));
|
|
212
|
+
if (url.startsWith("/__maizzle/lint/")) return await serveLint(url, res, config, normalizeComponentSources(config.components?.source, process.cwd()));
|
|
212
213
|
if (url.startsWith("/__maizzle/vue-source/")) return await serveVueSource(url, config, res);
|
|
213
214
|
if (url.startsWith("/__maizzle/plaintext/")) return await servePlaintext(url, config, renderer, res);
|
|
214
215
|
if (url.startsWith("/__maizzle/stats/")) return await serveStats(url, config, renderer, res);
|