@maizzle/framework 6.0.0-rc.9 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/maizzle.mjs +1 -1
- package/dist/build.d.ts +38 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +234 -0
- package/dist/build.js.map +1 -0
- package/dist/components/Body.vue +32 -3
- package/dist/components/Button.vue +91 -62
- package/dist/components/CodeBlock.vue +6 -4
- package/dist/components/CodeInline.vue +77 -6
- package/dist/components/Column.vue +67 -31
- package/dist/components/Container.vue +73 -12
- package/dist/components/Font.vue +96 -0
- package/dist/components/Head.vue +1 -1
- package/dist/components/Heading.vue +1 -1
- package/dist/components/Hr.vue +33 -0
- package/dist/components/Html.vue +36 -3
- package/dist/components/Img.vue +332 -0
- package/dist/components/Layout.vue +71 -21
- package/dist/components/Link.vue +1 -1
- package/dist/components/Markdown.vue +51 -24
- package/dist/components/MarkdownLayout.vue +39 -0
- package/dist/components/NotPlaintext.vue +14 -0
- package/dist/components/Outlook.vue +38 -11
- package/dist/components/OutlookBg.vue +241 -0
- package/dist/components/Plaintext.vue +14 -0
- package/dist/components/Preheader.vue +35 -10
- package/dist/components/QrCode.vue +157 -0
- package/dist/components/Raw.vue +28 -0
- package/dist/components/Row.vue +115 -22
- package/dist/components/Section.vue +65 -26
- package/dist/components/Spacer.vue +35 -29
- package/dist/components/Tailwind.vue +45 -0
- package/dist/components/Text.vue +3 -3
- package/dist/components/Vml.vue +207 -94
- package/dist/components/utils.d.ts +53 -0
- package/dist/components/utils.d.ts.map +1 -0
- package/dist/components/utils.js +80 -0
- package/dist/components/utils.js.map +1 -0
- package/dist/components/utils.ts +102 -0
- package/dist/composables/defineConfig.d.ts +13 -0
- package/dist/composables/defineConfig.d.ts.map +1 -0
- package/dist/composables/{defineConfig.mjs → defineConfig.js} +7 -9
- package/dist/composables/defineConfig.js.map +1 -0
- package/dist/composables/renderContext.d.ts +37 -0
- package/dist/composables/renderContext.d.ts.map +1 -0
- package/dist/composables/renderContext.js +6 -0
- package/dist/composables/renderContext.js.map +1 -0
- package/dist/composables/useBaseUrl.d.ts +19 -0
- package/dist/composables/useBaseUrl.d.ts.map +1 -0
- package/dist/composables/useBaseUrl.js +26 -0
- package/dist/composables/useBaseUrl.js.map +1 -0
- package/dist/composables/useConfig.d.ts +16 -0
- package/dist/composables/useConfig.d.ts.map +1 -0
- package/dist/composables/useConfig.js +19 -0
- package/dist/composables/useConfig.js.map +1 -0
- package/dist/composables/useCurrentTemplate.d.ts +31 -0
- package/dist/composables/useCurrentTemplate.d.ts.map +1 -0
- package/dist/composables/useCurrentTemplate.js +42 -0
- package/dist/composables/useCurrentTemplate.js.map +1 -0
- package/dist/composables/{useDoctype.d.mts → useDoctype.d.ts} +1 -1
- package/dist/composables/useDoctype.d.ts.map +1 -0
- package/dist/composables/{useDoctype.mjs → useDoctype.js} +3 -4
- package/dist/composables/useDoctype.js.map +1 -0
- package/dist/composables/{useEvent.d.mts → useEvent.d.ts} +3 -3
- package/dist/composables/useEvent.d.ts.map +1 -0
- package/dist/composables/{useEvent.mjs → useEvent.js} +4 -5
- package/dist/composables/useEvent.js.map +1 -0
- package/dist/composables/useFont.d.ts +50 -0
- package/dist/composables/useFont.d.ts.map +1 -0
- package/dist/composables/useFont.js +92 -0
- package/dist/composables/useFont.js.map +1 -0
- package/dist/composables/useOutlookFallback.d.ts +21 -0
- package/dist/composables/useOutlookFallback.d.ts.map +1 -0
- package/dist/composables/useOutlookFallback.js +29 -0
- package/dist/composables/useOutlookFallback.js.map +1 -0
- package/dist/composables/useOutputPath.d.ts +17 -0
- package/dist/composables/useOutputPath.d.ts.map +1 -0
- package/dist/composables/useOutputPath.js +23 -0
- package/dist/composables/useOutputPath.js.map +1 -0
- package/dist/composables/{usePlaintext.d.mts → usePlaintext.d.ts} +3 -1
- package/dist/composables/usePlaintext.d.ts.map +1 -0
- package/dist/composables/{usePlaintext.mjs → usePlaintext.js} +4 -4
- package/dist/composables/usePlaintext.js.map +1 -0
- package/dist/composables/usePreheader.d.ts +25 -0
- package/dist/composables/usePreheader.d.ts.map +1 -0
- package/dist/composables/usePreheader.js +28 -0
- package/dist/composables/usePreheader.js.map +1 -0
- package/dist/composables/useTransformers.d.ts +34 -0
- package/dist/composables/useTransformers.d.ts.map +1 -0
- package/dist/composables/useTransformers.js +48 -0
- package/dist/composables/useTransformers.js.map +1 -0
- package/dist/composables/useUrlQuery.d.ts +19 -0
- package/dist/composables/useUrlQuery.d.ts.map +1 -0
- package/dist/composables/useUrlQuery.js +26 -0
- package/dist/composables/useUrlQuery.js.map +1 -0
- package/dist/config/{defaults.d.mts → defaults.d.ts} +2 -2
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/{defaults.mjs → defaults.js} +10 -6
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +24 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/{index.mjs → index.js} +45 -14
- package/dist/config/index.js.map +1 -0
- package/dist/events/{index.d.mts → index.d.ts} +35 -12
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/{index.mjs → index.js} +31 -13
- package/dist/events/index.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +40 -0
- package/dist/{plaintext.d.mts → plaintext.d.ts} +1 -1
- package/dist/plaintext.d.ts.map +1 -0
- package/dist/{plaintext.mjs → plaintext.js} +4 -5
- package/dist/plaintext.js.map +1 -0
- package/dist/{plugin.d.mts → plugin.d.ts} +2 -2
- package/dist/plugin.d.ts.map +1 -0
- package/dist/{plugin.mjs → plugin.js} +8 -9
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/postcss/{mergeMediaQueries.d.mts → mergeMediaQueries.d.ts} +2 -2
- package/dist/plugins/postcss/mergeMediaQueries.d.ts.map +1 -0
- package/dist/plugins/postcss/{mergeMediaQueries.mjs → mergeMediaQueries.js} +2 -3
- package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -0
- package/dist/plugins/postcss/{pruneVars.d.mts → pruneVars.d.ts} +1 -1
- package/dist/plugins/postcss/pruneVars.d.ts.map +1 -0
- package/dist/plugins/postcss/{pruneVars.mjs → pruneVars.js} +2 -2
- package/dist/plugins/postcss/pruneVars.js.map +1 -0
- package/dist/plugins/postcss/quoteFontFamilies.d.ts +13 -0
- package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -0
- package/dist/plugins/postcss/quoteFontFamilies.js +84 -0
- package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -0
- package/dist/plugins/postcss/{removeDeclarations.d.mts → removeDeclarations.d.ts} +1 -1
- package/dist/plugins/postcss/removeDeclarations.d.ts.map +1 -0
- package/dist/plugins/postcss/{removeDeclarations.mjs → removeDeclarations.js} +2 -2
- package/dist/plugins/postcss/removeDeclarations.js.map +1 -0
- package/dist/plugins/postcss/resolveMaizzleImports.d.ts +16 -0
- package/dist/plugins/postcss/resolveMaizzleImports.d.ts.map +1 -0
- package/dist/plugins/postcss/resolveMaizzleImports.js +39 -0
- package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -0
- package/dist/plugins/postcss/resolveProps.d.ts +8 -0
- package/dist/plugins/postcss/resolveProps.d.ts.map +1 -0
- package/dist/plugins/postcss/resolveProps.js +155 -0
- package/dist/plugins/postcss/resolveProps.js.map +1 -0
- package/dist/plugins/postcss/{tailwindCleanup.d.mts → tailwindCleanup.d.ts} +2 -2
- package/dist/plugins/postcss/tailwindCleanup.d.ts.map +1 -0
- package/dist/plugins/postcss/{tailwindCleanup.mjs → tailwindCleanup.js} +5 -3
- package/dist/plugins/postcss/tailwindCleanup.js.map +1 -0
- package/dist/prepare.d.ts +17 -0
- package/dist/prepare.d.ts.map +1 -0
- package/dist/prepare.js +44 -0
- package/dist/prepare.js.map +1 -0
- 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/buildTemplate.d.ts +49 -0
- package/dist/render/buildTemplate.d.ts.map +1 -0
- package/dist/render/buildTemplate.js +141 -0
- package/dist/render/buildTemplate.js.map +1 -0
- package/dist/render/{createRenderer.d.mts → createRenderer.d.ts} +14 -6
- package/dist/render/createRenderer.d.ts.map +1 -0
- package/dist/render/createRenderer.js +468 -0
- package/dist/render/createRenderer.js.map +1 -0
- package/dist/render/index.d.ts +18 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +59 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/injectFonts.d.ts +15 -0
- package/dist/render/injectFonts.d.ts.map +1 -0
- package/dist/render/injectFonts.js +45 -0
- package/dist/render/injectFonts.js.map +1 -0
- package/dist/render/parallel/buildWorker.d.ts +31 -0
- package/dist/render/parallel/buildWorker.d.ts.map +1 -0
- package/dist/render/parallel/buildWorker.js +66 -0
- package/dist/render/parallel/buildWorker.js.map +1 -0
- package/dist/render/parallel/worker.mjs +28 -0
- package/dist/render/plugins/codeBlockExtract.d.ts +14 -0
- package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -0
- package/dist/render/plugins/codeBlockExtract.js +38 -0
- package/dist/render/plugins/codeBlockExtract.js.map +1 -0
- package/dist/render/plugins/markdownExtract.d.ts +12 -0
- package/dist/render/plugins/markdownExtract.d.ts.map +1 -0
- package/dist/render/plugins/markdownExtract.js +49 -0
- package/dist/render/plugins/markdownExtract.js.map +1 -0
- package/dist/render/plugins/rawExtract.d.ts +14 -0
- package/dist/render/plugins/rawExtract.d.ts.map +1 -0
- package/dist/render/plugins/rawExtract.js +34 -0
- package/dist/render/plugins/rawExtract.js.map +1 -0
- package/dist/render/plugins/rowSourceLocation.d.ts +18 -0
- package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -0
- package/dist/render/plugins/rowSourceLocation.js +45 -0
- package/dist/render/plugins/rowSourceLocation.js.map +1 -0
- package/dist/{serve.d.mts → serve.d.ts} +5 -3
- package/dist/serve.d.ts.map +1 -0
- package/dist/{serve.mjs → serve.js} +201 -107
- package/dist/serve.js.map +1 -0
- package/dist/server/compatibility.d.ts +59 -0
- package/dist/server/compatibility.d.ts.map +1 -0
- package/dist/server/compatibility.js +959 -0
- package/dist/server/compatibility.js.map +1 -0
- package/dist/server/{email.d.mts → email.d.ts} +2 -2
- package/dist/server/email.d.ts.map +1 -0
- package/dist/server/{email.mjs → email.js} +2 -3
- package/dist/server/email.js.map +1 -0
- package/dist/server/linter.d.ts +20 -0
- package/dist/server/linter.d.ts.map +1 -0
- package/dist/server/linter.js +345 -0
- package/dist/server/linter.js.map +1 -0
- package/dist/server/sfc-utils.d.ts +21 -0
- package/dist/server/sfc-utils.d.ts.map +1 -0
- package/dist/server/sfc-utils.js +198 -0
- package/dist/server/sfc-utils.js.map +1 -0
- package/dist/server/ui/.vite/deps/@lucide_vue.js +44967 -0
- package/dist/server/ui/.vite/deps/@lucide_vue.js.map +1 -0
- package/dist/server/ui/.vite/deps/@vueuse_core.js +8155 -0
- package/dist/server/ui/.vite/deps/@vueuse_core.js.map +1 -0
- package/dist/server/ui/.vite/deps/@vueuse_shared.js +1859 -0
- package/dist/server/ui/.vite/deps/@vueuse_shared.js.map +1 -0
- package/dist/server/ui/.vite/deps/_metadata.json +78 -0
- package/dist/server/ui/.vite/deps/chunk-EAsCxrDo.js +14 -0
- package/dist/server/ui/.vite/deps/class-variance-authority.js +57 -0
- package/dist/server/ui/.vite/deps/class-variance-authority.js.map +1 -0
- package/dist/server/ui/.vite/deps/clsx.js +18 -0
- package/dist/server/ui/.vite/deps/clsx.js.map +1 -0
- package/dist/server/ui/.vite/deps/culori.js +4312 -0
- package/dist/server/ui/.vite/deps/culori.js.map +1 -0
- package/dist/server/ui/.vite/deps/package.json +3 -0
- package/dist/server/ui/.vite/deps/reka-ui.js +44464 -0
- package/dist/server/ui/.vite/deps/reka-ui.js.map +1 -0
- package/dist/server/ui/.vite/deps/tailwind-merge.js +3458 -0
- package/dist/server/ui/.vite/deps/tailwind-merge.js.map +1 -0
- package/dist/server/ui/.vite/deps/vue-router.js +6383 -0
- package/dist/server/ui/.vite/deps/vue-router.js.map +1 -0
- package/dist/server/ui/.vite/deps/vue.js +2 -0
- package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-DaqjATE_.js +8785 -0
- package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-DaqjATE_.js.map +1 -0
- package/dist/server/ui/App.vue +106 -66
- package/dist/server/ui/components/SidebarClose.vue +12 -0
- package/dist/server/ui/components/ui/checkbox/Checkbox.vue +1 -1
- package/dist/server/ui/components/ui/command/Command.vue +5 -1
- package/dist/server/ui/components/ui/command/CommandInput.vue +2 -2
- package/dist/server/ui/components/ui/dialog/DialogContent.vue +1 -1
- package/dist/server/ui/components/ui/dialog/DialogScrollContent.vue +1 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +1 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
- package/dist/server/ui/components/ui/input/Input.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetContent.vue +1 -1
- package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +2 -2
- package/dist/server/ui/components/ui/tags-input/TagsInputInput.vue +1 -1
- package/dist/server/ui/components/ui/tags-input/TagsInputItemDelete.vue +1 -1
- package/dist/server/ui/lib/emulated-dark-mode.ts +146 -0
- package/dist/server/ui/main.css +25 -0
- package/dist/server/ui/pages/Home.vue +1 -1
- package/dist/server/ui/pages/Preview.vue +377 -186
- package/dist/server/ui/vite-env.d.ts +1 -0
- 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.d.ts +42 -0
- package/dist/transformers/addAttributes.d.ts.map +1 -0
- package/dist/transformers/{addAttributes.mjs → addAttributes.js} +40 -24
- package/dist/transformers/addAttributes.js.map +1 -0
- package/dist/transformers/attributeToStyle.d.ts +38 -0
- package/dist/transformers/attributeToStyle.d.ts.map +1 -0
- package/dist/transformers/attributeToStyle.js +94 -0
- package/dist/transformers/attributeToStyle.js.map +1 -0
- package/dist/transformers/base.d.ts +71 -0
- package/dist/transformers/base.d.ts.map +1 -0
- package/dist/transformers/{base.mjs → base.js} +65 -40
- package/dist/transformers/base.js.map +1 -0
- package/dist/transformers/columnWidth.d.ts +31 -0
- package/dist/transformers/columnWidth.d.ts.map +1 -0
- package/dist/transformers/columnWidth.js +527 -0
- package/dist/transformers/columnWidth.js.map +1 -0
- package/dist/transformers/entities.d.ts +37 -0
- package/dist/transformers/entities.d.ts.map +1 -0
- package/dist/transformers/entities.js +74 -0
- package/dist/transformers/entities.js.map +1 -0
- package/dist/transformers/filters/{defaults.d.mts → defaults.d.ts} +1 -1
- package/dist/transformers/filters/defaults.d.ts.map +1 -0
- package/dist/transformers/filters/{defaults.mjs → defaults.js} +2 -2
- package/dist/transformers/filters/defaults.js.map +1 -0
- package/dist/transformers/filters/index.d.ts +43 -0
- package/dist/transformers/filters/index.d.ts.map +1 -0
- package/dist/transformers/filters/index.js +89 -0
- package/dist/transformers/filters/index.js.map +1 -0
- package/dist/transformers/format.d.ts +22 -0
- package/dist/transformers/format.d.ts.map +1 -0
- package/dist/transformers/format.js +30 -0
- package/dist/transformers/format.js.map +1 -0
- package/dist/transformers/imgWidth.d.ts +20 -0
- package/dist/transformers/imgWidth.d.ts.map +1 -0
- package/dist/transformers/imgWidth.js +76 -0
- package/dist/transformers/imgWidth.js.map +1 -0
- package/dist/transformers/{index.d.mts → index.d.ts} +4 -3
- package/dist/transformers/index.d.ts.map +1 -0
- package/dist/transformers/index.js +163 -0
- package/dist/transformers/index.js.map +1 -0
- package/dist/transformers/inlineCss.d.ts +85 -0
- package/dist/transformers/inlineCss.d.ts.map +1 -0
- package/dist/transformers/inlineCss.js +112 -0
- package/dist/transformers/inlineCss.js.map +1 -0
- package/dist/transformers/inlineLink.d.ts +35 -0
- package/dist/transformers/inlineLink.d.ts.map +1 -0
- package/dist/transformers/{inlineLink.mjs → inlineLink.js} +35 -11
- package/dist/transformers/inlineLink.js.map +1 -0
- package/dist/transformers/minify.d.ts +21 -0
- package/dist/transformers/minify.d.ts.map +1 -0
- package/dist/transformers/minify.js +25 -0
- package/dist/transformers/minify.js.map +1 -0
- 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 +33 -0
- package/dist/transformers/msoPlaceholders.d.ts.map +1 -0
- package/dist/transformers/msoPlaceholders.js +114 -0
- package/dist/transformers/msoPlaceholders.js.map +1 -0
- package/dist/transformers/purgeCss.d.ts +43 -0
- package/dist/transformers/purgeCss.d.ts.map +1 -0
- package/dist/transformers/purgeCss.js +207 -0
- package/dist/transformers/purgeCss.js.map +1 -0
- package/dist/transformers/removeAttributes.d.ts +54 -0
- package/dist/transformers/removeAttributes.d.ts.map +1 -0
- package/dist/transformers/removeAttributes.js +72 -0
- package/dist/transformers/removeAttributes.js.map +1 -0
- package/dist/transformers/{replaceStrings.d.mts → replaceStrings.d.ts} +2 -2
- package/dist/transformers/replaceStrings.d.ts.map +1 -0
- package/dist/transformers/{replaceStrings.mjs → replaceStrings.js} +2 -2
- package/dist/transformers/replaceStrings.js.map +1 -0
- package/dist/transformers/safeSelectors.d.ts +37 -0
- package/dist/transformers/safeSelectors.d.ts.map +1 -0
- package/dist/transformers/{safeClassNames.mjs → safeSelectors.js} +40 -10
- package/dist/transformers/safeSelectors.js.map +1 -0
- package/dist/transformers/shorthandCss.d.ts +47 -0
- package/dist/transformers/shorthandCss.d.ts.map +1 -0
- package/dist/transformers/shorthandCss.js +92 -0
- package/dist/transformers/shorthandCss.js.map +1 -0
- package/dist/transformers/sixHex.d.ts +25 -0
- package/dist/transformers/sixHex.d.ts.map +1 -0
- package/dist/transformers/sixHex.js +42 -0
- package/dist/transformers/sixHex.js.map +1 -0
- package/dist/transformers/tailwindComponent.d.ts +16 -0
- package/dist/transformers/tailwindComponent.d.ts.map +1 -0
- package/dist/transformers/tailwindComponent.js +101 -0
- package/dist/transformers/tailwindComponent.js.map +1 -0
- package/dist/transformers/{tailwindcss.d.mts → tailwindcss.d.ts} +2 -2
- package/dist/transformers/tailwindcss.d.ts.map +1 -0
- package/dist/transformers/{tailwindcss.mjs → tailwindcss.js} +33 -74
- package/dist/transformers/tailwindcss.js.map +1 -0
- package/dist/transformers/urlQuery.d.ts +36 -0
- package/dist/transformers/urlQuery.d.ts.map +1 -0
- package/dist/transformers/urlQuery.js +77 -0
- package/dist/transformers/urlQuery.js.map +1 -0
- package/dist/types/{config.d.mts → config.d.ts} +231 -46
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/ast/index.d.ts +4 -0
- package/dist/utils/ast/index.js +4 -0
- package/dist/utils/ast/{parser.d.mts → parser.d.ts} +1 -1
- package/dist/utils/ast/parser.d.ts.map +1 -0
- package/dist/utils/ast/{parser.mjs → parser.js} +2 -3
- package/dist/utils/ast/parser.js.map +1 -0
- package/dist/utils/ast/{serializer.d.mts → serializer.d.ts} +1 -1
- package/dist/utils/ast/serializer.d.ts.map +1 -0
- package/dist/utils/ast/serializer.js +46 -0
- package/dist/utils/ast/serializer.js.map +1 -0
- package/dist/utils/ast/{walker.d.mts → walker.d.ts} +1 -1
- package/dist/utils/ast/walker.d.ts.map +1 -0
- package/dist/utils/ast/{walker.mjs → walker.js} +2 -2
- package/dist/utils/ast/walker.js.map +1 -0
- package/dist/utils/cloneConfig.d.ts +13 -0
- package/dist/utils/cloneConfig.d.ts.map +1 -0
- package/dist/utils/cloneConfig.js +21 -0
- package/dist/utils/cloneConfig.js.map +1 -0
- package/dist/utils/compileTailwindCss.d.ts +16 -0
- package/dist/utils/compileTailwindCss.d.ts.map +1 -0
- package/dist/utils/compileTailwindCss.js +55 -0
- package/dist/utils/compileTailwindCss.js.map +1 -0
- package/dist/utils/componentSources.d.ts +50 -0
- package/dist/utils/componentSources.d.ts.map +1 -0
- package/dist/utils/componentSources.js +50 -0
- package/dist/utils/componentSources.js.map +1 -0
- package/dist/utils/cssBox.d.ts +42 -0
- package/dist/utils/cssBox.d.ts.map +1 -0
- package/dist/utils/cssBox.js +151 -0
- package/dist/utils/cssBox.js.map +1 -0
- package/dist/utils/decodeStyleEntities.d.ts +15 -0
- package/dist/utils/decodeStyleEntities.d.ts.map +1 -0
- package/dist/utils/decodeStyleEntities.js +18 -0
- package/dist/utils/decodeStyleEntities.js.map +1 -0
- package/dist/utils/{detect.d.mts → detect.d.ts} +1 -1
- package/dist/utils/detect.d.ts.map +1 -0
- package/dist/utils/{detect.mjs → detect.js} +2 -3
- package/dist/utils/detect.js.map +1 -0
- 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.d.mts → url.d.ts} +1 -1
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/{url.mjs → url.js} +2 -3
- package/dist/utils/url.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/node_modules/@clack/core/CHANGELOG.md +44 -0
- package/node_modules/@clack/core/dist/index.d.mts +125 -5
- package/node_modules/@clack/core/dist/index.mjs +972 -11
- package/node_modules/@clack/core/package.json +6 -2
- package/node_modules/@clack/prompts/CHANGELOG.md +70 -0
- package/node_modules/@clack/prompts/README.md +129 -3
- package/node_modules/@clack/prompts/dist/index.d.mts +567 -33
- package/node_modules/@clack/prompts/dist/index.mjs +1378 -133
- package/node_modules/@clack/prompts/package.json +7 -4
- package/node_modules/fast-string-truncated-width/dist/index.js +36 -96
- package/node_modules/fast-string-truncated-width/dist/types.d.ts +0 -3
- package/node_modules/fast-string-truncated-width/dist/utils.d.ts +3 -3
- package/node_modules/fast-string-truncated-width/dist/utils.js +14 -9
- package/node_modules/fast-string-truncated-width/package.json +1 -1
- package/node_modules/fast-string-truncated-width/readme.md +2 -3
- package/node_modules/fast-string-width/package.json +2 -2
- package/node_modules/fast-string-width/readme.md +0 -3
- package/node_modules/fast-wrap-ansi/lib/main.js +4 -2
- package/node_modules/fast-wrap-ansi/package.json +11 -11
- 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 +8 -7
- 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 +46 -135
- package/node_modules/maizzle/dist/index.d.mts +1 -0
- package/node_modules/maizzle/dist/index.mjs +30 -7
- package/node_modules/maizzle/package.json +5 -4
- package/node_modules/nypm/dist/cli.mjs +28 -5
- package/node_modules/nypm/dist/index.d.mts +0 -8
- package/node_modules/nypm/dist/index.mjs +27 -4
- package/node_modules/nypm/package.json +12 -12
- package/node_modules/tinyexec/README.md +9 -1
- package/node_modules/tinyexec/dist/main.d.mts +22 -7
- package/node_modules/tinyexec/dist/main.mjs +189 -491
- package/node_modules/tinyexec/package.json +14 -16
- package/package.json +37 -30
- package/dist/_virtual/_rolldown/runtime.mjs +0 -32
- package/dist/build.d.mts +0 -19
- package/dist/build.d.mts.map +0 -1
- package/dist/build.mjs +0 -141
- package/dist/build.mjs.map +0 -1
- package/dist/components/Divider.vue +0 -133
- package/dist/components/Image.vue +0 -70
- package/dist/components/Overlap.vue +0 -80
- package/dist/components/utils.d.mts +0 -5
- package/dist/components/utils.d.mts.map +0 -1
- package/dist/components/utils.mjs +0 -9
- package/dist/components/utils.mjs.map +0 -1
- package/dist/composables/defineConfig.d.mts +0 -14
- package/dist/composables/defineConfig.d.mts.map +0 -1
- package/dist/composables/defineConfig.mjs.map +0 -1
- package/dist/composables/renderContext.d.mts +0 -24
- package/dist/composables/renderContext.d.mts.map +0 -1
- package/dist/composables/renderContext.mjs +0 -6
- package/dist/composables/renderContext.mjs.map +0 -1
- package/dist/composables/useConfig.d.mts +0 -9
- package/dist/composables/useConfig.d.mts.map +0 -1
- package/dist/composables/useConfig.mjs +0 -13
- package/dist/composables/useConfig.mjs.map +0 -1
- package/dist/composables/useDoctype.d.mts.map +0 -1
- package/dist/composables/useDoctype.mjs.map +0 -1
- package/dist/composables/useEvent.d.mts.map +0 -1
- package/dist/composables/useEvent.mjs.map +0 -1
- package/dist/composables/usePlaintext.d.mts.map +0 -1
- package/dist/composables/usePlaintext.mjs.map +0 -1
- package/dist/composables/usePreviewText.d.mts +0 -24
- package/dist/composables/usePreviewText.d.mts.map +0 -1
- package/dist/composables/usePreviewText.mjs +0 -29
- package/dist/composables/usePreviewText.mjs.map +0 -1
- package/dist/config/defaults.d.mts.map +0 -1
- package/dist/config/defaults.mjs.map +0 -1
- package/dist/config/index.d.mts +0 -15
- package/dist/config/index.d.mts.map +0 -1
- package/dist/config/index.mjs.map +0 -1
- package/dist/events/index.d.mts.map +0 -1
- package/dist/events/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -31
- package/dist/index.mjs +0 -31
- package/dist/node_modules/picomatch/index.mjs +0 -13
- package/dist/node_modules/picomatch/index.mjs.map +0 -1
- package/dist/node_modules/picomatch/lib/constants.mjs +0 -174
- package/dist/node_modules/picomatch/lib/constants.mjs.map +0 -1
- package/dist/node_modules/picomatch/lib/parse.mjs +0 -1067
- package/dist/node_modules/picomatch/lib/parse.mjs.map +0 -1
- package/dist/node_modules/picomatch/lib/picomatch.mjs +0 -304
- package/dist/node_modules/picomatch/lib/picomatch.mjs.map +0 -1
- package/dist/node_modules/picomatch/lib/scan.mjs +0 -296
- package/dist/node_modules/picomatch/lib/scan.mjs.map +0 -1
- package/dist/node_modules/picomatch/lib/utils.mjs +0 -53
- package/dist/node_modules/picomatch/lib/utils.mjs.map +0 -1
- package/dist/plaintext.d.mts.map +0 -1
- package/dist/plaintext.mjs.map +0 -1
- package/dist/plugin.d.mts.map +0 -1
- package/dist/plugin.mjs.map +0 -1
- package/dist/plugins/postcss/mergeMediaQueries.d.mts.map +0 -1
- package/dist/plugins/postcss/mergeMediaQueries.mjs.map +0 -1
- package/dist/plugins/postcss/pruneVars.d.mts.map +0 -1
- package/dist/plugins/postcss/pruneVars.mjs.map +0 -1
- package/dist/plugins/postcss/removeDeclarations.d.mts.map +0 -1
- package/dist/plugins/postcss/removeDeclarations.mjs.map +0 -1
- package/dist/plugins/postcss/tailwindCleanup.d.mts.map +0 -1
- package/dist/plugins/postcss/tailwindCleanup.mjs.map +0 -1
- package/dist/render/createRenderer.d.mts.map +0 -1
- package/dist/render/createRenderer.mjs +0 -286
- package/dist/render/createRenderer.mjs.map +0 -1
- package/dist/render/index.d.mts +0 -26
- package/dist/render/index.d.mts.map +0 -1
- package/dist/render/index.mjs +0 -46
- package/dist/render/index.mjs.map +0 -1
- package/dist/serve.d.mts.map +0 -1
- package/dist/serve.mjs.map +0 -1
- package/dist/server/compatibility.d.mts +0 -5
- package/dist/server/compatibility.d.mts.map +0 -1
- package/dist/server/compatibility.mjs +0 -97
- package/dist/server/compatibility.mjs.map +0 -1
- package/dist/server/email.d.mts.map +0 -1
- package/dist/server/email.mjs.map +0 -1
- package/dist/server/linter.d.mts +0 -5
- package/dist/server/linter.d.mts.map +0 -1
- package/dist/server/linter.mjs +0 -189
- package/dist/server/linter.mjs.map +0 -1
- package/dist/transformers/addAttributes.d.mts +0 -32
- package/dist/transformers/addAttributes.d.mts.map +0 -1
- package/dist/transformers/addAttributes.mjs.map +0 -1
- package/dist/transformers/attributeToStyle.d.mts +0 -25
- package/dist/transformers/attributeToStyle.d.mts.map +0 -1
- package/dist/transformers/attributeToStyle.mjs +0 -80
- package/dist/transformers/attributeToStyle.mjs.map +0 -1
- package/dist/transformers/base.d.mts +0 -8
- package/dist/transformers/base.d.mts.map +0 -1
- package/dist/transformers/base.mjs.map +0 -1
- package/dist/transformers/entities.d.mts +0 -8
- package/dist/transformers/entities.d.mts.map +0 -1
- package/dist/transformers/entities.mjs +0 -41
- package/dist/transformers/entities.mjs.map +0 -1
- package/dist/transformers/filters/defaults.d.mts.map +0 -1
- package/dist/transformers/filters/defaults.mjs.map +0 -1
- package/dist/transformers/filters/index.d.mts +0 -22
- package/dist/transformers/filters/index.d.mts.map +0 -1
- package/dist/transformers/filters/index.mjs +0 -67
- package/dist/transformers/filters/index.mjs.map +0 -1
- package/dist/transformers/format.d.mts +0 -15
- package/dist/transformers/format.d.mts.map +0 -1
- package/dist/transformers/format.mjs +0 -26
- package/dist/transformers/format.mjs.map +0 -1
- package/dist/transformers/index.d.mts.map +0 -1
- package/dist/transformers/index.mjs +0 -81
- package/dist/transformers/index.mjs.map +0 -1
- package/dist/transformers/inlineCSS.d.mts +0 -17
- package/dist/transformers/inlineCSS.d.mts.map +0 -1
- package/dist/transformers/inlineCSS.mjs +0 -70
- package/dist/transformers/inlineCSS.mjs.map +0 -1
- package/dist/transformers/inlineLink.d.mts +0 -14
- package/dist/transformers/inlineLink.d.mts.map +0 -1
- package/dist/transformers/inlineLink.mjs.map +0 -1
- package/dist/transformers/minify.d.mts +0 -17
- package/dist/transformers/minify.d.mts.map +0 -1
- package/dist/transformers/minify.mjs +0 -24
- package/dist/transformers/minify.mjs.map +0 -1
- package/dist/transformers/purgeCSS.d.mts +0 -23
- package/dist/transformers/purgeCSS.d.mts.map +0 -1
- package/dist/transformers/purgeCSS.mjs +0 -132
- package/dist/transformers/purgeCSS.mjs.map +0 -1
- package/dist/transformers/removeAttributes.d.mts +0 -31
- package/dist/transformers/removeAttributes.d.mts.map +0 -1
- package/dist/transformers/removeAttributes.mjs +0 -63
- package/dist/transformers/removeAttributes.mjs.map +0 -1
- package/dist/transformers/replaceStrings.d.mts.map +0 -1
- package/dist/transformers/replaceStrings.mjs.map +0 -1
- package/dist/transformers/safeClassNames.d.mts +0 -22
- package/dist/transformers/safeClassNames.d.mts.map +0 -1
- package/dist/transformers/safeClassNames.mjs.map +0 -1
- package/dist/transformers/shorthandCSS.d.mts +0 -24
- package/dist/transformers/shorthandCSS.d.mts.map +0 -1
- package/dist/transformers/shorthandCSS.mjs +0 -48
- package/dist/transformers/shorthandCSS.mjs.map +0 -1
- package/dist/transformers/sixHex.d.mts +0 -16
- package/dist/transformers/sixHex.d.mts.map +0 -1
- package/dist/transformers/sixHex.mjs +0 -30
- package/dist/transformers/sixHex.mjs.map +0 -1
- package/dist/transformers/tailwindcss.d.mts.map +0 -1
- package/dist/transformers/tailwindcss.mjs.map +0 -1
- package/dist/transformers/urlQuery.d.mts +0 -24
- package/dist/transformers/urlQuery.d.mts.map +0 -1
- package/dist/transformers/urlQuery.mjs +0 -65
- package/dist/transformers/urlQuery.mjs.map +0 -1
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/config.mjs +0 -1
- package/dist/types/index.d.mts +0 -2
- package/dist/types/index.mjs +0 -1
- package/dist/utils/ast/index.d.mts +0 -4
- package/dist/utils/ast/index.mjs +0 -5
- package/dist/utils/ast/parser.d.mts.map +0 -1
- package/dist/utils/ast/parser.mjs.map +0 -1
- package/dist/utils/ast/serializer.d.mts.map +0 -1
- package/dist/utils/ast/serializer.mjs +0 -37
- package/dist/utils/ast/serializer.mjs.map +0 -1
- package/dist/utils/ast/walker.d.mts.map +0 -1
- package/dist/utils/ast/walker.mjs.map +0 -1
- package/dist/utils/detect.d.mts.map +0 -1
- package/dist/utils/detect.mjs.map +0 -1
- package/dist/utils/url.d.mts.map +0 -1
- package/dist/utils/url.mjs.map +0 -1
- package/node_modules/@clack/core/dist/index.mjs.map +0 -1
- package/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
- package/node_modules/fast-wrap-ansi/lib/main.js.map +0 -1
- package/node_modules/maizzle/dist/commands/make/stubs/layout.vue +0 -39
- package/node_modules/tinyexec/dist/LICENSES.txt +0 -83
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../utils/ast/
|
|
1
|
+
import { parse } from "../utils/ast/parser.js";
|
|
2
|
+
import { walk } from "../utils/ast/walker.js";
|
|
3
|
+
import { serialize } from "../utils/ast/serializer.js";
|
|
4
|
+
import "../utils/ast/index.js";
|
|
3
5
|
import postcss from "postcss";
|
|
4
6
|
import safeParser from "postcss-safe-parser";
|
|
5
|
-
|
|
6
|
-
//#region src/transformers/safeClassNames.ts
|
|
7
|
+
//#region src/transformers/safeSelectors.ts
|
|
7
8
|
const DEFAULT_REPLACEMENTS = {
|
|
8
9
|
":": "-",
|
|
9
10
|
"/": "-",
|
|
@@ -50,7 +51,19 @@ function processCssSelectors(css, replacements) {
|
|
|
50
51
|
const selectorRegex = new RegExp(`\\\\(${Object.keys(replacements).map(escapeForRegex).join("|")})`, "g");
|
|
51
52
|
return postcss([(root) => {
|
|
52
53
|
root.walkRules((rule) => {
|
|
53
|
-
rule.selector = rule.selector.replace(selectorRegex, (
|
|
54
|
+
rule.selector = rule.selector.replace(selectorRegex, (matched, char, offset, str) => {
|
|
55
|
+
/**
|
|
56
|
+
* Yahoo Mail wraps content in a class literally named `&`, so
|
|
57
|
+
* the selector `.\&` must be preserved. Detect it as a
|
|
58
|
+
* `\&` that follows a `.` and ends the class atom
|
|
59
|
+
* (space, combinator, comma, `{`, or end-of-str).
|
|
60
|
+
*/
|
|
61
|
+
if (char === "&" && str[offset - 1] === ".") {
|
|
62
|
+
const next = str[offset + 2];
|
|
63
|
+
if (next === void 0 || /[\s,{>~+)]/.test(next)) return matched;
|
|
64
|
+
}
|
|
65
|
+
return replacements[char] ?? matched;
|
|
66
|
+
}).replaceAll("\\2c ", "_");
|
|
54
67
|
});
|
|
55
68
|
}]).process(css, { parser: safeParser }).css;
|
|
56
69
|
}
|
|
@@ -67,7 +80,7 @@ function processClassAttr(classStr, replacements) {
|
|
|
67
80
|
}).join(" ");
|
|
68
81
|
}
|
|
69
82
|
/**
|
|
70
|
-
* Safe
|
|
83
|
+
* Safe selectors transformer.
|
|
71
84
|
*
|
|
72
85
|
* Replaces unsafe characters (`:`, `/`, `[`, `]`, etc.) in:
|
|
73
86
|
* - CSS selectors inside `<style>` tags
|
|
@@ -79,8 +92,25 @@ function processClassAttr(classStr, replacements) {
|
|
|
79
92
|
* Enabled by default. Disable by setting `css.safe` to `false`.
|
|
80
93
|
* Customize replacements by passing a `Record<string, string>` — user
|
|
81
94
|
* values are merged on top of the defaults.
|
|
95
|
+
*
|
|
96
|
+
* @param html HTML string to transform.
|
|
97
|
+
* @param config CSS config (see {@link CssConfig}).
|
|
98
|
+
* @returns The transformed HTML string.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* import { safeSelectors } from '@maizzle/framework'
|
|
102
|
+
*
|
|
103
|
+
* const out = safeSelectors('<div class="sm:text-base"></div>')
|
|
82
104
|
*/
|
|
83
|
-
function
|
|
105
|
+
function safeSelectors(html, config = {}) {
|
|
106
|
+
return serialize(safeSelectorsDom(parse(html), config));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* DOM-form of {@link safeSelectors} used by the internal transformer pipeline.
|
|
110
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
111
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
112
|
+
*/
|
|
113
|
+
function safeSelectorsDom(dom, config = {}) {
|
|
84
114
|
const option = config.safe ?? true;
|
|
85
115
|
if (!option) return dom;
|
|
86
116
|
const replacements = option && typeof option === "object" ? {
|
|
@@ -97,7 +127,7 @@ function safeClassNames(dom, config = {}) {
|
|
|
97
127
|
});
|
|
98
128
|
return dom;
|
|
99
129
|
}
|
|
100
|
-
|
|
101
130
|
//#endregion
|
|
102
|
-
export {
|
|
103
|
-
|
|
131
|
+
export { safeSelectors, safeSelectorsDom };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=safeSelectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeSelectors.js","names":[],"sources":["../../src/transformers/safeSelectors.ts"],"sourcesContent":["import postcss from 'postcss'\nimport safeParser from 'postcss-safe-parser'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\nimport type { CssConfig } from '../types/config.ts'\n\nconst DEFAULT_REPLACEMENTS: Record<string, string> = {\n ':': '-',\n '/': '-',\n '%': 'pc',\n '.': '_',\n ',': '_',\n '#': '_',\n '[': '',\n ']': '',\n '(': '',\n ')': '',\n '{': '',\n '}': '',\n '!': '-i',\n '&': 'and-',\n '<': 'lt-',\n '=': 'eq-',\n '>': 'gt-',\n '|': 'or-',\n '@': 'at-',\n '?': 'q-',\n '\\\\': '-',\n '\"': '-',\n \"'\": '-',\n '*': '-',\n '+': '-',\n ';': '-',\n '^': '-',\n '`': '-',\n '~': '-',\n '$': '-',\n}\n\nfunction escapeForRegex(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/**\n * Replace escaped special characters in CSS selectors.\n *\n * Tailwind generates selectors like `.sm\\:text-base`. This function\n * replaces the `\\:` with `-` (or whatever the configured replacement is)\n * so the selector becomes `.sm-text-base`, which is safe for email clients.\n */\nfunction processCssSelectors(css: string, replacements: Record<string, string>): string {\n // Matches \\<char> in CSS selectors — e.g. \\: \\/ \\. \\[ etc.\n const selectorRegex = new RegExp(\n `\\\\\\\\(${Object.keys(replacements).map(escapeForRegex).join('|')})`,\n 'g',\n )\n\n return postcss([\n (root: postcss.Root) => {\n root.walkRules((rule: postcss.Rule) => {\n rule.selector = rule.selector\n .replace(selectorRegex, (matched, char, offset, str) => {\n /**\n * Yahoo Mail wraps content in a class literally named `&`, so\n * the selector `.\\&` must be preserved. Detect it as a\n * `\\&` that follows a `.` and ends the class atom\n * (space, combinator, comma, `{`, or end-of-str).\n */\n if (char === '&' && str[offset - 1] === '.') {\n const next = str[offset + 2]\n if (next === undefined || /[\\s,{>~+)]/.test(next)) return matched\n }\n return replacements[char] ?? matched\n })\n // Handle CSS unicode escape for comma (\\2c → _)\n .replaceAll('\\\\2c ', '_')\n })\n },\n ]).process(css, { parser: safeParser }).css\n}\n\n/**\n * Replace unsafe special characters in a class attribute value.\n *\n * Splits on whitespace and replaces each char from the replacements map\n * in each class token individually.\n */\nfunction processClassAttr(classStr: string, replacements: Record<string, string>): string {\n return classStr\n .split(/\\s+/)\n .filter(Boolean)\n .map((cls) => {\n for (const [from, to] of Object.entries(replacements)) {\n cls = cls.split(from).join(to)\n }\n return cls\n })\n .join(' ')\n}\n\n/**\n * Safe selectors transformer.\n *\n * Replaces unsafe characters (`:`, `/`, `[`, `]`, etc.) in:\n * - CSS selectors inside `<style>` tags\n * - HTML `class` attributes\n *\n * This makes Tailwind utility classes like `sm:text-base` safe for\n * email clients that cannot handle escaped characters in class names.\n *\n * Enabled by default. Disable by setting `css.safe` to `false`.\n * Customize replacements by passing a `Record<string, string>` — user\n * values are merged on top of the defaults.\n *\n * @param html HTML string to transform.\n * @param config CSS config (see {@link CssConfig}).\n * @returns The transformed HTML string.\n *\n * @example\n * import { safeSelectors } from '@maizzle/framework'\n *\n * const out = safeSelectors('<div class=\"sm:text-base\"></div>')\n */\nexport function safeSelectors(html: string, config: CssConfig = {}): string {\n return serialize(safeSelectorsDom(parse(html), config))\n}\n\n/**\n * DOM-form of {@link safeSelectors} 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 function safeSelectorsDom(dom: ChildNode[], config: CssConfig = {}): ChildNode[] {\n const option = config.safe ?? true\n\n if (!option) return dom\n\n const replacements: Record<string, string> =\n option && typeof option === 'object'\n ? { ...DEFAULT_REPLACEMENTS, ...option }\n : DEFAULT_REPLACEMENTS\n\n walk(dom, (node) => {\n const el = node as Element\n\n // Process CSS selectors inside <style> tags\n if (el.name === 'style' && el.children?.length) {\n const text = el.children.find((c) => c.type === 'text') as any\n if (text?.data?.trim()) {\n text.data = processCssSelectors(text.data, replacements)\n }\n }\n\n // Replace special chars in class attributes\n if ('attribs' in el && el.attribs?.class) {\n el.attribs.class = processClassAttr(el.attribs.class, replacements)\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;;AAMA,MAAM,uBAA+C;CACnD,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,SAAS,eAAe,GAAmB;CACzC,OAAO,EAAE,QAAQ,uBAAuB,MAAM;AAChD;;;;;;;;AASA,SAAS,oBAAoB,KAAa,cAA8C;CAEtF,MAAM,gBAAgB,IAAI,OACxB,QAAQ,OAAO,KAAK,YAAY,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,KAAK,GAAG,EAAE,IAChE,GACF;CAEA,OAAO,QAAQ,EACZ,SAAuB;EACtB,KAAK,WAAW,SAAuB;GACrC,KAAK,WAAW,KAAK,SAClB,QAAQ,gBAAgB,SAAS,MAAM,QAAQ,QAAQ;;;;;;;IAOtD,IAAI,SAAS,OAAO,IAAI,SAAS,OAAO,KAAK;KAC3C,MAAM,OAAO,IAAI,SAAS;KAC1B,IAAI,SAAS,KAAA,KAAa,aAAa,KAAK,IAAI,GAAG,OAAO;IAC5D;IACA,OAAO,aAAa,SAAS;GAC/B,CAAC,CAAC,CAED,WAAW,SAAS,GAAG;EAC5B,CAAC;CACH,CACF,CAAC,CAAC,CAAC,QAAQ,KAAK,EAAE,QAAQ,WAAW,CAAC,CAAC,CAAC;AAC1C;;;;;;;AAQA,SAAS,iBAAiB,UAAkB,cAA8C;CACxF,OAAO,SACJ,MAAM,KAAK,CAAC,CACZ,OAAO,OAAO,CAAC,CACf,KAAK,QAAQ;EACZ,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,YAAY,GAClD,MAAM,IAAI,MAAM,IAAI,CAAC,CAAC,KAAK,EAAE;EAE/B,OAAO;CACT,CAAC,CAAC,CACD,KAAK,GAAG;AACb;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,cAAc,MAAc,SAAoB,CAAC,GAAW;CAC1E,OAAO,UAAU,iBAAiB,MAAM,IAAI,GAAG,MAAM,CAAC;AACxD;;;;;;AAOA,SAAgB,iBAAiB,KAAkB,SAAoB,CAAC,GAAgB;CACtF,MAAM,SAAS,OAAO,QAAQ;CAE9B,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,eACJ,UAAU,OAAO,WAAW,WACxB;EAAE,GAAG;EAAsB,GAAG;CAAO,IACrC;CAEN,KAAK,MAAM,SAAS;EAClB,MAAM,KAAK;EAGX,IAAI,GAAG,SAAS,WAAW,GAAG,UAAU,QAAQ;GAC9C,MAAM,OAAO,GAAG,SAAS,MAAM,MAAM,EAAE,SAAS,MAAM;GACtD,IAAI,MAAM,MAAM,KAAK,GACnB,KAAK,OAAO,oBAAoB,KAAK,MAAM,YAAY;EAE3D;EAGA,IAAI,aAAa,MAAM,GAAG,SAAS,OACjC,GAAG,QAAQ,QAAQ,iBAAiB,GAAG,QAAQ,OAAO,YAAY;CAEtE,CAAC;CAED,OAAO;AACT"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ChildNode } from "domhandler";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/shorthandCss.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options for the `shorthandCss` transformer.
|
|
6
|
+
*/
|
|
7
|
+
interface ShorthandCssOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Restrict the transform to a list of HTML tag names. Omit to apply to
|
|
10
|
+
* every element with a `style` attribute.
|
|
11
|
+
*
|
|
12
|
+
* @example ['td', 'div']
|
|
13
|
+
*/
|
|
14
|
+
tags?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Rewrite longhand CSS inside inline `style` attributes with shorthand
|
|
18
|
+
* syntax. Works with margin, padding, and border when all sides are
|
|
19
|
+
* specified.
|
|
20
|
+
*
|
|
21
|
+
* For example:
|
|
22
|
+
* `margin-left: 2px; margin-right: 2px; margin-top: 4px; margin-bottom: 4px`
|
|
23
|
+
* becomes:
|
|
24
|
+
* `margin: 4px 2px`
|
|
25
|
+
*
|
|
26
|
+
* @param html HTML string to transform.
|
|
27
|
+
* @param options Optional Maizzle options (`tags`).
|
|
28
|
+
* @returns The transformed HTML string.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* import { shorthandCss } from '@maizzle/framework'
|
|
32
|
+
*
|
|
33
|
+
* const out = shorthandCss(
|
|
34
|
+
* '<p style="margin-top: 4px; margin-right: 2px; margin-bottom: 4px; margin-left: 2px;">x</p>',
|
|
35
|
+
* { tags: ['p'] },
|
|
36
|
+
* )
|
|
37
|
+
*/
|
|
38
|
+
declare function shorthandCss(html: string, options?: ShorthandCssOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* DOM-form of {@link shorthandCss} used by the internal transformer
|
|
41
|
+
* pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
42
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
43
|
+
*/
|
|
44
|
+
declare function shorthandCssDom(dom: ChildNode[], options?: ShorthandCssOptions): ChildNode[];
|
|
45
|
+
//#endregion
|
|
46
|
+
export { ShorthandCssOptions, shorthandCss, shorthandCssDom };
|
|
47
|
+
//# sourceMappingURL=shorthandCss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthandCss.d.ts","names":[],"sources":["../../src/transformers/shorthandCss.ts"],"mappings":";;;;;AASA;UAAiB,mBAAA;;;AAOX;AAyBN;;;EAzBE,IAAI;AAAA;;;;AAyBsE;AAS5E;;;;;;;;;;;;;;AAA+F;;;;iBAT/E,YAAA,CAAa,IAAA,UAAc,OAAA,GAAS,mBAAwB;;;;;;iBAS5D,eAAA,CAAgB,GAAA,EAAK,SAAA,IAAa,OAAA,GAAS,mBAAA,GAA2B,SAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { parse } from "../utils/ast/parser.js";
|
|
2
|
+
import { walk } from "../utils/ast/walker.js";
|
|
3
|
+
import { serialize } from "../utils/ast/serializer.js";
|
|
4
|
+
import "../utils/ast/index.js";
|
|
5
|
+
import postcss from "postcss";
|
|
6
|
+
import safeParser from "postcss-safe-parser";
|
|
7
|
+
import mergeLonghand from "postcss-merge-longhand";
|
|
8
|
+
//#region src/transformers/shorthandCss.ts
|
|
9
|
+
/**
|
|
10
|
+
* Rewrite longhand CSS inside inline `style` attributes with shorthand
|
|
11
|
+
* syntax. Works with margin, padding, and border when all sides are
|
|
12
|
+
* specified.
|
|
13
|
+
*
|
|
14
|
+
* For example:
|
|
15
|
+
* `margin-left: 2px; margin-right: 2px; margin-top: 4px; margin-bottom: 4px`
|
|
16
|
+
* becomes:
|
|
17
|
+
* `margin: 4px 2px`
|
|
18
|
+
*
|
|
19
|
+
* @param html HTML string to transform.
|
|
20
|
+
* @param options Optional Maizzle options (`tags`).
|
|
21
|
+
* @returns The transformed HTML string.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { shorthandCss } from '@maizzle/framework'
|
|
25
|
+
*
|
|
26
|
+
* const out = shorthandCss(
|
|
27
|
+
* '<p style="margin-top: 4px; margin-right: 2px; margin-bottom: 4px; margin-left: 2px;">x</p>',
|
|
28
|
+
* { tags: ['p'] },
|
|
29
|
+
* )
|
|
30
|
+
*/
|
|
31
|
+
function shorthandCss(html, options = {}) {
|
|
32
|
+
return serialize(shorthandCssDom(parse(html), options));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* DOM-form of {@link shorthandCss} used by the internal transformer
|
|
36
|
+
* pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
37
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
38
|
+
*/
|
|
39
|
+
function shorthandCssDom(dom, options = {}) {
|
|
40
|
+
const allowedTags = options.tags ?? [];
|
|
41
|
+
const hasTagFilter = allowedTags.length > 0;
|
|
42
|
+
/**
|
|
43
|
+
* Merge longhand within a single inline-style value. Returns the merged
|
|
44
|
+
* string when shorter, otherwise the original. Wraps the value in a
|
|
45
|
+
* dummy selector since postcss-merge-longhand operates on rules.
|
|
46
|
+
*/
|
|
47
|
+
const mergeStyleValue = (styleValue) => {
|
|
48
|
+
try {
|
|
49
|
+
const { css } = postcss().use(mergeLonghand).process(`div { ${styleValue} }`, { parser: safeParser });
|
|
50
|
+
const match = css.match(/div\s*\{\s*([^}]+)\s*\}/);
|
|
51
|
+
if (match && match[1]) {
|
|
52
|
+
const merged = match[1].trim();
|
|
53
|
+
if (merged !== styleValue) return merged;
|
|
54
|
+
}
|
|
55
|
+
} catch {}
|
|
56
|
+
return styleValue;
|
|
57
|
+
};
|
|
58
|
+
walk(dom, (node) => {
|
|
59
|
+
/**
|
|
60
|
+
* MSO conditional comments carry their own inline-style attributes
|
|
61
|
+
* (e.g. `<!--[if mso]><td style="…"><![endif]-->`) as opaque text.
|
|
62
|
+
* The element walker can't see them, so without this branch the td/
|
|
63
|
+
* v:rect styles inside comments stay longhand even when the visible
|
|
64
|
+
* div has already been merged. Match each `style="…"` substring,
|
|
65
|
+
* run it through mergeLonghand, splice back.
|
|
66
|
+
*
|
|
67
|
+
* Tag filter intentionally bypassed: the user can't address MSO td
|
|
68
|
+
* elements (they don't parse as elements), and these comments
|
|
69
|
+
* always wrap email-layout primitives anyway.
|
|
70
|
+
*/
|
|
71
|
+
if (node.type === "comment") {
|
|
72
|
+
const data = node.data;
|
|
73
|
+
if (!data || !data.includes("style=\"")) return;
|
|
74
|
+
const newData = data.replace(/style="([^"]*)"/g, (full, value) => {
|
|
75
|
+
const merged = mergeStyleValue(value);
|
|
76
|
+
return merged === value ? full : `style="${merged}"`;
|
|
77
|
+
});
|
|
78
|
+
if (newData !== data) node.data = newData;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const el = node;
|
|
82
|
+
if (!el.attribs?.style) return;
|
|
83
|
+
if (hasTagFilter && !allowedTags.includes(el.name)) return;
|
|
84
|
+
const merged = mergeStyleValue(el.attribs.style);
|
|
85
|
+
if (merged !== el.attribs.style) el.attribs.style = merged;
|
|
86
|
+
});
|
|
87
|
+
return dom;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { shorthandCss, shorthandCssDom };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=shorthandCss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthandCss.js","names":[],"sources":["../../src/transformers/shorthandCss.ts"],"sourcesContent":["import postcss from 'postcss'\nimport safeParser from 'postcss-safe-parser'\nimport mergeLonghand from 'postcss-merge-longhand'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\n\n/**\n * Options for the `shorthandCss` transformer.\n */\nexport interface ShorthandCssOptions {\n /**\n * Restrict the transform to a list of HTML tag names. Omit to apply to\n * every element with a `style` attribute.\n *\n * @example ['td', 'div']\n */\n tags?: string[]\n}\n\n/**\n * Rewrite longhand CSS inside inline `style` attributes with shorthand\n * syntax. Works with margin, padding, and border when all sides are\n * specified.\n *\n * For example:\n * `margin-left: 2px; margin-right: 2px; margin-top: 4px; margin-bottom: 4px`\n * becomes:\n * `margin: 4px 2px`\n *\n * @param html HTML string to transform.\n * @param options Optional Maizzle options (`tags`).\n * @returns The transformed HTML string.\n *\n * @example\n * import { shorthandCss } from '@maizzle/framework'\n *\n * const out = shorthandCss(\n * '<p style=\"margin-top: 4px; margin-right: 2px; margin-bottom: 4px; margin-left: 2px;\">x</p>',\n * { tags: ['p'] },\n * )\n */\nexport function shorthandCss(html: string, options: ShorthandCssOptions = {}): string {\n return serialize(shorthandCssDom(parse(html), options))\n}\n\n/**\n * DOM-form of {@link shorthandCss} used by the internal transformer\n * pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant\n * serialize/parse round-trips when chained with other transformers.\n */\nexport function shorthandCssDom(dom: ChildNode[], options: ShorthandCssOptions = {}): ChildNode[] {\n const allowedTags = options.tags ?? []\n const hasTagFilter = allowedTags.length > 0\n\n /**\n * Merge longhand within a single inline-style value. Returns the merged\n * string when shorter, otherwise the original. Wraps the value in a\n * dummy selector since postcss-merge-longhand operates on rules.\n */\n const mergeStyleValue = (styleValue: string): string => {\n try {\n const { css } = postcss()\n .use(mergeLonghand)\n .process(`div { ${styleValue} }`, { parser: safeParser })\n const match = css.match(/div\\s*\\{\\s*([^}]+)\\s*\\}/)\n if (match && match[1]) {\n const merged = match[1].trim()\n if (merged !== styleValue) return merged\n }\n }\n catch {}\n return styleValue\n }\n\n walk(dom, (node) => {\n /**\n * MSO conditional comments carry their own inline-style attributes\n * (e.g. `<!--[if mso]><td style=\"…\"><![endif]-->`) as opaque text.\n * The element walker can't see them, so without this branch the td/\n * v:rect styles inside comments stay longhand even when the visible\n * div has already been merged. Match each `style=\"…\"` substring,\n * run it through mergeLonghand, splice back.\n *\n * Tag filter intentionally bypassed: the user can't address MSO td\n * elements (they don't parse as elements), and these comments\n * always wrap email-layout primitives anyway.\n */\n if (node.type === 'comment') {\n const data = (node as any).data as string\n if (!data || !data.includes('style=\"')) return\n const newData = data.replace(/style=\"([^\"]*)\"/g, (full, value) => {\n const merged = mergeStyleValue(value)\n return merged === value ? full : `style=\"${merged}\"`\n })\n if (newData !== data) (node as any).data = newData\n return\n }\n\n const el = node as Element\n\n if (!el.attribs?.style) return\n if (hasTagFilter && !allowedTags.includes(el.name)) return\n\n const merged = mergeStyleValue(el.attribs.style)\n if (merged !== el.attribs.style) el.attribs.style = merged\n })\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,aAAa,MAAc,UAA+B,CAAC,GAAW;CACpF,OAAO,UAAU,gBAAgB,MAAM,IAAI,GAAG,OAAO,CAAC;AACxD;;;;;;AAOA,SAAgB,gBAAgB,KAAkB,UAA+B,CAAC,GAAgB;CAChG,MAAM,cAAc,QAAQ,QAAQ,CAAC;CACrC,MAAM,eAAe,YAAY,SAAS;;;;;;CAO1C,MAAM,mBAAmB,eAA+B;EACtD,IAAI;GACF,MAAM,EAAE,QAAQ,QAAQ,CAAC,CACtB,IAAI,aAAa,CAAC,CAClB,QAAQ,SAAS,WAAW,KAAK,EAAE,QAAQ,WAAW,CAAC;GAC1D,MAAM,QAAQ,IAAI,MAAM,yBAAyB;GACjD,IAAI,SAAS,MAAM,IAAI;IACrB,MAAM,SAAS,MAAM,EAAE,CAAC,KAAK;IAC7B,IAAI,WAAW,YAAY,OAAO;GACpC;EACF,QACM,CAAC;EACP,OAAO;CACT;CAEA,KAAK,MAAM,SAAS;;;;;;;;;;;;;EAalB,IAAI,KAAK,SAAS,WAAW;GAC3B,MAAM,OAAQ,KAAa;GAC3B,IAAI,CAAC,QAAQ,CAAC,KAAK,SAAS,UAAS,GAAG;GACxC,MAAM,UAAU,KAAK,QAAQ,qBAAqB,MAAM,UAAU;IAChE,MAAM,SAAS,gBAAgB,KAAK;IACpC,OAAO,WAAW,QAAQ,OAAO,UAAU,OAAO;GACpD,CAAC;GACD,IAAI,YAAY,MAAM,KAAc,OAAO;GAC3C;EACF;EAEA,MAAM,KAAK;EAEX,IAAI,CAAC,GAAG,SAAS,OAAO;EACxB,IAAI,gBAAgB,CAAC,YAAY,SAAS,GAAG,IAAI,GAAG;EAEpD,MAAM,SAAS,gBAAgB,GAAG,QAAQ,KAAK;EAC/C,IAAI,WAAW,GAAG,QAAQ,OAAO,GAAG,QAAQ,QAAQ;CACtD,CAAC;CAED,OAAO;AACT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChildNode } from "domhandler";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/sixHex.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Convert 3-digit HEX color codes to 6-digit in `bgcolor` and `color`
|
|
6
|
+
* attributes, for better email client compatibility.
|
|
7
|
+
*
|
|
8
|
+
* @param html HTML string to transform.
|
|
9
|
+
* @returns The transformed HTML string.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { sixHex } from '@maizzle/framework'
|
|
13
|
+
*
|
|
14
|
+
* const out = sixHex('<font color="#abc">x</font>')
|
|
15
|
+
*/
|
|
16
|
+
declare function sixHex(html: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* DOM-form of {@link sixHex} used by the internal transformer pipeline.
|
|
19
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
20
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
21
|
+
*/
|
|
22
|
+
declare function sixHexDom(dom: ChildNode[]): ChildNode[];
|
|
23
|
+
//#endregion
|
|
24
|
+
export { sixHex, sixHexDom };
|
|
25
|
+
//# sourceMappingURL=sixHex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sixHex.d.ts","names":[],"sources":["../../src/transformers/sixHex.ts"],"mappings":";;;;;AAkBA;;;;AAAmC;AASnC;;;;;iBATgB,MAAA,CAAO,IAAY;;;AASmB;;;iBAAtC,SAAA,CAAU,GAAA,EAAK,SAAA,KAAc,SAAS"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { parse } from "../utils/ast/parser.js";
|
|
2
|
+
import { walk } from "../utils/ast/walker.js";
|
|
3
|
+
import { serialize } from "../utils/ast/serializer.js";
|
|
4
|
+
import "../utils/ast/index.js";
|
|
5
|
+
import { conv } from "color-shorthand-hex-to-six-digit";
|
|
6
|
+
//#region src/transformers/sixHex.ts
|
|
7
|
+
const targets = new Set(["bgcolor", "color"]);
|
|
8
|
+
/**
|
|
9
|
+
* Convert 3-digit HEX color codes to 6-digit in `bgcolor` and `color`
|
|
10
|
+
* attributes, for better email client compatibility.
|
|
11
|
+
*
|
|
12
|
+
* @param html HTML string to transform.
|
|
13
|
+
* @returns The transformed HTML string.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { sixHex } from '@maizzle/framework'
|
|
17
|
+
*
|
|
18
|
+
* const out = sixHex('<font color="#abc">x</font>')
|
|
19
|
+
*/
|
|
20
|
+
function sixHex(html) {
|
|
21
|
+
return serialize(sixHexDom(parse(html)));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* DOM-form of {@link sixHex} used by the internal transformer pipeline.
|
|
25
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
26
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
27
|
+
*/
|
|
28
|
+
function sixHexDom(dom) {
|
|
29
|
+
walk(dom, (node) => {
|
|
30
|
+
const el = node;
|
|
31
|
+
if (!el.attribs) return;
|
|
32
|
+
for (const attr of targets) {
|
|
33
|
+
const value = el.attribs[attr];
|
|
34
|
+
if (value) el.attribs[attr] = conv(value);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return dom;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { sixHex, sixHexDom };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=sixHex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sixHex.js","names":[],"sources":["../../src/transformers/sixHex.ts"],"sourcesContent":["import { conv } from 'color-shorthand-hex-to-six-digit'\nimport type { ChildNode, Element } from 'domhandler'\nimport { parse, serialize, walk } from '../utils/ast/index.ts'\n\nconst targets = new Set(['bgcolor', 'color'])\n\n/**\n * Convert 3-digit HEX color codes to 6-digit in `bgcolor` and `color`\n * attributes, for better email client compatibility.\n *\n * @param html HTML string to transform.\n * @returns The transformed HTML string.\n *\n * @example\n * import { sixHex } from '@maizzle/framework'\n *\n * const out = sixHex('<font color=\"#abc\">x</font>')\n */\nexport function sixHex(html: string): string {\n return serialize(sixHexDom(parse(html)))\n}\n\n/**\n * DOM-form of {@link sixHex} 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 function sixHexDom(dom: ChildNode[]): ChildNode[] {\n walk(dom, (node) => {\n const el = node as Element\n\n if (!el.attribs) {\n return\n }\n\n for (const attr of targets) {\n const value = el.attribs[attr]\n\n if (value) {\n el.attribs[attr] = conv(value)\n }\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;AAIA,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,OAAO,CAAC;;;;;;;;;;;;;AAc5C,SAAgB,OAAO,MAAsB;CAC3C,OAAO,UAAU,UAAU,MAAM,IAAI,CAAC,CAAC;AACzC;;;;;;AAOA,SAAgB,UAAU,KAA+B;CACvD,KAAK,MAAM,SAAS;EAClB,MAAM,KAAK;EAEX,IAAI,CAAC,GAAG,SACN;EAGF,KAAK,MAAM,QAAQ,SAAS;GAC1B,MAAM,QAAQ,GAAG,QAAQ;GAEzB,IAAI,OACF,GAAG,QAAQ,QAAQ,KAAK,KAAK;EAEjC;CACF,CAAC;CAED,OAAO;AACT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaizzleConfig } from "../types/config.js";
|
|
2
|
+
import { TailwindBlock } from "../composables/renderContext.js";
|
|
3
|
+
import { ChildNode } from "domhandler";
|
|
4
|
+
|
|
5
|
+
//#region src/transformers/tailwindComponent.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Compile Tailwind CSS for each top-level <Tailwind> block in the render
|
|
8
|
+
* context. Nested <Tailwind> instances are flattened: their classes flow
|
|
9
|
+
* up to the outermost block, their `#config` slot (if any) is ignored.
|
|
10
|
+
* One <style> per outermost block is appended to <head>; marker comments
|
|
11
|
+
* are stripped after.
|
|
12
|
+
*/
|
|
13
|
+
declare function tailwindComponent(dom: ChildNode[], blocks: TailwindBlock[], config: MaizzleConfig, filePath?: string): Promise<ChildNode[]>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { tailwindComponent };
|
|
16
|
+
//# sourceMappingURL=tailwindComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwindComponent.d.ts","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"mappings":";;;;;;;AA0BA;;;;;iBAAsB,iBAAA,CACpB,GAAA,EAAK,SAAA,IACL,MAAA,EAAQ,aAAA,IACR,MAAA,EAAQ,aAAA,EACR,QAAA,YACC,OAAA,CAAQ,SAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.js";
|
|
2
|
+
import "../utils/ast/index.js";
|
|
3
|
+
import { compileTailwindCss } from "../utils/compileTailwindCss.js";
|
|
4
|
+
import { resolve } from "pathe";
|
|
5
|
+
//#region src/transformers/tailwindComponent.ts
|
|
6
|
+
const DEFAULT_SEED = "@import \"@maizzle/tailwindcss\" source(none);";
|
|
7
|
+
const OPEN_RE = /^mz-tw:(\S+)$/;
|
|
8
|
+
const CLOSE_RE = /^\/mz-tw:(\S+)$/;
|
|
9
|
+
/**
|
|
10
|
+
* Compile Tailwind CSS for each top-level <Tailwind> block in the render
|
|
11
|
+
* context. Nested <Tailwind> instances are flattened: their classes flow
|
|
12
|
+
* up to the outermost block, their `#config` slot (if any) is ignored.
|
|
13
|
+
* One <style> per outermost block is appended to <head>; marker comments
|
|
14
|
+
* are stripped after.
|
|
15
|
+
*/
|
|
16
|
+
async function tailwindComponent(dom, blocks, config, filePath) {
|
|
17
|
+
if (!blocks.length) return dom;
|
|
18
|
+
const map = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const b of blocks) map.set(b.id, {
|
|
20
|
+
id: b.id,
|
|
21
|
+
configCss: b.css,
|
|
22
|
+
nested: false,
|
|
23
|
+
classes: /* @__PURE__ */ new Set()
|
|
24
|
+
});
|
|
25
|
+
const stack = [];
|
|
26
|
+
const markers = [];
|
|
27
|
+
walk(dom, (node) => {
|
|
28
|
+
if (node.type === "comment") {
|
|
29
|
+
const data = node.data;
|
|
30
|
+
const open = data.match(OPEN_RE);
|
|
31
|
+
const close = data.match(CLOSE_RE);
|
|
32
|
+
if (open) {
|
|
33
|
+
const id = open[1];
|
|
34
|
+
const meta = map.get(id);
|
|
35
|
+
if (meta && stack.length > 0) meta.nested = true;
|
|
36
|
+
if (meta) stack.push(id);
|
|
37
|
+
markers.push(node);
|
|
38
|
+
} else if (close) {
|
|
39
|
+
const id = close[1];
|
|
40
|
+
if (stack[stack.length - 1] === id) stack.pop();
|
|
41
|
+
markers.push(node);
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const el = node;
|
|
46
|
+
/**
|
|
47
|
+
* Always assign to the OUTERMOST active marker (stack[0]) so nested
|
|
48
|
+
* <Tailwind> blocks merge their classes into the parent's scope.
|
|
49
|
+
*/
|
|
50
|
+
if (el.attribs?.class && stack.length > 0) map.get(stack[0]).classes.add(el.attribs.class);
|
|
51
|
+
});
|
|
52
|
+
const fromPath = filePath ?? resolve(process.cwd(), "template.vue");
|
|
53
|
+
let head;
|
|
54
|
+
walk(dom, (n) => {
|
|
55
|
+
if (!head && n.name === "head") head = n;
|
|
56
|
+
});
|
|
57
|
+
if (!head) throw new Error("`Tailwind` component requires `Head` component to be present in the template.");
|
|
58
|
+
/**
|
|
59
|
+
* Compile + inject one <style raw> per outermost block. `raw` opts
|
|
60
|
+
* the existing tailwindcss transformer out of recompiling
|
|
61
|
+
* already-compiled CSS.
|
|
62
|
+
*/
|
|
63
|
+
for (const meta of map.values()) {
|
|
64
|
+
if (meta.nested) continue;
|
|
65
|
+
const css = (await compileTailwindCss(buildCssInput(meta.configCss, meta.classes), config, `${fromPath}?tw=${meta.id}`)).trim();
|
|
66
|
+
if (!css) continue;
|
|
67
|
+
const styleNode = {
|
|
68
|
+
type: "tag",
|
|
69
|
+
name: "style",
|
|
70
|
+
attribs: { raw: "" },
|
|
71
|
+
children: [],
|
|
72
|
+
parent: head,
|
|
73
|
+
prev: null,
|
|
74
|
+
next: null
|
|
75
|
+
};
|
|
76
|
+
styleNode.children = [{
|
|
77
|
+
type: "text",
|
|
78
|
+
data: css,
|
|
79
|
+
parent: styleNode,
|
|
80
|
+
prev: null,
|
|
81
|
+
next: null
|
|
82
|
+
}];
|
|
83
|
+
head.children.push(styleNode);
|
|
84
|
+
}
|
|
85
|
+
for (const c of markers) {
|
|
86
|
+
const parent = c.parent;
|
|
87
|
+
if (!parent?.children) continue;
|
|
88
|
+
const i = parent.children.indexOf(c);
|
|
89
|
+
if (i >= 0) parent.children.splice(i, 1);
|
|
90
|
+
}
|
|
91
|
+
return dom;
|
|
92
|
+
}
|
|
93
|
+
function buildCssInput(configCss, classes) {
|
|
94
|
+
const seed = configCss ?? DEFAULT_SEED;
|
|
95
|
+
if (!classes.size) return seed;
|
|
96
|
+
return `${seed}\n@source inline("${[...classes].join(" ").replace(/"/g, "\\\"")}");`;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { tailwindComponent };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=tailwindComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwindComponent.js","names":[],"sources":["../../src/transformers/tailwindComponent.ts"],"sourcesContent":["import { resolve } from 'pathe'\nimport type { ChildNode, Element, Comment } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport { compileTailwindCss } from '../utils/compileTailwindCss.ts'\nimport type { TailwindBlock } from '../composables/renderContext.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\nconst DEFAULT_SEED = '@import \"@maizzle/tailwindcss\" source(none);'\n\ninterface BlockMeta {\n id: string\n configCss?: string\n nested: boolean\n classes: Set<string>\n}\n\nconst OPEN_RE = /^mz-tw:(\\S+)$/\nconst CLOSE_RE = /^\\/mz-tw:(\\S+)$/\n\n/**\n * Compile Tailwind CSS for each top-level <Tailwind> block in the render\n * context. Nested <Tailwind> instances are flattened: their classes flow\n * up to the outermost block, their `#config` slot (if any) is ignored.\n * One <style> per outermost block is appended to <head>; marker comments\n * are stripped after.\n */\nexport async function tailwindComponent(\n dom: ChildNode[],\n blocks: TailwindBlock[],\n config: MaizzleConfig,\n filePath?: string,\n): Promise<ChildNode[]> {\n if (!blocks.length) return dom\n\n const map = new Map<string, BlockMeta>()\n for (const b of blocks) {\n map.set(b.id, { id: b.id, configCss: b.css, nested: false, classes: new Set() })\n }\n\n const stack: string[] = []\n const markers: Comment[] = []\n\n walk(dom, (node) => {\n if (node.type === 'comment') {\n const data = (node as Comment).data\n const open = data.match(OPEN_RE)\n const close = data.match(CLOSE_RE)\n if (open) {\n const id = open[1]\n const meta = map.get(id)\n if (meta && stack.length > 0) meta.nested = true\n if (meta) stack.push(id)\n markers.push(node as Comment)\n } else if (close) {\n const id = close[1]\n if (stack[stack.length - 1] === id) stack.pop()\n markers.push(node as Comment)\n }\n return\n }\n\n const el = node as Element\n /**\n * Always assign to the OUTERMOST active marker (stack[0]) so nested\n * <Tailwind> blocks merge their classes into the parent's scope.\n */\n if (el.attribs?.class && stack.length > 0) {\n map.get(stack[0])!.classes.add(el.attribs.class)\n }\n })\n\n const fromPath = filePath ?? resolve(process.cwd(), 'template.vue')\n\n let head: Element | undefined\n walk(dom, (n) => {\n if (!head && (n as Element).name === 'head') head = n as Element\n })\n\n if (!head) {\n throw new Error('`Tailwind` component requires `Head` component to be present in the template.')\n }\n\n /**\n * Compile + inject one <style raw> per outermost block. `raw` opts\n * the existing tailwindcss transformer out of recompiling\n * already-compiled CSS.\n */\n for (const meta of map.values()) {\n if (meta.nested) continue\n\n const cssInput = buildCssInput(meta.configCss, meta.classes)\n const css = (await compileTailwindCss(cssInput, config, `${fromPath}?tw=${meta.id}`)).trim()\n if (!css) continue\n\n const styleNode: Element = {\n type: 'tag',\n name: 'style',\n attribs: { raw: '' },\n children: [],\n parent: head,\n prev: null,\n next: null,\n } as any\n\n const textNode = {\n type: 'text',\n data: css,\n parent: styleNode,\n prev: null,\n next: null,\n } as any\n\n styleNode.children = [textNode]\n head.children.push(styleNode)\n }\n\n // Strip marker comments from their parents\n for (const c of markers) {\n const parent = c.parent as Element | null\n if (!parent?.children) continue\n const i = parent.children.indexOf(c)\n if (i >= 0) parent.children.splice(i, 1)\n }\n\n return dom\n}\n\nfunction buildCssInput(configCss: string | undefined, classes: Set<string>): string {\n const seed = configCss ?? DEFAULT_SEED\n\n if (!classes.size) return seed\n\n const inline = [...classes].join(' ').replace(/\"/g, '\\\\\"')\n return `${seed}\\n@source inline(\"${inline}\");`\n}\n"],"mappings":";;;;;AAOA,MAAM,eAAe;AASrB,MAAM,UAAU;AAChB,MAAM,WAAW;;;;;;;;AASjB,eAAsB,kBACpB,KACA,QACA,QACA,UACsB;CACtB,IAAI,CAAC,OAAO,QAAQ,OAAO;CAE3B,MAAM,sBAAM,IAAI,IAAuB;CACvC,KAAK,MAAM,KAAK,QACd,IAAI,IAAI,EAAE,IAAI;EAAE,IAAI,EAAE;EAAI,WAAW,EAAE;EAAK,QAAQ;EAAO,yBAAS,IAAI,IAAI;CAAE,CAAC;CAGjF,MAAM,QAAkB,CAAC;CACzB,MAAM,UAAqB,CAAC;CAE5B,KAAK,MAAM,SAAS;EAClB,IAAI,KAAK,SAAS,WAAW;GAC3B,MAAM,OAAQ,KAAiB;GAC/B,MAAM,OAAO,KAAK,MAAM,OAAO;GAC/B,MAAM,QAAQ,KAAK,MAAM,QAAQ;GACjC,IAAI,MAAM;IACR,MAAM,KAAK,KAAK;IAChB,MAAM,OAAO,IAAI,IAAI,EAAE;IACvB,IAAI,QAAQ,MAAM,SAAS,GAAG,KAAK,SAAS;IAC5C,IAAI,MAAM,MAAM,KAAK,EAAE;IACvB,QAAQ,KAAK,IAAe;GAC9B,OAAO,IAAI,OAAO;IAChB,MAAM,KAAK,MAAM;IACjB,IAAI,MAAM,MAAM,SAAS,OAAO,IAAI,MAAM,IAAI;IAC9C,QAAQ,KAAK,IAAe;GAC9B;GACA;EACF;EAEA,MAAM,KAAK;;;;;EAKX,IAAI,GAAG,SAAS,SAAS,MAAM,SAAS,GACtC,IAAI,IAAI,MAAM,EAAE,CAAC,CAAE,QAAQ,IAAI,GAAG,QAAQ,KAAK;CAEnD,CAAC;CAED,MAAM,WAAW,YAAY,QAAQ,QAAQ,IAAI,GAAG,cAAc;CAElE,IAAI;CACJ,KAAK,MAAM,MAAM;EACf,IAAI,CAAC,QAAS,EAAc,SAAS,QAAQ,OAAO;CACtD,CAAC;CAED,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,+EAA+E;;;;;;CAQjG,KAAK,MAAM,QAAQ,IAAI,OAAO,GAAG;EAC/B,IAAI,KAAK,QAAQ;EAGjB,MAAM,OAAO,MAAM,mBADF,cAAc,KAAK,WAAW,KAAK,OACP,GAAG,QAAQ,GAAG,SAAS,MAAM,KAAK,IAAI,EAAA,CAAG,KAAK;EAC3F,IAAI,CAAC,KAAK;EAEV,MAAM,YAAqB;GACzB,MAAM;GACN,MAAM;GACN,SAAS,EAAE,KAAK,GAAG;GACnB,UAAU,CAAC;GACX,QAAQ;GACR,MAAM;GACN,MAAM;EACR;EAUA,UAAU,WAAW,CAAC;GAPpB,MAAM;GACN,MAAM;GACN,QAAQ;GACR,MAAM;GACN,MAAM;EAGqB,CAAC;EAC9B,KAAK,SAAS,KAAK,SAAS;CAC9B;CAGA,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,SAAS,EAAE;EACjB,IAAI,CAAC,QAAQ,UAAU;EACvB,MAAM,IAAI,OAAO,SAAS,QAAQ,CAAC;EACnC,IAAI,KAAK,GAAG,OAAO,SAAS,OAAO,GAAG,CAAC;CACzC;CAEA,OAAO;AACT;AAEA,SAAS,cAAc,WAA+B,SAA8B;CAClF,MAAM,OAAO,aAAa;CAE1B,IAAI,CAAC,QAAQ,MAAM,OAAO;CAG1B,OAAO,GAAG,KAAK,oBADA,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,QAAQ,MAAM,MACZ,EAAE;AAC5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaizzleConfig } from "../types/config.
|
|
1
|
+
import { MaizzleConfig } from "../types/config.js";
|
|
2
2
|
import { ChildNode } from "domhandler";
|
|
3
3
|
|
|
4
4
|
//#region src/transformers/tailwindcss.d.ts
|
|
@@ -21,4 +21,4 @@ import { ChildNode } from "domhandler";
|
|
|
21
21
|
declare function tailwindcss(dom: ChildNode[], config: MaizzleConfig, filePath?: string): Promise<ChildNode[]>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { tailwindcss };
|
|
24
|
-
//# sourceMappingURL=tailwindcss.d.
|
|
24
|
+
//# sourceMappingURL=tailwindcss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwindcss.d.ts","names":[],"sources":["../../src/transformers/tailwindcss.ts"],"mappings":";;;;;;AA6EA;;;;;;;;;;;;;;iBAAsB,WAAA,CAAY,GAAA,EAAK,SAAA,IAAa,MAAA,EAAQ,aAAA,EAAe,QAAA,YAAoB,OAAA,CAAQ,SAAA"}
|
|
@@ -1,39 +1,9 @@
|
|
|
1
|
-
import { walk } from "../utils/ast/walker.
|
|
2
|
-
import "../utils/ast/index.
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { dirname, relative, resolve } from "node:path";
|
|
7
|
-
import postcss from "postcss";
|
|
8
|
-
import tailwindcssPostcss from "@tailwindcss/postcss";
|
|
9
|
-
import customProperties from "postcss-custom-properties";
|
|
10
|
-
import postcssCalc from "postcss-calc";
|
|
11
|
-
import safeParser from "postcss-safe-parser";
|
|
12
|
-
import { transform } from "lightningcss";
|
|
13
|
-
|
|
1
|
+
import { walk } from "../utils/ast/walker.js";
|
|
2
|
+
import "../utils/ast/index.js";
|
|
3
|
+
import { compileTailwindCss } from "../utils/compileTailwindCss.js";
|
|
4
|
+
import { decodeStyleEntities } from "../utils/decodeStyleEntities.js";
|
|
5
|
+
import { dirname, relative, resolve } from "pathe";
|
|
14
6
|
//#region src/transformers/tailwindcss.ts
|
|
15
|
-
function createProcessor(config) {
|
|
16
|
-
return postcss([
|
|
17
|
-
tailwindcssPostcss({
|
|
18
|
-
base: config.css?.base,
|
|
19
|
-
transformAssetUrls: false,
|
|
20
|
-
optimize: false
|
|
21
|
-
}),
|
|
22
|
-
customProperties({ preserve: false }),
|
|
23
|
-
postcssCalc({}),
|
|
24
|
-
pruneVars_default()
|
|
25
|
-
]);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Decode HTML entities that Vue SSR encodes inside <style> tags.
|
|
29
|
-
*
|
|
30
|
-
* Vue's renderToString HTML-encodes quotes and other characters
|
|
31
|
-
* inside <style> tags within templates, breaking CSS like
|
|
32
|
-
* `@import "@maizzle/tailwindcss"` → `@import "..."`
|
|
33
|
-
*/
|
|
34
|
-
function decodeEntities(str) {
|
|
35
|
-
return str.replace(/"/g, "\"").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/'/g, "'");
|
|
36
|
-
}
|
|
37
7
|
/**
|
|
38
8
|
* Check if CSS content uses Tailwind features that require source scanning.
|
|
39
9
|
*
|
|
@@ -42,34 +12,7 @@ function decodeEntities(str) {
|
|
|
42
12
|
* and would pass through @source directives unconsumed.
|
|
43
13
|
*/
|
|
44
14
|
function usesTailwind(css) {
|
|
45
|
-
return /(@import\s+["'](tailwindcss|@maizzle\/tailwindcss)|@tailwind\s)/.test(css);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Lower modern CSS syntax using lightningcss.
|
|
49
|
-
*
|
|
50
|
-
* Targets IE 1 to maximize syntax lowering — converts modern features
|
|
51
|
-
* like nesting, oklch(), color-mix(), @property, etc. into simple CSS
|
|
52
|
-
* that email clients can understand.
|
|
53
|
-
*/
|
|
54
|
-
function lowerSyntax(css) {
|
|
55
|
-
return transform({
|
|
56
|
-
filename: "email.css",
|
|
57
|
-
code: Buffer.from(css),
|
|
58
|
-
minify: false,
|
|
59
|
-
targets: { ie: 128 }
|
|
60
|
-
}).code.toString();
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Run cleanup and media query merging on the compiled CSS.
|
|
64
|
-
*
|
|
65
|
-
* Removes unwanted selectors (:host, :lang) and at-rules (@layer, @property),
|
|
66
|
-
* then sorts and merges media queries.
|
|
67
|
-
*/
|
|
68
|
-
async function optimizeCss(css, config) {
|
|
69
|
-
const plugins = [...tailwindCleanup(config)];
|
|
70
|
-
const mediaPlugin = mergeMediaQueries(config);
|
|
71
|
-
if (mediaPlugin) plugins.push(mediaPlugin);
|
|
72
|
-
return (await postcss(plugins).process(css, { from: void 0 })).css;
|
|
15
|
+
return /((@import|@reference)\s+["'](tailwindcss|@maizzle\/tailwindcss)|@tailwind\s)/.test(css);
|
|
73
16
|
}
|
|
74
17
|
/**
|
|
75
18
|
* Build @source directives for Tailwind CSS scanning.
|
|
@@ -85,6 +28,13 @@ function buildSourceDirectives(dom, config, fromDir) {
|
|
|
85
28
|
const directives = [];
|
|
86
29
|
const excludePaths = [resolve(config.output?.path ?? "dist"), ...(config.css?.exclude ?? []).map((p) => resolve(p))];
|
|
87
30
|
for (const p of excludePaths) directives.push(`@source not "${relative(fromDir, resolve(p))}";`);
|
|
31
|
+
/**
|
|
32
|
+
* Inline source: collect all class attribute values from the rendered DOM.
|
|
33
|
+
* After Vue SSR, the DOM contains every class from every component
|
|
34
|
+
* (built-in framework components, user components, dynamic
|
|
35
|
+
* bindings). We pass these raw values to Tailwind's
|
|
36
|
+
* scanner via @source inline().
|
|
37
|
+
*/
|
|
88
38
|
const classes = [];
|
|
89
39
|
walk(dom, (n) => {
|
|
90
40
|
const cls = n.attribs?.class;
|
|
@@ -114,37 +64,46 @@ async function tailwindcss(dom, config, filePath) {
|
|
|
114
64
|
walk(dom, (node) => {
|
|
115
65
|
if (node.name !== "style") return;
|
|
116
66
|
const el = node;
|
|
117
|
-
|
|
118
|
-
|
|
67
|
+
/**
|
|
68
|
+
* `raw` opts out of compilation entirely (marker is consumed here).
|
|
69
|
+
* `embed`/`data-embed` only signal "preserve tag after inlining"
|
|
70
|
+
* — they still need to go through compile so Tailwind/@apply
|
|
71
|
+
* resolves.
|
|
72
|
+
*/
|
|
73
|
+
if ("raw" in el.attribs) {
|
|
119
74
|
delete el.attribs.raw;
|
|
120
75
|
return;
|
|
121
76
|
}
|
|
122
|
-
if ("embed" in attrs || "data-embed" in attrs) return;
|
|
123
77
|
const rawContent = el.children.filter((child) => child.type === "text").map((child) => child.data).join("");
|
|
124
78
|
if (!rawContent.trim()) return;
|
|
125
79
|
styleTags.push({
|
|
126
80
|
node: el,
|
|
127
|
-
cssContent:
|
|
81
|
+
cssContent: decodeStyleEntities(rawContent)
|
|
128
82
|
});
|
|
129
83
|
});
|
|
130
84
|
if (!styleTags.length) return dom;
|
|
131
85
|
const fromPath = filePath ?? resolve(process.cwd(), "template.vue");
|
|
132
86
|
const fromDir = dirname(fromPath);
|
|
133
87
|
const sourceDirectives = styleTags.some(({ cssContent }) => usesTailwind(cssContent)) ? buildSourceDirectives(dom, config, fromDir) : "";
|
|
134
|
-
const processor = createProcessor(config);
|
|
135
88
|
for (let i = 0; i < styleTags.length; i++) {
|
|
136
89
|
const { node, cssContent } = styleTags[i];
|
|
90
|
+
/**
|
|
91
|
+
* Only add source directives to style tags that import Tailwind —
|
|
92
|
+
* plain CSS doesn't need them and @tailwindcss/postcss would
|
|
93
|
+
* leave the directives unconsumed in the output.
|
|
94
|
+
*/
|
|
137
95
|
const fullCss = usesTailwind(cssContent) ? `${cssContent}\n${sourceDirectives}` : cssContent;
|
|
138
96
|
try {
|
|
139
97
|
node.children = [{
|
|
140
98
|
type: "text",
|
|
141
|
-
data: await
|
|
142
|
-
from: `${fromPath}?style=${i}`,
|
|
143
|
-
parser: safeParser
|
|
144
|
-
})).css), config),
|
|
99
|
+
data: await compileTailwindCss(fullCss, config, `${fromPath}?style=${i}`),
|
|
145
100
|
parent: node
|
|
146
101
|
}];
|
|
147
102
|
} catch {
|
|
103
|
+
/**
|
|
104
|
+
* If CSS processing fails, still replace with decoded content
|
|
105
|
+
* so HTML entities don't break the CSS.
|
|
106
|
+
*/
|
|
148
107
|
node.children = [{
|
|
149
108
|
type: "text",
|
|
150
109
|
data: cssContent,
|
|
@@ -154,7 +113,7 @@ async function tailwindcss(dom, config, filePath) {
|
|
|
154
113
|
}
|
|
155
114
|
return dom;
|
|
156
115
|
}
|
|
157
|
-
|
|
158
116
|
//#endregion
|
|
159
117
|
export { tailwindcss };
|
|
160
|
-
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=tailwindcss.js.map
|