@maizzle/framework 6.0.0-rc.14 → 6.0.0-rc.15

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.
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  * Render an empty `<head>` before the main head element.
7
7
  *
8
8
  * This is a workaround for Yahoo! Mail on Android, which
9
- * strips styles from the first `<head>` element.
9
+ * strips the first `<head>` element it finds.
10
10
  *
11
11
  * @default false
12
12
  */
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, useAttrs, type PropType } from 'vue'
2
+ import { computed, useAttrs, createStaticVNode, type PropType } from 'vue'
3
3
  import { twMerge } from 'tailwind-merge'
4
4
 
5
5
  defineOptions({ inheritAttrs: false })
@@ -30,6 +30,18 @@ const props = defineProps({
30
30
  type: String as PropType<'ltr' | 'rtl'>,
31
31
  default: 'ltr'
32
32
  },
33
+ /**
34
+ * Render an empty `<head>` before the main head element.
35
+ *
36
+ * This is a workaround for Yahoo! Mail on Android, which
37
+ * strips the first `<head>` element it finds.
38
+ *
39
+ * @default false
40
+ */
41
+ doubleHead: {
42
+ type: [Boolean, String],
43
+ default: false
44
+ },
33
45
  /**
34
46
  * Accessible label for the email article wrapper.
35
47
  *
@@ -46,10 +58,13 @@ const props = defineProps({
46
58
  const attrs = useAttrs()
47
59
  const bodyMergedClass = computed(() => twMerge('m-0 p-0 size-full [word-break:break-word]', props.bodyClass))
48
60
  const articleMergedClass = computed(() => twMerge('[font-size:max(16px,1rem)] font-inter', attrs.class as string))
61
+
62
+ const EmptyHead = () => createStaticVNode('<head></head>', 1)
49
63
  </script>
50
64
 
51
65
  <template>
52
66
  <html :lang="lang" :dir="dir" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
67
+ <EmptyHead v-if="props.doubleHead === true || props.doubleHead === 'true'" />
53
68
  <head>
54
69
  <meta charset="utf-8">
55
70
  <meta name="x-apple-disable-message-reformatting">
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { computed, createStaticVNode } from 'vue'
2
+ import { computed, createStaticVNode, type PropType } from 'vue'
3
3
 
4
4
  const VERSION_MAP = {
5
5
  2003: 11,
@@ -10,7 +10,10 @@ const VERSION_MAP = {
10
10
  2019: 16
11
11
  }
12
12
 
13
- const toMso = (v: string) => VERSION_MAP[v]
13
+ type Year = `${keyof typeof VERSION_MAP}`
14
+ type YearList = Year | (string & {})
15
+
16
+ const toMso = (v: string) => VERSION_MAP[v as unknown as keyof typeof VERSION_MAP]
14
17
 
15
18
  const parseList = (value: string) =>
16
19
  value
@@ -30,7 +33,7 @@ export default {
30
33
  * @example '2013'
31
34
  * @example '2013,2016'
32
35
  */
33
- only: String,
36
+ only: String as PropType<YearList>,
34
37
  /**
35
38
  * Render content in all Outlook versions except the specified one(s).
36
39
  *
@@ -39,31 +42,55 @@ export default {
39
42
  * @example '2007'
40
43
  * @example '2007,2010'
41
44
  */
42
- not: String,
45
+ not: String as PropType<YearList>,
43
46
  /**
44
47
  * Render content in Outlook versions lower than the specified year.
45
48
  *
46
49
  * @example '2013'
47
50
  */
48
- lt: String,
51
+ lt: String as PropType<Year>,
49
52
  /**
50
53
  * Render content in Outlook versions lower than or equal to the specified year.
51
54
  *
52
55
  * @example '2013'
53
56
  */
54
- lte: String,
57
+ lte: String as PropType<Year>,
55
58
  /**
56
59
  * Render content in Outlook versions greater than the specified year.
57
60
  *
58
61
  * @example '2010'
59
62
  */
60
- gt: String,
63
+ gt: String as PropType<Year>,
61
64
  /**
62
65
  * Render content in Outlook versions greater than or equal to the specified year.
63
66
  *
64
67
  * @example '2010'
65
68
  */
66
- gte: String
69
+ gte: String as PropType<Year>,
70
+ /**
71
+ * Raw HTML inserted at the start of the conditional comment, before the slot.
72
+ *
73
+ * Bypasses Vue's template parser, so unbalanced tags are preserved — useful
74
+ * for MSO ghost tables where the opening `<table><tr><td>` must live inside
75
+ * the conditional comment.
76
+ *
77
+ * @example '<table align="center" width="600"><tr><td>'
78
+ */
79
+ open: {
80
+ type: String,
81
+ default: ''
82
+ },
83
+ /**
84
+ * Raw HTML inserted at the end of the conditional comment, after the slot.
85
+ *
86
+ * Pair with `open` to close ghost-table tags inside the conditional.
87
+ *
88
+ * @example '</td></tr></table>'
89
+ */
90
+ close: {
91
+ type: String,
92
+ default: ''
93
+ }
67
94
  },
68
95
  setup(props, { slots }) {
69
96
  const condition = computed(() => {
@@ -97,13 +124,13 @@ export default {
97
124
  return 'mso'
98
125
  })
99
126
 
100
- const start = computed(() => `<!--[if ${condition.value}]>`)
101
- const end = `<![endif]-->`
127
+ const start = computed(() => `<!--[if ${condition.value}]>${props.open}`)
128
+ const end = computed(() => `${props.close}<![endif]-->`)
102
129
 
103
130
  return () => [
104
131
  createStaticVNode(start.value, 1),
105
132
  slots.default?.(),
106
- createStaticVNode(end, 1),
133
+ createStaticVNode(end.value, 1),
107
134
  ]
108
135
  }
109
136
  }
@@ -1,6 +1,11 @@
1
+ <script lang="ts">
2
+ const warnedLocations = new Set<string>()
3
+ </script>
4
+
1
5
  <script setup lang="ts">
2
- import { Comment, computed, createStaticVNode, provide, useAttrs, useSlots, Fragment } from 'vue'
6
+ import { Comment, Text, computed, createStaticVNode, provide, useAttrs, useSlots, Fragment } from 'vue'
3
7
  import type { VNode } from 'vue'
8
+ import Column from './Column.vue'
4
9
  import { hasWidthInStyle, hasWidthUtility, normalizeToPixels } from './utils.ts'
5
10
 
6
11
  defineOptions({ inheritAttrs: false })
@@ -49,6 +54,41 @@ function countChildren(vnodes: VNode[]): number {
49
54
  return count
50
55
  }
51
56
 
