@maizzle/framework 6.0.0-rc.14 → 6.0.0-rc.16
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/README.md +3 -3
- package/dist/components/Body.vue +9 -2
- package/dist/components/Button.vue +13 -8
- package/dist/components/Column.vue +22 -8
- package/dist/components/Container.vue +9 -5
- package/dist/components/Head.vue +1 -1
- package/dist/components/Html.vue +7 -2
- package/dist/components/Layout.vue +45 -15
- package/dist/components/Outlook.vue +38 -11
- package/dist/components/Overlap.vue +8 -3
- package/dist/components/Raw.vue +28 -0
- package/dist/components/Row.vue +72 -11
- package/dist/components/Section.vue +9 -5
- package/dist/components/Spacer.vue +9 -4
- package/dist/components/utils.d.mts +11 -1
- package/dist/components/utils.d.mts.map +1 -1
- package/dist/components/utils.mjs +11 -1
- package/dist/components/utils.mjs.map +1 -1
- package/dist/components/utils.ts +12 -0
- package/dist/composables/useOutlookFallback.d.mts +21 -0
- package/dist/composables/useOutlookFallback.d.mts.map +1 -0
- package/dist/composables/useOutlookFallback.mjs +30 -0
- package/dist/composables/useOutlookFallback.mjs.map +1 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- package/dist/prepare.d.mts +17 -0
- package/dist/prepare.d.mts.map +1 -0
- package/dist/prepare.mjs +44 -0
- package/dist/prepare.mjs.map +1 -0
- package/dist/render/createRenderer.d.mts.map +1 -1
- package/dist/render/createRenderer.mjs +9 -75
- package/dist/render/createRenderer.mjs.map +1 -1
- package/dist/render/plugins/codeBlockExtract.d.mts +14 -0
- package/dist/render/plugins/codeBlockExtract.d.mts.map +1 -0
- package/dist/render/plugins/codeBlockExtract.mjs +34 -0
- package/dist/render/plugins/codeBlockExtract.mjs.map +1 -0
- package/dist/render/plugins/markdownExtract.d.mts +12 -0
- package/dist/render/plugins/markdownExtract.d.mts.map +1 -0
- package/dist/render/plugins/markdownExtract.mjs +50 -0
- package/dist/render/plugins/markdownExtract.mjs.map +1 -0
- package/dist/render/plugins/rawExtract.d.mts +14 -0
- package/dist/render/plugins/rawExtract.d.mts.map +1 -0
- package/dist/render/plugins/rawExtract.mjs +34 -0
- package/dist/render/plugins/rawExtract.mjs.map +1 -0
- package/dist/render/plugins/rowSourceLocation.d.mts +18 -0
- package/dist/render/plugins/rowSourceLocation.d.mts.map +1 -0
- package/dist/render/plugins/rowSourceLocation.mjs +45 -0
- package/dist/render/plugins/rowSourceLocation.mjs.map +1 -0
- package/dist/server/ui/App.vue +47 -2
- package/dist/server/ui/pages/Preview.vue +32 -3
- package/dist/transformers/columnWidth.d.mts +9 -9
- package/dist/transformers/columnWidth.d.mts.map +1 -1
- package/dist/transformers/columnWidth.mjs +422 -41
- package/dist/transformers/columnWidth.mjs.map +1 -1
- package/dist/transformers/filters/index.mjs +1 -1
- package/dist/transformers/filters/index.mjs.map +1 -1
- package/dist/transformers/index.mjs +1 -1
- package/dist/transformers/index.mjs.map +1 -1
- package/node_modules/maizzle/dist/commands/new.mjs +3 -3
- package/node_modules/maizzle/dist/index.d.mts +1 -0
- package/node_modules/maizzle/dist/index.mjs +3 -0
- package/node_modules/maizzle/package.json +3 -2
- package/node_modules/nypm/dist/cli.mjs +28 -5
- package/node_modules/nypm/dist/index.d.mts +0 -8
- package/node_modules/nypm/dist/index.mjs +27 -4
- package/node_modules/nypm/package.json +12 -12
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, createStaticVNode, useAttrs } from 'vue'
|
|
3
|
-
import { hasWidthInStyle, hasWidthUtility, nextId, normalizeToPixels } from './utils.ts'
|
|
3
|
+
import { hasWidthInStyle, hasWidthUtility, nextId, normalizeToPixels, outlookFallbackProp } from './utils.ts'
|
|
4
|
+
import { useOutlookFallback } from '../composables/useOutlookFallback'
|
|
4
5
|
|
|
5
6
|
defineOptions({ inheritAttrs: false })
|
|
6
7
|
|
|
@@ -31,9 +32,12 @@ const props = defineProps({
|
|
|
31
32
|
msoStyle: {
|
|
32
33
|
type: String,
|
|
33
34
|
default: undefined
|
|
34
|
-
}
|
|
35
|
+
},
|
|
36
|
+
outlookFallback: outlookFallbackProp,
|
|
35
37
|
})
|
|
36
38
|
|
|
39
|
+
const outlookFallback = useOutlookFallback(props.outlookFallback)
|
|
40
|
+
|
|
37
41
|
const userStyle = computed(() => {
|
|
38
42
|
const s = attrs.style
|
|
39
43
|
if (!s) return ''
|
|
@@ -47,7 +51,7 @@ const userHasWidth = computed(() => {
|
|
|
47
51
|
return hasWidthUtility(cls) || hasWidthInStyle(userStyle.value)
|
|
48
52
|
})
|
|
49
53
|
|
|
50
|
-
const useMarker = props.width == null && userHasWidth.value
|
|
54
|
+
const useMarker = outlookFallback && props.width == null && userHasWidth.value
|
|
51
55
|
const msoId = useMarker ? nextId('s') : null
|
|
52
56
|
|
|
53
57
|
const divStyle = computed(() => {
|
|
@@ -96,7 +100,7 @@ const MsoAfter = () => createStaticVNode(
|
|
|
96
100
|
</script>
|
|
97
101
|
|
|
98
102
|
<template>
|
|
99
|
-
<MsoBefore />
|
|
103
|
+
<MsoBefore v-if="outlookFallback" />
|
|
100
104
|
<div
|
|
101
105
|
v-bind="restAttrs"
|
|
102
106
|
:style="divStyle"
|
|
@@ -106,5 +110,5 @@ const MsoAfter = () => createStaticVNode(
|
|
|
106
110
|
>
|
|
107
111
|
<slot />
|
|
108
112
|
</div>
|
|
109
|
-
<MsoAfter />
|
|
113
|
+
<MsoAfter v-if="outlookFallback" />
|
|
110
114
|
</template>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
import { normalizeToPixels } from './utils.ts'
|
|
3
|
+
import { normalizeToPixels, outlookFallbackProp } from './utils.ts'
|
|
4
|
+
import { useOutlookFallback } from '../composables/useOutlookFallback'
|
|
4
5
|
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
/** The type of spacer. */
|
|
@@ -22,9 +23,12 @@ const props = defineProps({
|
|
|
22
23
|
msoHeight: {
|
|
23
24
|
type: [String, Number],
|
|
24
25
|
default: null
|
|
25
|
-
}
|
|
26
|
+
},
|
|
27
|
+
outlookFallback: outlookFallbackProp,
|
|
26
28
|
})
|
|
27
29
|
|
|
30
|
+
const outlookFallback = useOutlookFallback(props.outlookFallback)
|
|
31
|
+
|
|
28
32
|
function parsePixelValue(value: string | number): number {
|
|
29
33
|
if (typeof value === 'number') return value
|
|
30
34
|
return Number.parseFloat(value) || 0
|
|
@@ -37,7 +41,7 @@ const verticalStyles = computed(() => {
|
|
|
37
41
|
s.push(`line-height: ${normalizeToPixels(props.height)};`)
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
if (props.msoHeight) {
|
|
44
|
+
if (outlookFallback && props.msoHeight) {
|
|
41
45
|
s.push(`mso-line-height-alt: ${normalizeToPixels(props.msoHeight)};`)
|
|
42
46
|
}
|
|
43
47
|
|
|
@@ -45,7 +49,8 @@ const verticalStyles = computed(() => {
|
|
|
45
49
|
})
|
|
46
50
|
|
|
47
51
|
const horizontalStyles = computed(() => {
|
|
48
|
-
|
|
52
|
+
const mso = outlookFallback ? msoFontWidth.value : ''
|
|
53
|
+
return `display:inline-block; width: ${normalizeToPixels(props.width)}; font-size: 16px;${mso}`
|
|
49
54
|
})
|
|
50
55
|
|
|
51
56
|
const msoFontWidth = computed(() => {
|
|
@@ -13,6 +13,16 @@ declare function hasWidthUtility(classStr: string): boolean;
|
|
|
13
13
|
declare function hasWidthInStyle(styleStr: string): boolean;
|
|
14
14
|
declare function hasHeightUtility(classStr: string): boolean;
|
|
15
15
|
declare function hasHeightInStyle(styleStr: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Shared prop for components that emit MSO/VML fallback markup. The
|
|
18
|
+
* `null` default acts as the "unset" sentinel — `useOutlookFallback`
|
|
19
|
+
* treats `null` as inherit-from-ancestor (root default `true`),
|
|
20
|
+
* letting users override per-component without losing inheritance.
|
|
21
|
+
*/
|
|
22
|
+
declare const outlookFallbackProp: {
|
|
23
|
+
readonly type: BooleanConstructor;
|
|
24
|
+
readonly default: null;
|
|
25
|
+
};
|
|
16
26
|
//#endregion
|
|
17
|
-
export { hasHeightInStyle, hasHeightUtility, hasWidthInStyle, hasWidthUtility, nextId, normalizeToPixels };
|
|
27
|
+
export { hasHeightInStyle, hasHeightUtility, hasWidthInStyle, hasWidthUtility, nextId, normalizeToPixels, outlookFallbackProp };
|
|
18
28
|
//# sourceMappingURL=utils.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/components/utils.ts"],"mappings":";iBAAgB,iBAAA,CAAkB,KAAA;AAAlC;;;;;AAiBA;;;AAjBA,iBAiBgB,MAAA,CAAO,MAAA;AAAA,iBAKP,eAAA,CAAgB,QAAA;AAAA,iBAQhB,eAAA,CAAgB,QAAA;AAAA,iBAIhB,gBAAA,CAAiB,QAAA;AAAA,iBAQjB,gBAAA,CAAiB,QAAA"}
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/components/utils.ts"],"mappings":";iBAAgB,iBAAA,CAAkB,KAAA;AAAlC;;;;;AAiBA;;;AAjBA,iBAiBgB,MAAA,CAAO,MAAA;AAAA,iBAKP,eAAA,CAAgB,QAAA;AAAA,iBAQhB,eAAA,CAAgB,QAAA;AAAA,iBAIhB,gBAAA,CAAiB,QAAA;AAAA,iBAQjB,gBAAA,CAAiB,QAAA;;;AAZjC;;;;cAsBa,mBAAA;EAAA,eAGH,kBAAA;EAAA"}
|
|
@@ -34,7 +34,17 @@ function hasHeightUtility(classStr) {
|
|
|
34
34
|
function hasHeightInStyle(styleStr) {
|
|
35
35
|
return /(?:^|;\s*)(?:max-height|height)\s*:/i.test(styleStr);
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Shared prop for components that emit MSO/VML fallback markup. The
|
|
39
|
+
* `null` default acts as the "unset" sentinel — `useOutlookFallback`
|
|
40
|
+
* treats `null` as inherit-from-ancestor (root default `true`),
|
|
41
|
+
* letting users override per-component without losing inheritance.
|
|
42
|
+
*/
|
|
43
|
+
const outlookFallbackProp = {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: null
|
|
46
|
+
};
|
|
37
47
|
|
|
38
48
|
//#endregion
|
|
39
|
-
export { hasHeightInStyle, hasHeightUtility, hasWidthInStyle, hasWidthUtility, nextId, normalizeToPixels };
|
|
49
|
+
export { hasHeightInStyle, hasHeightUtility, hasWidthInStyle, hasWidthUtility, nextId, normalizeToPixels, outlookFallbackProp };
|
|
40
50
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/components/utils.ts"],"sourcesContent":["export function normalizeToPixels(value: string | number): string {\n if (typeof value === 'number' || Number.isFinite(Number(value))) {\n return `${value}px`\n }\n return value\n}\n\nconst counters: Record<string, number> = {}\n\n/**\n * Module-scoped sequential ID generator. Used by components to mint\n * unique marker ids (e.g. `c1`, `c2`) for the post-render transformer.\n *\n * Must live here (not inside `<script setup>`) because Vue compiles\n * `<script setup>` into the component's `setup()` function — any\n * `let counter = 0` there resets per instance, causing id collisions.\n */\nexport function nextId(prefix: string): string {\n counters[prefix] = (counters[prefix] ?? 0) + 1\n return `${prefix}${counters[prefix]}`\n}\n\nexport function hasWidthUtility(classStr: string): boolean {\n return classStr.split(/\\s+/).some((c) => {\n const utility = c.split(':').pop() ?? ''\n const clean = utility.replace(/^!/, '')\n return /^(w-|max-w-|min-w-)/.test(clean)\n })\n}\n\nexport function hasWidthInStyle(styleStr: string): boolean {\n return /(?:^|;\\s*)(?:max-width|width)\\s*:/i.test(styleStr)\n}\n\nexport function hasHeightUtility(classStr: string): boolean {\n return classStr.split(/\\s+/).some((c) => {\n const utility = c.split(':').pop() ?? ''\n const clean = utility.replace(/^!/, '')\n return /^(h-|max-h-|min-h-)/.test(clean)\n })\n}\n\nexport function hasHeightInStyle(styleStr: string): boolean {\n return /(?:^|;\\s*)(?:max-height|height)\\s*:/i.test(styleStr)\n}\n"],"mappings":";AAAA,SAAgB,kBAAkB,OAAgC;AAChE,KAAI,OAAO,UAAU,YAAY,OAAO,SAAS,OAAO,MAAM,CAAC,CAC7D,QAAO,GAAG,MAAM;AAElB,QAAO;;AAGT,MAAM,WAAmC,EAAE;;;;;;;;;AAU3C,SAAgB,OAAO,QAAwB;AAC7C,UAAS,WAAW,SAAS,WAAW,KAAK;AAC7C,QAAO,GAAG,SAAS,SAAS;;AAG9B,SAAgB,gBAAgB,UAA2B;AACzD,QAAO,SAAS,MAAM,MAAM,CAAC,MAAM,MAAM;EAEvC,MAAM,SADU,EAAE,MAAM,IAAI,CAAC,KAAK,IAAI,IAChB,QAAQ,MAAM,GAAG;AACvC,SAAO,sBAAsB,KAAK,MAAM;GACxC;;AAGJ,SAAgB,gBAAgB,UAA2B;AACzD,QAAO,qCAAqC,KAAK,SAAS;;AAG5D,SAAgB,iBAAiB,UAA2B;AAC1D,QAAO,SAAS,MAAM,MAAM,CAAC,MAAM,MAAM;EAEvC,MAAM,SADU,EAAE,MAAM,IAAI,CAAC,KAAK,IAAI,IAChB,QAAQ,MAAM,GAAG;AACvC,SAAO,sBAAsB,KAAK,MAAM;GACxC;;AAGJ,SAAgB,iBAAiB,UAA2B;AAC1D,QAAO,uCAAuC,KAAK,SAAS"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/components/utils.ts"],"sourcesContent":["export function normalizeToPixels(value: string | number): string {\n if (typeof value === 'number' || Number.isFinite(Number(value))) {\n return `${value}px`\n }\n return value\n}\n\nconst counters: Record<string, number> = {}\n\n/**\n * Module-scoped sequential ID generator. Used by components to mint\n * unique marker ids (e.g. `c1`, `c2`) for the post-render transformer.\n *\n * Must live here (not inside `<script setup>`) because Vue compiles\n * `<script setup>` into the component's `setup()` function — any\n * `let counter = 0` there resets per instance, causing id collisions.\n */\nexport function nextId(prefix: string): string {\n counters[prefix] = (counters[prefix] ?? 0) + 1\n return `${prefix}${counters[prefix]}`\n}\n\nexport function hasWidthUtility(classStr: string): boolean {\n return classStr.split(/\\s+/).some((c) => {\n const utility = c.split(':').pop() ?? ''\n const clean = utility.replace(/^!/, '')\n return /^(w-|max-w-|min-w-)/.test(clean)\n })\n}\n\nexport function hasWidthInStyle(styleStr: string): boolean {\n return /(?:^|;\\s*)(?:max-width|width)\\s*:/i.test(styleStr)\n}\n\nexport function hasHeightUtility(classStr: string): boolean {\n return classStr.split(/\\s+/).some((c) => {\n const utility = c.split(':').pop() ?? ''\n const clean = utility.replace(/^!/, '')\n return /^(h-|max-h-|min-h-)/.test(clean)\n })\n}\n\nexport function hasHeightInStyle(styleStr: string): boolean {\n return /(?:^|;\\s*)(?:max-height|height)\\s*:/i.test(styleStr)\n}\n\n/**\n * Shared prop for components that emit MSO/VML fallback markup. The\n * `null` default acts as the \"unset\" sentinel — `useOutlookFallback`\n * treats `null` as inherit-from-ancestor (root default `true`),\n * letting users override per-component without losing inheritance.\n */\nexport const outlookFallbackProp = {\n type: Boolean,\n default: null,\n} as const\n\n"],"mappings":";AAAA,SAAgB,kBAAkB,OAAgC;AAChE,KAAI,OAAO,UAAU,YAAY,OAAO,SAAS,OAAO,MAAM,CAAC,CAC7D,QAAO,GAAG,MAAM;AAElB,QAAO;;AAGT,MAAM,WAAmC,EAAE;;;;;;;;;AAU3C,SAAgB,OAAO,QAAwB;AAC7C,UAAS,WAAW,SAAS,WAAW,KAAK;AAC7C,QAAO,GAAG,SAAS,SAAS;;AAG9B,SAAgB,gBAAgB,UAA2B;AACzD,QAAO,SAAS,MAAM,MAAM,CAAC,MAAM,MAAM;EAEvC,MAAM,SADU,EAAE,MAAM,IAAI,CAAC,KAAK,IAAI,IAChB,QAAQ,MAAM,GAAG;AACvC,SAAO,sBAAsB,KAAK,MAAM;GACxC;;AAGJ,SAAgB,gBAAgB,UAA2B;AACzD,QAAO,qCAAqC,KAAK,SAAS;;AAG5D,SAAgB,iBAAiB,UAA2B;AAC1D,QAAO,SAAS,MAAM,MAAM,CAAC,MAAM,MAAM;EAEvC,MAAM,SADU,EAAE,MAAM,IAAI,CAAC,KAAK,IAAI,IAChB,QAAQ,MAAM,GAAG;AACvC,SAAO,sBAAsB,KAAK,MAAM;GACxC;;AAGJ,SAAgB,iBAAiB,UAA2B;AAC1D,QAAO,uCAAuC,KAAK,SAAS;;;;;;;;AAS9D,MAAa,sBAAsB;CACjC,MAAM;CACN,SAAS;CACV"}
|
package/dist/components/utils.ts
CHANGED
|
@@ -43,3 +43,15 @@ export function hasHeightUtility(classStr: string): boolean {
|
|
|
43
43
|
export function hasHeightInStyle(styleStr: string): boolean {
|
|
44
44
|
return /(?:^|;\s*)(?:max-height|height)\s*:/i.test(styleStr)
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Shared prop for components that emit MSO/VML fallback markup. The
|
|
49
|
+
* `null` default acts as the "unset" sentinel — `useOutlookFallback`
|
|
50
|
+
* treats `null` as inherit-from-ancestor (root default `true`),
|
|
51
|
+
* letting users override per-component without losing inheritance.
|
|
52
|
+
*/
|
|
53
|
+
export const outlookFallbackProp = {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: null,
|
|
56
|
+
} as const
|
|
57
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/composables/useOutlookFallback.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Toggle whether descendants emit Outlook (MSO) and VML fallback markup.
|
|
4
|
+
*
|
|
5
|
+
* Call once in a Layout/template's `<script setup>` to disable for the
|
|
6
|
+
* whole tree:
|
|
7
|
+
* `useOutlookFallback(false)`
|
|
8
|
+
*
|
|
9
|
+
* Components inheriting `false` skip MSO ghost tables, VML rectangles,
|
|
10
|
+
* `xmlns:v`/`xmlns:o`, mso-specific CSS, and Button's `<Outlook>`
|
|
11
|
+
* spacers. Each MSO-aware component still accepts an `outlook-fallback`
|
|
12
|
+
* prop that overrides inheritance for its subtree.
|
|
13
|
+
*
|
|
14
|
+
* @param value Pass `true`/`false` to set; omit to just read the
|
|
15
|
+
* inherited value (defaults to `true` at the root).
|
|
16
|
+
* @returns The resolved boolean for the current component.
|
|
17
|
+
*/
|
|
18
|
+
declare function useOutlookFallback(value?: boolean | null): boolean;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { useOutlookFallback };
|
|
21
|
+
//# sourceMappingURL=useOutlookFallback.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOutlookFallback.d.mts","names":[],"sources":["../../src/composables/useOutlookFallback.ts"],"mappings":";;AAoBA;;;;;;;;;;;;;;;iBAAgB,kBAAA,CAAmB,KAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { inject, provide } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/composables/useOutlookFallback.ts
|
|
4
|
+
const OutlookFallbackKey = Symbol("OutlookFallback");
|
|
5
|
+
/**
|
|
6
|
+
* Toggle whether descendants emit Outlook (MSO) and VML fallback markup.
|
|
7
|
+
*
|
|
8
|
+
* Call once in a Layout/template's `<script setup>` to disable for the
|
|
9
|
+
* whole tree:
|
|
10
|
+
* `useOutlookFallback(false)`
|
|
11
|
+
*
|
|
12
|
+
* Components inheriting `false` skip MSO ghost tables, VML rectangles,
|
|
13
|
+
* `xmlns:v`/`xmlns:o`, mso-specific CSS, and Button's `<Outlook>`
|
|
14
|
+
* spacers. Each MSO-aware component still accepts an `outlook-fallback`
|
|
15
|
+
* prop that overrides inheritance for its subtree.
|
|
16
|
+
*
|
|
17
|
+
* @param value Pass `true`/`false` to set; omit to just read the
|
|
18
|
+
* inherited value (defaults to `true` at the root).
|
|
19
|
+
* @returns The resolved boolean for the current component.
|
|
20
|
+
*/
|
|
21
|
+
function useOutlookFallback(value) {
|
|
22
|
+
const inherited = inject(OutlookFallbackKey, true);
|
|
23
|
+
const enabled = value == null ? inherited : value;
|
|
24
|
+
provide(OutlookFallbackKey, enabled);
|
|
25
|
+
return enabled;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { useOutlookFallback };
|
|
30
|
+
//# sourceMappingURL=useOutlookFallback.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOutlookFallback.mjs","names":[],"sources":["../../src/composables/useOutlookFallback.ts"],"sourcesContent":["import { inject, provide, type InjectionKey } from 'vue'\n\nconst OutlookFallbackKey: InjectionKey<boolean> = Symbol('OutlookFallback')\n\n/**\n * Toggle whether descendants emit Outlook (MSO) and VML fallback markup.\n *\n * Call once in a Layout/template's `<script setup>` to disable for the\n * whole tree:\n * `useOutlookFallback(false)`\n *\n * Components inheriting `false` skip MSO ghost tables, VML rectangles,\n * `xmlns:v`/`xmlns:o`, mso-specific CSS, and Button's `<Outlook>`\n * spacers. Each MSO-aware component still accepts an `outlook-fallback`\n * prop that overrides inheritance for its subtree.\n *\n * @param value Pass `true`/`false` to set; omit to just read the\n * inherited value (defaults to `true` at the root).\n * @returns The resolved boolean for the current component.\n */\nexport function useOutlookFallback(value?: boolean | null): boolean {\n const inherited = inject(OutlookFallbackKey, true)\n const enabled = value == null ? inherited : value\n provide(OutlookFallbackKey, enabled)\n return enabled\n}\n"],"mappings":";;;AAEA,MAAM,qBAA4C,OAAO,kBAAkB;;;;;;;;;;;;;;;;;AAkB3E,SAAgB,mBAAmB,OAAiC;CAClE,MAAM,YAAY,OAAO,oBAAoB,KAAK;CAClD,MAAM,UAAU,SAAS,OAAO,YAAY;AAC5C,SAAQ,oBAAoB,QAAQ;AACpC,QAAO"}
|
package/dist/index.d.mts
CHANGED
|
@@ -6,11 +6,13 @@ import { useConfig } from "./composables/useConfig.mjs";
|
|
|
6
6
|
import { useDoctype } from "./composables/useDoctype.mjs";
|
|
7
7
|
import { useEvent } from "./composables/useEvent.mjs";
|
|
8
8
|
import { useFont } from "./composables/useFont.mjs";
|
|
9
|
+
import { useOutlookFallback } from "./composables/useOutlookFallback.mjs";
|
|
9
10
|
import { resolveConfig } from "./config/index.mjs";
|
|
10
11
|
import { maizzle } from "./plugin.mjs";
|
|
11
12
|
import { CreateRendererOptions, RenderedTemplate, Renderer, createRenderer } from "./render/createRenderer.mjs";
|
|
12
13
|
import { RenderOptions, RenderResult, render } from "./render/index.mjs";
|
|
13
14
|
import { serve } from "./serve.mjs";
|
|
15
|
+
import { PrepareOptions, prepare } from "./prepare.mjs";
|
|
14
16
|
import { createPlaintext } from "./plaintext.mjs";
|
|
15
17
|
import { inlineLink } from "./transformers/inlineLink.mjs";
|
|
16
18
|
import { urlQuery } from "./transformers/urlQuery.mjs";
|
|
@@ -29,4 +31,4 @@ import { replaceStrings } from "./transformers/replaceStrings.mjs";
|
|
|
29
31
|
import { format } from "./transformers/format.mjs";
|
|
30
32
|
import { minify } from "./transformers/minify.mjs";
|
|
31
33
|
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 };
|
|
34
|
+
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, useOutlookFallback, usePlaintext };
|
package/dist/index.mjs
CHANGED
|
@@ -23,10 +23,12 @@ 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";
|
|
30
|
+
import { useOutlookFallback } from "./composables/useOutlookFallback.mjs";
|
|
29
31
|
import { usePlaintext } from "./composables/usePlaintext.mjs";
|
|
30
32
|
import { useHead } from "@unhead/vue";
|
|
31
33
|
|
|
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 };
|
|
34
|
+
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, useOutlookFallback, 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"}
|
package/dist/prepare.mjs
ADDED
|
@@ -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":";;;;;;
|
|
1
|
+
{"version":3,"file":"createRenderer.d.mts","names":[],"sources":["../../src/render/createRenderer.ts"],"mappings":";;;;;;UAgCiB,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,7 +1,11 @@
|
|
|
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 {
|
|
4
|
+
import { rowSourceLocation } from "./plugins/rowSourceLocation.mjs";
|
|
5
|
+
import { rawExtract } from "./plugins/rawExtract.mjs";
|
|
6
|
+
import { codeBlockExtract } from "./plugins/codeBlockExtract.mjs";
|
|
7
|
+
import { markdownExtract } from "./plugins/markdownExtract.mjs";
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
5
9
|
import { dirname, resolve } from "node:path";
|
|
6
10
|
import { fileURLToPath } from "node:url";
|
|
7
11
|
import { defu } from "defu";
|
|
@@ -13,81 +17,10 @@ import AutoImport from "unplugin-auto-import/vite";
|
|
|
13
17
|
import Components from "unplugin-vue-components/vite";
|
|
14
18
|
import { unheadVueComposablesImports } from "@unhead/vue";
|
|
15
19
|
import { renderToString } from "vue/server-renderer";
|
|
16
|
-
import { createHead
|
|
20
|
+
import { createHead } from "@unhead/vue/server";
|
|
17
21
|
|
|
18
22
|
//#region src/render/createRenderer.ts
|
|
19
23
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
|
-
/**
|
|
21
|
-
* Vite plugin that extracts raw slot content from <CodeBlock> tags
|
|
22
|
-
* and passes it as a :code prop before Vue compiles the template.
|
|
23
|
-
*
|
|
24
|
-
* This lets users write HTML naturally inside CodeBlock slots without
|
|
25
|
-
* Vue attempting to compile it as template syntax.
|
|
26
|
-
*/
|
|
27
|
-
function codeBlockExtract() {
|
|
28
|
-
const re = /<(CodeBlock|code-block)((?:\s[^>]*?)?)>([\s\S]*?)<\/\1>/g;
|
|
29
|
-
return {
|
|
30
|
-
name: "maizzle:code-block-extract",
|
|
31
|
-
enforce: "pre",
|
|
32
|
-
transform(code, id) {
|
|
33
|
-
if (!id.endsWith(".vue") && !id.endsWith(".md")) return;
|
|
34
|
-
if (!code.includes("CodeBlock") && !code.includes("code-block")) return;
|
|
35
|
-
const transformed = code.replace(re, (_match, tag, attrs, content) => {
|
|
36
|
-
if (/(?:^|\s):code\b/.test(attrs) || /v-bind:code\b/.test(attrs)) return _match;
|
|
37
|
-
const stripped = content.replace(/^\n+/, "").replace(/\s+$/, "");
|
|
38
|
-
if (!stripped) return _match;
|
|
39
|
-
const minIndent = stripped.match(/^[ \t]*(?=\S)/gm)?.reduce((min, ws) => Math.min(min, ws.length), Infinity) ?? 0;
|
|
40
|
-
return `<${tag}${attrs} code="${(minIndent > 0 ? stripped.replace(new RegExp(`^[ \\t]{${minIndent}}`, "gm"), "") : stripped).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">")}" />`;
|
|
41
|
-
});
|
|
42
|
-
if (transformed !== code) return {
|
|
43
|
-
code: transformed,
|
|
44
|
-
map: null
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Vite plugin that pre-processes <Markdown> tags:
|
|
51
|
-
* - Extracts slot content, dedents it, and passes as :content prop
|
|
52
|
-
* - Resolves `src` prop to read file contents at build time
|
|
53
|
-
*/
|
|
54
|
-
function markdownExtract() {
|
|
55
|
-
const re = /<(Markdown|markdown)((?:\s[^>]*?)?)>([\s\S]*?)<\/\1>/g;
|
|
56
|
-
const selfClosingRe = /<(Markdown|markdown)((?:\s[^>]*?\bsrc\s*=\s*"[^"]*"[^>]*?))\/>/g;
|
|
57
|
-
return {
|
|
58
|
-
name: "maizzle:markdown-extract",
|
|
59
|
-
enforce: "pre",
|
|
60
|
-
transform(code, id) {
|
|
61
|
-
if (!id.endsWith(".vue") && !id.endsWith(".md")) return;
|
|
62
|
-
if (!code.includes("Markdown") && !code.includes("markdown")) return;
|
|
63
|
-
let transformed = code;
|
|
64
|
-
transformed = transformed.replace(re, (_match, tag, attrs, content) => {
|
|
65
|
-
if (/(?:^|\s):content\b/.test(attrs) || /v-bind:content\b/.test(attrs)) return _match;
|
|
66
|
-
const stripped = content.replace(/^\n+/, "").replace(/\s+$/, "");
|
|
67
|
-
if (!stripped) return _match;
|
|
68
|
-
const minIndent = stripped.match(/^[ \t]*(?=\S)/gm)?.reduce((min, ws) => Math.min(min, ws.length), Infinity) ?? 0;
|
|
69
|
-
return `<${tag}${attrs} content="${(minIndent > 0 ? stripped.replace(new RegExp(`^[ \\t]{${minIndent}}`, "gm"), "") : stripped).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">")}" />`;
|
|
70
|
-
});
|
|
71
|
-
transformed = transformed.replace(selfClosingRe, (_match, tag, attrs) => {
|
|
72
|
-
const srcMatch = attrs.match(/\bsrc\s*=\s*"([^"]*)"/);
|
|
73
|
-
if (!srcMatch) return _match;
|
|
74
|
-
const srcPath = srcMatch[1];
|
|
75
|
-
const resolvedPath = resolve(dirname(id), srcPath);
|
|
76
|
-
let fileContent;
|
|
77
|
-
try {
|
|
78
|
-
fileContent = readFileSync(resolvedPath, "utf-8").trim();
|
|
79
|
-
} catch {
|
|
80
|
-
return _match;
|
|
81
|
-
}
|
|
82
|
-
return `<${tag}${attrs.replace(/\s*\bsrc\s*=\s*"[^"]*"/, "")} content="${fileContent.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">")}" />`;
|
|
83
|
-
});
|
|
84
|
-
if (transformed !== code) return {
|
|
85
|
-
code: transformed,
|
|
86
|
-
map: null
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
24
|
const vuePkgDir = dirname(fileURLToPath(import.meta.resolve("vue/package.json")));
|
|
92
25
|
const vueServerRendererPkgDir = dirname(fileURLToPath(import.meta.resolve("@vue/server-renderer/package.json")));
|
|
93
26
|
const unheadVuePkgDir = resolve(dirname(fileURLToPath(import.meta.resolve("@unhead/vue"))), "..");
|
|
@@ -108,8 +41,10 @@ async function createRenderer(options = {}) {
|
|
|
108
41
|
const maizzleConfig = {
|
|
109
42
|
configFile: viteConfigFile ?? false,
|
|
110
43
|
plugins: [
|
|
44
|
+
rawExtract(),
|
|
111
45
|
codeBlockExtract(),
|
|
112
46
|
markdownExtract(),
|
|
47
|
+
rowSourceLocation(),
|
|
113
48
|
{
|
|
114
49
|
name: "maizzle:virtual-sfc",
|
|
115
50
|
resolveId(id) {
|
|
@@ -176,7 +111,6 @@ async function createRenderer(options = {}) {
|
|
|
176
111
|
server: {
|
|
177
112
|
middlewareMode: true,
|
|
178
113
|
hmr: false,
|
|
179
|
-
watch: null,
|
|
180
114
|
fs: { allow: [
|
|
181
115
|
process.cwd(),
|
|
182
116
|
root,
|
|
@@ -230,7 +164,7 @@ async function createRenderer(options = {}) {
|
|
|
230
164
|
app.provide(contextKey, renderContext);
|
|
231
165
|
const ssrContext = {};
|
|
232
166
|
let html = await renderToString(app, ssrContext);
|
|
233
|
-
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } =
|
|
167
|
+
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = head.render();
|
|
234
168
|
if (htmlAttrs) html = html.replace(/<html([^>]*)>/, `<html$1 ${htmlAttrs}>`);
|
|
235
169
|
if (headTags) html = html.replace("</head>", `${headTags}\n</head>`);
|
|
236
170
|
if (bodyAttrs) html = html.replace(/<body([^>]*)>/, `<body$1 ${bodyAttrs}>`);
|
|
@@ -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, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>')\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, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>')\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, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>')\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,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;EACN,SAAS;EACT,UAAU,MAAc,IAA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W,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"}
|
|
1
|
+
{"version":3,"file":"createRenderer.mjs","names":["merge"],"sources":["../../src/render/createRenderer.ts"],"sourcesContent":["import { dirname, resolve } from 'node:path'\nimport { existsSync } 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 } 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}\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 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 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 && !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 } = 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 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\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AO,MAAM,EAAE,CAAC,EAE5E;AACX,YAAK,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,14 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/render/plugins/codeBlockExtract.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vite plugin that extracts raw slot content from <CodeBlock> tags
|
|
6
|
+
* and passes it as a :code prop before Vue compiles the template.
|
|
7
|
+
*
|
|
8
|
+
* This lets users write HTML naturally inside CodeBlock slots without
|
|
9
|
+
* Vue attempting to compile it as template syntax.
|
|
10
|
+
*/
|
|
11
|
+
declare function codeBlockExtract(): Plugin;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { codeBlockExtract };
|
|
14
|
+
//# sourceMappingURL=codeBlockExtract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeBlockExtract.d.mts","names":[],"sources":["../../../src/render/plugins/codeBlockExtract.ts"],"mappings":";;;;;AASA;;;;;iBAAgB,gBAAA,CAAA,GAAoB,MAAA"}
|