@maizzle/framework 6.0.0-rc.18 → 6.0.0-rc.19
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 +10 -6
- package/dist/build.js.map +1 -1
- package/dist/components/Button.vue +17 -39
- package/dist/components/Container.vue +6 -6
- package/dist/components/Hr.vue +20 -120
- package/dist/components/Html.vue +19 -1
- package/dist/components/NotPlaintext.vue +14 -0
- package/dist/components/{Vml.vue → OutlookBg.vue} +1 -1
- package/dist/components/Plaintext.vue +14 -0
- package/dist/components/QrCode.vue +157 -0
- package/dist/components/Spacer.vue +28 -27
- package/dist/components/utils.js +1 -1
- package/dist/components/utils.js.map +1 -1
- package/dist/composables/defineConfig.js +1 -2
- package/dist/composables/defineConfig.js.map +1 -1
- package/dist/composables/renderContext.js +1 -1
- package/dist/composables/useBaseUrl.js +3 -4
- package/dist/composables/useBaseUrl.js.map +1 -1
- package/dist/composables/useConfig.js +1 -2
- package/dist/composables/useConfig.js.map +1 -1
- package/dist/composables/useDoctype.js +1 -2
- package/dist/composables/useDoctype.js.map +1 -1
- package/dist/composables/useEvent.js +1 -2
- package/dist/composables/useEvent.js.map +1 -1
- package/dist/composables/useFont.js +1 -2
- package/dist/composables/useFont.js.map +1 -1
- package/dist/composables/useOutlookFallback.js +1 -2
- package/dist/composables/useOutlookFallback.js.map +1 -1
- package/dist/composables/usePlaintext.d.ts +2 -0
- package/dist/composables/usePlaintext.d.ts.map +1 -1
- package/dist/composables/usePlaintext.js +2 -2
- package/dist/composables/usePlaintext.js.map +1 -1
- package/dist/composables/usePreheader.js +1 -2
- package/dist/composables/usePreheader.js.map +1 -1
- package/dist/composables/useTransformers.d.ts +3 -3
- package/dist/composables/useTransformers.js +4 -5
- package/dist/composables/useTransformers.js.map +1 -1
- package/dist/composables/useUrlQuery.js +3 -4
- package/dist/composables/useUrlQuery.js.map +1 -1
- package/dist/config/defaults.js +1 -1
- package/dist/config/index.js +1 -2
- package/dist/config/index.js.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/index.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +4 -5
- package/dist/plaintext.js +3 -4
- package/dist/plaintext.js.map +1 -1
- package/dist/plugin.js +1 -2
- package/dist/plugin.js.map +1 -1
- package/dist/plugins/postcss/mergeMediaQueries.js +1 -2
- package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -1
- package/dist/plugins/postcss/pruneVars.js +1 -1
- package/dist/plugins/postcss/pruneVars.js.map +1 -1
- package/dist/plugins/postcss/quoteFontFamilies.js +1 -1
- package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -1
- package/dist/plugins/postcss/removeDeclarations.js +1 -1
- package/dist/plugins/postcss/removeDeclarations.js.map +1 -1
- package/dist/plugins/postcss/resolveMaizzleImports.js +1 -2
- package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -1
- package/dist/plugins/postcss/resolveProps.js +1 -1
- package/dist/plugins/postcss/resolveProps.js.map +1 -1
- package/dist/plugins/postcss/tailwindCleanup.js +1 -1
- package/dist/plugins/postcss/tailwindCleanup.js.map +1 -1
- package/dist/prepare.js +1 -2
- package/dist/prepare.js.map +1 -1
- package/dist/render/active.d.ts +8 -0
- package/dist/render/active.d.ts.map +1 -0
- package/dist/render/active.js +12 -0
- package/dist/render/active.js.map +1 -0
- package/dist/render/createRenderer.d.ts.map +1 -1
- package/dist/render/createRenderer.js +6 -9
- package/dist/render/createRenderer.js.map +1 -1
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +13 -6
- package/dist/render/index.js.map +1 -1
- package/dist/render/injectFonts.js +1 -2
- package/dist/render/injectFonts.js.map +1 -1
- package/dist/render/plugins/codeBlockExtract.js +1 -1
- package/dist/render/plugins/codeBlockExtract.js.map +1 -1
- package/dist/render/plugins/markdownExtract.js +1 -2
- package/dist/render/plugins/markdownExtract.js.map +1 -1
- package/dist/render/plugins/rawExtract.js +1 -1
- package/dist/render/plugins/rawExtract.js.map +1 -1
- package/dist/render/plugins/rowSourceLocation.js +1 -1
- package/dist/render/plugins/rowSourceLocation.js.map +1 -1
- package/dist/serve.d.ts +2 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +12 -7
- package/dist/serve.js.map +1 -1
- package/dist/server/compatibility.js +1 -2
- package/dist/server/compatibility.js.map +1 -1
- package/dist/server/email.js +1 -2
- package/dist/server/email.js.map +1 -1
- package/dist/server/linter.js +1 -2
- package/dist/server/linter.js.map +1 -1
- package/dist/server/sfc-utils.js +1 -2
- package/dist/server/sfc-utils.js.map +1 -1
- package/dist/tests/render/_helpers.d.ts +6 -0
- package/dist/tests/render/_helpers.d.ts.map +1 -0
- package/dist/tests/render/_helpers.js +16 -0
- package/dist/tests/render/_helpers.js.map +1 -0
- package/dist/transformers/addAttributes.js +3 -4
- package/dist/transformers/addAttributes.js.map +1 -1
- package/dist/transformers/attributeToStyle.d.ts +27 -14
- package/dist/transformers/attributeToStyle.d.ts.map +1 -1
- package/dist/transformers/attributeToStyle.js +34 -20
- package/dist/transformers/attributeToStyle.js.map +1 -1
- package/dist/transformers/base.d.ts +66 -3
- package/dist/transformers/base.d.ts.map +1 -1
- package/dist/transformers/base.js +50 -24
- package/dist/transformers/base.js.map +1 -1
- package/dist/transformers/columnWidth.js +1 -2
- package/dist/transformers/columnWidth.js.map +1 -1
- package/dist/transformers/entities.d.ts +31 -2
- package/dist/transformers/entities.d.ts.map +1 -1
- package/dist/transformers/entities.js +39 -7
- package/dist/transformers/entities.js.map +1 -1
- package/dist/transformers/filters/defaults.js +1 -1
- package/dist/transformers/filters/defaults.js.map +1 -1
- package/dist/transformers/filters/index.d.ts +31 -10
- package/dist/transformers/filters/index.d.ts.map +1 -1
- package/dist/transformers/filters/index.js +36 -14
- package/dist/transformers/filters/index.js.map +1 -1
- package/dist/transformers/format.d.ts +14 -7
- package/dist/transformers/format.d.ts.map +1 -1
- package/dist/transformers/format.js +15 -11
- package/dist/transformers/format.js.map +1 -1
- package/dist/transformers/index.js +49 -29
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/inlineCss.d.ts +84 -0
- package/dist/transformers/inlineCss.d.ts.map +1 -0
- package/dist/transformers/{inlineCSS.js → inlineCss.js} +24 -14
- package/dist/transformers/inlineCss.js.map +1 -0
- package/dist/transformers/inlineLink.d.ts +26 -5
- package/dist/transformers/inlineLink.d.ts.map +1 -1
- package/dist/transformers/inlineLink.js +31 -7
- package/dist/transformers/inlineLink.js.map +1 -1
- package/dist/transformers/minify.d.ts +13 -9
- package/dist/transformers/minify.d.ts.map +1 -1
- package/dist/transformers/minify.js +14 -13
- package/dist/transformers/minify.js.map +1 -1
- package/dist/transformers/msoPlaceholders.js +1 -2
- package/dist/transformers/msoPlaceholders.js.map +1 -1
- package/dist/transformers/purgeCss.d.ts +43 -0
- package/dist/transformers/purgeCss.d.ts.map +1 -0
- package/dist/transformers/{purgeCSS.js → purgeCss.js} +32 -25
- package/dist/transformers/purgeCss.js.map +1 -0
- package/dist/transformers/removeAttributes.d.ts +43 -20
- package/dist/transformers/removeAttributes.d.ts.map +1 -1
- package/dist/transformers/removeAttributes.js +34 -27
- package/dist/transformers/removeAttributes.js.map +1 -1
- package/dist/transformers/replaceStrings.js +1 -1
- package/dist/transformers/replaceStrings.js.map +1 -1
- package/dist/transformers/safeClassNames.js +1 -2
- package/dist/transformers/safeClassNames.js.map +1 -1
- package/dist/transformers/shorthandCss.d.ts +47 -0
- package/dist/transformers/shorthandCss.d.ts.map +1 -0
- package/dist/transformers/shorthandCss.js +61 -0
- package/dist/transformers/shorthandCss.js.map +1 -0
- package/dist/transformers/sixHex.d.ts +16 -7
- package/dist/transformers/sixHex.d.ts.map +1 -1
- package/dist/transformers/sixHex.js +21 -9
- package/dist/transformers/sixHex.js.map +1 -1
- package/dist/transformers/tailwindComponent.js +1 -2
- package/dist/transformers/tailwindComponent.js.map +1 -1
- package/dist/transformers/tailwindcss.js +1 -2
- package/dist/transformers/tailwindcss.js.map +1 -1
- package/dist/transformers/urlQuery.d.ts +26 -14
- package/dist/transformers/urlQuery.d.ts.map +1 -1
- package/dist/transformers/urlQuery.js +32 -20
- package/dist/transformers/urlQuery.js.map +1 -1
- package/dist/types/config.d.ts +71 -19
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +1 -1
- package/dist/utils/ast/index.js +1 -2
- package/dist/utils/ast/parser.js +1 -2
- package/dist/utils/ast/parser.js.map +1 -1
- package/dist/utils/ast/serializer.js +1 -2
- package/dist/utils/ast/serializer.js.map +1 -1
- package/dist/utils/ast/walker.js +1 -1
- package/dist/utils/ast/walker.js.map +1 -1
- package/dist/utils/compileTailwindCss.js +1 -2
- package/dist/utils/compileTailwindCss.js.map +1 -1
- package/dist/utils/decodeStyleEntities.js +1 -1
- package/dist/utils/decodeStyleEntities.js.map +1 -1
- package/dist/utils/detect.js +1 -2
- package/dist/utils/detect.js.map +1 -1
- package/dist/utils/output-markers.d.ts +29 -0
- package/dist/utils/output-markers.d.ts.map +1 -0
- package/dist/utils/output-markers.js +68 -0
- package/dist/utils/output-markers.js.map +1 -0
- package/dist/utils/url.js +1 -2
- package/dist/utils/url.js.map +1 -1
- package/node_modules/maizzle/README.md +24 -0
- package/node_modules/maizzle/dist/commands/make/component.mjs +1 -1
- package/node_modules/maizzle/dist/commands/make/config.mjs +1 -1
- package/node_modules/maizzle/dist/commands/make/layout.mjs +3 -3
- package/node_modules/maizzle/dist/commands/make/scaffold.mjs +1 -1
- package/node_modules/maizzle/dist/commands/make/stubs/Layout.vue +146 -0
- package/node_modules/maizzle/dist/commands/make/stubs/component.vue +2 -4
- package/node_modules/maizzle/dist/commands/make/stubs/config.ts +1 -5
- package/node_modules/maizzle/dist/commands/make/template.mjs +1 -1
- package/node_modules/maizzle/dist/commands/new.mjs +29 -24
- package/node_modules/maizzle/dist/index.mjs +28 -8
- package/node_modules/maizzle/package.json +1 -1
- package/package.json +2 -2
- package/dist/transformers/inlineCSS.d.ts +0 -17
- package/dist/transformers/inlineCSS.d.ts.map +0 -1
- package/dist/transformers/inlineCSS.js.map +0 -1
- package/dist/transformers/purgeCSS.d.ts +0 -23
- package/dist/transformers/purgeCSS.d.ts.map +0 -1
- package/dist/transformers/purgeCSS.js.map +0 -1
- package/dist/transformers/shorthandCSS.d.ts +0 -24
- package/dist/transformers/shorthandCSS.d.ts.map +0 -1
- package/dist/transformers/shorthandCSS.js +0 -48
- package/dist/transformers/shorthandCSS.js.map +0 -1
- package/node_modules/maizzle/dist/commands/make/stubs/layout.vue +0 -39
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { parse } from "../utils/ast/parser.js";
|
|
2
2
|
import { serialize } from "../utils/ast/serializer.js";
|
|
3
3
|
import "../utils/ast/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { inlineLinkDom } from "./inlineLink.js";
|
|
5
5
|
import { tailwindComponent } from "./tailwindComponent.js";
|
|
6
6
|
import { tailwindcss } from "./tailwindcss.js";
|
|
7
7
|
import { safeClassNames } from "./safeClassNames.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { attributeToStyleDom } from "./attributeToStyle.js";
|
|
9
|
+
import { inlineCssDom } from "./inlineCss.js";
|
|
10
10
|
import { msoPlaceholders } from "./msoPlaceholders.js";
|
|
11
11
|
import { columnWidth } from "./columnWidth.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { removeAttributesDom } from "./removeAttributes.js";
|
|
13
|
+
import { shorthandCssDom } from "./shorthandCss.js";
|
|
14
|
+
import { sixHexDom } from "./sixHex.js";
|
|
15
15
|
import { addAttributes } from "./addAttributes.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
16
|
+
import { filtersDom } from "./filters/index.js";
|
|
17
|
+
import { baseDom } from "./base.js";
|
|
18
|
+
import { entitiesDom } from "./entities.js";
|
|
19
|
+
import { urlQueryDom } from "./urlQuery.js";
|
|
20
|
+
import { purgeCssDom } from "./purgeCss.js";
|
|
21
21
|
import { replaceStrings } from "./replaceStrings.js";
|
|
22
22
|
import { format } from "./format.js";
|
|
23
23
|
import { minify } from "./minify.js";
|
|
24
|
-
|
|
25
24
|
//#region src/transformers/index.ts
|
|
26
25
|
/**
|
|
27
26
|
* Run all Maizzle transformers on the rendered HTML.
|
|
@@ -60,10 +59,10 @@ async function runTransformers(html, config, filePath, doctype, tailwindBlocks)
|
|
|
60
59
|
if (toggles) {
|
|
61
60
|
const cssOver = {};
|
|
62
61
|
const htmlOver = {};
|
|
63
|
-
if (toggles.
|
|
64
|
-
if (toggles.
|
|
62
|
+
if (toggles.inlineCss === true) cssOver.inline = true;
|
|
63
|
+
if (toggles.purgeCss === true) cssOver.purge = true;
|
|
65
64
|
if (toggles.safeClassNames === true) cssOver.safe = true;
|
|
66
|
-
if (toggles.
|
|
65
|
+
if (toggles.shorthandCss === true) cssOver.shorthand = true;
|
|
67
66
|
if (toggles.sixHex === true) cssOver.sixHex = true;
|
|
68
67
|
if (toggles.prettify === true) htmlOver.format = true;
|
|
69
68
|
if (toggles.minify === true) htmlOver.minify = true;
|
|
@@ -81,33 +80,54 @@ async function runTransformers(html, config, filePath, doctype, tailwindBlocks)
|
|
|
81
80
|
};
|
|
82
81
|
}
|
|
83
82
|
let dom = parse(html);
|
|
84
|
-
dom = await
|
|
83
|
+
dom = await inlineLinkDom(dom, filePath);
|
|
85
84
|
if (tailwindBlocks?.length) dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath);
|
|
86
85
|
dom = await tailwindcss(dom, effective, filePath);
|
|
87
86
|
if (enabled("safeClassNames")) dom = safeClassNames(dom, effective.css);
|
|
88
|
-
if (enabled("attributeToStyle")) dom =
|
|
89
|
-
if (enabled("
|
|
87
|
+
if (enabled("attributeToStyle") && typeof effective.css?.inline === "object" && effective.css.inline.attributeToStyle) dom = attributeToStyleDom(dom, effective.css.inline.attributeToStyle);
|
|
88
|
+
if (enabled("inlineCss") && effective.css?.inline) {
|
|
89
|
+
const inlineOptions = typeof effective.css.inline === "object" ? effective.css.inline : {};
|
|
90
|
+
dom = inlineCssDom(dom, inlineOptions);
|
|
91
|
+
}
|
|
90
92
|
dom = msoPlaceholders(dom);
|
|
91
93
|
dom = columnWidth(dom);
|
|
92
|
-
if (enabled("removeAttributes"))
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
if (enabled("removeAttributes")) {
|
|
95
|
+
const removeRules = effective.html?.attributes?.remove;
|
|
96
|
+
dom = removeAttributesDom(dom, Array.isArray(removeRules) ? removeRules : []);
|
|
97
|
+
}
|
|
98
|
+
if (enabled("shorthandCss") && effective.css?.shorthand) {
|
|
99
|
+
const shorthandOptions = typeof effective.css.shorthand === "object" ? effective.css.shorthand : {};
|
|
100
|
+
dom = shorthandCssDom(dom, shorthandOptions);
|
|
101
|
+
}
|
|
102
|
+
if (enabled("sixHex") && effective.css?.sixHex !== false) dom = sixHexDom(dom);
|
|
95
103
|
if (enabled("addAttributes")) dom = addAttributes(dom, effective.html?.attributes);
|
|
96
|
-
if (enabled("filters")) dom =
|
|
97
|
-
if (enabled("baseURL")) dom =
|
|
98
|
-
if (enabled("urlQuery")
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
if (enabled("filters")) dom = filtersDom(dom, effective.filters);
|
|
105
|
+
if (enabled("baseURL") && effective.url?.base) dom = baseDom(dom, effective.url.base);
|
|
106
|
+
if (enabled("urlQuery") && effective.url?.query && Object.keys(effective.url.query).length > 0) {
|
|
107
|
+
const { _options: queryOptions, ...queryParams } = effective.url.query;
|
|
108
|
+
dom = urlQueryDom(dom, queryParams, queryOptions ?? {});
|
|
109
|
+
}
|
|
110
|
+
if (enabled("purgeCss") && effective.css?.purge) {
|
|
111
|
+
const purgeOptions = typeof effective.css.purge === "object" ? effective.css.purge : {};
|
|
112
|
+
dom = purgeCssDom(dom, purgeOptions);
|
|
113
|
+
}
|
|
114
|
+
if (enabled("entities")) dom = entitiesDom(dom, effective.html?.decodeEntities);
|
|
101
115
|
const isXhtml = doctype ? /xhtml/i.test(doctype) : false;
|
|
102
116
|
let result = serialize(dom, { selfClosingTags: isXhtml });
|
|
103
117
|
if (enabled("replaceStrings")) result = replaceStrings(result, effective);
|
|
104
118
|
const minifyWillRun = enabled("minify") && !!effective.html?.minify;
|
|
105
|
-
if (enabled("prettify") && !minifyWillRun
|
|
106
|
-
|
|
119
|
+
if (enabled("prettify") && !minifyWillRun && effective.html?.format) {
|
|
120
|
+
const formatOptions = typeof effective.html.format === "object" ? effective.html.format : {};
|
|
121
|
+
result = await format(result, formatOptions);
|
|
122
|
+
}
|
|
123
|
+
if (enabled("minify") && effective.html?.minify) {
|
|
124
|
+
const minifyOptions = typeof effective.html.minify === "object" ? effective.html.minify : {};
|
|
125
|
+
result = minify(result, minifyOptions);
|
|
126
|
+
}
|
|
107
127
|
if (!isXhtml) result = result.replace(/<!--\[if [^\]]*\]>[\s\S]*?<!\[endif\]-->|( \/>)/g, (match, selfClose) => selfClose ? ">" : match);
|
|
108
128
|
return result;
|
|
109
129
|
}
|
|
110
|
-
|
|
111
130
|
//#endregion
|
|
112
131
|
export { runTransformers };
|
|
132
|
+
|
|
113
133
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLink } from './inlineLink.ts'\nimport { tailwindComponent } from './tailwindComponent.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeClassNames } from './safeClassNames.ts'\nimport { attributeToStyle } from './attributeToStyle.ts'\nimport { inlineCSS } from './inlineCSS.ts'\nimport { msoPlaceholders } from './msoPlaceholders.ts'\nimport { columnWidth } from './columnWidth.ts'\nimport { removeAttributes } from './removeAttributes.ts'\nimport { shorthandCSS } from './shorthandCSS.ts'\nimport { sixHex } from './sixHex.ts'\nimport { addAttributes } from './addAttributes.ts'\nimport { filters } from './filters/index.ts'\nimport { base } from './base.ts'\nimport { entities } from './entities.ts'\nimport { urlQuery } from './urlQuery.ts'\nimport { purgeCSS } from './purgeCSS.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Six-digit HEX\n * 8. Add attributes\n * 9. Filters\n * 10. Base URL\n * 11. URL query\n * 12. Purge CSS (serializes/parses internally around email-comb)\n * 13. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 14. Replace strings\n * 15. Prettify\n * 16. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n doctype?: string,\n tailwindBlocks?: TailwindBlock[],\n): Promise<string> {\n // Per-transformer skip map — only honored when useTransformers is an object.\n // Whole-pipeline opt-out (`useTransformers === false`) is handled upstream\n // in build.ts / render so we never reach this function in that case.\n //\n // A toggle set to `true` *force-enables* its transformer for this run by\n // layering on the matching config slice (e.g. `prettify: true` sets\n // `html.format = true`). This only applies to transformers whose\n // enable flag is a plain boolean — data-driven ones (filters,\n // baseURL, urlQuery, etc.) need actual config values, so a\n // bare `true` for those is a no-op.\n const toggles = typeof config.useTransformers === 'object' ? config.useTransformers : null\n const enabled = (key: keyof NonNullable<typeof toggles>) => toggles?.[key] !== false\n\n let effective = config\n if (toggles) {\n const cssOver: Record<string, unknown> = {}\n const htmlOver: Record<string, unknown> = {}\n if (toggles.inlineCSS === true) cssOver.inline = true\n if (toggles.purgeCSS === true) cssOver.purge = true\n if (toggles.safeClassNames === true) cssOver.safe = true\n if (toggles.shorthandCSS === true) cssOver.shorthand = true\n if (toggles.sixHex === true) cssOver.sixHex = true\n if (toggles.prettify === true) htmlOver.format = true\n if (toggles.minify === true) htmlOver.minify = true\n if (toggles.entities === true) htmlOver.decodeEntities = true\n\n if (Object.keys(cssOver).length || Object.keys(htmlOver).length) {\n effective = {\n ...config,\n css: { ...config.css, ...cssOver },\n html: { ...config.html, ...htmlOver },\n }\n }\n }\n\n // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLink(dom, filePath)\n\n // 0.5. <Tailwind> component — compile per-block scoped CSS, inject into <head>\n if (tailwindBlocks?.length) {\n dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath)\n }\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, effective, filePath)\n\n // 2. Safe class names\n if (enabled('safeClassNames')) dom = safeClassNames(dom, effective.css)\n\n // 3. Attribute to style\n if (enabled('attributeToStyle')) dom = attributeToStyle(dom, effective.css)\n\n // 4. CSS inliner (serializes/parses internally around juice)\n if (enabled('inlineCSS')) dom = inlineCSS(dom, effective.css)\n\n // 4.5. Resolve MSO placeholders (table width + td style) from inlined CSS\n dom = msoPlaceholders(dom)\n\n // 4.6. Resolve Column min-width placeholders from nearest sized ancestor\n dom = columnWidth(dom)\n\n // 5. Remove attributes\n if (enabled('removeAttributes')) dom = removeAttributes(dom, effective.html?.attributes)\n\n // 6. Shorthand CSS\n if (enabled('shorthandCSS')) dom = shorthandCSS(dom, effective.css)\n\n // 7. Six-digit HEX\n if (enabled('sixHex')) dom = sixHex(dom, effective.css)\n\n // 8. Add attributes\n if (enabled('addAttributes')) dom = addAttributes(dom, effective.html?.attributes)\n\n // 9. Filters\n if (enabled('filters')) dom = filters(dom, effective.filters)\n\n // 10. Base URL (serializes/parses internally for VML/MSO regex passes)\n if (enabled('baseURL')) dom = base(dom, effective.url)\n\n // 11. URL query\n if (enabled('urlQuery')) dom = urlQuery(dom, effective.url)\n\n // 12. Purge CSS (serializes/parses internally around email-comb)\n if (enabled('purgeCSS')) dom = purgeCSS(dom, effective.css)\n\n // 13. Entities\n if (enabled('entities')) dom = entities(dom, effective.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n const isXhtml = doctype ? /xhtml/i.test(doctype) : false\n let result = serialize(dom, { selfClosingTags: isXhtml })\n\n // 14. Replace strings\n if (enabled('replaceStrings')) result = replaceStrings(result, effective)\n\n // 15. Format — skipped when `minify` is enabled\n const minifyWillRun = enabled('minify') && !!effective.html?.minify\n if (enabled('prettify') && !minifyWillRun) result = await format(result, effective)\n\n // 16. Minify\n if (enabled('minify')) result = minify(result, effective)\n\n // Strip self-closing slashes for HTML5 doctypes, but preserve content\n // inside MSO conditional comments (which are XML-ish and case/syntax sensitive).\n if (!isXhtml) {\n result = result.replace(\n /<!--\\[if [^\\]]*\\]>[\\s\\S]*?<!\\[endif\\]-->|( \\/>)/g,\n (match, selfClose) => selfClose ? '>' : match,\n )\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,eAAsB,gBACpB,MACA,QACA,UACA,SACA,gBACiB;CAWjB,MAAM,UAAU,OAAO,OAAO,oBAAoB,WAAW,OAAO,kBAAkB;CACtF,MAAM,WAAW,QAA2C,UAAU,SAAS;CAE/E,IAAI,YAAY;AAChB,KAAI,SAAS;EACX,MAAM,UAAmC,EAAE;EAC3C,MAAM,WAAoC,EAAE;AAC5C,MAAI,QAAQ,cAAc,KAAM,SAAQ,SAAS;AACjD,MAAI,QAAQ,aAAa,KAAM,SAAQ,QAAQ;AAC/C,MAAI,QAAQ,mBAAmB,KAAM,SAAQ,OAAO;AACpD,MAAI,QAAQ,iBAAiB,KAAM,SAAQ,YAAY;AACvD,MAAI,QAAQ,WAAW,KAAM,SAAQ,SAAS;AAC9C,MAAI,QAAQ,aAAa,KAAM,UAAS,SAAS;AACjD,MAAI,QAAQ,WAAW,KAAM,UAAS,SAAS;AAC/C,MAAI,QAAQ,aAAa,KAAM,UAAS,iBAAiB;AAEzD,MAAI,OAAO,KAAK,QAAQ,CAAC,UAAU,OAAO,KAAK,SAAS,CAAC,OACvD,aAAY;GACV,GAAG;GACH,KAAK;IAAE,GAAG,OAAO;IAAK,GAAG;IAAS;GAClC,MAAM;IAAE,GAAG,OAAO;IAAM,GAAG;IAAU;GACtC;;CAKL,IAAI,MAAM,MAAM,KAAK;AAGrB,OAAM,MAAM,WAAW,KAAK,SAAS;AAGrC,KAAI,gBAAgB,OAClB,OAAM,MAAM,kBAAkB,KAAK,gBAAgB,WAAW,SAAS;AAIzE,OAAM,MAAM,YAAY,KAAK,WAAW,SAAS;AAGjD,KAAI,QAAQ,iBAAiB,CAAE,OAAM,eAAe,KAAK,UAAU,IAAI;AAGvE,KAAI,QAAQ,mBAAmB,CAAE,OAAM,iBAAiB,KAAK,UAAU,IAAI;AAG3E,KAAI,QAAQ,YAAY,CAAE,OAAM,UAAU,KAAK,UAAU,IAAI;AAG7D,OAAM,gBAAgB,IAAI;AAG1B,OAAM,YAAY,IAAI;AAGtB,KAAI,QAAQ,mBAAmB,CAAE,OAAM,iBAAiB,KAAK,UAAU,MAAM,WAAW;AAGxF,KAAI,QAAQ,eAAe,CAAE,OAAM,aAAa,KAAK,UAAU,IAAI;AAGnE,KAAI,QAAQ,SAAS,CAAE,OAAM,OAAO,KAAK,UAAU,IAAI;AAGvD,KAAI,QAAQ,gBAAgB,CAAE,OAAM,cAAc,KAAK,UAAU,MAAM,WAAW;AAGlF,KAAI,QAAQ,UAAU,CAAE,OAAM,QAAQ,KAAK,UAAU,QAAQ;AAG7D,KAAI,QAAQ,UAAU,CAAE,OAAM,KAAK,KAAK,UAAU,IAAI;AAGtD,KAAI,QAAQ,WAAW,CAAE,OAAM,SAAS,KAAK,UAAU,IAAI;AAG3D,KAAI,QAAQ,WAAW,CAAE,OAAM,SAAS,KAAK,UAAU,IAAI;AAG3D,KAAI,QAAQ,WAAW,CAAE,OAAM,SAAS,KAAK,UAAU,MAAM,eAAe;CAG5E,MAAM,UAAU,UAAU,SAAS,KAAK,QAAQ,GAAG;CACnD,IAAI,SAAS,UAAU,KAAK,EAAE,iBAAiB,SAAS,CAAC;AAGzD,KAAI,QAAQ,iBAAiB,CAAE,UAAS,eAAe,QAAQ,UAAU;CAGzE,MAAM,gBAAgB,QAAQ,SAAS,IAAI,CAAC,CAAC,UAAU,MAAM;AAC7D,KAAI,QAAQ,WAAW,IAAI,CAAC,cAAe,UAAS,MAAM,OAAO,QAAQ,UAAU;AAGnF,KAAI,QAAQ,SAAS,CAAE,UAAS,OAAO,QAAQ,UAAU;AAIzD,KAAI,CAAC,QACH,UAAS,OAAO,QACd,qDACC,OAAO,cAAc,YAAY,MAAM,MACzC;AAGH,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLinkDom } from './inlineLink.ts'\nimport { tailwindComponent } from './tailwindComponent.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeClassNames } from './safeClassNames.ts'\nimport { attributeToStyleDom } from './attributeToStyle.ts'\nimport { inlineCssDom } from './inlineCss.ts'\nimport { msoPlaceholders } from './msoPlaceholders.ts'\nimport { columnWidth } from './columnWidth.ts'\nimport { removeAttributesDom } from './removeAttributes.ts'\nimport { shorthandCssDom } from './shorthandCss.ts'\nimport { sixHexDom } from './sixHex.ts'\nimport { addAttributes } from './addAttributes.ts'\nimport { filtersDom } from './filters/index.ts'\nimport { baseDom } from './base.ts'\nimport { entitiesDom } from './entities.ts'\nimport { urlQueryDom } from './urlQuery.ts'\nimport { purgeCssDom } from './purgeCss.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Six-digit HEX\n * 8. Add attributes\n * 9. Filters\n * 10. Base URL\n * 11. URL query\n * 12. Purge CSS (serializes/parses internally around email-comb)\n * 13. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 14. Replace strings\n * 15. Prettify\n * 16. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n doctype?: string,\n tailwindBlocks?: TailwindBlock[],\n): Promise<string> {\n // Per-transformer skip map — only honored when useTransformers is an object.\n // Whole-pipeline opt-out (`useTransformers === false`) is handled upstream\n // in build.ts / render so we never reach this function in that case.\n //\n // A toggle set to `true` *force-enables* its transformer for this run by\n // layering on the matching config slice (e.g. `prettify: true` sets\n // `html.format = true`). This only applies to transformers whose\n // enable flag is a plain boolean — data-driven ones (filters,\n // baseURL, urlQuery, etc.) need actual config values, so a\n // bare `true` for those is a no-op.\n const toggles = typeof config.useTransformers === 'object' ? config.useTransformers : null\n const enabled = (key: keyof NonNullable<typeof toggles>) => toggles?.[key] !== false\n\n let effective = config\n if (toggles) {\n const cssOver: Record<string, unknown> = {}\n const htmlOver: Record<string, unknown> = {}\n if (toggles.inlineCss === true) cssOver.inline = true\n if (toggles.purgeCss === true) cssOver.purge = true\n if (toggles.safeClassNames === true) cssOver.safe = true\n if (toggles.shorthandCss === true) cssOver.shorthand = true\n if (toggles.sixHex === true) cssOver.sixHex = true\n if (toggles.prettify === true) htmlOver.format = true\n if (toggles.minify === true) htmlOver.minify = true\n if (toggles.entities === true) htmlOver.decodeEntities = true\n\n if (Object.keys(cssOver).length || Object.keys(htmlOver).length) {\n effective = {\n ...config,\n css: { ...config.css, ...cssOver },\n html: { ...config.html, ...htmlOver },\n }\n }\n }\n\n // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLinkDom(dom, filePath)\n\n // 0.5. <Tailwind> component — compile per-block scoped CSS, inject into <head>\n if (tailwindBlocks?.length) {\n dom = await tailwindComponent(dom, tailwindBlocks, effective, filePath)\n }\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, effective, filePath)\n\n // 2. Safe class names\n if (enabled('safeClassNames')) dom = safeClassNames(dom, effective.css)\n\n // 3. Attribute to style\n if (enabled('attributeToStyle') && typeof effective.css?.inline === 'object' && effective.css.inline.attributeToStyle) {\n dom = attributeToStyleDom(dom, effective.css.inline.attributeToStyle)\n }\n\n // 4. CSS inliner (serializes/parses internally around juice)\n if (enabled('inlineCss') && effective.css?.inline) {\n const inlineOptions = typeof effective.css.inline === 'object' ? effective.css.inline : {}\n dom = inlineCssDom(dom, inlineOptions)\n }\n\n // 4.5. Resolve MSO placeholders (table width + td style) from inlined CSS\n dom = msoPlaceholders(dom)\n\n // 4.6. Resolve Column min-width placeholders from nearest sized ancestor\n dom = columnWidth(dom)\n\n // 5. Remove attributes\n if (enabled('removeAttributes')) {\n const removeRules = effective.html?.attributes?.remove\n dom = removeAttributesDom(dom, Array.isArray(removeRules) ? removeRules : [])\n }\n\n // 6. Shorthand CSS\n if (enabled('shorthandCss') && effective.css?.shorthand) {\n const shorthandOptions = typeof effective.css.shorthand === 'object' ? effective.css.shorthand : {}\n dom = shorthandCssDom(dom, shorthandOptions)\n }\n\n // 7. Six-digit HEX\n if (enabled('sixHex') && effective.css?.sixHex !== false) dom = sixHexDom(dom)\n\n // 8. Add attributes\n if (enabled('addAttributes')) dom = addAttributes(dom, effective.html?.attributes)\n\n // 9. Filters\n if (enabled('filters')) dom = filtersDom(dom, effective.filters)\n\n // 10. Base URL (serializes/parses internally for VML/MSO regex passes)\n if (enabled('baseURL') && effective.url?.base) dom = baseDom(dom, effective.url.base)\n\n // 11. URL query\n if (enabled('urlQuery') && effective.url?.query && Object.keys(effective.url.query).length > 0) {\n const { _options: queryOptions, ...queryParams } = effective.url.query as Record<string, unknown>\n dom = urlQueryDom(dom, queryParams, (queryOptions ?? {}) as import('../types/config.ts').UrlQueryOptions)\n }\n\n // 12. Remove unused CSS (serializes/parses internally around email-comb)\n if (enabled('purgeCss') && effective.css?.purge) {\n const purgeOptions = typeof effective.css.purge === 'object' ? effective.css.purge : {}\n dom = purgeCssDom(dom, purgeOptions)\n }\n\n // 13. Entities\n if (enabled('entities')) dom = entitiesDom(dom, effective.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n const isXhtml = doctype ? /xhtml/i.test(doctype) : false\n let result = serialize(dom, { selfClosingTags: isXhtml })\n\n // 14. Replace strings\n if (enabled('replaceStrings')) result = replaceStrings(result, effective)\n\n // 15. Format — skipped when `minify` is enabled\n const minifyWillRun = enabled('minify') && !!effective.html?.minify\n if (enabled('prettify') && !minifyWillRun && effective.html?.format) {\n const formatOptions = typeof effective.html.format === 'object' ? effective.html.format : {}\n result = await format(result, formatOptions)\n }\n\n // 16. Minify\n if (enabled('minify') && effective.html?.minify) {\n const minifyOptions = typeof effective.html.minify === 'object' ? effective.html.minify : {}\n result = minify(result, minifyOptions)\n }\n\n // Strip self-closing slashes for HTML5 doctypes, but preserve content\n // inside MSO conditional comments (which are XML-ish and case/syntax sensitive).\n if (!isXhtml) {\n result = result.replace(\n /<!--\\[if [^\\]]*\\]>[\\s\\S]*?<!\\[endif\\]-->|( \\/>)/g,\n (match, selfClose) => selfClose ? '>' : match,\n )\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,eAAsB,gBACpB,MACA,QACA,UACA,SACA,gBACiB;CAWjB,MAAM,UAAU,OAAO,OAAO,oBAAoB,WAAW,OAAO,kBAAkB;CACtF,MAAM,WAAW,QAA2C,UAAU,SAAS;CAE/E,IAAI,YAAY;CAChB,IAAI,SAAS;EACX,MAAM,UAAmC,EAAE;EAC3C,MAAM,WAAoC,EAAE;EAC5C,IAAI,QAAQ,cAAc,MAAM,QAAQ,SAAS;EACjD,IAAI,QAAQ,aAAa,MAAM,QAAQ,QAAQ;EAC/C,IAAI,QAAQ,mBAAmB,MAAM,QAAQ,OAAO;EACpD,IAAI,QAAQ,iBAAiB,MAAM,QAAQ,YAAY;EACvD,IAAI,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC9C,IAAI,QAAQ,aAAa,MAAM,SAAS,SAAS;EACjD,IAAI,QAAQ,WAAW,MAAM,SAAS,SAAS;EAC/C,IAAI,QAAQ,aAAa,MAAM,SAAS,iBAAiB;EAEzD,IAAI,OAAO,KAAK,QAAQ,CAAC,UAAU,OAAO,KAAK,SAAS,CAAC,QACvD,YAAY;GACV,GAAG;GACH,KAAK;IAAE,GAAG,OAAO;IAAK,GAAG;IAAS;GAClC,MAAM;IAAE,GAAG,OAAO;IAAM,GAAG;IAAU;GACtC;;CAKL,IAAI,MAAM,MAAM,KAAK;CAGrB,MAAM,MAAM,cAAc,KAAK,SAAS;CAGxC,IAAI,gBAAgB,QAClB,MAAM,MAAM,kBAAkB,KAAK,gBAAgB,WAAW,SAAS;CAIzE,MAAM,MAAM,YAAY,KAAK,WAAW,SAAS;CAGjD,IAAI,QAAQ,iBAAiB,EAAE,MAAM,eAAe,KAAK,UAAU,IAAI;CAGvE,IAAI,QAAQ,mBAAmB,IAAI,OAAO,UAAU,KAAK,WAAW,YAAY,UAAU,IAAI,OAAO,kBACnG,MAAM,oBAAoB,KAAK,UAAU,IAAI,OAAO,iBAAiB;CAIvE,IAAI,QAAQ,YAAY,IAAI,UAAU,KAAK,QAAQ;EACjD,MAAM,gBAAgB,OAAO,UAAU,IAAI,WAAW,WAAW,UAAU,IAAI,SAAS,EAAE;EAC1F,MAAM,aAAa,KAAK,cAAc;;CAIxC,MAAM,gBAAgB,IAAI;CAG1B,MAAM,YAAY,IAAI;CAGtB,IAAI,QAAQ,mBAAmB,EAAE;EAC/B,MAAM,cAAc,UAAU,MAAM,YAAY;EAChD,MAAM,oBAAoB,KAAK,MAAM,QAAQ,YAAY,GAAG,cAAc,EAAE,CAAC;;CAI/E,IAAI,QAAQ,eAAe,IAAI,UAAU,KAAK,WAAW;EACvD,MAAM,mBAAmB,OAAO,UAAU,IAAI,cAAc,WAAW,UAAU,IAAI,YAAY,EAAE;EACnG,MAAM,gBAAgB,KAAK,iBAAiB;;CAI9C,IAAI,QAAQ,SAAS,IAAI,UAAU,KAAK,WAAW,OAAO,MAAM,UAAU,IAAI;CAG9E,IAAI,QAAQ,gBAAgB,EAAE,MAAM,cAAc,KAAK,UAAU,MAAM,WAAW;CAGlF,IAAI,QAAQ,UAAU,EAAE,MAAM,WAAW,KAAK,UAAU,QAAQ;CAGhE,IAAI,QAAQ,UAAU,IAAI,UAAU,KAAK,MAAM,MAAM,QAAQ,KAAK,UAAU,IAAI,KAAK;CAGrF,IAAI,QAAQ,WAAW,IAAI,UAAU,KAAK,SAAS,OAAO,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,GAAG;EAC9F,MAAM,EAAE,UAAU,cAAc,GAAG,gBAAgB,UAAU,IAAI;EACjE,MAAM,YAAY,KAAK,aAAc,gBAAgB,EAAE,CAAkD;;CAI3G,IAAI,QAAQ,WAAW,IAAI,UAAU,KAAK,OAAO;EAC/C,MAAM,eAAe,OAAO,UAAU,IAAI,UAAU,WAAW,UAAU,IAAI,QAAQ,EAAE;EACvF,MAAM,YAAY,KAAK,aAAa;;CAItC,IAAI,QAAQ,WAAW,EAAE,MAAM,YAAY,KAAK,UAAU,MAAM,eAAe;CAG/E,MAAM,UAAU,UAAU,SAAS,KAAK,QAAQ,GAAG;CACnD,IAAI,SAAS,UAAU,KAAK,EAAE,iBAAiB,SAAS,CAAC;CAGzD,IAAI,QAAQ,iBAAiB,EAAE,SAAS,eAAe,QAAQ,UAAU;CAGzE,MAAM,gBAAgB,QAAQ,SAAS,IAAI,CAAC,CAAC,UAAU,MAAM;CAC7D,IAAI,QAAQ,WAAW,IAAI,CAAC,iBAAiB,UAAU,MAAM,QAAQ;EACnE,MAAM,gBAAgB,OAAO,UAAU,KAAK,WAAW,WAAW,UAAU,KAAK,SAAS,EAAE;EAC5F,SAAS,MAAM,OAAO,QAAQ,cAAc;;CAI9C,IAAI,QAAQ,SAAS,IAAI,UAAU,MAAM,QAAQ;EAC/C,MAAM,gBAAgB,OAAO,UAAU,KAAK,WAAW,WAAW,UAAU,KAAK,SAAS,EAAE;EAC5F,SAAS,OAAO,QAAQ,cAAc;;CAKxC,IAAI,CAAC,SACH,SAAS,OAAO,QACd,qDACC,OAAO,cAAc,YAAY,MAAM,MACzC;CAGH,OAAO"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ChildNode } from "domhandler";
|
|
2
|
+
import { Options } from "juice";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/inlineCss.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Options for the `inlineCss` transformer. Accepts every Juice option plus a
|
|
7
|
+
* handful of Maizzle-specific extras.
|
|
8
|
+
*/
|
|
9
|
+
interface InlineCssOptions extends Options {
|
|
10
|
+
/**
|
|
11
|
+
* Convert `0px`, `0em` etc. to `0` in inline styles.
|
|
12
|
+
*
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
preferUnitlessValues?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* CSS selectors to preserve in `<style>` tags, even after inlining.
|
|
18
|
+
* Mapped to Juice's `preservedSelectors` option.
|
|
19
|
+
*
|
|
20
|
+
* @default []
|
|
21
|
+
*/
|
|
22
|
+
safelist?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Additional CSS string to inline alongside `<style>` tag contents.
|
|
25
|
+
* Mapped to Juice's `extraCss` option.
|
|
26
|
+
*/
|
|
27
|
+
customCSS?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Duplicate CSS properties to HTML attributes.
|
|
30
|
+
* Mapped to Juice's static `styleToAttribute` property.
|
|
31
|
+
*/
|
|
32
|
+
styleToAttribute?: Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* CSS properties to exclude from inlining.
|
|
35
|
+
* Mapped to Juice's static `excludedProperties` property.
|
|
36
|
+
*/
|
|
37
|
+
excludedProperties?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Elements that can receive `width` HTML attributes.
|
|
40
|
+
* Mapped to Juice's static `widthElements` property.
|
|
41
|
+
*
|
|
42
|
+
* @default ['img', 'video']
|
|
43
|
+
*/
|
|
44
|
+
widthElements?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Elements that can receive `height` HTML attributes.
|
|
47
|
+
* Mapped to Juice's static `heightElements` property.
|
|
48
|
+
*
|
|
49
|
+
* @default ['img', 'video']
|
|
50
|
+
*/
|
|
51
|
+
heightElements?: string[];
|
|
52
|
+
/**
|
|
53
|
+
* Template language code blocks to preserve during inlining.
|
|
54
|
+
* Mapped to Juice's static `codeBlocks` property.
|
|
55
|
+
*/
|
|
56
|
+
codeBlocks?: Record<string, {
|
|
57
|
+
start: string;
|
|
58
|
+
end: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Inline CSS from `<style>` tags into `style` attributes on matching elements.
|
|
63
|
+
*
|
|
64
|
+
* @param html HTML string to transform.
|
|
65
|
+
* @param options Juice options plus Maizzle-specific extras.
|
|
66
|
+
* @returns The transformed HTML string.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* import { inlineCss } from '@maizzle/framework'
|
|
70
|
+
*
|
|
71
|
+
* const out = inlineCss('<style>.red{color:red}</style><p class="red">x</p>', {
|
|
72
|
+
* removeStyleTags: true,
|
|
73
|
+
* })
|
|
74
|
+
*/
|
|
75
|
+
declare function inlineCss(html: string, options?: InlineCssOptions): string;
|
|
76
|
+
/**
|
|
77
|
+
* DOM-form of {@link inlineCss} used by the internal transformer pipeline.
|
|
78
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids the redundant
|
|
79
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
80
|
+
*/
|
|
81
|
+
declare function inlineCssDom(dom: ChildNode[], options?: InlineCssOptions): ChildNode[];
|
|
82
|
+
//#endregion
|
|
83
|
+
export { InlineCssOptions, inlineCss, inlineCssDom };
|
|
84
|
+
//# sourceMappingURL=inlineCss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineCss.d.ts","names":[],"sources":["../../src/transformers/inlineCss.ts"],"mappings":";;;;;;AASA;;UAAiB,gBAAA,SAAyB,OAAA;EAuBrB;;;;;EAjBnB,oBAAA;EAAA;;;;;;EAOA,QAAA;EA6BA;;;;EAxBA,SAAA;EA6BgD;;AAiBlD;;EAzCE,gBAAA,GAAmB,MAAA;EAyCiD;;;;EApCpE,kBAAA;EAoCoE;AAStE;;;;;EAtCE,aAAA;EAsCuF;;;;;;EA/BvF,cAAA;EA+BuF;;;;EA1BvF,UAAA,GAAa,MAAA;IAAiB,KAAA;IAAe,GAAA;EAAA;AAAA;;;;;;;;;;;;;;;iBAiB/B,SAAA,CAAU,IAAA,UAAc,OAAA,GAAS,gBAAA;;;;;;iBASjC,YAAA,CAAa,GAAA,EAAK,SAAA,IAAa,OAAA,GAAS,gBAAA,GAAwB,SAAA"}
|
|
@@ -3,21 +3,31 @@ import { walk } from "../utils/ast/walker.js";
|
|
|
3
3
|
import { serialize } from "../utils/ast/serializer.js";
|
|
4
4
|
import "../utils/ast/index.js";
|
|
5
5
|
import juice from "juice";
|
|
6
|
-
|
|
7
|
-
//#region src/transformers/inlineCSS.ts
|
|
6
|
+
//#region src/transformers/inlineCss.ts
|
|
8
7
|
/**
|
|
9
|
-
* Inline CSS
|
|
8
|
+
* Inline CSS from `<style>` tags into `style` attributes on matching elements.
|
|
9
|
+
*
|
|
10
|
+
* @param html HTML string to transform.
|
|
11
|
+
* @param options Juice options plus Maizzle-specific extras.
|
|
12
|
+
* @returns The transformed HTML string.
|
|
10
13
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { inlineCss } from '@maizzle/framework'
|
|
13
16
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
17
|
+
* const out = inlineCss('<style>.red{color:red}</style><p class="red">x</p>', {
|
|
18
|
+
* removeStyleTags: true,
|
|
19
|
+
* })
|
|
16
20
|
*/
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
function inlineCss(html, options = {}) {
|
|
22
|
+
return serialize(inlineCssDom(parse(html), options));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* DOM-form of {@link inlineCss} used by the internal transformer pipeline.
|
|
26
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids the redundant
|
|
27
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
28
|
+
*/
|
|
29
|
+
function inlineCssDom(dom, options = {}) {
|
|
30
|
+
const { preferUnitlessValues = true, safelist, customCSS = "", styleToAttribute, excludedProperties, widthElements, heightElements, codeBlocks, ...juicePassthrough } = options;
|
|
21
31
|
juice.styleToAttribute = styleToAttribute ?? {};
|
|
22
32
|
juice.excludedProperties = ["--tw-shadow", ...excludedProperties ?? []];
|
|
23
33
|
juice.widthElements = (widthElements ?? ["img", "video"]).map((i) => i.toUpperCase());
|
|
@@ -75,7 +85,7 @@ function inlineCSS(dom, config = {}) {
|
|
|
75
85
|
});
|
|
76
86
|
return result;
|
|
77
87
|
}
|
|
78
|
-
|
|
79
88
|
//#endregion
|
|
80
|
-
export {
|
|
81
|
-
|
|
89
|
+
export { inlineCss, inlineCssDom };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=inlineCss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineCss.js","names":[],"sources":["../../src/transformers/inlineCss.ts"],"sourcesContent":["import juice from 'juice'\nimport { walk, parse, serialize } from '../utils/ast/index.ts'\nimport type { ChildNode, Element } from 'domhandler'\nimport type { Options as JuiceOptions } from 'juice'\n\n/**\n * Options for the `inlineCss` transformer. Accepts every Juice option plus a\n * handful of Maizzle-specific extras.\n */\nexport interface InlineCssOptions extends JuiceOptions {\n /**\n * Convert `0px`, `0em` etc. to `0` in inline styles.\n *\n * @default true\n */\n preferUnitlessValues?: boolean\n /**\n * CSS selectors to preserve in `<style>` tags, even after inlining.\n * Mapped to Juice's `preservedSelectors` option.\n *\n * @default []\n */\n safelist?: string[]\n /**\n * Additional CSS string to inline alongside `<style>` tag contents.\n * Mapped to Juice's `extraCss` option.\n */\n customCSS?: string\n /**\n * Duplicate CSS properties to HTML attributes.\n * Mapped to Juice's static `styleToAttribute` property.\n */\n styleToAttribute?: Record<string, string>\n /**\n * CSS properties to exclude from inlining.\n * Mapped to Juice's static `excludedProperties` property.\n */\n excludedProperties?: string[]\n /**\n * Elements that can receive `width` HTML attributes.\n * Mapped to Juice's static `widthElements` property.\n *\n * @default ['img', 'video']\n */\n widthElements?: string[]\n /**\n * Elements that can receive `height` HTML attributes.\n * Mapped to Juice's static `heightElements` property.\n *\n * @default ['img', 'video']\n */\n heightElements?: string[]\n /**\n * Template language code blocks to preserve during inlining.\n * Mapped to Juice's static `codeBlocks` property.\n */\n codeBlocks?: Record<string, { start: string; end: string }>\n}\n\n/**\n * Inline CSS from `<style>` tags into `style` attributes on matching elements.\n *\n * @param html HTML string to transform.\n * @param options Juice options plus Maizzle-specific extras.\n * @returns The transformed HTML string.\n *\n * @example\n * import { inlineCss } from '@maizzle/framework'\n *\n * const out = inlineCss('<style>.red{color:red}</style><p class=\"red\">x</p>', {\n * removeStyleTags: true,\n * })\n */\nexport function inlineCss(html: string, options: InlineCssOptions = {}): string {\n return serialize(inlineCssDom(parse(html), options))\n}\n\n/**\n * DOM-form of {@link inlineCss} used by the internal transformer pipeline.\n * Takes a parsed DOM, returns a parsed DOM — avoids the redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport function inlineCssDom(dom: ChildNode[], options: InlineCssOptions = {}): ChildNode[] {\n const {\n preferUnitlessValues = true,\n safelist,\n customCSS = '',\n styleToAttribute,\n excludedProperties,\n widthElements,\n heightElements,\n codeBlocks,\n ...juicePassthrough\n } = options\n\n // Configure Juice static properties\n juice.styleToAttribute = styleToAttribute ?? {}\n juice.excludedProperties = ['--tw-shadow', ...(excludedProperties ?? [])]\n juice.widthElements = (widthElements ?? ['img', 'video']).map(i => i.toUpperCase()) as unknown as HTMLElement[]\n juice.heightElements = (heightElements ?? ['img', 'video']).map(i => i.toUpperCase()) as unknown as HTMLElement[]\n\n // Add custom code blocks\n if (codeBlocks && typeof codeBlocks === 'object') {\n Object.entries(codeBlocks).forEach(([key, value]) => {\n if (value.start && value.end) {\n juice.codeBlocks[key] = value\n }\n })\n }\n\n // Handle style tags with embed attributes.\n // We add a marker attribute that persists through the pipeline,\n // then restore data-embed from it after Juice runs.\n walk(dom, (node) => {\n const el = node as Element\n if (el.name === 'style' && el.attribs) {\n // Sync data-embed ↔ embed. Use `in` so presence-only attrs\n // (<style embed> → attribs.embed === '') still count.\n if ('embed' in el.attribs && !('data-embed' in el.attribs)) {\n el.attribs['data-embed'] = ''\n }\n if ('data-embed' in el.attribs && !('embed' in el.attribs)) {\n el.attribs.embed = ''\n }\n\n // Add marker that persists through the pipeline\n if ('data-embed' in el.attribs) {\n el.attribs['data-maizzle-embed'] = ''\n }\n }\n })\n\n // Serialize for juice (juice requires a string)\n const serialized = serialize(dom)\n\n let inlinedHtml: string\n\n try {\n const juiceOptions: JuiceOptions = {\n removeStyleTags: juicePassthrough.removeStyleTags ?? false,\n removeInlinedSelectors: juicePassthrough.removeInlinedSelectors ?? true,\n applyWidthAttributes: juicePassthrough.applyWidthAttributes ?? true,\n applyHeightAttributes: juicePassthrough.applyHeightAttributes ?? true,\n preservedSelectors: safelist ?? [],\n ...customCSS ? { extraCss: customCSS } : {},\n inlineDuplicateProperties: juicePassthrough.inlineDuplicateProperties ?? true,\n ...juicePassthrough,\n }\n\n inlinedHtml = juice(serialized, juiceOptions)\n } catch {\n // If Juice fails, return the dom unchanged\n return dom\n }\n\n // Post-process for preferUnitlessValues\n const result = parse(inlinedHtml)\n\n walk(result, (node) => {\n const el = node as Element\n if (el.attribs?.style) {\n // Normalize style formatting: ensure spaces after : and ;\n let style = el.attribs.style\n .replace(/:\\s*/g, ': ')\n .replace(/;\\s*/g, '; ')\n .trimEnd()\n\n // Ensure trailing semicolon\n if (!style.endsWith(';')) {\n style += ';'\n }\n\n if (preferUnitlessValues) {\n style = style.replace(\n /\\b0(px|rem|em|%|vh|vw|vmin|vmax|in|cm|mm|pt|pc|ex|ch)\\b/g,\n '0'\n )\n }\n\n el.attribs.style = style\n }\n })\n\n /**\n * Restore `embed` from our marker so the purge step can detect\n * these tags and skip them. Drop `data-embed` (juice's name)\n * since it's redundant once `embed` is back, and let purge\n * strip `embed` itself at the end of its run.\n */\n walk(result, (node) => {\n const el = node as Element\n if (el.name === 'style' && el.attribs && 'data-maizzle-embed' in el.attribs) {\n el.attribs.embed = ''\n delete el.attribs['data-embed']\n delete el.attribs['data-maizzle-embed']\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,UAAU,MAAc,UAA4B,EAAE,EAAU;CAC9E,OAAO,UAAU,aAAa,MAAM,KAAK,EAAE,QAAQ,CAAC;;;;;;;AAQtD,SAAgB,aAAa,KAAkB,UAA4B,EAAE,EAAe;CAC1F,MAAM,EACJ,uBAAuB,MACvB,UACA,YAAY,IACZ,kBACA,oBACA,eACA,gBACA,YACA,GAAG,qBACD;CAGJ,MAAM,mBAAmB,oBAAoB,EAAE;CAC/C,MAAM,qBAAqB,CAAC,eAAe,GAAI,sBAAsB,EAAE,CAAE;CACzE,MAAM,iBAAiB,iBAAiB,CAAC,OAAO,QAAQ,EAAE,KAAI,MAAK,EAAE,aAAa,CAAC;CACnF,MAAM,kBAAkB,kBAAkB,CAAC,OAAO,QAAQ,EAAE,KAAI,MAAK,EAAE,aAAa,CAAC;CAGrF,IAAI,cAAc,OAAO,eAAe,UACtC,OAAO,QAAQ,WAAW,CAAC,SAAS,CAAC,KAAK,WAAW;EACnD,IAAI,MAAM,SAAS,MAAM,KACvB,MAAM,WAAW,OAAO;GAE1B;CAMJ,KAAK,MAAM,SAAS;EAClB,MAAM,KAAK;EACX,IAAI,GAAG,SAAS,WAAW,GAAG,SAAS;GAGrC,IAAI,WAAW,GAAG,WAAW,EAAE,gBAAgB,GAAG,UAChD,GAAG,QAAQ,gBAAgB;GAE7B,IAAI,gBAAgB,GAAG,WAAW,EAAE,WAAW,GAAG,UAChD,GAAG,QAAQ,QAAQ;GAIrB,IAAI,gBAAgB,GAAG,SACrB,GAAG,QAAQ,wBAAwB;;GAGvC;CAGF,MAAM,aAAa,UAAU,IAAI;CAEjC,IAAI;CAEJ,IAAI;EAYF,cAAc,MAAM,YAAY;GAV9B,iBAAiB,iBAAiB,mBAAmB;GACrD,wBAAwB,iBAAiB,0BAA0B;GACnE,sBAAsB,iBAAiB,wBAAwB;GAC/D,uBAAuB,iBAAiB,yBAAyB;GACjE,oBAAoB,YAAY,EAAE;GAClC,GAAG,YAAY,EAAE,UAAU,WAAW,GAAG,EAAE;GAC3C,2BAA2B,iBAAiB,6BAA6B;GACzE,GAAG;GAGuC,CAAC;SACvC;EAEN,OAAO;;CAIT,MAAM,SAAS,MAAM,YAAY;CAEjC,KAAK,SAAS,SAAS;EACrB,MAAM,KAAK;EACX,IAAI,GAAG,SAAS,OAAO;GAErB,IAAI,QAAQ,GAAG,QAAQ,MACpB,QAAQ,SAAS,KAAK,CACtB,QAAQ,SAAS,KAAK,CACtB,SAAS;GAGZ,IAAI,CAAC,MAAM,SAAS,IAAI,EACtB,SAAS;GAGX,IAAI,sBACF,QAAQ,MAAM,QACZ,4DACA,IACD;GAGH,GAAG,QAAQ,QAAQ;;GAErB;;;;;;;CAQF,KAAK,SAAS,SAAS;EACrB,MAAM,KAAK;EACX,IAAI,GAAG,SAAS,WAAW,GAAG,WAAW,wBAAwB,GAAG,SAAS;GAC3E,GAAG,QAAQ,QAAQ;GACnB,OAAO,GAAG,QAAQ;GAClB,OAAO,GAAG,QAAQ;;GAEpB;CAEF,OAAO"}
|
|
@@ -4,11 +4,32 @@ import { ChildNode } from "domhandler";
|
|
|
4
4
|
/**
|
|
5
5
|
* Inline `<link rel="stylesheet">` tags as `<style>` tags.
|
|
6
6
|
*
|
|
7
|
-
* - Local file paths are
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
7
|
+
* - Local file paths are inlined when `filePath` is provided (resolved
|
|
8
|
+
* relative to it).
|
|
9
|
+
* - Remote URLs (`http://` / `https://`) are only inlined when the link
|
|
10
|
+
* carries an `inline` attribute, e.g. `<link rel="stylesheet" inline href="…">`.
|
|
11
|
+
*
|
|
12
|
+
* @param html HTML string to transform.
|
|
13
|
+
* @param filePath Path of the source file the HTML came from, used as the
|
|
14
|
+
* base for resolving relative `href` values. Required for
|
|
15
|
+
* local-file inlining; remote `inline` links work without it.
|
|
16
|
+
* @returns The transformed HTML string.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* import { inlineLink } from '@maizzle/framework'
|
|
20
|
+
*
|
|
21
|
+
* const out = await inlineLink(
|
|
22
|
+
* '<link rel="stylesheet" href="./styles.css">',
|
|
23
|
+
* '/path/to/template.html',
|
|
24
|
+
* )
|
|
25
|
+
*/
|
|
26
|
+
declare function inlineLink(html: string, filePath?: string): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* DOM-form of {@link inlineLink} used by the internal transformer pipeline.
|
|
29
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
30
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
10
31
|
*/
|
|
11
|
-
declare function
|
|
32
|
+
declare function inlineLinkDom(dom: ChildNode[], filePath?: string): Promise<ChildNode[]>;
|
|
12
33
|
//#endregion
|
|
13
|
-
export { inlineLink };
|
|
34
|
+
export { inlineLink, inlineLinkDom };
|
|
14
35
|
//# sourceMappingURL=inlineLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineLink.d.ts","names":[],"sources":["../../src/transformers/inlineLink.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"inlineLink.d.ts","names":[],"sources":["../../src/transformers/inlineLink.ts"],"mappings":";;;;;AA2BA;;;;;;;;;AASA;;;;;;;;;;;iBATsB,UAAA,CAAW,IAAA,UAAc,QAAA,YAAoB,OAAA;;;;;;iBAS7C,aAAA,CAAc,GAAA,EAAK,SAAA,IAAa,QAAA,YAAoB,OAAA,CAAQ,SAAA"}
|
|
@@ -1,17 +1,41 @@
|
|
|
1
|
+
import { parse } from "../utils/ast/parser.js";
|
|
1
2
|
import { walk } from "../utils/ast/walker.js";
|
|
3
|
+
import { serialize } from "../utils/ast/serializer.js";
|
|
2
4
|
import "../utils/ast/index.js";
|
|
3
5
|
import { readFileSync } from "node:fs";
|
|
4
6
|
import { dirname, resolve } from "node:path";
|
|
5
|
-
|
|
6
7
|
//#region src/transformers/inlineLink.ts
|
|
7
8
|
/**
|
|
8
9
|
* Inline `<link rel="stylesheet">` tags as `<style>` tags.
|
|
9
10
|
*
|
|
10
|
-
* - Local file paths are
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
11
|
+
* - Local file paths are inlined when `filePath` is provided (resolved
|
|
12
|
+
* relative to it).
|
|
13
|
+
* - Remote URLs (`http://` / `https://`) are only inlined when the link
|
|
14
|
+
* carries an `inline` attribute, e.g. `<link rel="stylesheet" inline href="…">`.
|
|
15
|
+
*
|
|
16
|
+
* @param html HTML string to transform.
|
|
17
|
+
* @param filePath Path of the source file the HTML came from, used as the
|
|
18
|
+
* base for resolving relative `href` values. Required for
|
|
19
|
+
* local-file inlining; remote `inline` links work without it.
|
|
20
|
+
* @returns The transformed HTML string.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { inlineLink } from '@maizzle/framework'
|
|
24
|
+
*
|
|
25
|
+
* const out = await inlineLink(
|
|
26
|
+
* '<link rel="stylesheet" href="./styles.css">',
|
|
27
|
+
* '/path/to/template.html',
|
|
28
|
+
* )
|
|
13
29
|
*/
|
|
14
|
-
async function inlineLink(
|
|
30
|
+
async function inlineLink(html, filePath) {
|
|
31
|
+
return serialize(await inlineLinkDom(parse(html), filePath));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* DOM-form of {@link inlineLink} used by the internal transformer pipeline.
|
|
35
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
36
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
37
|
+
*/
|
|
38
|
+
async function inlineLinkDom(dom, filePath) {
|
|
15
39
|
const links = [];
|
|
16
40
|
walk(dom, (node) => {
|
|
17
41
|
if (node.name !== "link") return;
|
|
@@ -70,7 +94,7 @@ async function inlineLink(dom, filePath) {
|
|
|
70
94
|
}
|
|
71
95
|
return dom;
|
|
72
96
|
}
|
|
73
|
-
|
|
74
97
|
//#endregion
|
|
75
|
-
export { inlineLink };
|
|
98
|
+
export { inlineLink, inlineLinkDom };
|
|
99
|
+
|
|
76
100
|
//# sourceMappingURL=inlineLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineLink.js","names":[],"sources":["../../src/transformers/inlineLink.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport type { ChildNode, Element } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\n\n/**\n * Inline `<link rel=\"stylesheet\">` tags as `<style>` tags.\n *\n * - Local file paths are
|
|
1
|
+
{"version":3,"file":"inlineLink.js","names":[],"sources":["../../src/transformers/inlineLink.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\n\n/**\n * Inline `<link rel=\"stylesheet\">` tags as `<style>` tags.\n *\n * - Local file paths are inlined when `filePath` is provided (resolved\n * relative to it).\n * - Remote URLs (`http://` / `https://`) are only inlined when the link\n * carries an `inline` attribute, e.g. `<link rel=\"stylesheet\" inline href=\"…\">`.\n *\n * @param html HTML string to transform.\n * @param filePath Path of the source file the HTML came from, used as the\n * base for resolving relative `href` values. Required for\n * local-file inlining; remote `inline` links work without it.\n * @returns The transformed HTML string.\n *\n * @example\n * import { inlineLink } from '@maizzle/framework'\n *\n * const out = await inlineLink(\n * '<link rel=\"stylesheet\" href=\"./styles.css\">',\n * '/path/to/template.html',\n * )\n */\nexport async function inlineLink(html: string, filePath?: string): Promise<string> {\n return serialize(await inlineLinkDom(parse(html), filePath))\n}\n\n/**\n * DOM-form of {@link inlineLink} used by the internal transformer pipeline.\n * Takes a parsed DOM, returns a parsed DOM — avoids redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport async function inlineLinkDom(dom: ChildNode[], filePath?: string): Promise<ChildNode[]> {\n const links: { node: Element; parent: ChildNode; index: number }[] = []\n\n walk(dom, (node) => {\n if ((node as Element).name !== 'link') return\n\n const el = node as Element\n const attrs = el.attribs || {}\n\n if (attrs.rel !== 'stylesheet' || !attrs.href) return\n\n const parent = el.parent as ChildNode\n\n if (parent && 'children' in parent) {\n const index = (parent.children as ChildNode[]).indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent, index })\n }\n } else {\n // Top-level node\n const index = dom.indexOf(el)\n if (index !== -1) {\n links.push({ node: el, parent: null as any, index })\n }\n }\n })\n\n for (const { node, parent, index } of links) {\n const href = node.attribs.href\n const isRemote = href.startsWith('http://') || href.startsWith('https://')\n\n let css: string | undefined\n\n if (isRemote) {\n if (!('inline' in node.attribs)) continue\n\n try {\n const response = await fetch(href)\n css = await response.text()\n } catch {\n continue\n }\n } else {\n if (!filePath) continue\n\n try {\n const absolutePath = resolve(dirname(filePath), href)\n css = readFileSync(absolutePath, 'utf8')\n } catch {\n continue\n }\n }\n\n const styleNode = {\n type: 'tag',\n name: 'style',\n attribs: {},\n children: [{\n type: 'text',\n data: css,\n parent: null as any,\n }],\n parent: parent || null,\n } as any\n\n // Set parent reference on the text child\n styleNode.children[0].parent = styleNode\n\n const siblings = parent && 'children' in parent\n ? parent.children as ChildNode[]\n : dom\n\n siblings.splice(index, 1, styleNode)\n }\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,eAAsB,WAAW,MAAc,UAAoC;CACjF,OAAO,UAAU,MAAM,cAAc,MAAM,KAAK,EAAE,SAAS,CAAC;;;;;;;AAQ9D,eAAsB,cAAc,KAAkB,UAAyC;CAC7F,MAAM,QAA+D,EAAE;CAEvE,KAAK,MAAM,SAAS;EAClB,IAAK,KAAiB,SAAS,QAAQ;EAEvC,MAAM,KAAK;EACX,MAAM,QAAQ,GAAG,WAAW,EAAE;EAE9B,IAAI,MAAM,QAAQ,gBAAgB,CAAC,MAAM,MAAM;EAE/C,MAAM,SAAS,GAAG;EAElB,IAAI,UAAU,cAAc,QAAQ;GAClC,MAAM,QAAS,OAAO,SAAyB,QAAQ,GAAG;GAC1D,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI;IAAQ;IAAO,CAAC;SAEpC;GAEL,MAAM,QAAQ,IAAI,QAAQ,GAAG;GAC7B,IAAI,UAAU,IACZ,MAAM,KAAK;IAAE,MAAM;IAAI,QAAQ;IAAa;IAAO,CAAC;;GAGxD;CAEF,KAAK,MAAM,EAAE,MAAM,QAAQ,WAAW,OAAO;EAC3C,MAAM,OAAO,KAAK,QAAQ;EAC1B,MAAM,WAAW,KAAK,WAAW,UAAU,IAAI,KAAK,WAAW,WAAW;EAE1E,IAAI;EAEJ,IAAI,UAAU;GACZ,IAAI,EAAE,YAAY,KAAK,UAAU;GAEjC,IAAI;IAEF,MAAM,OAAM,MADW,MAAM,KAAK,EACb,MAAM;WACrB;IACN;;SAEG;GACL,IAAI,CAAC,UAAU;GAEf,IAAI;IAEF,MAAM,aADe,QAAQ,QAAQ,SAAS,EAAE,KACjB,EAAE,OAAO;WAClC;IACN;;;EAIJ,MAAM,YAAY;GAChB,MAAM;GACN,MAAM;GACN,SAAS,EAAE;GACX,UAAU,CAAC;IACT,MAAM;IACN,MAAM;IACN,QAAQ;IACT,CAAC;GACF,QAAQ,UAAU;GACnB;EAGD,UAAU,SAAS,GAAG,SAAS;EAM/B,CAJiB,UAAU,cAAc,SACrC,OAAO,WACP,KAEK,OAAO,OAAO,GAAG,UAAU;;CAGtC,OAAO"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Opts, Opts as MinifyOptions } from "html-crush";
|
|
2
2
|
|
|
3
3
|
//#region src/transformers/minify.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Minify
|
|
5
|
+
* Minify an HTML string using `html-crush`. Maizzle's only default that
|
|
6
|
+
* differs from html-crush's own defaults is `removeLineBreaks: true`.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* @param html HTML string to minify.
|
|
9
|
+
* @param options [html-crush options](https://codsen.com/os/html-crush) merged
|
|
10
|
+
* on top of the Maizzle defaults.
|
|
11
|
+
* @returns The minified HTML string.
|
|
10
12
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { minify } from '@maizzle/framework'
|
|
15
|
+
*
|
|
16
|
+
* const tight = minify('<p> hello </p>', { removeIndentations: true })
|
|
13
17
|
*/
|
|
14
|
-
declare function minify(html: string,
|
|
18
|
+
declare function minify(html: string, options?: Partial<Opts>): string;
|
|
15
19
|
//#endregion
|
|
16
|
-
export { minify };
|
|
20
|
+
export { type MinifyOptions, minify };
|
|
17
21
|
//# sourceMappingURL=minify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minify.d.ts","names":[],"sources":["../../src/transformers/minify.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"minify.d.ts","names":[],"sources":["../../src/transformers/minify.ts"],"mappings":";;;;AAwBA;;;;;;;;;;;;;iBAAgB,MAAA,CAAO,IAAA,UAAc,OAAA,GAAS,OAAA,CAAQ,IAAA"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { defu } from "defu";
|
|
1
|
+
import { defu as defu$1 } from "defu";
|
|
2
2
|
import { crush } from "html-crush";
|
|
3
|
-
|
|
4
3
|
//#region src/transformers/minify.ts
|
|
5
4
|
const DEFAULT_OPTIONS = { removeLineBreaks: true };
|
|
6
5
|
/**
|
|
7
|
-
* Minify
|
|
6
|
+
* Minify an HTML string using `html-crush`. Maizzle's only default that
|
|
7
|
+
* differs from html-crush's own defaults is `removeLineBreaks: true`.
|
|
8
|
+
*
|
|
9
|
+
* @param html HTML string to minify.
|
|
10
|
+
* @param options [html-crush options](https://codsen.com/os/html-crush) merged
|
|
11
|
+
* on top of the Maizzle defaults.
|
|
12
|
+
* @returns The minified HTML string.
|
|
8
13
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* User options are merged on top of the defaults.
|
|
14
|
+
* @example
|
|
15
|
+
* import { minify } from '@maizzle/framework'
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
* is `removeLineBreaks: true`.
|
|
17
|
+
* const tight = minify('<p> hello </p>', { removeIndentations: true })
|
|
15
18
|
*/
|
|
16
|
-
function minify(html,
|
|
17
|
-
|
|
18
|
-
if (!option) return html;
|
|
19
|
-
return crush(html, defu(typeof option === "object" ? option : {}, DEFAULT_OPTIONS)).result;
|
|
19
|
+
function minify(html, options = {}) {
|
|
20
|
+
return crush(html, defu$1(options, DEFAULT_OPTIONS)).result;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
22
|
//#endregion
|
|
23
23
|
export { minify };
|
|
24
|
+
|
|
24
25
|
//# sourceMappingURL=minify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minify.js","names":["merge"],"sources":["../../src/transformers/minify.ts"],"sourcesContent":["import { crush } from 'html-crush'\nimport { defu as merge } from 'defu'\nimport type { Opts } from 'html-crush'\
|
|
1
|
+
{"version":3,"file":"minify.js","names":["merge"],"sources":["../../src/transformers/minify.ts"],"sourcesContent":["import { crush } from 'html-crush'\nimport { defu as merge } from 'defu'\nimport type { Opts as HtmlCrushOptions } from 'html-crush'\n\nexport type { Opts as MinifyOptions } from 'html-crush'\n\nconst DEFAULT_OPTIONS: Partial<HtmlCrushOptions> = {\n removeLineBreaks: true,\n}\n\n/**\n * Minify an HTML string using `html-crush`. Maizzle's only default that\n * differs from html-crush's own defaults is `removeLineBreaks: true`.\n *\n * @param html HTML string to minify.\n * @param options [html-crush options](https://codsen.com/os/html-crush) merged\n * on top of the Maizzle defaults.\n * @returns The minified HTML string.\n *\n * @example\n * import { minify } from '@maizzle/framework'\n *\n * const tight = minify('<p> hello </p>', { removeIndentations: true })\n */\nexport function minify(html: string, options: Partial<HtmlCrushOptions> = {}): string {\n const merged = merge(options, DEFAULT_OPTIONS) as Partial<HtmlCrushOptions>\n return crush(html, merged).result\n}\n"],"mappings":";;;AAMA,MAAM,kBAA6C,EACjD,kBAAkB,MACnB;;;;;;;;;;;;;;;AAgBD,SAAgB,OAAO,MAAc,UAAqC,EAAE,EAAU;CAEpF,OAAO,MAAM,MADEA,OAAM,SAAS,gBACL,CAAC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { walk } from "../utils/ast/walker.js";
|
|
2
2
|
import "../utils/ast/index.js";
|
|
3
|
-
|
|
4
3
|
//#region src/transformers/msoPlaceholders.ts
|
|
5
4
|
const RE_MAX_WIDTH = /(?:^|;\s*)max-width:\s*([^;]+)/i;
|
|
6
5
|
const RE_WIDTH = /(?:^|;\s*)width:\s*([^;]+)/i;
|
|
@@ -83,7 +82,7 @@ function msoPlaceholders(dom) {
|
|
|
83
82
|
});
|
|
84
83
|
return dom;
|
|
85
84
|
}
|
|
86
|
-
|
|
87
85
|
//#endregion
|
|
88
86
|
export { msoPlaceholders };
|
|
87
|
+
|
|
89
88
|
//# sourceMappingURL=msoPlaceholders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msoPlaceholders.js","names":[],"sources":["../../src/transformers/msoPlaceholders.ts"],"sourcesContent":["import { walk } from '../utils/ast/index.ts'\nimport type { ChildNode, Element } from 'domhandler'\n\nconst RE_MAX_WIDTH = /(?:^|;\\s*)max-width:\\s*([^;]+)/i\nconst RE_WIDTH = /(?:^|;\\s*)width:\\s*([^;]+)/i\nconst RE_PERCENT = /^[\\d.]+%$/\nconst PADDING_DECL_RE = /(?:^|;)\\s*(padding(?:-[a-z-]+)?\\s*:\\s*[^;]+)/gi\n\nfunction resolveWidth(value: string): string | null {\n const trimmed = value.trim()\n if (RE_PERCENT.test(trimmed)) return trimmed\n const m = trimmed.match(/^([\\d.]+)(px|rem|em|pt)?$/i)\n if (!m) return null\n const n = parseFloat(m[1])\n switch ((m[2] || 'px').toLowerCase()) {\n case 'px': return `${Math.round(n)}px`\n case 'rem':\n case 'em': return `${Math.round(n * 16)}px`\n case 'pt': return `${Math.round(n * 1.333)}px`\n default: return null\n }\n}\n\n/**\n * Resolve all `__MAIZZLE_MSO*__` placeholders inside MSO conditional comments\n * by reading inlined style + `data-*` markers on the paired elements.\n *\n * Two placeholder families:\n *\n * MSOW (`__MAIZZLE_MSOW_{id}__`) — emitted by `<Container>` and `<Section>`.\n * Source element is marked with `data-maizzle-msow-id`. Reads inlined\n * `max-width:` (falls back to `width:`) and normalizes to px. Falls\n * back to `data-maizzle-msow-fallback` (default `600px`) when the\n * value can't be parsed.\n *\n * MSOTDSTYLE (`__MAIZZLE_MSOTDSTYLE_{id}__`) — emitted by `<Container>`'s\n * MSO `<td>`. Source element is marked with `data-maizzle-mso-td-id`.\n * Copies every `padding*` declaration from inlined style and appends\n * the `data-maizzle-mso-style` value (the user's `msoStyle` prop).\n * Empty input resolves to '' so the placeholder collapses cleanly.\n *\n * Single collect-walk + single substitute-walk: the same Container div\n * carries both marker kinds, so one element visit fills both maps.\n */\nexport function msoPlaceholders(dom: ChildNode[]): ChildNode[] {\n const widths = new Map<string, string>()\n const tdStyles = new Map<string, string>()\n\n walk(dom, (node) => {\n const el = node as Element\n const a = el.attribs\n if (!a) return\n\n const msowId = a['data-maizzle-msow-id']\n const tdId = a['data-maizzle-mso-td-id']\n if (!msowId && !tdId) return\n\n const style = a.style ?? ''\n\n if (msowId) {\n delete a['data-maizzle-msow-id']\n const fallback = a['data-maizzle-msow-fallback'] ?? '600px'\n delete a['data-maizzle-msow-fallback']\n const raw = style.match(RE_MAX_WIDTH)?.[1] ?? style.match(RE_WIDTH)?.[1]\n const resolved = raw ? resolveWidth(raw) : null\n widths.set(msowId, resolved ?? fallback)\n }\n\n if (tdId) {\n delete a['data-maizzle-mso-td-id']\n const msoStyle = (a['data-maizzle-mso-style'] ?? '').trim().replace(/;\\s*$/, '')\n delete a['data-maizzle-mso-style']\n\n const parts: string[] = []\n if (style) {\n for (const m of style.matchAll(PADDING_DECL_RE)) {\n parts.push(m[1].trim())\n }\n }\n if (msoStyle) parts.push(msoStyle)\n\n tdStyles.set(tdId, parts.length ? ` style=\"${parts.join('; ')}\"` : '')\n }\n })\n\n if (widths.size === 0 && tdStyles.size === 0) return dom\n\n walk(dom, (node) => {\n if (node.type !== 'comment') return\n let data = (node as any).data as string\n if (!data) return\n const hasMsow = widths.size > 0 && data.includes('__MAIZZLE_MSOW_')\n const hasTd = tdStyles.size > 0 && data.includes('__MAIZZLE_MSOTDSTYLE_')\n if (!hasMsow && !hasTd) return\n\n if (hasMsow) {\n for (const [id, val] of widths) {\n data = data.replaceAll(`__MAIZZLE_MSOW_${id}__`, val)\n }\n }\n if (hasTd) {\n for (const [id, val] of tdStyles) {\n data = data.replaceAll(`__MAIZZLE_MSOTDSTYLE_${id}__`, val)\n }\n }\n ;(node as any).data = data\n })\n\n return dom\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"msoPlaceholders.js","names":["el"],"sources":["../../src/transformers/msoPlaceholders.ts"],"sourcesContent":["import { walk } from '../utils/ast/index.ts'\nimport type { ChildNode, Element } from 'domhandler'\n\nconst RE_MAX_WIDTH = /(?:^|;\\s*)max-width:\\s*([^;]+)/i\nconst RE_WIDTH = /(?:^|;\\s*)width:\\s*([^;]+)/i\nconst RE_PERCENT = /^[\\d.]+%$/\nconst PADDING_DECL_RE = /(?:^|;)\\s*(padding(?:-[a-z-]+)?\\s*:\\s*[^;]+)/gi\n\nfunction resolveWidth(value: string): string | null {\n const trimmed = value.trim()\n if (RE_PERCENT.test(trimmed)) return trimmed\n const m = trimmed.match(/^([\\d.]+)(px|rem|em|pt)?$/i)\n if (!m) return null\n const n = parseFloat(m[1])\n switch ((m[2] || 'px').toLowerCase()) {\n case 'px': return `${Math.round(n)}px`\n case 'rem':\n case 'em': return `${Math.round(n * 16)}px`\n case 'pt': return `${Math.round(n * 1.333)}px`\n default: return null\n }\n}\n\n/**\n * Resolve all `__MAIZZLE_MSO*__` placeholders inside MSO conditional comments\n * by reading inlined style + `data-*` markers on the paired elements.\n *\n * Two placeholder families:\n *\n * MSOW (`__MAIZZLE_MSOW_{id}__`) — emitted by `<Container>` and `<Section>`.\n * Source element is marked with `data-maizzle-msow-id`. Reads inlined\n * `max-width:` (falls back to `width:`) and normalizes to px. Falls\n * back to `data-maizzle-msow-fallback` (default `600px`) when the\n * value can't be parsed.\n *\n * MSOTDSTYLE (`__MAIZZLE_MSOTDSTYLE_{id}__`) — emitted by `<Container>`'s\n * MSO `<td>`. Source element is marked with `data-maizzle-mso-td-id`.\n * Copies every `padding*` declaration from inlined style and appends\n * the `data-maizzle-mso-style` value (the user's `msoStyle` prop).\n * Empty input resolves to '' so the placeholder collapses cleanly.\n *\n * Single collect-walk + single substitute-walk: the same Container div\n * carries both marker kinds, so one element visit fills both maps.\n */\nexport function msoPlaceholders(dom: ChildNode[]): ChildNode[] {\n const widths = new Map<string, string>()\n const tdStyles = new Map<string, string>()\n\n walk(dom, (node) => {\n const el = node as Element\n const a = el.attribs\n if (!a) return\n\n const msowId = a['data-maizzle-msow-id']\n const tdId = a['data-maizzle-mso-td-id']\n if (!msowId && !tdId) return\n\n const style = a.style ?? ''\n\n if (msowId) {\n delete a['data-maizzle-msow-id']\n const fallback = a['data-maizzle-msow-fallback'] ?? '600px'\n delete a['data-maizzle-msow-fallback']\n const raw = style.match(RE_MAX_WIDTH)?.[1] ?? style.match(RE_WIDTH)?.[1]\n const resolved = raw ? resolveWidth(raw) : null\n widths.set(msowId, resolved ?? fallback)\n }\n\n if (tdId) {\n delete a['data-maizzle-mso-td-id']\n const msoStyle = (a['data-maizzle-mso-style'] ?? '').trim().replace(/;\\s*$/, '')\n delete a['data-maizzle-mso-style']\n\n const parts: string[] = []\n if (style) {\n for (const m of style.matchAll(PADDING_DECL_RE)) {\n parts.push(m[1].trim())\n }\n }\n if (msoStyle) parts.push(msoStyle)\n\n tdStyles.set(tdId, parts.length ? ` style=\"${parts.join('; ')}\"` : '')\n }\n })\n\n if (widths.size === 0 && tdStyles.size === 0) return dom\n\n walk(dom, (node) => {\n if (node.type !== 'comment') return\n let data = (node as any).data as string\n if (!data) return\n const hasMsow = widths.size > 0 && data.includes('__MAIZZLE_MSOW_')\n const hasTd = tdStyles.size > 0 && data.includes('__MAIZZLE_MSOTDSTYLE_')\n if (!hasMsow && !hasTd) return\n\n if (hasMsow) {\n for (const [id, val] of widths) {\n data = data.replaceAll(`__MAIZZLE_MSOW_${id}__`, val)\n }\n }\n if (hasTd) {\n for (const [id, val] of tdStyles) {\n data = data.replaceAll(`__MAIZZLE_MSOTDSTYLE_${id}__`, val)\n }\n }\n ;(node as any).data = data\n })\n\n return dom\n}\n"],"mappings":";;;AAGA,MAAM,eAAe;AACrB,MAAM,WAAW;AACjB,MAAM,aAAa;AACnB,MAAM,kBAAkB;AAExB,SAAS,aAAa,OAA8B;CAClD,MAAM,UAAU,MAAM,MAAM;CAC5B,IAAI,WAAW,KAAK,QAAQ,EAAE,OAAO;CACrC,MAAM,IAAI,QAAQ,MAAM,6BAA6B;CACrD,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,IAAI,WAAW,EAAE,GAAG;CAC1B,SAAS,EAAE,MAAM,MAAM,aAAa,EAApC;EACE,KAAK,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;EACnC,KAAK;EACL,KAAK,MAAM,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,CAAC;EACxC,KAAK,MAAM,OAAO,GAAG,KAAK,MAAM,IAAI,MAAM,CAAC;EAC3C,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBpB,SAAgB,gBAAgB,KAA+B;CAC7D,MAAM,yBAAS,IAAI,KAAqB;CACxC,MAAM,2BAAW,IAAI,KAAqB;CAE1C,KAAK,MAAM,SAAS;EAElB,MAAM,IAAIA,KAAG;EACb,IAAI,CAAC,GAAG;EAER,MAAM,SAAS,EAAE;EACjB,MAAM,OAAO,EAAE;EACf,IAAI,CAAC,UAAU,CAAC,MAAM;EAEtB,MAAM,QAAQ,EAAE,SAAS;EAEzB,IAAI,QAAQ;GACV,OAAO,EAAE;GACT,MAAM,WAAW,EAAE,iCAAiC;GACpD,OAAO,EAAE;GACT,MAAM,MAAM,MAAM,MAAM,aAAa,GAAG,MAAM,MAAM,MAAM,SAAS,GAAG;GACtE,MAAM,WAAW,MAAM,aAAa,IAAI,GAAG;GAC3C,OAAO,IAAI,QAAQ,YAAY,SAAS;;EAG1C,IAAI,MAAM;GACR,OAAO,EAAE;GACT,MAAM,YAAY,EAAE,6BAA6B,IAAI,MAAM,CAAC,QAAQ,SAAS,GAAG;GAChF,OAAO,EAAE;GAET,MAAM,QAAkB,EAAE;GAC1B,IAAI,OACF,KAAK,MAAM,KAAK,MAAM,SAAS,gBAAgB,EAC7C,MAAM,KAAK,EAAE,GAAG,MAAM,CAAC;GAG3B,IAAI,UAAU,MAAM,KAAK,SAAS;GAElC,SAAS,IAAI,MAAM,MAAM,SAAS,WAAW,MAAM,KAAK,KAAK,CAAC,KAAK,GAAG;;GAExE;CAEF,IAAI,OAAO,SAAS,KAAK,SAAS,SAAS,GAAG,OAAO;CAErD,KAAK,MAAM,SAAS;EAClB,IAAI,KAAK,SAAS,WAAW;EAC7B,IAAI,OAAQ,KAAa;EACzB,IAAI,CAAC,MAAM;EACX,MAAM,UAAU,OAAO,OAAO,KAAK,KAAK,SAAS,kBAAkB;EACnE,MAAM,QAAQ,SAAS,OAAO,KAAK,KAAK,SAAS,wBAAwB;EACzE,IAAI,CAAC,WAAW,CAAC,OAAO;EAExB,IAAI,SACF,KAAK,MAAM,CAAC,IAAI,QAAQ,QACtB,OAAO,KAAK,WAAW,kBAAkB,GAAG,KAAK,IAAI;EAGzD,IAAI,OACF,KAAK,MAAM,CAAC,IAAI,QAAQ,UACtB,OAAO,KAAK,WAAW,wBAAwB,GAAG,KAAK,IAAI;EAG9D,KAAc,OAAO;GACtB;CAEF,OAAO"}
|