57
+ function hasColumnChild(vnodes: VNode[]): boolean {
58
+ for (const vnode of vnodes) {
59
+ if (vnode.type === Fragment && Array.isArray(vnode.children)) {
60
+ if (hasColumnChild(vnode.children as VNode[])) return true
61
+ } else if (vnode.type === Column) {
62
+ return true
63
+ } else if (
64
+ typeof vnode.type === 'object'
65
+ && vnode.type !== null
66
+ && '__name' in vnode.type
67
+ && (vnode.type as { __name?: string }).__name === 'Column'
68
+ ) {
69
+ return true
70
+ }
71
+ }
72
+ return false
73
+ }
74
+
75
+ function hasMeaningfulContent(vnodes: VNode[]): boolean {
76
+ for (const vnode of vnodes) {
77
+ if (vnode.type === Comment) continue
78
+ if (vnode.type === Fragment && Array.isArray(vnode.children)) {
79
+ if (hasMeaningfulContent(vnode.children as VNode[])) return true
80
+ continue
81
+ }
82
+ if (vnode.type === Text) {
83
+ if (typeof vnode.children === 'string' && vnode.children.trim()) return true
84
+ continue
85
+ }
86
+ if (typeof vnode.type === 'symbol') continue
87
+ return true
88
+ }
89
+ return false
90
+ }
91
+
52
92
  const columnCount = computed(() => {
53
93
  if (props.cols) return props.cols
54
94
 
@@ -78,7 +118,7 @@ const colWidthSource = computed(() => {
78
118
  })
79
119
 
80
120
  const restAttrs = computed(() => {
81
- const { style: _, ...rest } = attrs
121
+ const { style: _, 'data-maizzle-loc': __, ...rest } = attrs
82
122
  return rest
83
123
  })
84
124
 
@@ -97,6 +137,16 @@ const MsoAfter = () => createStaticVNode(
97
137
  '<!--[if mso]></tr></table><![endif]-->',
98
138
  1
99
139
  )
140
+
141
+ const initialChildren = slots.default?.() ?? []
142
+ if (hasMeaningfulContent(initialChildren) && !hasColumnChild(initialChildren)) {
143
+ const loc = (attrs['data-maizzle-loc'] as string | undefined) ?? '<unknown location>'
144
+ if (!warnedLocations.has(loc)) {
145
+ warnedLocations.add(loc)
146
+ const display = loc.split('/').pop() ?? loc
147
+ console.warn(`[maizzle] <Row> in ${display} has no <Column> inside it. Layout will break in Outlook.`)
148
+ }
149
+ }
100
150
  </script>
101
151
 
102
152
  <template>
package/dist/index.d.mts CHANGED
@@ -11,6 +11,7 @@ import { maizzle } from "./plugin.mjs";
11
11
  import { CreateRendererOptions, RenderedTemplate, Renderer, createRenderer } from "./render/createRenderer.mjs";
12
12
  import { RenderOptions, RenderResult, render } from "./render/index.mjs";
13
13
  import { serve } from "./serve.mjs";
14
+ import { PrepareOptions, prepare } from "./prepare.mjs";
14
15
  import { createPlaintext } from "./plaintext.mjs";
15
16
  import { inlineLink } from "./transformers/inlineLink.mjs";
16
17
  import { urlQuery } from "./transformers/urlQuery.mjs";
@@ -29,4 +30,4 @@ import { replaceStrings } from "./transformers/replaceStrings.mjs";
29
30
  import { format } from "./transformers/format.mjs";
30
31
  import { minify } from "./transformers/minify.mjs";
31
32
  import { useHead } from "@unhead/vue";
32
- export { type AttributesConfig, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type HtmlConfig, type MaizzleConfig, type RenderOptions, type RenderResult, type RenderedTemplate, type Renderer, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCSS, inlineLink, maizzle, minify, removeAttributes, purgeCSS as removeUnusedCSS, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCSS, sixHex, urlQuery, useConfig, useDoctype, useEvent, useFont, useHead, usePlaintext };
33
+ export { type AttributesConfig, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type HtmlConfig, type MaizzleConfig, type PrepareOptions, type RenderOptions, type RenderResult, type RenderedTemplate, type Renderer, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCSS, inlineLink, maizzle, minify, prepare, removeAttributes, purgeCSS as removeUnusedCSS, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCSS, sixHex, urlQuery, useConfig, useDoctype, useEvent, useFont, useHead, usePlaintext };
package/dist/index.mjs CHANGED
@@ -23,10 +23,11 @@ import { build } from "./build.mjs";
23
23
  import { maizzle } from "./plugin.mjs";
24
24
  import { render } from "./render/index.mjs";
25
25
  import { serve } from "./serve.mjs";
26
+ import { prepare } from "./prepare.mjs";
26
27
  import { useDoctype } from "./composables/useDoctype.mjs";
27
28
  import { useEvent } from "./composables/useEvent.mjs";
28
29
  import { useFont } from "./composables/useFont.mjs";
29
30
  import { usePlaintext } from "./composables/usePlaintext.mjs";
30
31
  import { useHead } from "@unhead/vue";
31
32
 
32
- export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCSS, inlineLink, maizzle, minify, removeAttributes, purgeCSS as removeUnusedCSS, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCSS, sixHex, urlQuery, useConfig, useDoctype, useEvent, useFont, useHead, usePlaintext };
33
+ export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCSS, inlineLink, maizzle, minify, prepare, removeAttributes, purgeCSS as removeUnusedCSS, render, replaceStrings, resolveConfig, safeClassNames, serve, shorthandCSS, sixHex, urlQuery, useConfig, useDoctype, useEvent, useFont, useHead, usePlaintext };
@@ -0,0 +1,17 @@
1
+ //#region src/prepare.d.ts
2
+ interface PrepareOptions {
3
+ /** Path to a Maizzle config file. */
4
+ config?: string;
5
+ }
6
+ /**
7
+ * Generate IDE type definitions in `.maizzle/`
8
+ * (`auto-imports.d.ts` and `components.d.ts`).
9
+ *
10
+ * Intended as a `postinstall` step so editors get autocompletion before the
11
+ * user runs `dev` or `build`. Spins up the renderer with `dts: true`, runs
12
+ * a trivial render to trigger the unplugin scans, then shuts down.
13
+ */
14
+ declare function prepare(options?: PrepareOptions): Promise<void>;
15
+ //#endregion
16
+ export { PrepareOptions, prepare };
17
+ //# sourceMappingURL=prepare.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.d.mts","names":[],"sources":["../src/prepare.ts"],"mappings":";UAMiB,cAAA;EAAA;EAEf,MAAA;AAAA;;;AAWF;;;;;;iBAAsB,OAAA,CAAQ,OAAA,GAAS,cAAA,GAAsB,OAAA"}
@@ -0,0 +1,44 @@
1
+ import { resolveConfig } from "./config/index.mjs";
2
+ import { isLaravel } from "./utils/detect.mjs";
3
+ import { createRenderer } from "./render/createRenderer.mjs";
4
+ import { relative, resolve } from "node:path";
5
+ import ora from "ora";
6
+
7
+ //#region src/prepare.ts
8
+ /**
9
+ * Generate IDE type definitions in `.maizzle/`
10
+ * (`auto-imports.d.ts` and `components.d.ts`).
11
+ *
12
+ * Intended as a `postinstall` step so editors get autocompletion before the
13
+ * user runs `dev` or `build`. Spins up the renderer with `dts: true`, runs
14
+ * a trivial render to trigger the unplugin scans, then shuts down.
15
+ */
16
+ async function prepare(options = {}) {
17
+ const spinner = ora({
18
+ text: "Generating types...",
19
+ spinner: "circleHalves"
20
+ }).start();
21
+ const config = await resolveConfig(options.config);
22
+ const renderer = await createRenderer({
23
+ dts: true,
24
+ markdown: config.markdown,
25
+ root: config.root,
26
+ componentDirs: [config.components?.source ?? []].flat(),
27
+ vite: config.vite
28
+ });
29
+ try {
30
+ await renderer.render("<template><div></div></template>", config);
31
+ } finally {
32
+ await renderer.close();
33
+ }
34
+ const dtsDir = isLaravel() ? resolve(process.cwd(), "resources/js/types/maizzle") : resolve(config.root, ".maizzle");
35
+ const displayPath = relative(process.cwd(), dtsDir) || dtsDir;
36
+ spinner.stopAndPersist({
37
+ symbol: "✅",
38
+ text: `Types generated in ${displayPath}`
39
+ });
40
+ }
41
+
42
+ //#endregion
43
+ export { prepare };
44
+ //# sourceMappingURL=prepare.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.mjs","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: [config.components?.source ?? []].flat(),\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":";;;;;;;;;;;;;;;AAmBA,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,CAAC,OAAO,YAAY,UAAU,EAAE,CAAC,CAAC,MAAM;EACvD,MAAM,OAAO;EACd,CAAC;AAEF,KAAI;AACF,QAAM,SAAS,OAAO,oCAAoC,OAAO;WACzD;AACR,QAAM,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;AAEvD,SAAQ,eAAe;EACrB,QAAQ;EACR,MAAM,sBAAsB;EAC7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createRenderer.d.mts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":";;;;;;UAyJiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,cAAA,EAAgB,aAAA;EAChB,gBAAA,EAAkB,aAAA;EAClB,SAAA,GAAY,aAAA;AAAA;AAAA,UAGG,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;EAZC;EAchB,GAAA;EAbkB;EAelB,QAAA,GAAW,cAAA;EAdC;EAgBZ,IAAA;EAhByB;EAkBzB,aAAA;EAfuB;EAiBvB,IAAA,GAAO,YAAA;AAAA;;;;;;;iBASa,cAAA,CACpB,OAAA,GAAS,qBAAA,GACR,OAAA,CAAQ,QAAA"}
1
+ {"version":3,"file":"createRenderer.d.mts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":";;;;;;UA0JiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,cAAA,EAAgB,aAAA;EAChB,gBAAA,EAAkB,aAAA;EAClB,SAAA,GAAY,aAAA;AAAA;AAAA,UAGG,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;EAZC;EAchB,GAAA;EAbkB;EAelB,QAAA,GAAW,cAAA;EAdC;EAgBZ,IAAA;EAhByB;EAkBzB,aAAA;EAfuB;EAiBvB,IAAA,GAAO,YAAA;AAAA;;;;;;;iBASa,cAAA,CACpB,OAAA,GAAS,qBAAA,GACR,OAAA,CAAQ,QAAA"}
@@ -1,6 +1,7 @@
1
1
  import { MaizzleConfigKey } from "../composables/useConfig.mjs";
2
2
  import { RenderContextKey } from "../composables/renderContext.mjs";
3
3
  import { isLaravel } from "../utils/detect.mjs";
4
+ import { rowSourceLocation } from "./plugins/rowSourceLocation.mjs";
4
5
  import { existsSync, readFileSync } from "node:fs";
5
6
  import { dirname, resolve } from "node:path";
6
7
  import { fileURLToPath } from "node:url";
