@maizzle/framework 6.0.0-rc.2 → 6.0.0-rc.21
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 +20 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +163 -0
- package/dist/build.js.map +1 -0
- package/dist/components/Body.vue +128 -0
- package/dist/components/Button.vue +148 -52
- package/dist/components/CodeBlock.vue +69 -0
- package/dist/components/CodeInline.vue +49 -0
- package/dist/components/Column.vue +108 -0
- package/dist/components/Container.vue +123 -0
- package/dist/components/Font.vue +96 -0
- package/dist/components/Head.vue +30 -0
- package/dist/components/Heading.vue +28 -0
- package/dist/components/Hr.vue +33 -0
- package/dist/components/Html.vue +137 -0
- package/dist/components/Img.vue +70 -0
- package/dist/components/Layout.vue +143 -0
- package/dist/components/Link.vue +26 -0
- package/dist/components/Markdown.vue +89 -0
- package/dist/components/MarkdownLayout.vue +39 -0
- package/dist/components/NotPlaintext.vue +14 -0
- package/dist/components/Outlook.vue +74 -11
- package/dist/components/OutlookBg.vue +241 -0
- package/dist/components/Overlap.vue +156 -0
- package/dist/components/Plaintext.vue +14 -0
- package/dist/components/Preheader.vue +15 -0
- package/dist/components/QrCode.vue +157 -0
- package/dist/components/Raw.vue +28 -0
- package/dist/components/Row.vue +184 -0
- package/dist/components/Section.vue +124 -0
- package/dist/components/Spacer.vue +70 -21
- package/dist/components/Tailwind.vue +43 -0
- package/dist/components/Text.vue +29 -0
- package/dist/components/utils.d.ts +28 -0
- package/dist/components/utils.d.ts.map +1 -0
- package/dist/components/utils.js +50 -0
- package/dist/components/utils.js.map +1 -0
- package/dist/components/utils.ts +51 -0
- package/dist/composables/{defineConfig.d.mts → defineConfig.d.ts} +2 -2
- package/dist/composables/defineConfig.d.ts.map +1 -0
- package/dist/composables/{defineConfig.mjs → defineConfig.js} +4 -5
- 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.mjs → renderContext.js} +2 -2
- 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.mts → useConfig.d.ts} +2 -2
- package/dist/composables/useConfig.d.ts.map +1 -0
- package/dist/composables/{useConfig.mjs → useConfig.js} +2 -3
- 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 +35 -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/{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 +24 -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.mts → index.d.ts} +4 -4
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/{index.mjs → index.js} +12 -10
- package/dist/config/index.js.map +1 -0
- package/dist/events/{index.d.mts → index.d.ts} +30 -12
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/{index.mjs → index.js} +26 -13
- package/dist/events/index.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +38 -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.js +57 -0
- 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 +144 -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.js +68 -0
- 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/{createRenderer.d.mts → createRenderer.d.ts} +15 -7
- package/dist/render/createRenderer.d.ts.map +1 -0
- package/dist/render/createRenderer.js +320 -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 +53 -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/plugins/codeBlockExtract.d.ts +14 -0
- package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -0
- package/dist/render/plugins/codeBlockExtract.js +34 -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} +4 -2
- package/dist/serve.d.ts.map +1 -0
- package/dist/{serve.mjs → serve.js} +203 -78
- 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 +911 -0
- package/dist/server/compatibility.js.map +1 -0
- package/dist/server/email.d.ts +17 -0
- package/dist/server/email.d.ts.map +1 -0
- package/dist/server/email.js +40 -0
- 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 +339 -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/App.vue +253 -77
- package/dist/server/ui/components/SidebarClose.vue +12 -0
- package/dist/server/ui/components/ui/checkbox/Checkbox.vue +35 -0
- package/dist/server/ui/components/ui/checkbox/index.ts +1 -0
- package/dist/server/ui/components/ui/command/Command.vue +5 -1
- package/dist/server/ui/components/ui/command/CommandDialog.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandInput.vue +19 -1
- package/dist/server/ui/components/ui/command/CommandItem.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandList.vue +1 -1
- package/dist/server/ui/components/ui/command/CommandShortcut.vue +1 -1
- package/dist/server/ui/components/ui/dialog/DialogOverlay.vue +9 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/dist/server/ui/components/ui/input/Input.vue +1 -1
- package/dist/server/ui/components/ui/scroll-area/ScrollBar.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetContent.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetOverlay.vue +9 -1
- package/dist/server/ui/components/ui/sidebar/Sidebar.vue +8 -1
- package/dist/server/ui/components/ui/sidebar/SidebarProvider.vue +1 -1
- package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +5 -4
- package/dist/server/ui/components/ui/tags-input/TagsInput.vue +26 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputInput.vue +17 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItem.vue +19 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItemDelete.vue +22 -0
- package/dist/server/ui/components/ui/tags-input/TagsInputItemText.vue +17 -0
- package/dist/server/ui/components/ui/tags-input/index.ts +5 -0
- package/dist/server/ui/components/ui/toggle/index.ts +3 -3
- package/dist/server/ui/components/ui/toggle-group/ToggleGroup.vue +1 -1
- package/dist/server/ui/components/ui/toggle-group/ToggleGroupItem.vue +2 -2
- package/dist/server/ui/lib/emulated-dark-mode.ts +131 -0
- package/dist/server/ui/main.css +20 -20
- package/dist/server/ui/pages/Home.vue +12 -5
- package/dist/server/ui/pages/Preview.vue +716 -276
- 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.mts → addAttributes.d.ts} +2 -2
- package/dist/transformers/addAttributes.d.ts.map +1 -0
- package/dist/transformers/{addAttributes.mjs → addAttributes.js} +16 -13
- 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} +56 -30
- 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 +546 -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 +73 -0
- package/dist/transformers/entities.js.map +1 -0
- package/dist/transformers/filters/defaults.d.ts +6 -0
- package/dist/transformers/filters/defaults.d.ts.map +1 -0
- package/dist/transformers/filters/defaults.js +78 -0
- 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/{index.d.mts → index.d.ts} +14 -11
- package/dist/transformers/index.d.ts.map +1 -0
- package/dist/transformers/index.js +133 -0
- package/dist/transformers/index.js.map +1 -0
- package/dist/transformers/inlineCss.d.ts +84 -0
- package/dist/transformers/inlineCss.d.ts.map +1 -0
- package/dist/transformers/inlineCss.js +91 -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} +34 -10
- 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/msoPlaceholders.d.ts +28 -0
- package/dist/transformers/msoPlaceholders.d.ts.map +1 -0
- package/dist/transformers/msoPlaceholders.js +88 -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 +181 -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 +70 -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/{safeClassNames.d.mts → safeClassNames.d.ts} +2 -2
- package/dist/transformers/safeClassNames.d.ts.map +1 -0
- package/dist/transformers/{safeClassNames.mjs → safeClassNames.js} +4 -5
- package/dist/transformers/safeClassNames.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 +61 -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 +92 -0
- package/dist/transformers/tailwindComponent.js.map +1 -0
- package/dist/transformers/{tailwindcss.d.mts → tailwindcss.d.ts} +8 -4
- package/dist/transformers/tailwindcss.d.ts.map +1 -0
- package/dist/transformers/tailwindcss.js +97 -0
- 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.ts +737 -0
- 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.ts +8 -0
- package/dist/utils/ast/serializer.d.ts.map +1 -0
- package/dist/utils/ast/serializer.js +36 -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/compileTailwindCss.d.ts +16 -0
- package/dist/utils/compileTailwindCss.d.ts.map +1 -0
- package/dist/utils/compileTailwindCss.js +54 -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/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.ts +5 -0
- package/dist/utils/detect.d.ts.map +1 -0
- package/dist/utils/detect.js +10 -0
- 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 +8 -0
- package/node_modules/@clack/core/dist/index.d.mts +18 -4
- package/node_modules/@clack/core/dist/index.mjs +16 -10
- package/node_modules/@clack/core/dist/index.mjs.map +1 -1
- package/node_modules/@clack/core/package.json +5 -2
- package/node_modules/@clack/prompts/CHANGELOG.md +15 -0
- package/node_modules/@clack/prompts/README.md +107 -2
- package/node_modules/@clack/prompts/dist/index.d.mts +16 -11
- package/node_modules/@clack/prompts/dist/index.mjs +114 -107
- package/node_modules/@clack/prompts/dist/index.mjs.map +1 -1
- 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 -1
- package/node_modules/fast-wrap-ansi/lib/main.js.map +1 -1
- package/node_modules/fast-wrap-ansi/package.json +2 -2
- 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 +32 -52
- 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 +4 -3
- 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 +1 -1
- package/node_modules/tinyexec/dist/main.d.mts +6 -6
- package/node_modules/tinyexec/dist/main.mjs +126 -134
- package/node_modules/tinyexec/package.json +9 -9
- package/package.json +31 -21
- package/dist/build.d.mts +0 -19
- package/dist/build.d.mts.map +0 -1
- package/dist/build.mjs +0 -139
- package/dist/build.mjs.map +0 -1
- package/dist/components/Divider.vue +0 -105
- package/dist/components/Vml.vue +0 -89
- 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.map +0 -1
- package/dist/composables/defineConfig.mjs.map +0 -1
- package/dist/composables/renderContext.d.mts +0 -19
- package/dist/composables/renderContext.d.mts.map +0 -1
- package/dist/composables/renderContext.mjs.map +0 -1
- package/dist/composables/useConfig.d.mts.map +0 -1
- 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/config/defaults.d.mts.map +0 -1
- package/dist/config/defaults.mjs.map +0 -1
- 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 -29
- package/dist/index.mjs +0 -29
- 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 +0 -41
- 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 +0 -35
- package/dist/plugins/postcss/tailwindCleanup.mjs.map +0 -1
- package/dist/render/createRenderer.d.mts.map +0 -1
- package/dist/render/createRenderer.mjs +0 -155
- 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 -44
- 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 -6
- package/dist/server/compatibility.d.mts.map +0 -1
- package/dist/server/compatibility.mjs +0 -83
- package/dist/server/compatibility.mjs.map +0 -1
- package/dist/server/linter.d.mts +0 -6
- package/dist/server/linter.d.mts.map +0 -1
- package/dist/server/linter.mjs +0 -200
- package/dist/server/linter.mjs.map +0 -1
- package/dist/server/ui/components/ui/resizable/ResizableHandle.vue +0 -30
- package/dist/server/ui/components/ui/resizable/ResizablePanel.vue +0 -21
- package/dist/server/ui/components/ui/resizable/ResizablePanelGroup.vue +0 -25
- package/dist/server/ui/components/ui/resizable/index.ts +0 -3
- 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 -38
- package/dist/transformers/entities.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 -73
- package/dist/transformers/index.mjs.map +0 -1
- package/dist/transformers/inlineCSS.d.mts +0 -30
- package/dist/transformers/inlineCSS.d.mts.map +0 -1
- package/dist/transformers/inlineCSS.mjs +0 -79
- 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 -66
- 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.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/tailwindcss.d.mts.map +0 -1
- package/dist/transformers/tailwindcss.mjs +0 -136
- 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 +0 -149
- 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 +0 -7
- package/dist/utils/ast/serializer.d.mts.map +0 -1
- package/dist/utils/ast/serializer.mjs +0 -13
- 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/url.d.mts.map +0 -1
- package/dist/utils/url.mjs.map +0 -1
- package/node_modules/maizzle/dist/commands/make/stubs/layout.vue +0 -39
|
@@ -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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 juice from "juice";
|
|
6
|
+
//#region src/transformers/inlineCss.ts
|
|
7
|
+
/**
|
|
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.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { inlineCss } from '@maizzle/framework'
|
|
16
|
+
*
|
|
17
|
+
* const out = inlineCss('<style>.red{color:red}</style><p class="red">x</p>', {
|
|
18
|
+
* removeStyleTags: true,
|
|
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;
|
|
31
|
+
juice.styleToAttribute = styleToAttribute ?? {};
|
|
32
|
+
juice.excludedProperties = ["--tw-shadow", ...excludedProperties ?? []];
|
|
33
|
+
juice.widthElements = (widthElements ?? ["img", "video"]).map((i) => i.toUpperCase());
|
|
34
|
+
juice.heightElements = (heightElements ?? ["img", "video"]).map((i) => i.toUpperCase());
|
|
35
|
+
if (codeBlocks && typeof codeBlocks === "object") Object.entries(codeBlocks).forEach(([key, value]) => {
|
|
36
|
+
if (value.start && value.end) juice.codeBlocks[key] = value;
|
|
37
|
+
});
|
|
38
|
+
walk(dom, (node) => {
|
|
39
|
+
const el = node;
|
|
40
|
+
if (el.name === "style" && el.attribs) {
|
|
41
|
+
if ("embed" in el.attribs && !("data-embed" in el.attribs)) el.attribs["data-embed"] = "";
|
|
42
|
+
if ("data-embed" in el.attribs && !("embed" in el.attribs)) el.attribs.embed = "";
|
|
43
|
+
if ("data-embed" in el.attribs) el.attribs["data-maizzle-embed"] = "";
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const serialized = serialize(dom);
|
|
47
|
+
let inlinedHtml;
|
|
48
|
+
try {
|
|
49
|
+
inlinedHtml = juice(serialized, {
|
|
50
|
+
removeStyleTags: juicePassthrough.removeStyleTags ?? false,
|
|
51
|
+
removeInlinedSelectors: juicePassthrough.removeInlinedSelectors ?? true,
|
|
52
|
+
applyWidthAttributes: juicePassthrough.applyWidthAttributes ?? true,
|
|
53
|
+
applyHeightAttributes: juicePassthrough.applyHeightAttributes ?? true,
|
|
54
|
+
preservedSelectors: safelist ?? [],
|
|
55
|
+
...customCSS ? { extraCss: customCSS } : {},
|
|
56
|
+
inlineDuplicateProperties: juicePassthrough.inlineDuplicateProperties ?? true,
|
|
57
|
+
...juicePassthrough
|
|
58
|
+
});
|
|
59
|
+
} catch {
|
|
60
|
+
return dom;
|
|
61
|
+
}
|
|
62
|
+
const result = parse(inlinedHtml);
|
|
63
|
+
walk(result, (node) => {
|
|
64
|
+
const el = node;
|
|
65
|
+
if (el.attribs?.style) {
|
|
66
|
+
let style = el.attribs.style.replace(/:\s*/g, ": ").replace(/;\s*/g, "; ").trimEnd();
|
|
67
|
+
if (!style.endsWith(";")) style += ";";
|
|
68
|
+
if (preferUnitlessValues) style = style.replace(/\b0(px|rem|em|%|vh|vw|vmin|vmax|in|cm|mm|pt|pc|ex|ch)\b/g, "0");
|
|
69
|
+
el.attribs.style = style;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Restore `embed` from our marker so the purge step can detect
|
|
74
|
+
* these tags and skip them. Drop `data-embed` (juice's name)
|
|
75
|
+
* since it's redundant once `embed` is back, and let purge
|
|
76
|
+
* strip `embed` itself at the end of its run.
|
|
77
|
+
*/
|
|
78
|
+
walk(result, (node) => {
|
|
79
|
+
const el = node;
|
|
80
|
+
if (el.name === "style" && el.attribs && "data-maizzle-embed" in el.attribs) {
|
|
81
|
+
el.attribs.embed = "";
|
|
82
|
+
delete el.attribs["data-embed"];
|
|
83
|
+
delete el.attribs["data-maizzle-embed"];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChildNode } from "domhandler";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/inlineLink.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Inline `<link rel="stylesheet">` tags as `<style>` tags.
|
|
6
|
+
*
|
|
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.
|
|
31
|
+
*/
|
|
32
|
+
declare function inlineLinkDom(dom: ChildNode[], filePath?: string): Promise<ChildNode[]>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { inlineLink, inlineLinkDom };
|
|
35
|
+
//# sourceMappingURL=inlineLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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 {
|
|
2
|
-
import "../utils/ast/
|
|
1
|
+
import { parse as parse$1 } 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 { 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$1(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 };
|
|
76
|
-
|
|
98
|
+
export { inlineLink, inlineLinkDom };
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=inlineLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineLink.js","names":["parse"],"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,cAAcA,QAAM,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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Opts, Opts as MinifyOptions } from "html-crush";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/minify.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Minify an HTML string using `html-crush`. Maizzle's only default that
|
|
6
|
+
* differs from html-crush's own defaults is `removeLineBreaks: true`.
|
|
7
|
+
*
|
|
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.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { minify } from '@maizzle/framework'
|
|
15
|
+
*
|
|
16
|
+
* const tight = minify('<p> hello </p>', { removeIndentations: true })
|
|
17
|
+
*/
|
|
18
|
+
declare function minify(html: string, options?: Partial<Opts>): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { type MinifyOptions, minify };
|
|
21
|
+
//# sourceMappingURL=minify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defu as defu$1 } from "defu";
|
|
2
|
+
import { crush } from "html-crush";
|
|
3
|
+
//#region src/transformers/minify.ts
|
|
4
|
+
const DEFAULT_OPTIONS = { removeLineBreaks: true };
|
|
5
|
+
/**
|
|
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.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { minify } from '@maizzle/framework'
|
|
16
|
+
*
|
|
17
|
+
* const tight = minify('<p> hello </p>', { removeIndentations: true })
|
|
18
|
+
*/
|
|
19
|
+
function minify(html, options = {}) {
|
|
20
|
+
return crush(html, defu$1(options, DEFAULT_OPTIONS)).result;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { minify };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=minify.js.map
|
|
@@ -0,0 +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 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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ChildNode } from "domhandler";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/msoPlaceholders.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolve all `__MAIZZLE_MSO*__` placeholders inside MSO conditional comments
|
|
6
|
+
* by reading inlined style + `data-*` markers on the paired elements.
|
|
7
|
+
*
|
|
8
|
+
* Two placeholder families:
|
|
9
|
+
*
|
|
10
|
+
* MSOW (`__MAIZZLE_MSOW_{id}__`) — emitted by `<Container>` and `<Section>`.
|
|
11
|
+
* Source element is marked with `data-maizzle-msow-id`. Reads inlined
|
|
12
|
+
* `max-width:` (falls back to `width:`) and normalizes to px. Falls
|
|
13
|
+
* back to `data-maizzle-msow-fallback` (default `600px`) when the
|
|
14
|
+
* value can't be parsed.
|
|
15
|
+
*
|
|
16
|
+
* MSOTDSTYLE (`__MAIZZLE_MSOTDSTYLE_{id}__`) — emitted by `<Container>`'s
|
|
17
|
+
* MSO `<td>`. Source element is marked with `data-maizzle-mso-td-id`.
|
|
18
|
+
* Copies every `padding*` declaration from inlined style and appends
|
|
19
|
+
* the `data-maizzle-mso-style` value (the user's `msoStyle` prop).
|
|
20
|
+
* Empty input resolves to '' so the placeholder collapses cleanly.
|
|
21
|
+
*
|
|
22
|
+
* Single collect-walk + single substitute-walk: the same Container div
|
|
23
|
+
* carries both marker kinds, so one element visit fills both maps.
|
|
24
|
+
*/
|
|
25
|
+
declare function msoPlaceholders(dom: ChildNode[]): ChildNode[];
|
|
26
|
+
//#endregion
|
|
27
|
+
export { msoPlaceholders };
|
|
28
|
+
//# sourceMappingURL=msoPlaceholders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msoPlaceholders.d.ts","names":[],"sources":["../../src/transformers/msoPlaceholders.ts"],"mappings":";;;;;AA4CA;;;;;;;;;;;;;;;;;;;iBAAgB,eAAA,CAAgB,GAAA,EAAK,SAAA,KAAc,SAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.js";
|
|
2
|
+
import "../utils/ast/index.js";
|
|
3
|
+
//#region src/transformers/msoPlaceholders.ts
|
|
4
|
+
const RE_MAX_WIDTH = /(?:^|;\s*)max-width:\s*([^;]+)/i;
|
|
5
|
+
const RE_WIDTH = /(?:^|;\s*)width:\s*([^;]+)/i;
|
|
6
|
+
const RE_PERCENT = /^[\d.]+%$/;
|
|
7
|
+
const PADDING_DECL_RE = /(?:^|;)\s*(padding(?:-[a-z-]+)?\s*:\s*[^;]+)/gi;
|
|
8
|
+
function resolveWidth(value) {
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
if (RE_PERCENT.test(trimmed)) return trimmed;
|
|
11
|
+
const m = trimmed.match(/^([\d.]+)(px|rem|em|pt)?$/i);
|
|
12
|
+
if (!m) return null;
|
|
13
|
+
const n = parseFloat(m[1]);
|
|
14
|
+
switch ((m[2] || "px").toLowerCase()) {
|
|
15
|
+
case "px": return `${Math.round(n)}px`;
|
|
16
|
+
case "rem":
|
|
17
|
+
case "em": return `${Math.round(n * 16)}px`;
|
|
18
|
+
case "pt": return `${Math.round(n * 1.333)}px`;
|
|
19
|
+
default: return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve all `__MAIZZLE_MSO*__` placeholders inside MSO conditional comments
|
|
24
|
+
* by reading inlined style + `data-*` markers on the paired elements.
|
|
25
|
+
*
|
|
26
|
+
* Two placeholder families:
|
|
27
|
+
*
|
|
28
|
+
* MSOW (`__MAIZZLE_MSOW_{id}__`) — emitted by `<Container>` and `<Section>`.
|
|
29
|
+
* Source element is marked with `data-maizzle-msow-id`. Reads inlined
|
|
30
|
+
* `max-width:` (falls back to `width:`) and normalizes to px. Falls
|
|
31
|
+
* back to `data-maizzle-msow-fallback` (default `600px`) when the
|
|
32
|
+
* value can't be parsed.
|
|
33
|
+
*
|
|
34
|
+
* MSOTDSTYLE (`__MAIZZLE_MSOTDSTYLE_{id}__`) — emitted by `<Container>`'s
|
|
35
|
+
* MSO `<td>`. Source element is marked with `data-maizzle-mso-td-id`.
|
|
36
|
+
* Copies every `padding*` declaration from inlined style and appends
|
|
37
|
+
* the `data-maizzle-mso-style` value (the user's `msoStyle` prop).
|
|
38
|
+
* Empty input resolves to '' so the placeholder collapses cleanly.
|
|
39
|
+
*
|
|
40
|
+
* Single collect-walk + single substitute-walk: the same Container div
|
|
41
|
+
* carries both marker kinds, so one element visit fills both maps.
|
|
42
|
+
*/
|
|
43
|
+
function msoPlaceholders(dom) {
|
|
44
|
+
const widths = /* @__PURE__ */ new Map();
|
|
45
|
+
const tdStyles = /* @__PURE__ */ new Map();
|
|
46
|
+
walk(dom, (node) => {
|
|
47
|
+
const a = node.attribs;
|
|
48
|
+
if (!a) return;
|
|
49
|
+
const msowId = a["data-maizzle-msow-id"];
|
|
50
|
+
const tdId = a["data-maizzle-mso-td-id"];
|
|
51
|
+
if (!msowId && !tdId) return;
|
|
52
|
+
const style = a.style ?? "";
|
|
53
|
+
if (msowId) {
|
|
54
|
+
delete a["data-maizzle-msow-id"];
|
|
55
|
+
const fallback = a["data-maizzle-msow-fallback"] ?? "600px";
|
|
56
|
+
delete a["data-maizzle-msow-fallback"];
|
|
57
|
+
const raw = style.match(RE_MAX_WIDTH)?.[1] ?? style.match(RE_WIDTH)?.[1];
|
|
58
|
+
const resolved = raw ? resolveWidth(raw) : null;
|
|
59
|
+
widths.set(msowId, resolved ?? fallback);
|
|
60
|
+
}
|
|
61
|
+
if (tdId) {
|
|
62
|
+
delete a["data-maizzle-mso-td-id"];
|
|
63
|
+
const msoStyle = (a["data-maizzle-mso-style"] ?? "").trim().replace(/;\s*$/, "");
|
|
64
|
+
delete a["data-maizzle-mso-style"];
|
|
65
|
+
const parts = [];
|
|
66
|
+
if (style) for (const m of style.matchAll(PADDING_DECL_RE)) parts.push(m[1].trim());
|
|
67
|
+
if (msoStyle) parts.push(msoStyle);
|
|
68
|
+
tdStyles.set(tdId, parts.length ? ` style="${parts.join("; ")}"` : "");
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (widths.size === 0 && tdStyles.size === 0) return dom;
|
|
72
|
+
walk(dom, (node) => {
|
|
73
|
+
if (node.type !== "comment") return;
|
|
74
|
+
let data = node.data;
|
|
75
|
+
if (!data) return;
|
|
76
|
+
const hasMsow = widths.size > 0 && data.includes("__MAIZZLE_MSOW_");
|
|
77
|
+
const hasTd = tdStyles.size > 0 && data.includes("__MAIZZLE_MSOTDSTYLE_");
|
|
78
|
+
if (!hasMsow && !hasTd) return;
|
|
79
|
+
if (hasMsow) for (const [id, val] of widths) data = data.replaceAll(`__MAIZZLE_MSOW_${id}__`, val);
|
|
80
|
+
if (hasTd) for (const [id, val] of tdStyles) data = data.replaceAll(`__MAIZZLE_MSOTDSTYLE_${id}__`, val);
|
|
81
|
+
node.data = data;
|
|
82
|
+
});
|
|
83
|
+
return dom;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { msoPlaceholders };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=msoPlaceholders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ChildNode } from "domhandler";
|
|
2
|
+
import { Opts } from "email-comb";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/purgeCss.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Options for the `purgeCss` transformer.
|
|
7
|
+
*/
|
|
8
|
+
interface PurgeCssOptions extends Partial<Omit<Opts, 'whitelist'>> {
|
|
9
|
+
/**
|
|
10
|
+
* Selectors to preserve regardless of whether they're matched in the
|
|
11
|
+
* markup. Appended to Maizzle's built-in safelist (Gmail, Apple Mail,
|
|
12
|
+
* Outlook.com hooks, etc). Mapped to email-comb's `whitelist` option.
|
|
13
|
+
*/
|
|
14
|
+
safelist?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Remove unused CSS from an HTML string.
|
|
18
|
+
*
|
|
19
|
+
* Uses `email-comb` together with a DOM-aware deep-purge step to strip
|
|
20
|
+
* CSS selectors and class/id references that are not matched anywhere
|
|
21
|
+
* in the document body.
|
|
22
|
+
*
|
|
23
|
+
* @param html HTML string to transform.
|
|
24
|
+
* @param options Email-comb options plus a Maizzle `safelist`.
|
|
25
|
+
* @returns The transformed HTML string.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import { purgeCss } from '@maizzle/framework'
|
|
29
|
+
*
|
|
30
|
+
* const out = purgeCss('<style>.a{}.b{}</style><p class="a">x</p>', {
|
|
31
|
+
* safelist: ['.keep'],
|
|
32
|
+
* })
|
|
33
|
+
*/
|
|
34
|
+
declare function purgeCss(html: string, options?: PurgeCssOptions): string;
|
|
35
|
+
/**
|
|
36
|
+
* DOM-form of {@link purgeCss} used by the internal transformer
|
|
37
|
+
* pipeline. Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
38
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
39
|
+
*/
|
|
40
|
+
declare function purgeCssDom(dom: ChildNode[], options?: PurgeCssOptions): ChildNode[];
|
|
41
|
+
//#endregion
|
|
42
|
+
export { PurgeCssOptions, purgeCss, purgeCssDom };
|
|
43
|
+
//# sourceMappingURL=purgeCss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purgeCss.d.ts","names":[],"sources":["../../src/transformers/purgeCss.ts"],"mappings":";;;;;;AAqCA;UAAiB,eAAA,SAAwB,OAAA,CAAQ,IAAA,CAAK,IAAA;;;;;;EAMpD,QAAA;AAAA;;;;;;AAqBF;;;;;;;;;AASA;;;;iBATgB,QAAA,CAAS,IAAA,UAAc,OAAA,GAAS,eAAA;;;;;;iBAShC,WAAA,CAAY,GAAA,EAAK,SAAA,IAAa,OAAA,GAAS,eAAA,GAAuB,SAAA"}
|