@maizzle/framework 6.0.0-rc.20 → 6.0.0-rc.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +53 -43
- package/dist/build.js.map +1 -1
- package/dist/components/Body.vue +1 -1
- package/dist/components/CodeBlock.vue +1 -1
- package/dist/components/CodeInline.vue +72 -2
- package/dist/components/Column.vue +2 -1
- package/dist/components/Container.vue +1 -11
- package/dist/components/Img.vue +199 -4
- package/dist/components/Preheader.vue +33 -5
- package/dist/components/Section.vue +9 -14
- package/dist/components/Text.vue +1 -1
- package/dist/composables/defineConfig.d.ts +3 -4
- package/dist/composables/defineConfig.d.ts.map +1 -1
- package/dist/composables/defineConfig.js +3 -4
- package/dist/composables/defineConfig.js.map +1 -1
- package/dist/composables/renderContext.d.ts +1 -2
- package/dist/composables/renderContext.d.ts.map +1 -1
- package/dist/composables/renderContext.js.map +1 -1
- package/dist/composables/useCurrentTemplate.d.ts +31 -0
- package/dist/composables/useCurrentTemplate.d.ts.map +1 -0
- package/dist/composables/useCurrentTemplate.js +35 -0
- package/dist/composables/useCurrentTemplate.js.map +1 -0
- package/dist/composables/useEvent.d.ts +1 -1
- package/dist/composables/useEvent.js +1 -1
- package/dist/composables/useEvent.js.map +1 -1
- package/dist/composables/usePreheader.d.ts +6 -5
- package/dist/composables/usePreheader.d.ts.map +1 -1
- package/dist/composables/usePreheader.js +3 -3
- package/dist/composables/usePreheader.js.map +1 -1
- package/dist/composables/useTransformers.d.ts +1 -1
- package/dist/composables/useTransformers.js +1 -1
- package/dist/composables/useTransformers.js.map +1 -1
- package/dist/events/index.d.ts +20 -8
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +5 -8
- package/dist/events/index.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/render/createRenderer.js +4 -3
- package/dist/render/createRenderer.js.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +3 -2
- package/dist/serve.js.map +1 -1
- package/dist/transformers/addAttributes.d.ts +18 -8
- package/dist/transformers/addAttributes.d.ts.map +1 -1
- package/dist/transformers/addAttributes.js +22 -8
- package/dist/transformers/addAttributes.js.map +1 -1
- package/dist/transformers/columnWidth.d.ts.map +1 -1
- package/dist/transformers/columnWidth.js +136 -150
- package/dist/transformers/columnWidth.js.map +1 -1
- package/dist/transformers/entities.d.ts.map +1 -1
- package/dist/transformers/entities.js +1 -0
- package/dist/transformers/entities.js.map +1 -1
- package/dist/transformers/index.d.ts.map +1 -1
- package/dist/transformers/index.js +7 -5
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/inlineCss.js +2 -7
- package/dist/transformers/inlineCss.js.map +1 -1
- package/dist/transformers/inlineLink.js +2 -2
- package/dist/transformers/inlineLink.js.map +1 -1
- package/dist/transformers/minifyCodeInline.d.ts +29 -0
- package/dist/transformers/minifyCodeInline.d.ts.map +1 -0
- package/dist/transformers/minifyCodeInline.js +36 -0
- package/dist/transformers/minifyCodeInline.js.map +1 -0
- package/dist/transformers/msoPlaceholders.d.ts +10 -5
- package/dist/transformers/msoPlaceholders.d.ts.map +1 -1
- package/dist/transformers/msoPlaceholders.js +38 -7
- package/dist/transformers/msoPlaceholders.js.map +1 -1
- package/dist/transformers/safeSelectors.d.ts +37 -0
- package/dist/transformers/safeSelectors.d.ts.map +1 -0
- package/dist/transformers/{safeClassNames.js → safeSelectors.js} +24 -5
- package/dist/transformers/safeSelectors.js.map +1 -0
- package/dist/transformers/shorthandCss.js +38 -7
- package/dist/transformers/shorthandCss.js.map +1 -1
- package/dist/transformers/tailwindComponent.js +1 -1
- package/dist/transformers/tailwindComponent.js.map +1 -1
- package/dist/types/config.d.ts +19 -9
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/ast/serializer.d.ts.map +1 -1
- package/dist/utils/ast/serializer.js +27 -17
- package/dist/utils/ast/serializer.js.map +1 -1
- package/dist/utils/cssBox.d.ts +42 -0
- package/dist/utils/cssBox.d.ts.map +1 -0
- package/dist/utils/cssBox.js +156 -0
- package/dist/utils/cssBox.js.map +1 -0
- package/dist/utils/watchPaths.d.ts +11 -0
- package/dist/utils/watchPaths.d.ts.map +1 -0
- package/dist/utils/watchPaths.js +19 -0
- package/dist/utils/watchPaths.js.map +1 -0
- package/package.json +1 -1
- package/dist/transformers/safeClassNames.d.ts +0 -22
- package/dist/transformers/safeClassNames.d.ts.map +0 -1
- package/dist/transformers/safeClassNames.js.map +0 -1
|
@@ -63,6 +63,7 @@ const userHasWidth = computed(() => {
|
|
|
63
63
|
|
|
64
64
|
const useMarker = outlookFallback && props.width == null && userHasWidth.value
|
|
65
65
|
const msoId = useMarker ? nextId('s') : null
|
|
66
|
+
const tdId = outlookFallback ? nextId('st') : null
|
|
66
67
|
|
|
67
68
|
const divStyle = computed(() => {
|
|
68
69
|
const parts: string[] = []
|
|
@@ -76,13 +77,6 @@ const restAttrs = computed(() => {
|
|
|
76
77
|
return rest
|
|
77
78
|
})
|
|
78
79
|
|
|
79
|
-
const tdStyles = computed(() => {
|
|
80
|
-
const parts: string[] = []
|
|
81
|
-
if (userStyle.value) parts.push(userStyle.value)
|
|
82
|
-
if (props.msoStyle) parts.push(props.msoStyle)
|
|
83
|
-
return parts.length ? parts.join('; ') : ''
|
|
84
|
-
})
|
|
85
|
-
|
|
86
80
|
const msoWidth = computed(() => {
|
|
87
81
|
if (props.width != null) return normalizeToPixels(props.width)
|
|
88
82
|
if (useMarker) return `__MAIZZLE_MSOW_${msoId}__`
|
|
@@ -95,13 +89,12 @@ const colWidthSource = computed(() => {
|
|
|
95
89
|
return null
|
|
96
90
|
})
|
|
97
91
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
92
|
+
const tdMarker = tdId ? `__MAIZZLE_MSOTDSTYLE_${tdId}__` : ''
|
|
93
|
+
|
|
94
|
+
const MsoBefore = () => createStaticVNode(
|
|
95
|
+
`<!--[if mso]><table role="none" cellpadding="0" cellspacing="0" style="width: ${msoWidth.value}"><tr><td${tdMarker}><![endif]-->`,
|
|
96
|
+
1
|
|
97
|
+
)
|
|
105
98
|
|
|
106
99
|
const MsoAfter = () => createStaticVNode(
|
|
107
100
|
'<!--[if mso]></td></tr></table><![endif]-->',
|
|
@@ -117,6 +110,8 @@ const MsoAfter = () => createStaticVNode(
|
|
|
117
110
|
:data-maizzle-msow-id="msoId"
|
|
118
111
|
:data-maizzle-msow-fallback="useMarker ? '100%' : null"
|
|
119
112
|
:data-maizzle-cw="colWidthSource"
|
|
113
|
+
:data-maizzle-mso-td-id="tdId"
|
|
114
|
+
:data-maizzle-mso-style="tdId && props.msoStyle ? props.msoStyle : null"
|
|
120
115
|
>
|
|
121
116
|
<slot />
|
|
122
117
|
</div>
|
package/dist/components/Text.vue
CHANGED
|
@@ -18,7 +18,7 @@ const props = defineProps({
|
|
|
18
18
|
|
|
19
19
|
const attrs = useAttrs()
|
|
20
20
|
|
|
21
|
-
const defaultClass = computed(() => props.as === 'span' ? 'text-base' : '
|
|
21
|
+
const defaultClass = computed(() => props.as === 'span' ? 'text-base' : 'mt-4 text-base')
|
|
22
22
|
const mergedClass = computed(() => twMerge(defaultClass.value, attrs.class as string))
|
|
23
23
|
</script>
|
|
24
24
|
|
|
@@ -3,10 +3,9 @@ import { MaizzleConfig } from "../types/config.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Define Maizzle config.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the result to child components via useConfig()
|
|
6
|
+
* In maizzle.config.ts: typed identity function, returns the config as-is
|
|
7
|
+
* In Vue SFC `<script setup>`: merges with the global config and provides
|
|
8
|
+
* the result to child components via `useConfig()`
|
|
10
9
|
*/
|
|
11
10
|
declare function defineConfig(data?: Partial<MaizzleConfig>): MaizzleConfig;
|
|
12
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineConfig.d.ts","names":[],"sources":["../../src/composables/defineConfig.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"defineConfig.d.ts","names":[],"sources":["../../src/composables/defineConfig.ts"],"mappings":";;;;;AAoBA;;;;iBAAgB,YAAA,CAAa,IAAA,GAAM,OAAA,CAAQ,aAAA,IAAsB,aAAA"}
|
|
@@ -12,10 +12,9 @@ const merge = createDefu((obj, key, value) => {
|
|
|
12
12
|
/**
|
|
13
13
|
* Define Maizzle config.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* the result to child components via useConfig()
|
|
15
|
+
* In maizzle.config.ts: typed identity function, returns the config as-is
|
|
16
|
+
* In Vue SFC `<script setup>`: merges with the global config and provides
|
|
17
|
+
* the result to child components via `useConfig()`
|
|
19
18
|
*/
|
|
20
19
|
function defineConfig(data = {}) {
|
|
21
20
|
if (getCurrentInstance()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineConfig.js","names":[],"sources":["../../src/composables/defineConfig.ts"],"sourcesContent":["import { getCurrentInstance, inject, provide } from 'vue'\nimport { createDefu } from 'defu'\nimport { MaizzleConfigKey } from './useConfig.ts'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nconst merge = createDefu((obj, key, value) => {\n if (Array.isArray(obj[key])) {\n obj[key] = value\n return true\n }\n})\n\n/**\n * Define Maizzle config.\n *\n *
|
|
1
|
+
{"version":3,"file":"defineConfig.js","names":[],"sources":["../../src/composables/defineConfig.ts"],"sourcesContent":["import { getCurrentInstance, inject, provide } from 'vue'\nimport { createDefu } from 'defu'\nimport { MaizzleConfigKey } from './useConfig.ts'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nconst merge = createDefu((obj, key, value) => {\n if (Array.isArray(obj[key])) {\n obj[key] = value\n return true\n }\n})\n\n/**\n * Define Maizzle config.\n *\n * In maizzle.config.ts: typed identity function, returns the config as-is\n * In Vue SFC `<script setup>`: merges with the global config and provides\n * the result to child components via `useConfig()`\n */\nexport function defineConfig(data: Partial<MaizzleConfig> = {}): MaizzleConfig {\n // Inside a Vue SFC — merge with global config and provide to children\n if (getCurrentInstance()) {\n const globalConfig = inject(MaizzleConfigKey, {} as MaizzleConfig)\n const merged = merge(data, globalConfig) as MaizzleConfig\n\n const ctx = inject(RenderContextKey)\n if (ctx) ctx.sfcConfig = merged\n\n provide(MaizzleConfigKey, merged)\n\n return merged\n }\n\n // Outside Vue (maizzle.config.ts) — just return the config\n return data as MaizzleConfig\n}\n"],"mappings":";;;;;AAMA,MAAM,QAAQ,YAAY,KAAK,KAAK,UAAU;CAC5C,IAAI,MAAM,QAAQ,IAAI,KAAK,EAAE;EAC3B,IAAI,OAAO;EACX,OAAO;;EAET;;;;;;;;AASF,SAAgB,aAAa,OAA+B,EAAE,EAAiB;CAE7E,IAAI,oBAAoB,EAAE;EAExB,MAAM,SAAS,MAAM,MADA,OAAO,kBAAkB,EAAE,CACT,CAAC;EAExC,MAAM,MAAM,OAAO,iBAAiB;EACpC,IAAI,KAAK,IAAI,YAAY;EAEzB,QAAQ,kBAAkB,OAAO;EAEjC,OAAO;;CAIT,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MaizzleConfig } from "../types/config.js";
|
|
2
1
|
import { EventMap, EventName } from "../events/index.js";
|
|
2
|
+
import { MaizzleConfig } from "../types/config.js";
|
|
3
3
|
import { UsePlaintextOptions } from "./usePlaintext.js";
|
|
4
4
|
import { InjectionKey } from "vue";
|
|
5
5
|
|
|
@@ -20,7 +20,6 @@ interface RenderContext {
|
|
|
20
20
|
preheader?: {
|
|
21
21
|
text: string;
|
|
22
22
|
fillerCount: number;
|
|
23
|
-
shyCount: number;
|
|
24
23
|
};
|
|
25
24
|
sfcConfig?: MaizzleConfig;
|
|
26
25
|
sfcEventHandlers: Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderContext.d.ts","names":[],"sources":["../../src/composables/renderContext.ts"],"mappings":";;;;;;UAKiB,gBAAA;EACf,MAAA;EACA,IAAA;EACA,WAAA;EACA,GAAA;AAAA;AAAA,UAGe,aAAA;EACf,EAAA;EANA;EAQA,GAAA;AAAA;AAAA,UAGe,aAAA;EACf,OAAA;EACA,SAAA;IAAc,IAAA;IAAc,WAAA;
|
|
1
|
+
{"version":3,"file":"renderContext.d.ts","names":[],"sources":["../../src/composables/renderContext.ts"],"mappings":";;;;;;UAKiB,gBAAA;EACf,MAAA;EACA,IAAA;EACA,WAAA;EACA,GAAA;AAAA;AAAA,UAGe,aAAA;EACf,EAAA;EANA;EAQA,GAAA;AAAA;AAAA,UAGe,aAAA;EACf,OAAA;EACA,SAAA;IAAc,IAAA;IAAc,WAAA;EAAA;EAC5B,SAAA,GAAY,aAAA;EACZ,gBAAA,EAAkB,KAAA;IAAQ,IAAA,EAAM,SAAA;IAAW,OAAA,EAAS,QAAA,CAAS,SAAA;EAAA;EAC7D,SAAA,GAAY,mBAAA;EACZ,KAAA,GAAQ,gBAAA;EACR,cAAA,GAAiB,aAAA;AAAA;AAAA,cAGN,gBAAA,EAAkB,YAAA,CAAa,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderContext.js","names":[],"sources":["../../src/composables/renderContext.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\nimport type { UsePlaintextOptions } from './usePlaintext.ts'\n\nexport interface FontRegistration {\n family: string\n slug: string\n declaration: string\n url: string\n}\n\nexport interface TailwindBlock {\n id: string\n /** Optional raw CSS from the component's `#config` slot. */\n css?: string\n}\n\nexport interface RenderContext {\n doctype?: string\n preheader?: { text: string; fillerCount: number
|
|
1
|
+
{"version":3,"file":"renderContext.js","names":[],"sources":["../../src/composables/renderContext.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { MaizzleConfig } from '../types/index.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\nimport type { UsePlaintextOptions } from './usePlaintext.ts'\n\nexport interface FontRegistration {\n family: string\n slug: string\n declaration: string\n url: string\n}\n\nexport interface TailwindBlock {\n id: string\n /** Optional raw CSS from the component's `#config` slot. */\n css?: string\n}\n\nexport interface RenderContext {\n doctype?: string\n preheader?: { text: string; fillerCount: number }\n sfcConfig?: MaizzleConfig\n sfcEventHandlers: Array<{ name: EventName; handler: EventMap[EventName] }>\n plaintext?: UsePlaintextOptions\n fonts?: FontRegistration[]\n tailwindBlocks?: TailwindBlock[]\n}\n\nexport const RenderContextKey: InjectionKey<RenderContext> = Symbol('RenderContext')\n"],"mappings":";AA4BA,MAAa,mBAAgD,OAAO,gBAAgB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ParsedPath } from "node:path";
|
|
2
|
+
|
|
3
|
+
//#region src/composables/useCurrentTemplate.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Internal — set by the build loop before each template iteration and
|
|
6
|
+
* cleared in `finally`. Not exported from the package entrypoint.
|
|
7
|
+
*/
|
|
8
|
+
declare function _setCurrentTemplate(parsed: ParsedPath | undefined): void;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the parsed path of the template currently being processed,
|
|
11
|
+
* or `undefined` when called outside the per-template scope (e.g. from
|
|
12
|
+
* `beforeCreate` / `afterBuild`, or outside a build entirely).
|
|
13
|
+
*
|
|
14
|
+
* Usage in an SFC `<script setup>`:
|
|
15
|
+
* ```ts
|
|
16
|
+
* const file = useCurrentTemplate()
|
|
17
|
+
* console.log(file?.name) // 'welcome'
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Usage in an event handler:
|
|
21
|
+
* ```ts
|
|
22
|
+
* beforeRender() {
|
|
23
|
+
* const file = useCurrentTemplate()
|
|
24
|
+
* // file?.dir, file?.name, file?.ext, file?.base, file?.root
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare function useCurrentTemplate(): ParsedPath | undefined;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { _setCurrentTemplate, useCurrentTemplate };
|
|
31
|
+
//# sourceMappingURL=useCurrentTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentTemplate.d.ts","names":[],"sources":["../../src/composables/useCurrentTemplate.ts"],"mappings":";;;;;AAQA;;iBAAgB,mBAAA,CAAoB,MAAA,EAAQ,UAAA;;;AAuB5C;;;;;;;;;;;;;;;;;iBAAgB,kBAAA,CAAA,GAAsB,UAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/composables/useCurrentTemplate.ts
|
|
2
|
+
let current;
|
|
3
|
+
/**
|
|
4
|
+
* Internal — set by the build loop before each template iteration and
|
|
5
|
+
* cleared in `finally`. Not exported from the package entrypoint.
|
|
6
|
+
*/
|
|
7
|
+
function _setCurrentTemplate(parsed) {
|
|
8
|
+
current = parsed;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns the parsed path of the template currently being processed,
|
|
12
|
+
* or `undefined` when called outside the per-template scope (e.g. from
|
|
13
|
+
* `beforeCreate` / `afterBuild`, or outside a build entirely).
|
|
14
|
+
*
|
|
15
|
+
* Usage in an SFC `<script setup>`:
|
|
16
|
+
* ```ts
|
|
17
|
+
* const file = useCurrentTemplate()
|
|
18
|
+
* console.log(file?.name) // 'welcome'
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Usage in an event handler:
|
|
22
|
+
* ```ts
|
|
23
|
+
* beforeRender() {
|
|
24
|
+
* const file = useCurrentTemplate()
|
|
25
|
+
* // file?.dir, file?.name, file?.ext, file?.base, file?.root
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function useCurrentTemplate() {
|
|
30
|
+
return current;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { _setCurrentTemplate, useCurrentTemplate };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=useCurrentTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentTemplate.js","names":[],"sources":["../../src/composables/useCurrentTemplate.ts"],"sourcesContent":["import type { ParsedPath } from 'node:path'\n\nlet current: ParsedPath | undefined\n\n/**\n * Internal — set by the build loop before each template iteration and\n * cleared in `finally`. Not exported from the package entrypoint.\n */\nexport function _setCurrentTemplate(parsed: ParsedPath | undefined): void {\n current = parsed\n}\n\n/**\n * Returns the parsed path of the template currently being processed,\n * or `undefined` when called outside the per-template scope (e.g. from\n * `beforeCreate` / `afterBuild`, or outside a build entirely).\n *\n * Usage in an SFC `<script setup>`:\n * ```ts\n * const file = useCurrentTemplate()\n * console.log(file?.name) // 'welcome'\n * ```\n *\n * Usage in an event handler:\n * ```ts\n * beforeRender() {\n * const file = useCurrentTemplate()\n * // file?.dir, file?.name, file?.ext, file?.base, file?.root\n * }\n * ```\n */\nexport function useCurrentTemplate(): ParsedPath | undefined {\n return current\n}\n"],"mappings":";AAEA,IAAI;;;;;AAMJ,SAAgB,oBAAoB,QAAsC;CACxE,UAAU;;;;;;;;;;;;;;;;;;;;;AAsBZ,SAAgB,qBAA6C;CAC3D,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEvent.js","names":[],"sources":["../../src/composables/useEvent.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\n\n/**\n * Register an event handler from within an SFC's <script setup>.\n *\n * Usage:\n * ```ts\n * useEvent('beforeRender', ({ config, template }) => {\n * return template.replace('foo', 'bar')\n * })\n * ```\n */\nexport function useEvent<K extends EventName>(name: K, handler: EventMap[K]) {\n const ctx = inject(RenderContextKey)\n if (ctx) ctx.sfcEventHandlers.push({ name, handler })\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,SAA8B,MAAS,SAAsB;CAC3E,MAAM,MAAM,OAAO,iBAAiB;CACpC,IAAI,KAAK,IAAI,iBAAiB,KAAK;EAAE;EAAM;EAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"useEvent.js","names":[],"sources":["../../src/composables/useEvent.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { EventName, EventMap } from '../events/index.ts'\n\n/**\n * Register an event handler from within an SFC's <script setup>.\n *\n * Usage:\n * ```ts\n * useEvent('beforeRender', ({ config, template }) => {\n * return template.source.replace('foo', 'bar')\n * })\n * ```\n */\nexport function useEvent<K extends EventName>(name: K, handler: EventMap[K]) {\n const ctx = inject(RenderContextKey)\n if (ctx) ctx.sfcEventHandlers.push({ name, handler })\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,SAA8B,MAAS,SAAsB;CAC3E,MAAM,MAAM,OAAO,iBAAiB;CACpC,IAAI,KAAK,IAAI,iBAAiB,KAAK;EAAE;EAAM;EAAS,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
//#region src/composables/usePreheader.d.ts
|
|
2
2
|
interface UsePreheaderOptions {
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Explicit number of filler sequences to render. When omitted, the count
|
|
5
|
+
* is auto-derived to fill the 200-char inbox preview budget.
|
|
6
|
+
*/
|
|
7
|
+
spaces?: number;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Set the preheader text for the current email template.
|
|
@@ -15,7 +16,7 @@ interface UsePreheaderOptions {
|
|
|
15
16
|
* Usage in SFC <script setup>:
|
|
16
17
|
* ```ts
|
|
17
18
|
* usePreheader('Thanks for signing up!')
|
|
18
|
-
* usePreheader('Welcome!', {
|
|
19
|
+
* usePreheader('Welcome!', { spaces: 50 })
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
22
|
declare function usePreheader(text: string, options?: UsePreheaderOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreheader.d.ts","names":[],"sources":["../../src/composables/usePreheader.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"usePreheader.d.ts","names":[],"sources":["../../src/composables/usePreheader.ts"],"mappings":";UAKiB,mBAAA;EAAA;;;;EAKf,MAAA;AAAA;;;;;;;;;;;;;;iBAgBc,YAAA,CAAa,IAAA,UAAc,OAAA,GAAU,mBAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RenderContextKey } from "./renderContext.js";
|
|
2
2
|
import { inject } from "vue";
|
|
3
3
|
//#region src/composables/usePreheader.ts
|
|
4
|
+
const PREVIEW_LENGTH = 200;
|
|
4
5
|
/**
|
|
5
6
|
* Set the preheader text for the current email template.
|
|
6
7
|
*
|
|
@@ -11,15 +12,14 @@ import { inject } from "vue";
|
|
|
11
12
|
* Usage in SFC <script setup>:
|
|
12
13
|
* ```ts
|
|
13
14
|
* usePreheader('Thanks for signing up!')
|
|
14
|
-
* usePreheader('Welcome!', {
|
|
15
|
+
* usePreheader('Welcome!', { spaces: 50 })
|
|
15
16
|
* ```
|
|
16
17
|
*/
|
|
17
18
|
function usePreheader(text, options) {
|
|
18
19
|
const ctx = inject(RenderContextKey);
|
|
19
20
|
if (ctx) ctx.preheader = {
|
|
20
21
|
text,
|
|
21
|
-
fillerCount: options?.
|
|
22
|
-
shyCount: options?.shyCount ?? 150
|
|
22
|
+
fillerCount: options?.spaces !== void 0 ? Math.max(0, options.spaces) : Math.max(0, PREVIEW_LENGTH - text.length)
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreheader.js","names":[],"sources":["../../src/composables/usePreheader.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { RenderContextKey } from './renderContext.ts'\n\nexport interface UsePreheaderOptions {\n
|
|
1
|
+
{"version":3,"file":"usePreheader.js","names":[],"sources":["../../src/composables/usePreheader.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { RenderContextKey } from './renderContext.ts'\n\nconst PREVIEW_LENGTH = 200\n\nexport interface UsePreheaderOptions {\n /**\n * Explicit number of filler sequences to render. When omitted, the count\n * is auto-derived to fill the 200-char inbox preview budget.\n */\n spaces?: number\n}\n\n/**\n * Set the preheader text for the current email template.\n *\n * Injects a hidden `<div>` at the start of `<body>` with the preheader text\n * followed by filler characters that prevent email clients from pulling\n * in body content after the preheader.\n *\n * Usage in SFC <script setup>:\n * ```ts\n * usePreheader('Thanks for signing up!')\n * usePreheader('Welcome!', { spaces: 50 })\n * ```\n */\nexport function usePreheader(text: string, options?: UsePreheaderOptions): void {\n const ctx = inject(RenderContextKey)\n if (ctx) {\n const fillerCount = options?.spaces !== undefined\n ? Math.max(0, options.spaces)\n : Math.max(0, PREVIEW_LENGTH - text.length)\n ctx.preheader = { text, fillerCount }\n }\n}\n"],"mappings":";;;AAGA,MAAM,iBAAiB;;;;;;;;;;;;;;AAuBvB,SAAgB,aAAa,MAAc,SAAqC;CAC9E,MAAM,MAAM,OAAO,iBAAiB;CACpC,IAAI,KAIF,IAAI,YAAY;EAAE;EAAM,aAHJ,SAAS,WAAW,KAAA,IACpC,KAAK,IAAI,GAAG,QAAQ,OAAO,GAC3B,KAAK,IAAI,GAAG,iBAAiB,KAAK,OAAO;EACR"}
|
|
@@ -11,7 +11,7 @@ import { TransformerToggles } from "../types/config.js";
|
|
|
11
11
|
* - `useTransformers({ prettify: true, minify: true })` *enables*
|
|
12
12
|
* transformers that would otherwise no-op (boolean-driven ones:
|
|
13
13
|
* inlineCss, purgeCss, prettify, minify, shorthandCss, sixHex,
|
|
14
|
-
*
|
|
14
|
+
* safeSelectors, entities). Same effect as setting their config
|
|
15
15
|
* slice directly, scoped to one template.
|
|
16
16
|
*
|
|
17
17
|
* Data-driven transformers (filters, baseURL, urlQuery, addAttributes,
|
|
@@ -13,7 +13,7 @@ import { getCurrentInstance, inject, provide } from "vue";
|
|
|
13
13
|
* - `useTransformers({ prettify: true, minify: true })` *enables*
|
|
14
14
|
* transformers that would otherwise no-op (boolean-driven ones:
|
|
15
15
|
* inlineCss, purgeCss, prettify, minify, shorthandCss, sixHex,
|
|
16
|
-
*
|
|
16
|
+
* safeSelectors, entities). Same effect as setting their config
|
|
17
17
|
* slice directly, scoped to one template.
|
|
18
18
|
*
|
|
19
19
|
* Data-driven transformers (filters, baseURL, urlQuery, addAttributes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransformers.js","names":[],"sources":["../../src/composables/useTransformers.ts"],"sourcesContent":["import { getCurrentInstance, inject, provide } from 'vue'\nimport { MaizzleConfigKey } from './useConfig.ts'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { MaizzleConfig, TransformerToggles } from '../types/index.ts'\n\n/**\n * Toggle the transformer pipeline for the current template.\n *\n * - `useTransformers(false)` skips the entire pipeline (CSS inlining,\n * purging, shorthand, etc).\n * - `useTransformers(true)` (or no argument) keeps everything on.\n * - `useTransformers({ inlineCss: false, minify: false })` runs the\n * pipeline but skips the listed transformers.\n * - `useTransformers({ prettify: true, minify: true })` *enables*\n * transformers that would otherwise no-op (boolean-driven ones:\n * inlineCss, purgeCss, prettify, minify, shorthandCss, sixHex,\n *
|
|
1
|
+
{"version":3,"file":"useTransformers.js","names":[],"sources":["../../src/composables/useTransformers.ts"],"sourcesContent":["import { getCurrentInstance, inject, provide } from 'vue'\nimport { MaizzleConfigKey } from './useConfig.ts'\nimport { RenderContextKey } from './renderContext.ts'\nimport type { MaizzleConfig, TransformerToggles } from '../types/index.ts'\n\n/**\n * Toggle the transformer pipeline for the current template.\n *\n * - `useTransformers(false)` skips the entire pipeline (CSS inlining,\n * purging, shorthand, etc).\n * - `useTransformers(true)` (or no argument) keeps everything on.\n * - `useTransformers({ inlineCss: false, minify: false })` runs the\n * pipeline but skips the listed transformers.\n * - `useTransformers({ prettify: true, minify: true })` *enables*\n * transformers that would otherwise no-op (boolean-driven ones:\n * inlineCss, purgeCss, prettify, minify, shorthandCss, sixHex,\n * safeSelectors, entities). Same effect as setting their config\n * slice directly, scoped to one template.\n *\n * Data-driven transformers (filters, baseURL, urlQuery, addAttributes,\n * removeAttributes, replaceStrings, attributeToStyle) need actual\n * values in config — a bare `true` toggle for them is a no-op.\n *\n * Mirrors the `useTransformers` config flag, scoped to a single template\n * — no need to edit `maizzle.config.ts`.\n *\n * Usage in SFC <script setup>:\n * ```ts\n * useTransformers(false)\n * useTransformers({ inlineCss: false, minify: false })\n * useTransformers({ prettify: true })\n * ```\n */\nexport function useTransformers(value: boolean | TransformerToggles = true): void {\n if (!getCurrentInstance()) return\n\n const ctx = inject(RenderContextKey)\n if (!ctx) return\n\n const globalConfig = inject(MaizzleConfigKey, {} as MaizzleConfig)\n const merged: MaizzleConfig = {\n ...(ctx.sfcConfig ?? globalConfig),\n useTransformers: value,\n }\n\n ctx.sfcConfig = merged\n provide(MaizzleConfigKey, merged)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,gBAAgB,QAAsC,MAAY;CAChF,IAAI,CAAC,oBAAoB,EAAE;CAE3B,MAAM,MAAM,OAAO,iBAAiB;CACpC,IAAI,CAAC,KAAK;CAEV,MAAM,eAAe,OAAO,kBAAkB,EAAE,CAAkB;CAClE,MAAM,SAAwB;EAC5B,GAAI,IAAI,aAAa;EACrB,iBAAiB;EAClB;CAED,IAAI,YAAY;CAChB,QAAQ,kBAAkB,OAAO"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import { MaizzleConfig } from "../types/config.js";
|
|
2
|
+
import { ParsedPath } from "node:path";
|
|
3
|
+
|
|
2
4
|
//#region src/events/index.d.ts
|
|
3
5
|
type EventName = 'beforeCreate' | 'beforeRender' | 'afterRender' | 'afterTransform' | 'afterBuild';
|
|
6
|
+
/**
|
|
7
|
+
* Info about the template currently being processed, passed to per-template
|
|
8
|
+
* event handlers. `source` is the SFC file contents; `path` is the result of
|
|
9
|
+
* `path.parse(absolutePath)` — `{ root, dir, base, ext, name }`.
|
|
10
|
+
*/
|
|
11
|
+
interface TemplateInfo {
|
|
12
|
+
source: string;
|
|
13
|
+
path: ParsedPath;
|
|
14
|
+
}
|
|
4
15
|
interface EventMap {
|
|
5
16
|
beforeCreate: (params: {
|
|
6
17
|
config: MaizzleConfig;
|
|
7
18
|
}) => void | Promise<void>;
|
|
8
19
|
beforeRender: (params: {
|
|
9
20
|
config: MaizzleConfig;
|
|
10
|
-
template:
|
|
21
|
+
template: TemplateInfo;
|
|
11
22
|
}) => string | void | Promise<string | void>;
|
|
12
23
|
afterRender: (params: {
|
|
13
24
|
config: MaizzleConfig;
|
|
14
|
-
template:
|
|
25
|
+
template: TemplateInfo;
|
|
15
26
|
html: string;
|
|
16
27
|
}) => string | void | Promise<string | void>;
|
|
17
28
|
afterTransform: (params: {
|
|
18
29
|
config: MaizzleConfig;
|
|
19
|
-
template:
|
|
30
|
+
template: TemplateInfo;
|
|
20
31
|
html: string;
|
|
21
32
|
}) => string | void | Promise<string | void>;
|
|
22
33
|
afterBuild: (params: {
|
|
@@ -49,18 +60,19 @@ declare class EventManager {
|
|
|
49
60
|
config: MaizzleConfig;
|
|
50
61
|
}): Promise<void>;
|
|
51
62
|
/**
|
|
52
|
-
* Fire beforeRender — if a handler returns a string, it replaces
|
|
63
|
+
* Fire beforeRender — if a handler returns a string, it replaces
|
|
64
|
+
* `template.source` for subsequent handlers and the renderer.
|
|
53
65
|
*/
|
|
54
66
|
fireBeforeRender(params: {
|
|
55
67
|
config: MaizzleConfig;
|
|
56
|
-
template:
|
|
68
|
+
template: TemplateInfo;
|
|
57
69
|
}): Promise<string>;
|
|
58
70
|
/**
|
|
59
71
|
* Fire afterRender — if a handler returns a string, it replaces `html`.
|
|
60
72
|
*/
|
|
61
73
|
fireAfterRender(params: {
|
|
62
74
|
config: MaizzleConfig;
|
|
63
|
-
template:
|
|
75
|
+
template: TemplateInfo;
|
|
64
76
|
html: string;
|
|
65
77
|
}): Promise<string>;
|
|
66
78
|
/**
|
|
@@ -68,7 +80,7 @@ declare class EventManager {
|
|
|
68
80
|
*/
|
|
69
81
|
fireAfterTransform(params: {
|
|
70
82
|
config: MaizzleConfig;
|
|
71
|
-
template:
|
|
83
|
+
template: TemplateInfo;
|
|
72
84
|
html: string;
|
|
73
85
|
}): Promise<string>;
|
|
74
86
|
/**
|
|
@@ -93,5 +105,5 @@ declare class EventManager {
|
|
|
93
105
|
clear(): void;
|
|
94
106
|
}
|
|
95
107
|
//#endregion
|
|
96
|
-
export { EventManager, EventMap, EventName };
|
|
108
|
+
export { EventManager, EventMap, EventName, TemplateInfo };
|
|
97
109
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/events/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/events/index.ts"],"mappings":";;;;KAGY,SAAA;;;AAAZ;;;UAOiB,YAAA;EACf,MAAA;EACA,IAAA,EAAM,UAAA;AAAA;AAAA,UAGS,QAAA;EACf,YAAA,GAAe,MAAA;IAAU,MAAA,EAAQ,aAAA;EAAA,aAA2B,OAAA;EAC5D,YAAA,GAAe,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;EAAA,sBAAmC,OAAA;EAC7F,WAAA,GAAc,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,sBAAmC,OAAA;EAC1G,cAAA,GAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,sBAAmC,OAAA;EAC7G,UAAA,GAAa,MAAA;IAAU,KAAA;IAAiB,MAAA,EAAQ,aAAA;EAAA,aAA2B,OAAA;AAAA;;;;;;;;cAUhE,YAAA;EAAA,QACH,QAAA;EAAA,QAIA,kBAAA;EAlBwC;;;EAuBhD,cAAA,CAAe,MAAA,EAAQ,aAAA;EAtBvB;;;EAqCA,EAAA,WAAa,SAAA,CAAA,CAAW,IAAA,EAAM,CAAA,EAAG,OAAA,EAAS,QAAA,CAAS,CAAA;EArCM;;;EAgDnD,gBAAA,CAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;EAAA,IAAe,OAAA;EA/CrB;;;;EA2D7B,gBAAA,CAAiB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;EAAA,IAAiB,OAAA;EA1D3C;;;EA2ElC,eAAA,CAAgB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,IAAiB,OAAA;EAjEzE;;;EAoFjB,kBAAA,CAAmB,MAAA;IAAU,MAAA,EAAQ,aAAA;IAAe,QAAA,EAAU,YAAA;IAAc,IAAA;EAAA,IAAiB,OAAA;EApC1D;;;EAuDnC,cAAA,CAAe,MAAA;IAAU,KAAA;IAAiB,MAAA,EAAQ,aAAA;EAAA,IAAe,OAAA;EAnBH;;;;;;;;EAmCpE,gBAAA,CAAiB,MAAA,GAAQ,SAAA;EA7GzB;;;EA2HA,KAAA,CAAA;AAAA"}
|
package/dist/events/index.js
CHANGED
|
@@ -40,19 +40,16 @@ var EventManager = class {
|
|
|
40
40
|
for (const handler of handlers) await handler(params);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Fire beforeRender — if a handler returns a string, it replaces
|
|
43
|
+
* Fire beforeRender — if a handler returns a string, it replaces
|
|
44
|
+
* `template.source` for subsequent handlers and the renderer.
|
|
44
45
|
*/
|
|
45
46
|
async fireBeforeRender(params) {
|
|
46
47
|
const handlers = this.handlers.get("beforeRender") ?? [];
|
|
47
|
-
let { template } = params;
|
|
48
48
|
for (const handler of handlers) {
|
|
49
|
-
const result = await handler(
|
|
50
|
-
|
|
51
|
-
template
|
|
52
|
-
});
|
|
53
|
-
if (typeof result === "string") template = result;
|
|
49
|
+
const result = await handler(params);
|
|
50
|
+
if (typeof result === "string") params.template.source = result;
|
|
54
51
|
}
|
|
55
|
-
return template;
|
|
52
|
+
return params.template.source;
|
|
56
53
|
}
|
|
57
54
|
/**
|
|
58
55
|
* Fire afterRender — if a handler returns a string, it replaces `html`.
|
package/dist/events/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/events/index.ts"],"sourcesContent":["import type { MaizzleConfig } from '../types/index.ts'\n\nexport type EventName = 'beforeCreate' | 'beforeRender' | 'afterRender' | 'afterTransform' | 'afterBuild'\n\nexport interface EventMap {\n beforeCreate: (params: { config: MaizzleConfig }) => void | Promise<void>\n beforeRender: (params: { config: MaizzleConfig; template:
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/events/index.ts"],"sourcesContent":["import type { ParsedPath } from 'node:path'\nimport type { MaizzleConfig } from '../types/index.ts'\n\nexport type EventName = 'beforeCreate' | 'beforeRender' | 'afterRender' | 'afterTransform' | 'afterBuild'\n\n/**\n * Info about the template currently being processed, passed to per-template\n * event handlers. `source` is the SFC file contents; `path` is the result of\n * `path.parse(absolutePath)` — `{ root, dir, base, ext, name }`.\n */\nexport interface TemplateInfo {\n source: string\n path: ParsedPath\n}\n\nexport interface EventMap {\n beforeCreate: (params: { config: MaizzleConfig }) => void | Promise<void>\n beforeRender: (params: { config: MaizzleConfig; template: TemplateInfo }) => string | void | Promise<string | void>\n afterRender: (params: { config: MaizzleConfig; template: TemplateInfo; html: string }) => string | void | Promise<string | void>\n afterTransform: (params: { config: MaizzleConfig; template: TemplateInfo; html: string }) => string | void | Promise<string | void>\n afterBuild: (params: { files: string[]; config: MaizzleConfig }) => void | Promise<void>\n}\n\n/**\n * Central event manager that collects handlers from config and useEvent() calls.\n *\n * Handlers are run in order: config handler first, then SFC handlers in registration order.\n * For events that return a value (beforeRender, afterRender, afterTransform),\n * the returned value replaces the corresponding input for the next handler.\n */\nexport class EventManager {\n private handlers = new Map<EventName, EventMap[EventName][]>()\n // Snapshot of config-handler counts per event, captured at registerConfig().\n // clearSfcHandlers() truncates each list back to this count, dropping any\n // SFC-registered handlers that were appended after.\n private configHandlerCount = new Map<EventName, number>()\n\n /**\n * Register handlers from the Maizzle config.\n */\n registerConfig(config: MaizzleConfig) {\n const eventNames: EventName[] = ['beforeCreate', 'beforeRender', 'afterRender', 'afterTransform', 'afterBuild']\n\n for (const name of eventNames) {\n const handler = config[name]\n if (typeof handler === 'function') {\n this.on(name, handler as EventMap[typeof name])\n }\n this.configHandlerCount.set(name, this.handlers.get(name)?.length ?? 0)\n }\n }\n\n /**\n * Register a handler for an event (used by useEvent composable).\n */\n on<K extends EventName>(name: K, handler: EventMap[K]) {\n if (!this.handlers.has(name)) {\n this.handlers.set(name, [])\n }\n\n this.handlers.get(name)!.push(handler)\n }\n\n /**\n * Fire beforeCreate — runs all handlers, config is mutated in place.\n */\n async fireBeforeCreate(params: { config: MaizzleConfig }) {\n const handlers = this.handlers.get('beforeCreate') ?? []\n\n for (const handler of handlers) {\n await (handler as EventMap['beforeCreate'])(params)\n }\n }\n\n /**\n * Fire beforeRender — if a handler returns a string, it replaces\n * `template.source` for subsequent handlers and the renderer.\n */\n async fireBeforeRender(params: { config: MaizzleConfig; template: TemplateInfo }): Promise<string> {\n const handlers = this.handlers.get('beforeRender') ?? []\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['beforeRender'])(params)\n\n if (typeof result === 'string') {\n params.template.source = result\n }\n }\n\n return params.template.source\n }\n\n /**\n * Fire afterRender — if a handler returns a string, it replaces `html`.\n */\n async fireAfterRender(params: { config: MaizzleConfig; template: TemplateInfo; html: string }): Promise<string> {\n const handlers = this.handlers.get('afterRender') ?? []\n\n let { html } = params\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['afterRender'])({ config: params.config, template: params.template, html })\n\n if (typeof result === 'string') {\n html = result\n }\n }\n\n return html\n }\n\n /**\n * Fire afterTransform — if a handler returns a string, it replaces `html`.\n */\n async fireAfterTransform(params: { config: MaizzleConfig; template: TemplateInfo; html: string }): Promise<string> {\n const handlers = this.handlers.get('afterTransform') ?? []\n\n let { html } = params\n\n for (const handler of handlers) {\n const result = await (handler as EventMap['afterTransform'])({ config: params.config, template: params.template, html })\n\n if (typeof result === 'string') {\n html = result\n }\n }\n\n return html\n }\n\n /**\n * Fire afterBuild — runs all handlers with the file list.\n */\n async fireAfterBuild(params: { files: string[]; config: MaizzleConfig }) {\n const handlers = this.handlers.get('afterBuild') ?? []\n\n for (const handler of handlers) {\n await (handler as EventMap['afterBuild'])(params)\n }\n }\n\n /**\n * Drop SFC-registered handlers, keep config-registered ones.\n *\n * Per default, only clears events whose scope is per-template\n * (`beforeRender`, `afterRender`, `afterTransform`). Build-scoped events\n * (`afterBuild`) accumulate across all templates and fire once at end of\n * build. Pass an explicit list to override.\n */\n clearSfcHandlers(events: EventName[] = ['beforeRender', 'afterRender', 'afterTransform']) {\n for (const name of events) {\n const handlers = this.handlers.get(name)\n if (!handlers) continue\n const keep = this.configHandlerCount.get(name) ?? 0\n if (handlers.length > keep) {\n this.handlers.set(name, handlers.slice(0, keep))\n }\n }\n }\n\n /**\n * Clear all handlers entirely.\n */\n clear() {\n this.handlers.clear()\n }\n}\n"],"mappings":";;;;;;;;AA8BA,IAAa,eAAb,MAA0B;CACxB,2BAAmB,IAAI,KAAuC;CAI9D,qCAA6B,IAAI,KAAwB;;;;CAKzD,eAAe,QAAuB;EAGpC,KAAK,MAAM,QAAQ;GAFc;GAAgB;GAAgB;GAAe;GAAkB;GAErE,EAAE;GAC7B,MAAM,UAAU,OAAO;GACvB,IAAI,OAAO,YAAY,YACrB,KAAK,GAAG,MAAM,QAAiC;GAEjD,KAAK,mBAAmB,IAAI,MAAM,KAAK,SAAS,IAAI,KAAK,EAAE,UAAU,EAAE;;;;;;CAO3E,GAAwB,MAAS,SAAsB;EACrD,IAAI,CAAC,KAAK,SAAS,IAAI,KAAK,EAC1B,KAAK,SAAS,IAAI,MAAM,EAAE,CAAC;EAG7B,KAAK,SAAS,IAAI,KAAK,CAAE,KAAK,QAAQ;;;;;CAMxC,MAAM,iBAAiB,QAAmC;EACxD,MAAM,WAAW,KAAK,SAAS,IAAI,eAAe,IAAI,EAAE;EAExD,KAAK,MAAM,WAAW,UACpB,MAAO,QAAqC,OAAO;;;;;;CAQvD,MAAM,iBAAiB,QAA4E;EACjG,MAAM,WAAW,KAAK,SAAS,IAAI,eAAe,IAAI,EAAE;EAExD,KAAK,MAAM,WAAW,UAAU;GAC9B,MAAM,SAAS,MAAO,QAAqC,OAAO;GAElE,IAAI,OAAO,WAAW,UACpB,OAAO,SAAS,SAAS;;EAI7B,OAAO,OAAO,SAAS;;;;;CAMzB,MAAM,gBAAgB,QAA0F;EAC9G,MAAM,WAAW,KAAK,SAAS,IAAI,cAAc,IAAI,EAAE;EAEvD,IAAI,EAAE,SAAS;EAEf,KAAK,MAAM,WAAW,UAAU;GAC9B,MAAM,SAAS,MAAO,QAAoC;IAAE,QAAQ,OAAO;IAAQ,UAAU,OAAO;IAAU;IAAM,CAAC;GAErH,IAAI,OAAO,WAAW,UACpB,OAAO;;EAIX,OAAO;;;;;CAMT,MAAM,mBAAmB,QAA0F;EACjH,MAAM,WAAW,KAAK,SAAS,IAAI,iBAAiB,IAAI,EAAE;EAE1D,IAAI,EAAE,SAAS;EAEf,KAAK,MAAM,WAAW,UAAU;GAC9B,MAAM,SAAS,MAAO,QAAuC;IAAE,QAAQ,OAAO;IAAQ,UAAU,OAAO;IAAU;IAAM,CAAC;GAExH,IAAI,OAAO,WAAW,UACpB,OAAO;;EAIX,OAAO;;;;;CAMT,MAAM,eAAe,QAAoD;EACvE,MAAM,WAAW,KAAK,SAAS,IAAI,aAAa,IAAI,EAAE;EAEtD,KAAK,MAAM,WAAW,UACpB,MAAO,QAAmC,OAAO;;;;;;;;;;CAYrD,iBAAiB,SAAsB;EAAC;EAAgB;EAAe;EAAiB,EAAE;EACxF,KAAK,MAAM,QAAQ,QAAQ;GACzB,MAAM,WAAW,KAAK,SAAS,IAAI,KAAK;GACxC,IAAI,CAAC,UAAU;GACf,MAAM,OAAO,KAAK,mBAAmB,IAAI,KAAK,IAAI;GAClD,IAAI,SAAS,SAAS,MACpB,KAAK,SAAS,IAAI,MAAM,SAAS,MAAM,GAAG,KAAK,CAAC;;;;;;CAQtD,QAAQ;EACN,KAAK,SAAS,OAAO"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { defineConfig } from "./composables/defineConfig.js";
|
|
|
4
4
|
import { usePlaintext } from "./composables/usePlaintext.js";
|
|
5
5
|
import { useBaseUrl } from "./composables/useBaseUrl.js";
|
|
6
6
|
import { useConfig } from "./composables/useConfig.js";
|
|
7
|
+
import { useCurrentTemplate } from "./composables/useCurrentTemplate.js";
|
|
7
8
|
import { useDoctype } from "./composables/useDoctype.js";
|
|
8
9
|
import { useEvent } from "./composables/useEvent.js";
|
|
9
10
|
import { useFont } from "./composables/useFont.js";
|
|
@@ -22,7 +23,7 @@ import { inlineLink } from "./transformers/inlineLink.js";
|
|
|
22
23
|
import { urlQuery } from "./transformers/urlQuery.js";
|
|
23
24
|
import { BaseUrlOptions, base } from "./transformers/base.js";
|
|
24
25
|
import { entities } from "./transformers/entities.js";
|
|
25
|
-
import {
|
|
26
|
+
import { safeSelectors } from "./transformers/safeSelectors.js";
|
|
26
27
|
import { attributeToStyle } from "./transformers/attributeToStyle.js";
|
|
27
28
|
import { InlineCssOptions, inlineCss } from "./transformers/inlineCss.js";
|
|
28
29
|
import { ShorthandCssOptions, shorthandCss } from "./transformers/shorthandCss.js";
|
|
@@ -35,4 +36,4 @@ import { replaceStrings } from "./transformers/replaceStrings.js";
|
|
|
35
36
|
import { FormatOptions, format } from "./transformers/format.js";
|
|
36
37
|
import { MinifyOptions, minify } from "./transformers/minify.js";
|
|
37
38
|
import { useHead } from "@unhead/vue";
|
|
38
|
-
export { type AttributesConfig, type BaseUrlOptions, type ComponentSource, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, type NormalizedComponentSource, type PlaintextConfig, type PrepareOptions, type PurgeCssOptions, type RemoveAttributeOption, type RemoveAttributeRule, type RenderResult, type RenderedTemplate, type Renderer, type ShorthandCssOptions, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig,
|
|
39
|
+
export { type AttributesConfig, type BaseUrlOptions, type ComponentSource, type CreateRendererOptions, type CssConfig, type EntitiesConfig, type FilterFunction, type FiltersConfig, type FormatOptions, type HtmlConfig, type InlineCssOptions, type MaizzleConfig, type MinifyOptions, type NormalizedComponentSource, type PlaintextConfig, type PrepareOptions, type PurgeCssOptions, type RemoveAttributeOption, type RemoveAttributeRule, type RenderResult, type RenderedTemplate, type Renderer, type ShorthandCssOptions, type UrlConfig, type UrlQuery, type UrlQueryOptions, addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeSelectors, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { useConfig } from "./composables/useConfig.js";
|
|
|
2
2
|
import { defineConfig } from "./composables/defineConfig.js";
|
|
3
3
|
import { resolveConfig } from "./config/index.js";
|
|
4
4
|
import { inlineLink } from "./transformers/inlineLink.js";
|
|
5
|
-
import {
|
|
5
|
+
import { safeSelectors } from "./transformers/safeSelectors.js";
|
|
6
6
|
import { attributeToStyle } from "./transformers/attributeToStyle.js";
|
|
7
7
|
import { inlineCss } from "./transformers/inlineCss.js";
|
|
8
8
|
import { removeAttributes } from "./transformers/removeAttributes.js";
|
|
@@ -20,6 +20,7 @@ import { minify } from "./transformers/minify.js";
|
|
|
20
20
|
import { normalizeComponentSources } from "./utils/componentSources.js";
|
|
21
21
|
import { createRenderer } from "./render/createRenderer.js";
|
|
22
22
|
import { createPlaintext } from "./plaintext.js";
|
|
23
|
+
import { useCurrentTemplate } from "./composables/useCurrentTemplate.js";
|
|
23
24
|
import { build } from "./build.js";
|
|
24
25
|
import { maizzle } from "./plugin.js";
|
|
25
26
|
import { render } from "./render/index.js";
|
|
@@ -34,4 +35,4 @@ import { useTransformers } from "./composables/useTransformers.js";
|
|
|
34
35
|
import { useBaseUrl } from "./composables/useBaseUrl.js";
|
|
35
36
|
import { useUrlQuery } from "./composables/useUrlQuery.js";
|
|
36
37
|
import { useHead } from "@unhead/vue";
|
|
37
|
-
export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig,
|
|
38
|
+
export { addAttributes, attributeToStyle, base, build, createPlaintext, createRenderer, defineConfig, entities, filters, format, inlineCss, inlineLink, maizzle, minify, normalizeComponentSources, prepare, purgeCss, removeAttributes, render, replaceStrings, resolveConfig, safeSelectors, serve, shorthandCss, sixHex, urlQuery, useBaseUrl, useConfig, useCurrentTemplate, useDoctype, useEvent, useFont, useHead, useOutlookFallback, usePlaintext, useTransformers, useUrlQuery };
|
|
@@ -246,7 +246,8 @@ async function createRenderer(options = {}) {
|
|
|
246
246
|
const app = createSSRApp(component);
|
|
247
247
|
app.use(head);
|
|
248
248
|
if (config.vue) {
|
|
249
|
-
|
|
249
|
+
const plugins = typeof config.vue.plugins === "function" ? config.vue.plugins() : config.vue.plugins ?? [];
|
|
250
|
+
for (const plugin of plugins) app.use(plugin);
|
|
250
251
|
for (const [name, directive] of Object.entries(config.vue.directives ?? {})) app.directive(name, directive);
|
|
251
252
|
Object.assign(app.config.globalProperties, config.vue.globalProperties);
|
|
252
253
|
}
|
|
@@ -286,8 +287,8 @@ async function createRenderer(options = {}) {
|
|
|
286
287
|
html = serializeDom(dom);
|
|
287
288
|
}
|
|
288
289
|
if (renderContext.preheader) {
|
|
289
|
-
const { text, fillerCount
|
|
290
|
-
const previewHtml = `<div style="display:none">${text}${"
|
|
290
|
+
const { text, fillerCount } = renderContext.preheader;
|
|
291
|
+
const previewHtml = `<div style="display:none">${text}${" ͏ ".repeat(fillerCount)}\u00A0</div>`;
|
|
291
292
|
html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`);
|
|
292
293
|
}
|
|
293
294
|
html = html.replaceAll("<!--[-->", "").replaceAll("<!--]-->", "").replaceAll("<!--teleport start anchor-->", "").replaceAll("<!--teleport anchor-->", "").replaceAll("<!--teleport start-->", "").replaceAll("<!--teleport end-->", "");
|