@@ -110,6 +111,7 @@ async function createRenderer(options = {}) {
110
111
  plugins: [
111
112
  codeBlockExtract(),
112
113
  markdownExtract(),
114
+ rowSourceLocation(),
113
115
  {
114
116
  name: "maizzle:virtual-sfc",
115
117
  resolveId(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"createRenderer.mjs","names":["merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, resolve } from 'node:path'\nimport { readFileSync, existsSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { isLaravel } from '../utils/detect.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, renderSSRHead } 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\n/**\n * Vite plugin that extracts raw slot content from <CodeBlock> tags\n * and passes it as a :code prop before Vue compiles the template.\n *\n * This lets users write HTML naturally inside CodeBlock slots without\n * Vue attempting to compile it as template syntax.\n */\nfunction codeBlockExtract() {\n // Matches <CodeBlock ...>content</CodeBlock> (and kebab-case <code-block>)\n const re = /<(CodeBlock|code-block)((?:\\s[^>]*?)?)>([\\s\\S]*?)<\\/\\1>/g\n\n return {\n name: 'maizzle:code-block-extract',\n enforce: 'pre' as const,\n transform(code: string, id: string) {\n if (!id.endsWith('.vue') && !id.endsWith('.md')) return\n if (!code.includes('CodeBlock') && !code.includes('code-block')) return\n\n const transformed = code.replace(re, (_match, tag, attrs, content) => {\n // Skip if already has a :code or v-bind:code prop\n if (/(?:^|\\s):code\\b/.test(attrs) || /v-bind:code\\b/.test(attrs)) return _match\n\n // Strip leading/trailing blank lines, then dedent based on\n // the minimum indent of non-empty lines (à la min-indent)\n const stripped = content.replace(/^\\n+/, '').replace(/\\s+$/, '')\n if (!stripped) return _match\n\n const minIndent = stripped.match(/^[ \\t]*(?=\\S)/gm)\n ?.reduce((min, ws) => Math.min(min, ws.length), Infinity) ?? 0\n\n const dedented = minIndent > 0\n ? stripped.replace(new RegExp(`^[ \\\\t]{${minIndent}}`, 'gm'), '')\n : stripped\n\n // HTML-escape for safe embedding in a static attribute value.\n const escaped = dedented\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n\n return `<${tag}${attrs} code=\"${escaped}\" />`\n })\n\n if (transformed !== code) {\n return { code: transformed, map: null }\n }\n },\n }\n}\n\n/**\n * Vite plugin that pre-processes <Markdown> tags:\n * - Extracts slot content, dedents it, and passes as :content prop\n * - Resolves `src` prop to read file contents at build time\n */\nfunction markdownExtract() {\n const re = /<(Markdown|markdown)((?:\\s[^>]*?)?)>([\\s\\S]*?)<\\/\\1>/g\n const selfClosingRe = /<(Markdown|markdown)((?:\\s[^>]*?\\bsrc\\s*=\\s*\"[^\"]*\"[^>]*?))\\/>/g\n\n return {\n name: 'maizzle:markdown-extract',\n enforce: 'pre' as const,\n transform(code: string, id: string) {\n if (!id.endsWith('.vue') && !id.endsWith('.md')) return\n if (!code.includes('Markdown') && !code.includes('markdown')) return\n\n let transformed = code\n\n // Handle <Markdown>content</Markdown>\n transformed = transformed.replace(re, (_match, tag, attrs, content) => {\n if (/(?:^|\\s):content\\b/.test(attrs) || /v-bind:content\\b/.test(attrs)) return _match\n\n const stripped = content.replace(/^\\n+/, '').replace(/\\s+$/, '')\n if (!stripped) return _match\n\n const minIndent = stripped.match(/^[ \\t]*(?=\\S)/gm)\n ?.reduce((min: number, ws: string) => Math.min(min, ws.length), Infinity) ?? 0\n\n const dedented = minIndent > 0\n ? stripped.replace(new RegExp(`^[ \\\\t]{${minIndent}}`, 'gm'), '')\n : stripped\n\n const escaped = dedented\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n\n return `<${tag}${attrs} content=\"${escaped}\" />`\n })\n\n // Handle <Markdown src=\"./file.md\" /> — resolve and inline file content\n transformed = transformed.replace(selfClosingRe, (_match, tag, attrs) => {\n const srcMatch = attrs.match(/\\bsrc\\s*=\\s*\"([^\"]*)\"/)\n if (!srcMatch) return _match\n\n const srcPath = srcMatch[1]\n const resolvedPath = resolve(dirname(id), srcPath)\n\n let fileContent: string\n try {\n fileContent = readFileSync(resolvedPath, 'utf-8').trim()\n } catch {\n return _match\n }\n\n // Remove src prop, add content prop\n const cleanAttrs = attrs.replace(/\\s*\\bsrc\\s*=\\s*\"[^\"]*\"/, '')\n const escaped = fileContent\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n\n return `<${tag}${cleanAttrs} content=\"${escaped}\" />`\n })\n\n if (transformed !== code) {\n return { code: transformed, map: null }\n }\n },\n }\n}\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}\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 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 // Check for a user vite.config file in the project root\n const viteConfigFile = ['vite.config.ts', 'vite.config.js']\n .map(f => resolve(root, f))\n .find(f => existsSync(f))\n\n const maizzleConfig: InlineConfig = {\n configFile: viteConfigFile ?? false,\n plugins: [\n codeBlockExtract(),\n markdownExtract(),\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 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 watch: null,\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 && !viteConfigFile\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 } = await renderSSRHead(head)\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 return {\n html,\n doctype: renderContext.doctype,\n templateConfig: renderContext.sfcConfig ?? config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\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":";;;;;;;;;;;;;;;;;;AAqBA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;;;;;;;;AASzD,SAAS,mBAAmB;CAE1B,MAAM,KAAK;AAEX,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,MAAc,IAAY;AAClC,OAAI,CAAC,GAAG,SAAS,OAAO,IAAI,CAAC,GAAG,SAAS,MAAM,CAAE;AACjD,OAAI,CAAC,KAAK,SAAS,YAAY,IAAI,CAAC,KAAK,SAAS,aAAa,CAAE;GAEjE,MAAM,cAAc,KAAK,QAAQ,KAAK,QAAQ,KAAK,OAAO,YAAY;AAEpE,QAAI,kBAAkB,KAAK,MAAM,IAAI,gBAAgB,KAAK,MAAM,CAAE,QAAO;IAIzE,MAAM,WAAW,QAAQ,QAAQ,QAAQ,GAAG,CAAC,QAAQ,QAAQ,GAAG;AAChE,QAAI,CAAC,SAAU,QAAO;IAEtB,MAAM,YAAY,SAAS,MAAM,kBAAkB,EAC/C,QAAQ,KAAK,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO,EAAE,SAAS,IAAI;AAa/D,WAAO,IAAI,MAAM,MAAM,UAXN,YAAY,IACzB,SAAS,QAAQ,IAAI,OAAO,WAAW,UAAU,IAAI,KAAK,EA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esContent":["import { dirname, resolve } from 'node:path'\nimport { readFileSync, existsSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { isLaravel } from '../utils/detect.ts'\nimport { rowSourceLocation } from './plugins/rowSourceLocation.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, renderSSRHead } 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\n/**\n * Vite plugin that extracts raw slot content from <CodeBlock> tags\n * and passes it as a :code prop before Vue compiles the template.\n *\n * This lets users write HTML naturally inside CodeBlock slots without\n * Vue attempting to compile it as template syntax.\n */\nfunction codeBlockExtract() {\n // Matches <CodeBlock ...>content</CodeBlock> (and kebab-case <code-block>)\n const re = /<(CodeBlock|code-block)((?:\\s[^>]*?)?)>([\\s\\S]*?)<\\/\\1>/g\n\n return {\n name: 'maizzle:code-block-extract',\n enforce: 'pre' as const,\n transform(code: string, id: string) {\n if (!id.endsWith('.vue') && !id.endsWith('.md')) return\n if (!code.includes('CodeBlock') && !code.includes('code-block')) return\n\n const transformed = code.replace(re, (_match, tag, attrs, content) => {\n // Skip if already has a :code or v-bind:code prop\n if (/(?:^|\\s):code\\b/.test(attrs) || /v-bind:code\\b/.test(attrs)) return _match\n\n // Strip leading/trailing blank lines, then dedent based on\n // the minimum indent of non-empty lines (à la min-indent)\n const stripped = content.replace(/^\\n+/, '').replace(/\\s+$/, '')\n if (!stripped) return _match\n\n const minIndent = stripped.match(/^[ \\t]*(?=\\S)/gm)\n ?.reduce((min, ws) => Math.min(min, ws.length), Infinity) ?? 0\n\n const dedented = minIndent > 0\n ? stripped.replace(new RegExp(`^[ \\\\t]{${minIndent}}`, 'gm'), '')\n : stripped\n\n // HTML-escape for safe embedding in a static attribute value.\n const escaped = dedented\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n\n return `<${tag}${attrs} code=\"${escaped}\" />`\n })\n\n if (transformed !== code) {\n return { code: transformed, map: null }\n }\n },\n }\n}\n\n/**\n * Vite plugin that pre-processes <Markdown> tags:\n * - Extracts slot content, dedents it, and passes as :content prop\n * - Resolves `src` prop to read file contents at build time\n */\nfunction markdownExtract() {\n const re = /<(Markdown|markdown)((?:\\s[^>]*?)?)>([\\s\\S]*?)<\\/\\1>/g\n const selfClosingRe = /<(Markdown|markdown)((?:\\s[^>]*?\\bsrc\\s*=\\s*\"[^\"]*\"[^>]*?))\\/>/g\n\n return {\n name: 'maizzle:markdown-extract',\n enforce: 'pre' as const,\n transform(code: string, id: string) {\n if (!id.endsWith('.vue') && !id.endsWith('.md')) return\n if (!code.includes('Markdown') && !code.includes('markdown')) return\n\n let transformed = code\n\n // Handle <Markdown>content</Markdown>\n transformed = transformed.replace(re, (_match, tag, attrs, content) => {\n if (/(?:^|\\s):content\\b/.test(attrs) || /v-bind:content\\b/.test(attrs)) return _match\n\n const stripped = content.replace(/^\\n+/, '').replace(/\\s+$/, '')\n if (!stripped) return _match\n\n const minIndent = stripped.match(/^[ \\t]*(?=\\S)/gm)\n ?.reduce((min: number, ws: string) => Math.min(min, ws.length), Infinity) ?? 0\n\n const dedented = minIndent > 0\n ? stripped.replace(new RegExp(`^[ \\\\t]{${minIndent}}`, 'gm'), '')\n : stripped\n\n const escaped = dedented\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n\n return `<${tag}${attrs} content=\"${escaped}\" />`\n })\n\n // Handle <Markdown src=\"./file.md\" /> — resolve and inline file content\n transformed = transformed.replace(selfClosingRe, (_match, tag, attrs) => {\n const srcMatch = attrs.match(/\\bsrc\\s*=\\s*\"([^\"]*)\"/)\n if (!srcMatch) return _match\n\n const srcPath = srcMatch[1]\n const resolvedPath = resolve(dirname(id), srcPath)\n\n let fileContent: string\n try {\n fileContent = readFileSync(resolvedPath, 'utf-8').trim()\n } catch {\n return _match\n }\n\n // Remove src prop, add content prop\n const cleanAttrs = attrs.replace(/\\s*\\bsrc\\s*=\\s*\"[^\"]*\"/, '')\n const escaped = fileContent\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n\n return `<${tag}${cleanAttrs} content=\"${escaped}\" />`\n })\n\n if (transformed !== code) {\n return { code: transformed, map: null }\n }\n },\n }\n}\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}\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 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 // Check for a user vite.config file in the project root\n const viteConfigFile = ['vite.config.ts', 'vite.config.js']\n .map(f => resolve(root, f))\n .find(f => existsSync(f))\n\n const maizzleConfig: InlineConfig = {\n configFile: viteConfigFile ?? false,\n plugins: [\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 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 watch: null,\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 && !viteConfigFile\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 } = await renderSSRHead(head)\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 return {\n html,\n doctype: renderContext.doctype,\n templateConfig: renderContext.sfcConfig ?? config,\n sfcEventHandlers: renderContext.sfcEventHandlers,\n plaintext: renderContext.plaintext,\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":";;;;;;;;;;;;;;;;;;;AAsBA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;;;;;;;;AASzD,SAAS,mBAAmB;CAE1B,MAAM,KAAK;AAEX,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,MAAc,IAAY;AAClC,OAAI,CAAC,GAAG,SAAS,OAAO,IAAI,CAAC,GAAG,SAAS,MAAM,CAAE;AACjD,OAAI,CAAC,KAAK,SAAS,YAAY,IAAI,CAAC,KAAK,SAAS,aAAa,CAAE;GAEjE,MAAM,cAAc,KAAK,QAAQ,KAAK,QAAQ,KAAK,OAAO,YAAY;AAEpE,QAAI,kBAAkB,KAAK,MAAM,IAAI,gBAAgB,KAAK,MAAM,CAAE,QAAO;IAIzE,MAAM,WAAW,QAAQ,QAAQ,QAAQ,GAAG,CAAC,QAAQ,QAAQ,GAAG;AAChE,QAAI,CAAC,SAAU,QAAO;IAEtB,MAAM,YAAY,SAAS,MAAM,kBAAkB,EAC/C,QAAQ,KAAK,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO,EAAE,SAAS,IAAI;AAa/D,WAAO,IAAI,MAAM,MAAM,UAXN,YAAY,IACzB,SAAS,QAAQ,IAAI,OAAO,WAAW,UAAU,IAAI,KAAK,EAAE,GAAG,GAC/D,UAID,QAAQ,MAAM,QAAQ,CACtB,QAAQ,MAAM,SAAS,CACvB,QAAQ,MAAM,OAAO,CACrB,QAAQ,MAAM,OAAO,CAEgB;KACxC;AAEF,OAAI,gBAAgB,KAClB,QAAO;IAAE,MAAM;IAAa,KAAK;IAAM;;EAG5C;;;;;;;AAQH,SAAS,kBAAkB;CACzB,MAAM,KAAK;CACX,MAAM,gBAAgB;AAEtB,QAAO;EACL,MAAM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MAAM,SAAS,eAClB,OAAM,SAAS;AAGjB,UAAG,WAAW,UACV,CAAC,GAAG,gBAAgB,GAAI,GAAG,YAAY,EAAE,CAAE,GAC3C,CAAC,GAAI,GAAG,YAAY,EAAE,EAAG,GAAG,eAAe;;OAEjD;;AAIN,QAAI,UAAU;KACZ,MAAM,EAAE,gBAAgB,MAAM,OAAO;AACrC,iBAAY,KAAK,cAAc,OAAQ,UAAU,KAAK;;AAGxD,WAAO,aAAa,IAAI;;AAI1B,OAAI,cAAc,WAAW;IAC3B,MAAM,EAAE,MAAM,aAAa,aAAa,cAAc;IAGtD,MAAM,cAAc,6BAA6B,OAFlC,MAAgB,OAAO,YAAY,GACrC,KAAU,OAAO,SAAS,CAC+B;AACtE,WAAO,KAAK,QAAQ,iBAAiB,WAAW,cAAc;;AAGhE,UAAO;IACL;IACA,SAAS,cAAc;IACvB,gBAAgB,cAAc,aAAa;IAC3C,kBAAkB,cAAc;IAChC,WAAW,cAAc;IAC1B;;EAGH,MAAM,WAAW,UAAiC;GAChD,MAAM,MAAM,MAAM,OAAO,YAAY,eAAe,SAAS;AAC7D,OAAI,IACF,QAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,gBAA+B;AACnC,QAAK,MAAM,OAAO,OAAO,YAAY,cAAc,QAAQ,CACzD,QAAO,YAAY,iBAAiB,IAAI;;EAI5C,MAAM,QAAuB;AAC3B,SAAM,OAAO,OAAO;;EAEvB"}
@@ -0,0 +1,18 @@
1
+ import { Plugin } from "vite";
2
+
3
+ //#region src/render/plugins/rowSourceLocation.d.ts
4
+ /**
5
+ * Vite plugin that injects `data-maizzle-loc="<file>:<line>"` into every
6
+ * `<Row>`/`<row>` opening tag in user templates.
7
+ *
8
+ * Used by Row.vue's runtime to point the user at the exact line in their
9
+ * template when they misuse Row (e.g. without a Column child).
10
+ *
11
+ * Only transforms inside `<template>` blocks of SFCs (or the entire file
12
+ * for `.md` templates) so `<Row>` mentions in `<script>` blocks (e.g. in
13
+ * string literals or comments) are left untouched.
14
+ */
15
+ declare function rowSourceLocation(): Plugin;
16
+ //#endregion
17
+ export { rowSourceLocation };
18
+ //# sourceMappingURL=rowSourceLocation.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rowSourceLocation.d.mts","names":[],"sources":["../../../src/render/plugins/rowSourceLocation.ts"],"mappings":";;;;;AAaA;;;;;;;;;iBAAgB,iBAAA,CAAA,GAAqB,MAAA"}
@@ -0,0 +1,45 @@
1
+ //#region src/render/plugins/rowSourceLocation.ts
2
+ /**
3
+ * Vite plugin that injects `data-maizzle-loc="<file>:<line>"` into every
4
+ * `<Row>`/`<row>` opening tag in user templates.
5
+ *
6
+ * Used by Row.vue's runtime to point the user at the exact line in their
7
+ * template when they misuse Row (e.g. without a Column child).
8
+ *
9
+ * Only transforms inside `<template>` blocks of SFCs (or the entire file
10
+ * for `.md` templates) so `<Row>` mentions in `<script>` blocks (e.g. in
11
+ * string literals or comments) are left untouched.
12
+ */
13
+ function rowSourceLocation() {
14
+ const tagRe = /(<(?:Row|row))(\b[^>]*?)(\/?>)/g;
15
+ function injectLoc(html, htmlOffset, fullCode, id) {
16
+ return html.replace(tagRe, (match, tag, attrs, end, localOffset) => {
17
+ if (/\bdata-maizzle-loc\s*=/.test(attrs)) return match;
18
+ const absoluteOffset = htmlOffset + localOffset;
19
+ return `${tag}${attrs} data-maizzle-loc="${id}:${fullCode.slice(0, absoluteOffset).split("\n").length}"${end}`;
20
+ });
21
+ }
22
+ return {
23
+ name: "maizzle:row-loc",
24
+ enforce: "pre",
25
+ transform(code, id) {
26
+ const isVue = id.endsWith(".vue");
27
+ const isMd = id.endsWith(".md");
28
+ if (!isVue && !isMd) return;
29
+ if (!code.includes("<Row") && !code.includes("<row")) return;
30
+ let transformed;
31
+ if (isVue) transformed = code.replace(/(<template\b[^>]*>)([\s\S]*?)(<\/template>)/g, (_match, open, inner, close, offset) => {
32
+ return open + injectLoc(inner, offset + open.length, code, id) + close;
33
+ });
34
+ else transformed = injectLoc(code, 0, code, id);
35
+ if (transformed !== code) return {
36
+ code: transformed,
37
+ map: null
38
+ };
39
+ }
40
+ };
41
+ }
42
+
43
+ //#endregion
44
+ export { rowSourceLocation };
45
+ //# sourceMappingURL=rowSourceLocation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rowSourceLocation.mjs","names":[],"sources":["../../../src/render/plugins/rowSourceLocation.ts"],"sourcesContent":["import type { Plugin } from 'vite'\n\n/**\n * Vite plugin that injects `data-maizzle-loc=\"<file>:<line>\"` into every\n * `<Row>`/`<row>` opening tag in user templates.\n *\n * Used by Row.vue's runtime to point the user at the exact line in their\n * template when they misuse Row (e.g. without a Column child).\n *\n * Only transforms inside `<template>` blocks of SFCs (or the entire file\n * for `.md` templates) so `<Row>` mentions in `<script>` blocks (e.g. in\n * string literals or comments) are left untouched.\n */\nexport function rowSourceLocation(): Plugin {\n const tagRe = /(<(?:Row|row))(\\b[^>]*?)(\\/?>)/g\n\n function injectLoc(html: string, htmlOffset: number, fullCode: string, id: string): string {\n return html.replace(tagRe, (match, tag, attrs, end, localOffset: number) => {\n if (/\\bdata-maizzle-loc\\s*=/.test(attrs)) return match\n const absoluteOffset = htmlOffset + localOffset\n const line = fullCode.slice(0, absoluteOffset).split('\\n').length\n return `${tag}${attrs} data-maizzle-loc=\"${id}:${line}\"${end}`\n })\n }\n\n return {\n name: 'maizzle:row-loc',\n enforce: 'pre',\n transform(code, id) {\n const isVue = id.endsWith('.vue')\n const isMd = id.endsWith('.md')\n if (!isVue && !isMd) return\n if (!code.includes('<Row') && !code.includes('<row')) return\n\n let transformed: string\n\n if (isVue) {\n // Replace inside every <template>...</template> block, leaving\n // <script> and <style> blocks alone.\n const templateBlock = /(<template\\b[^>]*>)([\\s\\S]*?)(<\\/template>)/g\n transformed = code.replace(templateBlock, (_match, open, inner, close, offset: number) => {\n const innerOffset = offset + open.length\n return open + injectLoc(inner, innerOffset, code, id) + close\n })\n } else {\n transformed = injectLoc(code, 0, code, id)\n }\n\n if (transformed !== code) {\n return { code: transformed, map: null }\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,oBAA4B;CAC1C,MAAM,QAAQ;CAEd,SAAS,UAAU,MAAc,YAAoB,UAAkB,IAAoB;AACzF,SAAO,KAAK,QAAQ,QAAQ,OAAO,KAAK,OAAO,KAAK,gBAAwB;AAC1E,OAAI,yBAAyB,KAAK,MAAM,CAAE,QAAO;GACjD,MAAM,iBAAiB,aAAa;AAEpC,UAAO,GAAG,MAAM,MAAM,qBAAqB,GAAG,GADjC,SAAS,MAAM,GAAG,eAAe,CAAC,MAAM,KAAK,CAAC,OACL,GAAG;IACzD;;AAGJ,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,MAAM,IAAI;GAClB,MAAM,QAAQ,GAAG,SAAS,OAAO;GACjC,MAAM,OAAO,GAAG,SAAS,MAAM;AAC/B,OAAI,CAAC,SAAS,CAAC,KAAM;AACrB,OAAI,CAAC,KAAK,SAAS,OAAO,IAAI,CAAC,KAAK,SAAS,OAAO,CAAE;GAEtD,IAAI;AAEJ,OAAI,MAIF,eAAc,KAAK,QADG,iDACqB,QAAQ,MAAM,OAAO,OAAO,WAAmB;AAExF,WAAO,OAAO,UAAU,OADJ,SAAS,KAAK,QACU,MAAM,GAAG,GAAG;KACxD;OAEF,eAAc,UAAU,MAAM,GAAG,MAAM,GAAG;AAG5C,OAAI,gBAAgB,KAClB,QAAO;IAAE,MAAM;IAAa,KAAK;IAAM;;EAG5C"}
@@ -9,7 +9,7 @@ import { Text } from "domhandler";
9
9
  * Process children before parents so nested filter elements work correctly.
10
10
  */
11
11
  function walkBottomUp(nodes, callback) {
12
- for (const node of [...nodes]) {
12
+ for (const node of nodes.slice()) {
13
13
  if ("children" in node && node.children?.length) walkBottomUp(node.children, callback);
14
14
  callback(node);
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/transformers/filters/index.ts"],"sourcesContent":["import { Text } from 'domhandler'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize } from '../../utils/ast/index.ts'\nimport { defaults } from './defaults.ts'\n\nexport type { FilterFunction } from './defaults.ts'\nexport type FiltersConfig = false | Record<string, (str: string, value: string) => string>\n\n/**\n * Process children before parents so nested filter elements work correctly.\n */\nfunction walkBottomUp(nodes: ChildNode[], callback: (node: ChildNode) => void): void {\n for (const node of [...nodes]) {\n if ('children' in node && node.children?.length) {\n walkBottomUp(node.children as ChildNode[], callback)\n }\n\n callback(node)\n }\n}\n\n/**\n * Filters transformer.\n *\n * Applies transformation functions to the content of elements that\n * have matching filter attributes. Multiple filters on the same element\n * are executed in the order the attributes are defined.\n *\n * Default filters include string manipulation (uppercase, lowercase, trim, etc.),\n * math operations (plus, minus, multiply, etc.), and more.\n *\n * Custom filters can be added via config, and will be merged with defaults.\n * Set config to `false` to disable all filters.\n */\nexport function filters(dom: ChildNode[], config: FiltersConfig = {}): ChildNode[] {\n if (config === false) return dom\n\n const allFilters = { ...defaults, ...config }\n const filterNames = new Set(Object.keys(allFilters))\n\n walkBottomUp(dom, (node) => {\n const el = node as Element\n\n if (!el.attribs) return\n\n // Collect matching filter attributes in source order\n const matched: Array<{ name: string; value: string }> = []\n\n for (const attr of Object.keys(el.attribs)) {\n if (filterNames.has(attr)) {\n matched.push({ name: attr, value: el.attribs[attr] })\n }\n }\n\n if (matched.length === 0) return\n\n // Serialize children to get innerHTML\n let content = serialize(el.children as ChildNode[])\n\n // Apply each filter in attribute order\n for (const { name, value } of matched) {\n content = allFilters[name](content, value)\n delete el.attribs[name]\n }\n\n // Replace children with the filtered content\n if (content === '') {\n el.children = []\n } else if (/<[a-z/!]/i.test(content)) {\n // Result contains HTML elements — parse back to DOM\n const newChildren = parse(content)\n\n for (const child of newChildren) {\n child.parent = el as any\n }\n\n el.children = newChildren as ChildNode[]\n } else {\n // Text-only result — create a text node directly to preserve entity strings\n const textNode = new Text(content)\n textNode.parent = el as any\n el.children = [textNode]\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAS,aAAa,OAAoB,UAA2C;AACnF,MAAK,MAAM,QAAQ,CAAC,GAAG,MAAM,EAAE;AAC7B,MAAI,cAAc,QAAQ,KAAK,UAAU,OACvC,cAAa,KAAK,UAAyB,SAAS;AAGtD,WAAS,KAAK;;;;;;;;;;;;;;;;AAiBlB,SAAgB,QAAQ,KAAkB,SAAwB,EAAE,EAAe;AACjF,KAAI,WAAW,MAAO,QAAO;CAE7B,MAAM,aAAa;EAAE,GAAG;EAAU,GAAG;EAAQ;CAC7C,MAAM,cAAc,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC;AAEpD,cAAa,MAAM,SAAS;EAC1B,MAAM,KAAK;AAEX,MAAI,CAAC,GAAG,QAAS;EAGjB,MAAM,UAAkD,EAAE;AAE1D,OAAK,MAAM,QAAQ,OAAO,KAAK,GAAG,QAAQ,CACxC,KAAI,YAAY,IAAI,KAAK,CACvB,SAAQ,KAAK;GAAE,MAAM;GAAM,OAAO,GAAG,QAAQ;GAAO,CAAC;AAIzD,MAAI,QAAQ,WAAW,EAAG;EAG1B,IAAI,UAAU,UAAU,GAAG,SAAwB;AAGnD,OAAK,MAAM,EAAE,MAAM,WAAW,SAAS;AACrC,aAAU,WAAW,MAAM,SAAS,MAAM;AAC1C,UAAO,GAAG,QAAQ;;AAIpB,MAAI,YAAY,GACd,IAAG,WAAW,EAAE;WACP,YAAY,KAAK,QAAQ,EAAE;GAEpC,MAAM,cAAc,MAAM,QAAQ;AAElC,QAAK,MAAM,SAAS,YAClB,OAAM,SAAS;AAGjB,MAAG,WAAW;SACT;GAEL,MAAM,WAAW,IAAI,KAAK,QAAQ;AAClC,YAAS,SAAS;AAClB,MAAG,WAAW,CAAC,SAAS;;GAE1B;AAEF,QAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/transformers/filters/index.ts"],"sourcesContent":["import { Text } from 'domhandler'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize } from '../../utils/ast/index.ts'\nimport { defaults } from './defaults.ts'\n\nexport type { FilterFunction } from './defaults.ts'\nexport type FiltersConfig = false | Record<string, (str: string, value: string) => string>\n\n/**\n * Process children before parents so nested filter elements work correctly.\n */\nfunction walkBottomUp(nodes: ChildNode[], callback: (node: ChildNode) => void): void {\n for (const node of nodes.slice()) {\n if ('children' in node && node.children?.length) {\n walkBottomUp(node.children as ChildNode[], callback)\n }\n\n callback(node)\n }\n}\n\n/**\n * Filters transformer.\n *\n * Applies transformation functions to the content of elements that\n * have matching filter attributes. Multiple filters on the same element\n * are executed in the order the attributes are defined.\n *\n * Default filters include string manipulation (uppercase, lowercase, trim, etc.),\n * math operations (plus, minus, multiply, etc.), and more.\n *\n * Custom filters can be added via config, and will be merged with defaults.\n * Set config to `false` to disable all filters.\n */\nexport function filters(dom: ChildNode[], config: FiltersConfig = {}): ChildNode[] {\n if (config === false) return dom\n\n const allFilters = { ...defaults, ...config }\n const filterNames = new Set(Object.keys(allFilters))\n\n walkBottomUp(dom, (node) => {\n const el = node as Element\n\n if (!el.attribs) return\n\n // Collect matching filter attributes in source order\n const matched: Array<{ name: string; value: string }> = []\n\n for (const attr of Object.keys(el.attribs)) {\n if (filterNames.has(attr)) {\n matched.push({ name: attr, value: el.attribs[attr] })\n }\n }\n\n if (matched.length === 0) return\n\n // Serialize children to get innerHTML\n let content = serialize(el.children as ChildNode[])\n\n // Apply each filter in attribute order\n for (const { name, value } of matched) {\n content = allFilters[name](content, value)\n delete el.attribs[name]\n }\n\n // Replace children with the filtered content\n if (content === '') {\n el.children = []\n } else if (/<[a-z/!]/i.test(content)) {\n // Result contains HTML elements — parse back to DOM\n const newChildren = parse(content)\n\n for (const child of newChildren) {\n child.parent = el as any\n }\n\n el.children = newChildren as ChildNode[]\n } else {\n // Text-only result — create a text node directly to preserve entity strings\n const textNode = new Text(content)\n textNode.parent = el as any\n el.children = [textNode]\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAS,aAAa,OAAoB,UAA2C;AACnF,MAAK,MAAM,QAAQ,MAAM,OAAO,EAAE;AAChC,MAAI,cAAc,QAAQ,KAAK,UAAU,OACvC,cAAa,KAAK,UAAyB,SAAS;AAGtD,WAAS,KAAK;;;;;;;;;;;;;;;;AAiBlB,SAAgB,QAAQ,KAAkB,SAAwB,EAAE,EAAe;AACjF,KAAI,WAAW,MAAO,QAAO;CAE7B,MAAM,aAAa;EAAE,GAAG;EAAU,GAAG;EAAQ;CAC7C,MAAM,cAAc,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC;AAEpD,cAAa,MAAM,SAAS;EAC1B,MAAM,KAAK;AAEX,MAAI,CAAC,GAAG,QAAS;EAGjB,MAAM,UAAkD,EAAE;AAE1D,OAAK,MAAM,QAAQ,OAAO,KAAK,GAAG,QAAQ,CACxC,KAAI,YAAY,IAAI,KAAK,CACvB,SAAQ,KAAK;GAAE,MAAM;GAAM,OAAO,GAAG,QAAQ;GAAO,CAAC;AAIzD,MAAI,QAAQ,WAAW,EAAG;EAG1B,IAAI,UAAU,UAAU,GAAG,SAAwB;AAGnD,OAAK,MAAM,EAAE,MAAM,WAAW,SAAS;AACrC,aAAU,WAAW,MAAM,SAAS,MAAM;AAC1C,UAAO,GAAG,QAAQ;;AAIpB,MAAI,YAAY,GACd,IAAG,WAAW,EAAE;WACP,YAAY,KAAK,QAAQ,EAAE;GAEpC,MAAM,cAAc,MAAM,QAAQ;AAElC,QAAK,MAAM,SAAS,YAClB,OAAM,SAAS;AAGjB,MAAG,WAAW;SACT;GAEL,MAAM,WAAW,IAAI,KAAK,QAAQ;AAClC,YAAS,SAAS;AAClB,MAAG,WAAW,CAAC,SAAS;;GAE1B;AAEF,QAAO"}
@@ -53,6 +53,7 @@ import { minify } from "./minify.mjs";
53
53
  * 16. Minify
54
54
  */
55
55
  async function runTransformers(html, config, filePath, doctype) {
56
+ html = html.replaceAll("<!--[-->", "").replaceAll("<!--]-->", "").replaceAll("<!--teleport start anchor-->", "").replaceAll("<!--teleport anchor-->", "").replaceAll("<!--teleport start-->", "").replaceAll("<!--teleport end-->", "");
56
57
  let dom = parse(html);
57
58
  dom = await inlineLink(dom, filePath);
58
59
  dom = await tailwindcss(dom, config, filePath);
@@ -72,7 +73,6 @@ async function runTransformers(html, config, filePath, doctype) {
72
73
  dom = entities(dom, config.html?.decodeEntities);
73
74
  const isXhtml = doctype ? /xhtml/i.test(doctype) : false;
74
75
  let result = serialize(dom, { selfClosingTags: isXhtml });
75
- result = result.replaceAll("<!--[-->", "").replaceAll("<!--]-->", "").replaceAll("<!--teleport start anchor-->", "").replaceAll("<!--teleport anchor-->", "").replaceAll("<!--teleport start-->", "").replaceAll("<!--teleport end-->", "");
76
76
  result = replaceStrings(result, config);
77
77
  result = await format(result, config);
78
78
  result = minify(result, config);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLink } from './inlineLink.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeClassNames } from './safeClassNames.ts'\nimport { attributeToStyle } from './attributeToStyle.ts'\nimport { inlineCSS } from './inlineCSS.ts'\nimport { msoWidthFromClass } from './msoWidthFromClass.ts'\nimport { columnWidth } from './columnWidth.ts'\nimport { removeAttributes } from './removeAttributes.ts'\nimport { shorthandCSS } from './shorthandCSS.ts'\nimport { sixHex } from './sixHex.ts'\nimport { addAttributes } from './addAttributes.ts'\nimport { filters } from './filters/index.ts'\nimport { base } from './base.ts'\nimport { entities } from './entities.ts'\nimport { urlQuery } from './urlQuery.ts'\nimport { purgeCSS } from './purgeCSS.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Six-digit HEX\n * 8. Add attributes\n * 9. Filters\n * 10. Base URL\n * 11. URL query\n * 12. Purge CSS (serializes/parses internally around email-comb)\n * 13. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 14. Replace strings\n * 15. Prettify\n * 16. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n doctype?: string,\n): Promise<string> {\n // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLink(dom, filePath)\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, config, filePath)\n\n // 2. Safe class names\n dom = safeClassNames(dom, config.css)\n\n // 3. Attribute to style\n dom = attributeToStyle(dom, config.css)\n\n // 4. CSS inliner (serializes/parses internally around juice)\n dom = inlineCSS(dom, config.css)\n\n // 4.5. Resolve MSO width placeholders from inlined max-width/width\n dom = msoWidthFromClass(dom)\n\n // 4.6. Resolve Column min-width placeholders from nearest sized ancestor\n dom = columnWidth(dom)\n\n // 5. Remove attributes\n dom = removeAttributes(dom, config.html?.attributes)\n\n // 6. Shorthand CSS\n dom = shorthandCSS(dom, config.css)\n\n // 7. Six-digit HEX\n dom = sixHex(dom, config.css)\n\n // 8. Add attributes\n dom = addAttributes(dom, config.html?.attributes)\n\n // 9. Filters\n dom = filters(dom, config.filters)\n\n // 10. Base URL (serializes/parses internally for VML/MSO regex passes)\n dom = base(dom, config.url)\n\n // 11. URL query\n dom = urlQuery(dom, config.url)\n\n // 12. Purge CSS (serializes/parses internally around email-comb)\n dom = purgeCSS(dom, config.css)\n\n // 13. Entities\n dom = entities(dom, config.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n const isXhtml = doctype ? /xhtml/i.test(doctype) : false\n let result = serialize(dom, { selfClosingTags: isXhtml })\n\n // Remove Vue-generated comments after serializing\n result = result\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n .replaceAll('<!--teleport start anchor-->', '')\n .replaceAll('<!--teleport anchor-->', '')\n .replaceAll('<!--teleport start-->', '')\n .replaceAll('<!--teleport end-->', '')\n\n // 14. Replace strings\n result = replaceStrings(result, config)\n\n // 15. Format\n result = await format(result, config)\n\n // 16. Minify\n result = minify(result, config)\n\n // Strip self-closing slashes for HTML5 doctypes\n if (!isXhtml) {\n result = result.replace(/ \\/>/g, '>')\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,eAAsB,gBACpB,MACA,QACA,UACA,SACiB;CAEjB,IAAI,MAAM,MAAM,KAAK;AAGrB,OAAM,MAAM,WAAW,KAAK,SAAS;AAGrC,OAAM,MAAM,YAAY,KAAK,QAAQ,SAAS;AAG9C,OAAM,eAAe,KAAK,OAAO,IAAI;AAGrC,OAAM,iBAAiB,KAAK,OAAO,IAAI;AAGvC,OAAM,UAAU,KAAK,OAAO,IAAI;AAGhC,OAAM,kBAAkB,IAAI;AAG5B,OAAM,YAAY,IAAI;AAGtB,OAAM,iBAAiB,KAAK,OAAO,MAAM,WAAW;AAGpD,OAAM,aAAa,KAAK,OAAO,IAAI;AAGnC,OAAM,OAAO,KAAK,OAAO,IAAI;AAG7B,OAAM,cAAc,KAAK,OAAO,MAAM,WAAW;AAGjD,OAAM,QAAQ,KAAK,OAAO,QAAQ;AAGlC,OAAM,KAAK,KAAK,OAAO,IAAI;AAG3B,OAAM,SAAS,KAAK,OAAO,IAAI;AAG/B,OAAM,SAAS,KAAK,OAAO,IAAI;AAG/B,OAAM,SAAS,KAAK,OAAO,MAAM,eAAe;CAGhD,MAAM,UAAU,UAAU,SAAS,KAAK,QAAQ,GAAG;CACnD,IAAI,SAAS,UAAU,KAAK,EAAE,iBAAiB,SAAS,CAAC;AAGzD,UAAS,OACN,WAAW,YAAY,GAAG,CAC1B,WAAW,YAAY,GAAG,CAC1B,WAAW,gCAAgC,GAAG,CAC9C,WAAW,0BAA0B,GAAG,CACxC,WAAW,yBAAyB,GAAG,CACvC,WAAW,uBAAuB,GAAG;AAGxC,UAAS,eAAe,QAAQ,OAAO;AAGvC,UAAS,MAAM,OAAO,QAAQ,OAAO;AAGrC,UAAS,OAAO,QAAQ,OAAO;AAG/B,KAAI,CAAC,QACH,UAAS,OAAO,QAAQ,SAAS,IAAI;AAGvC,QAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLink } from './inlineLink.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeClassNames } from './safeClassNames.ts'\nimport { attributeToStyle } from './attributeToStyle.ts'\nimport { inlineCSS } from './inlineCSS.ts'\nimport { msoWidthFromClass } from './msoWidthFromClass.ts'\nimport { columnWidth } from './columnWidth.ts'\nimport { removeAttributes } from './removeAttributes.ts'\nimport { shorthandCSS } from './shorthandCSS.ts'\nimport { sixHex } from './sixHex.ts'\nimport { addAttributes } from './addAttributes.ts'\nimport { filters } from './filters/index.ts'\nimport { base } from './base.ts'\nimport { entities } from './entities.ts'\nimport { urlQuery } from './urlQuery.ts'\nimport { purgeCSS } from './purgeCSS.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Six-digit HEX\n * 8. Add attributes\n * 9. Filters\n * 10. Base URL\n * 11. URL query\n * 12. Purge CSS (serializes/parses internally around email-comb)\n * 13. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 14. Replace strings\n * 15. Prettify\n * 16. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n doctype?: string,\n): Promise<string> {\n // Strip Vue SSR fragment markers before parsing. They contain `-->`, which\n // prematurely terminates conditional comments like `<!--[if mso]>...<![endif]-->`\n // when htmlparser2 reads them, swallowing real markup into comment data.\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 // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLink(dom, filePath)\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, config, filePath)\n\n // 2. Safe class names\n dom = safeClassNames(dom, config.css)\n\n // 3. Attribute to style\n dom = attributeToStyle(dom, config.css)\n\n // 4. CSS inliner (serializes/parses internally around juice)\n dom = inlineCSS(dom, config.css)\n\n // 4.5. Resolve MSO width placeholders from inlined max-width/width\n dom = msoWidthFromClass(dom)\n\n // 4.6. Resolve Column min-width placeholders from nearest sized ancestor\n dom = columnWidth(dom)\n\n // 5. Remove attributes\n dom = removeAttributes(dom, config.html?.attributes)\n\n // 6. Shorthand CSS\n dom = shorthandCSS(dom, config.css)\n\n // 7. Six-digit HEX\n dom = sixHex(dom, config.css)\n\n // 8. Add attributes\n dom = addAttributes(dom, config.html?.attributes)\n\n // 9. Filters\n dom = filters(dom, config.filters)\n\n // 10. Base URL (serializes/parses internally for VML/MSO regex passes)\n dom = base(dom, config.url)\n\n // 11. URL query\n dom = urlQuery(dom, config.url)\n\n // 12. Purge CSS (serializes/parses internally around email-comb)\n dom = purgeCSS(dom, config.css)\n\n // 13. Entities\n dom = entities(dom, config.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n const isXhtml = doctype ? /xhtml/i.test(doctype) : false\n let result = serialize(dom, { selfClosingTags: isXhtml })\n\n // 14. Replace strings\n result = replaceStrings(result, config)\n\n // 15. Format\n result = await format(result, config)\n\n // 16. Minify\n result = minify(result, config)\n\n // Strip self-closing slashes for HTML5 doctypes\n if (!isXhtml) {\n result = result.replace(/ \\/>/g, '>')\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,eAAsB,gBACpB,MACA,QACA,UACA,SACiB;AAIjB,QAAO,KACJ,WAAW,YAAY,GAAG,CAC1B,WAAW,YAAY,GAAG,CAC1B,WAAW,gCAAgC,GAAG,CAC9C,WAAW,0BAA0B,GAAG,CACxC,WAAW,yBAAyB,GAAG,CACvC,WAAW,uBAAuB,GAAG;CAGxC,IAAI,MAAM,MAAM,KAAK;AAGrB,OAAM,MAAM,WAAW,KAAK,SAAS;AAGrC,OAAM,MAAM,YAAY,KAAK,QAAQ,SAAS;AAG9C,OAAM,eAAe,KAAK,OAAO,IAAI;AAGrC,OAAM,iBAAiB,KAAK,OAAO,IAAI;AAGvC,OAAM,UAAU,KAAK,OAAO,IAAI;AAGhC,OAAM,kBAAkB,IAAI;AAG5B,OAAM,YAAY,IAAI;AAGtB,OAAM,iBAAiB,KAAK,OAAO,MAAM,WAAW;AAGpD,OAAM,aAAa,KAAK,OAAO,IAAI;AAGnC,OAAM,OAAO,KAAK,OAAO,IAAI;AAG7B,OAAM,cAAc,KAAK,OAAO,MAAM,WAAW;AAGjD,OAAM,QAAQ,KAAK,OAAO,QAAQ;AAGlC,OAAM,KAAK,KAAK,OAAO,IAAI;AAG3B,OAAM,SAAS,KAAK,OAAO,IAAI;AAG/B,OAAM,SAAS,KAAK,OAAO,IAAI;AAG/B,OAAM,SAAS,KAAK,OAAO,MAAM,eAAe;CAGhD,MAAM,UAAU,UAAU,SAAS,KAAK,QAAQ,GAAG;CACnD,IAAI,SAAS,UAAU,KAAK,EAAE,iBAAiB,SAAS,CAAC;AAGzD,UAAS,eAAe,QAAQ,OAAO;AAGvC,UAAS,MAAM,OAAO,QAAQ,OAAO;AAGrC,UAAS,OAAO,QAAQ,OAAO;AAG/B,KAAI,CAAC,QACH,UAAS,OAAO,QAAQ,SAAS,IAAI;AAGvC,QAAO"}
@@ -3,7 +3,7 @@ import color from "picocolors";
3
3
  import * as p from "@clack/prompts";
4
4
  import { rm } from "node:fs/promises";
5
5
  import { existsSync } from "node:fs";
6
- import { execFileSync } from "node:child_process";
6
+ import { execSync } from "node:child_process";
7
7
  import { installDependencies } from "nypm";
8
8
  //#region src/commands/new.ts
9
9
  const starters = [
@@ -210,7 +210,7 @@ async function newProject(starterArg, dirArg, options = {}) {
210
210
  message: "Install dependencies?",
211
211
  initialValue: true
212
212
  }),
213
- pm: async () => "npm"
213
+ pm: async () => options.pm || "npm"
214
214
  }, { onCancel: () => {
215
215
  p.cancel("💀");
216
216
  process.exit(0);
@@ -228,7 +228,7 @@ async function newProject(starterArg, dirArg, options = {}) {
228
228
  spinner.stop(`Created project in ${project.path}`);
229
229
  if (project.install) {
230
230
  try {
231
- execFileSync(project.pm, ["--version"], { stdio: "ignore" });
231
+ execSync(`${project.pm} --version`, { stdio: "ignore" });
232
232
  } catch {
233
233
  p.log.error(`${project.pm} is not installed. Please install it first.`);
234
234
  process.exit(1);
@@ -2,6 +2,7 @@
2
2
  interface Framework {
3
3
  serve: (options?: any) => Promise<any>;
4
4
  build: (options?: any) => Promise<any>;
5
+ prepare: (options?: any) => Promise<any>;
5
6
  }
6
7
  declare function bootstrap(framework?: Framework): Promise<void>;
7
8
  //#endregion
@@ -22,6 +22,9 @@ async function bootstrap(framework) {
22
22
  output: options.output
23
23
  });
24
24
  });
25
+ program.command("prepare").description("Generate IDE type definitions in .maizzle/").option("-c, --config <path>", "Path to maizzle config file").action(async (options) => {
26
+ await framework.prepare({ config: options.config });
27
+ });
25
28
  }
26
29
  program.command("new [starter] [directory]").description("Create a new Maizzle project").option("-i, --install", "Install dependencies").option("--pm <manager>", "Package manager to use").action(async (starter, directory, options) => {
27
30
  await newProject(starter, directory, options);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maizzle",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool for the Maizzle Email Framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,7 +19,8 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "build": "tsdown",
22
- "prepublishOnly": "npm run build",
22
+ "typecheck": "tsc --noEmit",
23
+ "prepublishOnly": "npm run typecheck && npm run build",
23
24
  "dev": "vitest",
24
25
  "test": "vitest run --coverage",
25
26
  "release": "npm run build && npx np"
@@ -8,7 +8,7 @@ import { existsSync } from "node:fs";
8
8
  import { readFile } from "node:fs/promises";
9
9
  import { join as join$1 } from "node:path";
10
10
  var name = "nypm";
11
- var version = "0.6.4";
11
+ var version = "0.6.5";
12
12
  var description = "Unified Package Manager for Node.js";
13
13
  const packageManagers = [
14
14
  {
@@ -86,11 +86,32 @@ async function findup(cwd, match, options = {}) {
86
86
  segments.pop();
87
87
  }
88
88
  }
89
- async function readPackageJSON(cwd) {
89
+ async function readPackageJSON(cwd, options = {}) {
90
90
  return findup(cwd, (p) => {
91
91
  const pkgPath = join$1(p, "package.json");
92
92
  if (existsSync(pkgPath)) return readFile(pkgPath, "utf8").then((data) => JSON.parse(data));
93
- });
93
+ }, options);
94
+ }
95
+ async function readInstalledPackageJSON(pkgName, cwd) {
96
+ const pkgJSONPath = await findup(cwd, (p) => {
97
+ const candidate = join$1(p, "node_modules", pkgName, "package.json");
98
+ if (existsSync(candidate)) return candidate;
99
+ }, { includeParentDirs: true });
100
+ if (!pkgJSONPath) return null;
101
+ try {
102
+ return JSON.parse(await readFile(pkgJSONPath, "utf8"));
103
+ } catch {
104
+ return null;
105
+ }
106
+ }
107
+ async function readPackageJSONFromResolver(requireFn, pkgName) {
108
+ let resolved;
109
+ try {
110
+ resolved = requireFn.resolve(pkgName);
111
+ } catch {
112
+ return null;
113
+ }
114
+ return readPackageJSON(resolved, { includeParentDirs: true });
94
115
  }
95
116
  function cached(fn) {
96
117
  let v;
@@ -222,8 +243,10 @@ async function addDependency(name, options = {}) {
222
243
  const _require = createRequire(join$1(resolvedOptions.cwd, "/_.js"));
223
244
  for (const _name of names) {
224
245
  const pkgName = _name.match(/^(.[^@]+)/)?.[0];
225
- const pkg = await readPackageJSON(_require.resolve(pkgName));
226
- if (!pkg?.peerDependencies || pkg?.name !== pkgName) continue;
246
+ if (!pkgName) continue;
247
+ let pkg = await readPackageJSONFromResolver(_require, pkgName);
248
+ if (pkg?.name !== pkgName) pkg = await readInstalledPackageJSON(pkgName, resolvedOptions.cwd);
249
+ if (!pkg?.peerDependencies) continue;
227
250
  for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
228
251
  if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) continue;
229
252
  if (existingPkg?.dependencies?.[peerDependency] || existingPkg?.devDependencies?.[peerDependency]) continue;
@@ -1,4 +1,3 @@
1
- //#region src/types.d.ts
2
1
  type PackageManagerName = "npm" | "yarn" | "pnpm" | "bun" | "deno";
3
2
  type PackageManager = {
4
3
  name: PackageManagerName;
@@ -27,8 +26,6 @@ type OperationResult = {
27
26
  args: string[];
28
27
  };
29
28
  };
30
- //#endregion
31
- //#region src/package-manager.d.ts
32
29
  type DetectPackageManagerOptions = {
33
30
  /**
34
31
  * Whether to ignore the lock file
@@ -64,8 +61,6 @@ declare const packageManagers: PackageManager[];
64
61
  declare function detectPackageManager(cwd: string, options?: DetectPackageManagerOptions): Promise<(PackageManager & {
65
62
  warnings?: string[];
66
63
  }) | undefined>;
67
- //#endregion
68
- //#region src/api.d.ts
69
64
  /**
70
65
  * Installs project dependencies.
71
66
  *
@@ -172,8 +167,6 @@ declare function dlx(name: string, options?: Pick<OperationOptions, "cwd" | "env
172
167
  short?: boolean;
173
168
  packages?: string[];
174
169
  }): Promise<OperationResult>;
175
- //#endregion
176
- //#region src/cmd.d.ts
177
170
  /**
178
171
  * Get the command to install dependencies with the package manager.
179
172
  */
@@ -205,5 +198,4 @@ declare function dlxCommand(packageManager: PackageManagerName, name: string, op
205
198
  short?: boolean;
206
199
  packages?: string[];
207
200
  }): string;
208
- //#endregion
209
201
  export { DetectPackageManagerOptions, OperationOptions, OperationResult, PackageManager, PackageManagerName, addDependency, addDependencyCommand, addDevDependency, dedupeDependencies, detectPackageManager, dlx, dlxCommand, ensureDependencyInstalled, installDependencies, installDependenciesCommand, packageManagers, removeDependency, runScript, runScriptCommand };
@@ -13,11 +13,32 @@ async function findup(cwd, match, options = {}) {
13
13
  segments.pop();
14
14
  }
15
15
  }
16
- async function readPackageJSON(cwd) {
16
+ async function readPackageJSON(cwd, options = {}) {
17
17
  return findup(cwd, (p) => {
18
18
  const pkgPath = join$1(p, "package.json");
19
19
  if (existsSync(pkgPath)) return readFile(pkgPath, "utf8").then((data) => JSON.parse(data));
20
- });
20
+ }, options);
21
+ }
22
+ async function readInstalledPackageJSON(pkgName, cwd) {
23
+ const pkgJSONPath = await findup(cwd, (p) => {
24
+ const candidate = join$1(p, "node_modules", pkgName, "package.json");
25
+ if (existsSync(candidate)) return candidate;
26
+ }, { includeParentDirs: true });
27
+ if (!pkgJSONPath) return null;
28
+ try {
29
+ return JSON.parse(await readFile(pkgJSONPath, "utf8"));
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+ async function readPackageJSONFromResolver(requireFn, pkgName) {
35
+ let resolved;
36
+ try {
37
+ resolved = requireFn.resolve(pkgName);
38
+ } catch {
39
+ return null;
40
+ }
41
+ return readPackageJSON(resolved, { includeParentDirs: true });
21
42
  }
22
43
  function cached(fn) {
23
44
  let v;
@@ -307,8 +328,10 @@ async function addDependency(name, options = {}) {
307
328
  const _require = createRequire(join$1(resolvedOptions.cwd, "/_.js"));
308
329
  for (const _name of names) {
309
330
  const pkgName = _name.match(/^(.[^@]+)/)?.[0];
310
- const pkg = await readPackageJSON(_require.resolve(pkgName));
311
- if (!pkg?.peerDependencies || pkg?.name !== pkgName) continue;
331
+ if (!pkgName) continue;
332
+ let pkg = await readPackageJSONFromResolver(_require, pkgName);
333
+ if (pkg?.name !== pkgName) pkg = await readInstalledPackageJSON(pkgName, resolvedOptions.cwd);
334
+ if (!pkg?.peerDependencies) continue;
312
335
  for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
313
336
  if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) continue;
314
337
  if (existingPkg?.dependencies?.[peerDependency] || existingPkg?.devDependencies?.[peerDependency]) continue;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nypm",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "Unified Package Manager for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "unjs/nypm",
@@ -18,25 +18,25 @@
18
18
  ".": "./dist/index.mjs"
19
19
  },
20
20
  "dependencies": {
21
- "citty": "^0.2.0",
21
+ "citty": "^0.2.2",
22
22
  "pathe": "^2.0.3",
23
- "tinyexec": "^1.0.2"
23
+ "tinyexec": "^1.1.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "^25.2.1",
27
- "@typescript/native-preview": "^7.0.0-dev.20260205.1",
28
- "@vitest/coverage-v8": "^4.0.18",
26
+ "@types/node": "^25.6.0",
27
+ "@typescript/native-preview": "^7.0.0-dev.20260424.1",
28
+ "@vitest/coverage-v8": "^4.1.5",
29
29
  "automd": "^0.4.3",
30
30
  "changelogen": "^0.6.2",
31
31
  "eslint-config-unjs": "^0.6.2",
32
- "obuild": "^0.4.22",
33
- "oxfmt": "^0.28.0",
34
- "oxlint": "^1.43.0",
32
+ "obuild": "^0.4.33",
33
+ "oxfmt": "^0.46.0",
34
+ "oxlint": "^1.61.0",
35
35
  "pkg-types": "^2.3.0",
36
- "std-env": "^3.10.0",
37
- "typescript": "^5.9.3",
36
+ "std-env": "^4.1.0",
37
+ "typescript": "^6.0.3",
38
38
  "ufo": "^1.6.3",
39
- "vitest": "^4.0.18"
39
+ "vitest": "^4.1.5"
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=18"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "6.0.0-rc.14",
3
+ "version": "6.0.0-rc.15",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "type": "module",