@maizzle/framework 6.0.0-8 → 6.0.0-rc.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/bin/maizzle.mjs +10 -0
- package/dist/build.d.mts +19 -0
- package/dist/build.d.mts.map +1 -0
- package/dist/build.mjs +121 -0
- package/dist/build.mjs.map +1 -0
- package/dist/components/Button.vue +141 -0
- package/dist/components/Divider.vue +105 -0
- package/dist/components/NoWidows.vue +123 -0
- package/dist/components/NotOutlook.vue +17 -0
- package/dist/components/Outlook.vue +74 -0
- package/dist/components/Spacer.vue +36 -0
- package/dist/components/Vml.vue +89 -0
- package/dist/components/WithUrl.vue +190 -0
- package/dist/components/utils.d.mts +5 -0
- package/dist/components/utils.d.mts.map +1 -0
- package/dist/components/utils.mjs +9 -0
- package/dist/components/utils.mjs.map +1 -0
- package/dist/components/utils.ts +6 -0
- package/dist/composables/defineConfig.d.mts +14 -0
- package/dist/composables/defineConfig.d.mts.map +1 -0
- package/dist/composables/defineConfig.mjs +34 -0
- package/dist/composables/defineConfig.mjs.map +1 -0
- package/dist/composables/renderContext.d.mts +19 -0
- package/dist/composables/renderContext.d.mts.map +1 -0
- package/dist/composables/renderContext.mjs +6 -0
- package/dist/composables/renderContext.mjs.map +1 -0
- package/dist/composables/useConfig.d.mts +9 -0
- package/dist/composables/useConfig.d.mts.map +1 -0
- package/dist/composables/useConfig.mjs +13 -0
- package/dist/composables/useConfig.mjs.map +1 -0
- package/dist/composables/useDoctype.d.mts +13 -0
- package/dist/composables/useDoctype.d.mts.map +1 -0
- package/dist/composables/useDoctype.mjs +20 -0
- package/dist/composables/useDoctype.mjs.map +1 -0
- package/dist/composables/useEvent.d.mts +17 -0
- package/dist/composables/useEvent.d.mts.map +1 -0
- package/dist/composables/useEvent.mjs +25 -0
- package/dist/composables/useEvent.mjs.map +1 -0
- package/dist/composables/usePlaintext.d.mts +19 -0
- package/dist/composables/usePlaintext.d.mts.map +1 -0
- package/dist/composables/usePlaintext.mjs +22 -0
- package/dist/composables/usePlaintext.mjs.map +1 -0
- package/dist/config/defaults.d.mts +6 -0
- package/dist/config/defaults.d.mts.map +1 -0
- package/dist/config/defaults.mjs +28 -0
- package/dist/config/defaults.mjs.map +1 -0
- package/dist/config/index.d.mts +15 -0
- package/dist/config/index.d.mts.map +1 -0
- package/dist/config/index.mjs +47 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/events/index.d.mts +91 -0
- package/dist/events/index.d.mts.map +1 -0
- package/dist/events/index.mjs +110 -0
- package/dist/events/index.mjs.map +1 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +29 -0
- package/dist/plaintext.d.mts +5 -0
- package/dist/plaintext.d.mts.map +1 -0
- package/dist/plaintext.mjs +15 -0
- package/dist/plaintext.mjs.map +1 -0
- package/dist/plugin.d.mts +17 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +41 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/plugins/postcss/mergeMediaQueries.d.mts +18 -0
- package/dist/plugins/postcss/mergeMediaQueries.d.mts.map +1 -0
- package/dist/plugins/postcss/mergeMediaQueries.mjs +22 -0
- package/dist/plugins/postcss/mergeMediaQueries.mjs.map +1 -0
- package/dist/plugins/postcss/pruneVars.d.mts +8 -0
- package/dist/plugins/postcss/pruneVars.d.mts.map +1 -0
- package/dist/plugins/postcss/pruneVars.mjs +49 -0
- package/dist/plugins/postcss/pruneVars.mjs.map +1 -0
- package/dist/plugins/postcss/removeDeclarations.d.mts +12 -0
- package/dist/plugins/postcss/removeDeclarations.d.mts.map +1 -0
- package/dist/plugins/postcss/removeDeclarations.mjs +45 -0
- package/dist/plugins/postcss/removeDeclarations.mjs.map +1 -0
- package/dist/plugins/postcss/tailwindCleanup.d.mts +18 -0
- package/dist/plugins/postcss/tailwindCleanup.d.mts.map +1 -0
- package/dist/plugins/postcss/tailwindCleanup.mjs +35 -0
- package/dist/plugins/postcss/tailwindCleanup.mjs.map +1 -0
- package/dist/render/createRenderer.d.mts +34 -0
- package/dist/render/createRenderer.d.mts.map +1 -0
- package/dist/render/createRenderer.mjs +149 -0
- package/dist/render/createRenderer.mjs.map +1 -0
- package/dist/render/index.d.mts +26 -0
- package/dist/render/index.d.mts.map +1 -0
- package/dist/render/index.mjs +40 -0
- package/dist/render/index.mjs.map +1 -0
- package/dist/serve.d.mts +25 -0
- package/dist/serve.d.mts.map +1 -0
- package/dist/serve.mjs +402 -0
- package/dist/serve.mjs.map +1 -0
- package/dist/server/compatibility.d.mts +6 -0
- package/dist/server/compatibility.d.mts.map +1 -0
- package/dist/server/compatibility.mjs +83 -0
- package/dist/server/compatibility.mjs.map +1 -0
- package/dist/server/linter.d.mts +6 -0
- package/dist/server/linter.d.mts.map +1 -0
- package/dist/server/linter.mjs +200 -0
- package/dist/server/linter.mjs.map +1 -0
- package/dist/server/ui/App.vue +360 -0
- package/dist/server/ui/components/ui/button/Button.vue +31 -0
- package/dist/server/ui/components/ui/button/index.ts +38 -0
- package/dist/server/ui/components/ui/command/Command.vue +87 -0
- package/dist/server/ui/components/ui/command/CommandDialog.vue +31 -0
- package/dist/server/ui/components/ui/command/CommandEmpty.vue +27 -0
- package/dist/server/ui/components/ui/command/CommandGroup.vue +45 -0
- package/dist/server/ui/components/ui/command/CommandInput.vue +39 -0
- package/dist/server/ui/components/ui/command/CommandItem.vue +76 -0
- package/dist/server/ui/components/ui/command/CommandList.vue +25 -0
- package/dist/server/ui/components/ui/command/CommandSeparator.vue +21 -0
- package/dist/server/ui/components/ui/command/CommandShortcut.vue +17 -0
- package/dist/server/ui/components/ui/command/index.ts +25 -0
- package/dist/server/ui/components/ui/dialog/Dialog.vue +19 -0
- package/dist/server/ui/components/ui/dialog/DialogClose.vue +15 -0
- package/dist/server/ui/components/ui/dialog/DialogContent.vue +53 -0
- package/dist/server/ui/components/ui/dialog/DialogDescription.vue +23 -0
- package/dist/server/ui/components/ui/dialog/DialogFooter.vue +27 -0
- package/dist/server/ui/components/ui/dialog/DialogHeader.vue +17 -0
- package/dist/server/ui/components/ui/dialog/DialogOverlay.vue +21 -0
- package/dist/server/ui/components/ui/dialog/DialogScrollContent.vue +59 -0
- package/dist/server/ui/components/ui/dialog/DialogTitle.vue +23 -0
- package/dist/server/ui/components/ui/dialog/DialogTrigger.vue +15 -0
- package/dist/server/ui/components/ui/dialog/index.ts +10 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +39 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuContent.vue +39 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuGroup.vue +15 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuItem.vue +31 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuLabel.vue +23 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +40 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSeparator.vue +23 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuShortcut.vue +17 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSub.vue +18 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubContent.vue +27 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +31 -0
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
- package/dist/server/ui/components/ui/dropdown-menu/index.ts +16 -0
- package/dist/server/ui/components/ui/empty/Empty.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyContent.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyDescription.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyHeader.vue +20 -0
- package/dist/server/ui/components/ui/empty/EmptyMedia.vue +21 -0
- package/dist/server/ui/components/ui/empty/EmptyTitle.vue +17 -0
- package/dist/server/ui/components/ui/empty/index.ts +26 -0
- package/dist/server/ui/components/ui/input/Input.vue +33 -0
- package/dist/server/ui/components/ui/input/index.ts +1 -0
- package/dist/server/ui/components/ui/kbd/Kbd.vue +20 -0
- package/dist/server/ui/components/ui/kbd/KbdGroup.vue +17 -0
- package/dist/server/ui/components/ui/kbd/index.ts +2 -0
- package/dist/server/ui/components/ui/resizable/ResizableHandle.vue +30 -0
- package/dist/server/ui/components/ui/resizable/ResizablePanel.vue +21 -0
- package/dist/server/ui/components/ui/resizable/ResizablePanelGroup.vue +25 -0
- package/dist/server/ui/components/ui/resizable/index.ts +3 -0
- package/dist/server/ui/components/ui/scroll-area/ScrollArea.vue +33 -0
- package/dist/server/ui/components/ui/scroll-area/ScrollBar.vue +32 -0
- package/dist/server/ui/components/ui/scroll-area/index.ts +2 -0
- package/dist/server/ui/components/ui/separator/Separator.vue +29 -0
- package/dist/server/ui/components/ui/separator/index.ts +1 -0
- package/dist/server/ui/components/ui/sheet/Sheet.vue +19 -0
- package/dist/server/ui/components/ui/sheet/SheetClose.vue +15 -0
- package/dist/server/ui/components/ui/sheet/SheetContent.vue +62 -0
- package/dist/server/ui/components/ui/sheet/SheetDescription.vue +21 -0
- package/dist/server/ui/components/ui/sheet/SheetFooter.vue +16 -0
- package/dist/server/ui/components/ui/sheet/SheetHeader.vue +15 -0
- package/dist/server/ui/components/ui/sheet/SheetOverlay.vue +21 -0
- package/dist/server/ui/components/ui/sheet/SheetTitle.vue +21 -0
- package/dist/server/ui/components/ui/sheet/SheetTrigger.vue +15 -0
- package/dist/server/ui/components/ui/sheet/index.ts +8 -0
- package/dist/server/ui/components/ui/sidebar/Sidebar.vue +96 -0
- package/dist/server/ui/components/ui/sidebar/SidebarContent.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarFooter.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroup.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroupAction.vue +27 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroupContent.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarGroupLabel.vue +25 -0
- package/dist/server/ui/components/ui/sidebar/SidebarHeader.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarInput.vue +31 -0
- package/dist/server/ui/components/ui/sidebar/SidebarInset.vue +21 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenu.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuAction.vue +35 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuBadge.vue +26 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuButton.vue +48 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuButtonChild.vue +36 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuItem.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSkeleton.vue +35 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSub.vue +22 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSubButton.vue +36 -0
- package/dist/server/ui/components/ui/sidebar/SidebarMenuSubItem.vue +18 -0
- package/dist/server/ui/components/ui/sidebar/SidebarProvider.vue +82 -0
- package/dist/server/ui/components/ui/sidebar/SidebarRail.vue +33 -0
- package/dist/server/ui/components/ui/sidebar/SidebarSeparator.vue +19 -0
- package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +28 -0
- package/dist/server/ui/components/ui/sidebar/index.ts +60 -0
- package/dist/server/ui/components/ui/sidebar/utils.ts +19 -0
- package/dist/server/ui/components/ui/skeleton/Skeleton.vue +17 -0
- package/dist/server/ui/components/ui/skeleton/index.ts +1 -0
- package/dist/server/ui/components/ui/tabs/Tabs.vue +24 -0
- package/dist/server/ui/components/ui/tabs/TabsContent.vue +21 -0
- package/dist/server/ui/components/ui/tabs/TabsList.vue +24 -0
- package/dist/server/ui/components/ui/tabs/TabsTrigger.vue +26 -0
- package/dist/server/ui/components/ui/tabs/index.ts +4 -0
- package/dist/server/ui/components/ui/toggle/Toggle.vue +35 -0
- package/dist/server/ui/components/ui/toggle/index.ts +28 -0
- package/dist/server/ui/components/ui/toggle-group/ToggleGroup.vue +49 -0
- package/dist/server/ui/components/ui/toggle-group/ToggleGroupItem.vue +46 -0
- package/dist/server/ui/components/ui/toggle-group/index.ts +2 -0
- package/dist/server/ui/components/ui/tooltip/Tooltip.vue +19 -0
- package/dist/server/ui/components/ui/tooltip/TooltipContent.vue +34 -0
- package/dist/server/ui/components/ui/tooltip/TooltipProvider.vue +14 -0
- package/dist/server/ui/components/ui/tooltip/TooltipTrigger.vue +15 -0
- package/dist/server/ui/components/ui/tooltip/index.ts +4 -0
- package/dist/server/ui/favicon.svg +1 -0
- package/dist/server/ui/index.html +13 -0
- package/dist/server/ui/lib/utils.ts +7 -0
- package/dist/server/ui/logo-gradient.svg +1 -0
- package/dist/server/ui/logo.svg +1 -0
- package/dist/server/ui/main.css +129 -0
- package/dist/server/ui/main.ts +16 -0
- package/dist/server/ui/mark-gradient.svg +1 -0
- package/dist/server/ui/mark.svg +1 -0
- package/dist/server/ui/pages/Home.vue +39 -0
- package/dist/server/ui/pages/Preview.vue +609 -0
- package/dist/server/ui/stripes.svg +174 -0
- package/dist/transformers/addAttributes.d.mts +32 -0
- package/dist/transformers/addAttributes.d.mts.map +1 -0
- package/dist/transformers/addAttributes.mjs +101 -0
- package/dist/transformers/addAttributes.mjs.map +1 -0
- package/dist/transformers/attributeToStyle.d.mts +25 -0
- package/dist/transformers/attributeToStyle.d.mts.map +1 -0
- package/dist/transformers/attributeToStyle.mjs +80 -0
- package/dist/transformers/attributeToStyle.mjs.map +1 -0
- package/dist/transformers/base.d.mts +8 -0
- package/dist/transformers/base.d.mts.map +1 -0
- package/dist/transformers/base.mjs +160 -0
- package/dist/transformers/base.mjs.map +1 -0
- package/dist/transformers/entities.d.mts +8 -0
- package/dist/transformers/entities.d.mts.map +1 -0
- package/dist/transformers/entities.mjs +38 -0
- package/dist/transformers/entities.mjs.map +1 -0
- package/dist/transformers/format.d.mts +15 -0
- package/dist/transformers/format.d.mts.map +1 -0
- package/dist/transformers/format.mjs +26 -0
- package/dist/transformers/format.mjs.map +1 -0
- package/dist/transformers/index.d.mts +35 -0
- package/dist/transformers/index.d.mts.map +1 -0
- package/dist/transformers/index.mjs +73 -0
- package/dist/transformers/index.mjs.map +1 -0
- package/dist/transformers/inlineCSS.d.mts +30 -0
- package/dist/transformers/inlineCSS.d.mts.map +1 -0
- package/dist/transformers/inlineCSS.mjs +79 -0
- package/dist/transformers/inlineCSS.mjs.map +1 -0
- package/dist/transformers/inlineLink.d.mts +14 -0
- package/dist/transformers/inlineLink.d.mts.map +1 -0
- package/dist/transformers/inlineLink.mjs +76 -0
- package/dist/transformers/inlineLink.mjs.map +1 -0
- package/dist/transformers/minify.d.mts +17 -0
- package/dist/transformers/minify.d.mts.map +1 -0
- package/dist/transformers/minify.mjs +24 -0
- package/dist/transformers/minify.mjs.map +1 -0
- package/dist/transformers/purgeCSS.d.mts +23 -0
- package/dist/transformers/purgeCSS.d.mts.map +1 -0
- package/dist/transformers/purgeCSS.mjs +66 -0
- package/dist/transformers/purgeCSS.mjs.map +1 -0
- package/dist/transformers/removeAttributes.d.mts +31 -0
- package/dist/transformers/removeAttributes.d.mts.map +1 -0
- package/dist/transformers/removeAttributes.mjs +63 -0
- package/dist/transformers/removeAttributes.mjs.map +1 -0
- package/dist/transformers/replaceStrings.d.mts +16 -0
- package/dist/transformers/replaceStrings.d.mts.map +1 -0
- package/dist/transformers/replaceStrings.mjs +19 -0
- package/dist/transformers/replaceStrings.mjs.map +1 -0
- package/dist/transformers/safeClassNames.d.mts +22 -0
- package/dist/transformers/safeClassNames.d.mts.map +1 -0
- package/dist/transformers/safeClassNames.mjs +103 -0
- package/dist/transformers/safeClassNames.mjs.map +1 -0
- package/dist/transformers/shorthandCSS.d.mts +24 -0
- package/dist/transformers/shorthandCSS.d.mts.map +1 -0
- package/dist/transformers/shorthandCSS.mjs +48 -0
- package/dist/transformers/shorthandCSS.mjs.map +1 -0
- package/dist/transformers/tailwindcss.d.mts +20 -0
- package/dist/transformers/tailwindcss.d.mts.map +1 -0
- package/dist/transformers/tailwindcss.mjs +136 -0
- package/dist/transformers/tailwindcss.mjs.map +1 -0
- package/dist/transformers/urlQuery.d.mts +24 -0
- package/dist/transformers/urlQuery.d.mts.map +1 -0
- package/dist/transformers/urlQuery.mjs +65 -0
- package/dist/transformers/urlQuery.mjs.map +1 -0
- package/dist/types/config.d.mts +129 -0
- package/dist/types/config.d.mts.map +1 -0
- package/dist/types/config.mjs +1 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/dist/utils/ast/index.d.mts +4 -0
- package/dist/utils/ast/index.mjs +5 -0
- package/dist/utils/ast/parser.d.mts +7 -0
- package/dist/utils/ast/parser.d.mts.map +1 -0
- package/dist/utils/ast/parser.mjs +15 -0
- package/dist/utils/ast/parser.mjs.map +1 -0
- package/dist/utils/ast/serializer.d.mts +7 -0
- package/dist/utils/ast/serializer.d.mts.map +1 -0
- package/dist/utils/ast/serializer.mjs +13 -0
- package/dist/utils/ast/serializer.mjs.map +1 -0
- package/dist/utils/ast/walker.d.mts +7 -0
- package/dist/utils/ast/walker.d.mts.map +1 -0
- package/dist/utils/ast/walker.mjs +12 -0
- package/dist/utils/ast/walker.mjs.map +1 -0
- package/dist/utils/url.d.mts +8 -0
- package/dist/utils/url.d.mts.map +1 -0
- package/dist/utils/url.mjs +32 -0
- package/dist/utils/url.mjs.map +1 -0
- package/node_modules/@clack/core/CHANGELOG.md +257 -0
- package/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/@clack/core/README.md +22 -0
- package/node_modules/@clack/core/dist/index.cjs +15 -0
- package/node_modules/@clack/core/dist/index.cjs.map +1 -0
- package/node_modules/@clack/core/dist/index.d.cts +211 -0
- package/node_modules/@clack/core/dist/index.d.mts +211 -0
- package/node_modules/@clack/core/dist/index.d.ts +211 -0
- package/node_modules/@clack/core/dist/index.mjs +15 -0
- package/node_modules/@clack/core/dist/index.mjs.map +1 -0
- package/node_modules/@clack/core/package.json +62 -0
- package/node_modules/@clack/prompts/CHANGELOG.md +412 -0
- package/node_modules/@clack/prompts/LICENSE +9 -0
- package/node_modules/@clack/prompts/README.md +207 -0
- package/node_modules/@clack/prompts/dist/index.cjs +87 -0
- package/node_modules/@clack/prompts/dist/index.cjs.map +1 -0
- package/node_modules/@clack/prompts/dist/index.d.cts +165 -0
- package/node_modules/@clack/prompts/dist/index.d.mts +165 -0
- package/node_modules/@clack/prompts/dist/index.d.ts +165 -0
- package/node_modules/@clack/prompts/dist/index.mjs +87 -0
- package/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
- package/node_modules/@clack/prompts/package.json +61 -0
- package/node_modules/@maizzle/cli/LICENSE +21 -0
- package/node_modules/@maizzle/cli/README.md +58 -0
- package/node_modules/@maizzle/cli/dist/commands/make/component.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/component.mjs +31 -0
- package/node_modules/@maizzle/cli/dist/commands/make/config.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/config.mjs +21 -0
- package/node_modules/@maizzle/cli/dist/commands/make/layout.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/layout.mjs +31 -0
- package/node_modules/@maizzle/cli/dist/commands/make/scaffold.d.mts +5 -0
- package/node_modules/@maizzle/cli/dist/commands/make/scaffold.mjs +28 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/component.vue +9 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/config.ts +9 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/layout.vue +39 -0
- package/node_modules/@maizzle/cli/dist/commands/make/stubs/template.vue +8 -0
- package/node_modules/@maizzle/cli/dist/commands/make/template.d.mts +4 -0
- package/node_modules/@maizzle/cli/dist/commands/make/template.mjs +31 -0
- package/node_modules/@maizzle/cli/dist/index.d.mts +8 -0
- package/node_modules/@maizzle/cli/dist/index.mjs +42 -0
- package/node_modules/@maizzle/cli/package.json +59 -0
- package/node_modules/citty/LICENSE +36 -0
- package/node_modules/citty/README.md +134 -0
- package/node_modules/citty/dist/index.cjs +475 -0
- package/node_modules/citty/dist/index.d.cts +80 -0
- package/node_modules/citty/dist/index.d.mts +80 -0
- package/node_modules/citty/dist/index.d.ts +80 -0
- package/node_modules/citty/dist/index.mjs +463 -0
- package/node_modules/citty/package.json +49 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1149 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2662 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +709 -0
- package/node_modules/commander/lib/option.js +367 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +82 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +1045 -0
- package/node_modules/consola/LICENSE +47 -0
- package/node_modules/consola/README.md +352 -0
- package/node_modules/consola/basic.d.ts +1 -0
- package/node_modules/consola/browser.d.ts +1 -0
- package/node_modules/consola/core.d.ts +1 -0
- package/node_modules/consola/dist/basic.cjs +32 -0
- package/node_modules/consola/dist/basic.d.cts +23 -0
- package/node_modules/consola/dist/basic.d.mts +21 -0
- package/node_modules/consola/dist/basic.d.ts +23 -0
- package/node_modules/consola/dist/basic.mjs +24 -0
- package/node_modules/consola/dist/browser.cjs +84 -0
- package/node_modules/consola/dist/browser.d.cts +23 -0
- package/node_modules/consola/dist/browser.d.mts +21 -0
- package/node_modules/consola/dist/browser.d.ts +23 -0
- package/node_modules/consola/dist/browser.mjs +76 -0
- package/node_modules/consola/dist/chunks/prompt.cjs +288 -0
- package/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/node_modules/consola/dist/core.cjs +517 -0
- package/node_modules/consola/dist/core.d.cts +459 -0
- package/node_modules/consola/dist/core.d.mts +459 -0
- package/node_modules/consola/dist/core.d.ts +459 -0
- package/node_modules/consola/dist/core.mjs +512 -0
- package/node_modules/consola/dist/index.cjs +663 -0
- package/node_modules/consola/dist/index.d.cts +24 -0
- package/node_modules/consola/dist/index.d.mts +22 -0
- package/node_modules/consola/dist/index.d.ts +24 -0
- package/node_modules/consola/dist/index.mjs +651 -0
- package/node_modules/consola/dist/shared/consola.DCGIlDNP.cjs +75 -0
- package/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/node_modules/consola/dist/shared/consola.DwRq1yyg.cjs +312 -0
- package/node_modules/consola/dist/utils.cjs +64 -0
- package/node_modules/consola/dist/utils.d.cts +286 -0
- package/node_modules/consola/dist/utils.d.mts +286 -0
- package/node_modules/consola/dist/utils.d.ts +286 -0
- package/node_modules/consola/dist/utils.mjs +54 -0
- package/node_modules/consola/lib/index.cjs +10 -0
- package/node_modules/consola/package.json +136 -0
- package/node_modules/consola/utils.d.ts +1 -0
- package/node_modules/create-maizzle/README.md +86 -0
- package/node_modules/create-maizzle/bin/create-maizzle.mjs +4 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/CHANGELOG.md +340 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/README.md +22 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.d.mts +349 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs +11 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/dist/index.mjs.map +1 -0
- package/node_modules/create-maizzle/node_modules/@clack/core/package.json +60 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/CHANGELOG.md +576 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/LICENSE +9 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/README.md +270 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.d.mts +391 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs +137 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
- package/node_modules/create-maizzle/node_modules/@clack/prompts/package.json +65 -0
- package/node_modules/create-maizzle/package.json +47 -0
- package/node_modules/create-maizzle/src/index.js +242 -0
- package/node_modules/defu/LICENSE +21 -0
- package/node_modules/defu/README.md +171 -0
- package/node_modules/defu/dist/defu.cjs +77 -0
- package/node_modules/defu/dist/defu.d.cts +31 -0
- package/node_modules/defu/dist/defu.d.mts +29 -0
- package/node_modules/defu/dist/defu.d.ts +31 -0
- package/node_modules/defu/dist/defu.mjs +69 -0
- package/node_modules/defu/lib/defu.cjs +10 -0
- package/node_modules/defu/lib/defu.d.cts +12 -0
- package/node_modules/defu/package.json +48 -0
- package/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/index.js +171 -0
- package/node_modules/fast-string-truncated-width/dist/types.d.ts +22 -0
- package/node_modules/fast-string-truncated-width/dist/types.js +2 -0
- package/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
- package/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
- package/node_modules/fast-string-truncated-width/license +21 -0
- package/node_modules/fast-string-truncated-width/package.json +35 -0
- package/node_modules/fast-string-truncated-width/readme.md +60 -0
- package/node_modules/fast-string-width/dist/index.d.ts +4 -0
- package/node_modules/fast-string-width/dist/index.js +14 -0
- package/node_modules/fast-string-width/license +21 -0
- package/node_modules/fast-string-width/package.json +34 -0
- package/node_modules/fast-string-width/readme.md +45 -0
- package/node_modules/fast-wrap-ansi/LICENSE +23 -0
- package/node_modules/fast-wrap-ansi/README.md +26 -0
- package/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
- package/node_modules/fast-wrap-ansi/lib/main.js +216 -0
- package/node_modules/fast-wrap-ansi/lib/main.js.map +1 -0
- package/node_modules/fast-wrap-ansi/package.json +51 -0
- package/node_modules/giget/LICENSE +184 -0
- package/node_modules/giget/README.md +248 -0
- package/node_modules/giget/dist/cli.mjs +112 -0
- package/node_modules/giget/dist/index.d.mts +49 -0
- package/node_modules/giget/dist/index.mjs +22 -0
- package/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +468 -0
- package/node_modules/giget/package.json +62 -0
- package/node_modules/node-fetch-native/LICENSE +114 -0
- package/node_modules/node-fetch-native/README.md +225 -0
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +2 -0
- package/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +2 -0
- package/node_modules/node-fetch-native/dist/index.cjs +1 -0
- package/node_modules/node-fetch-native/dist/index.mjs +1 -0
- package/node_modules/node-fetch-native/dist/native.cjs +1 -0
- package/node_modules/node-fetch-native/dist/native.mjs +1 -0
- package/node_modules/node-fetch-native/dist/node.cjs +19 -0
- package/node_modules/node-fetch-native/dist/node.mjs +19 -0
- package/node_modules/node-fetch-native/dist/polyfill.cjs +1 -0
- package/node_modules/node-fetch-native/dist/polyfill.mjs +1 -0
- package/node_modules/node-fetch-native/dist/proxy-stub.cjs +1 -0
- package/node_modules/node-fetch-native/dist/proxy-stub.mjs +1 -0
- package/node_modules/node-fetch-native/dist/proxy.cjs +58 -0
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +1 -0
- package/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +1 -0
- package/node_modules/node-fetch-native/index.d.ts +1 -0
- package/node_modules/node-fetch-native/lib/empty.cjs +0 -0
- package/node_modules/node-fetch-native/lib/empty.mjs +0 -0
- package/node_modules/node-fetch-native/lib/index.cjs +11 -0
- package/node_modules/node-fetch-native/lib/index.d.cts +10 -0
- package/node_modules/node-fetch-native/lib/index.d.mts +10 -0
- package/node_modules/node-fetch-native/lib/index.d.ts +10 -0
- package/node_modules/node-fetch-native/lib/native.cjs +11 -0
- package/node_modules/node-fetch-native/lib/polyfill.d.cts +1 -0
- package/node_modules/node-fetch-native/lib/polyfill.d.mts +1 -0
- package/node_modules/node-fetch-native/lib/polyfill.d.ts +1 -0
- package/node_modules/node-fetch-native/lib/proxy.d.ts +32 -0
- package/node_modules/node-fetch-native/node.d.ts +1 -0
- package/node_modules/node-fetch-native/package.json +138 -0
- package/node_modules/node-fetch-native/polyfill.d.ts +1 -0
- package/node_modules/node-fetch-native/proxy.d.ts +1 -0
- package/node_modules/nypm/LICENSE +21 -0
- package/node_modules/nypm/README.md +152 -0
- package/node_modules/nypm/dist/cli.d.mts +1 -0
- package/node_modules/nypm/dist/cli.mjs +460 -0
- package/node_modules/nypm/dist/index.d.mts +209 -0
- package/node_modules/nypm/dist/index.mjs +423 -0
- package/node_modules/nypm/node_modules/citty/LICENSE +21 -0
- package/node_modules/nypm/node_modules/citty/README.md +231 -0
- package/node_modules/nypm/node_modules/citty/dist/THIRD-PARTY-LICENSES.md +33 -0
- package/node_modules/nypm/node_modules/citty/dist/_chunks/libs/scule.mjs +70 -0
- package/node_modules/nypm/node_modules/citty/dist/index.d.mts +112 -0
- package/node_modules/nypm/node_modules/citty/dist/index.mjs +425 -0
- package/node_modules/nypm/node_modules/citty/package.json +42 -0
- package/node_modules/nypm/package.json +54 -0
- package/node_modules/pathe/LICENSE +70 -0
- package/node_modules/pathe/README.md +73 -0
- package/node_modules/pathe/dist/index.cjs +39 -0
- package/node_modules/pathe/dist/index.d.cts +47 -0
- package/node_modules/pathe/dist/index.d.mts +47 -0
- package/node_modules/pathe/dist/index.d.ts +47 -0
- package/node_modules/pathe/dist/index.mjs +19 -0
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +266 -0
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/node_modules/pathe/dist/utils.cjs +82 -0
- package/node_modules/pathe/dist/utils.d.cts +32 -0
- package/node_modules/pathe/dist/utils.d.mts +32 -0
- package/node_modules/pathe/dist/utils.d.ts +32 -0
- package/node_modules/pathe/dist/utils.mjs +77 -0
- package/node_modules/pathe/package.json +61 -0
- package/node_modules/pathe/utils.d.ts +1 -0
- package/node_modules/picocolors/LICENSE +15 -0
- package/node_modules/picocolors/README.md +21 -0
- package/node_modules/picocolors/package.json +25 -0
- package/node_modules/picocolors/picocolors.browser.js +4 -0
- package/node_modules/picocolors/picocolors.d.ts +5 -0
- package/node_modules/picocolors/picocolors.js +75 -0
- package/node_modules/picocolors/types.d.ts +51 -0
- package/node_modules/sisteransi/license +21 -0
- package/node_modules/sisteransi/package.json +34 -0
- package/node_modules/sisteransi/readme.md +113 -0
- package/node_modules/sisteransi/src/index.js +58 -0
- package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
- package/node_modules/tinyexec/LICENSE +21 -0
- package/node_modules/tinyexec/README.md +269 -0
- package/node_modules/tinyexec/dist/LICENSES.txt +83 -0
- package/node_modules/tinyexec/dist/main.d.mts +71 -0
- package/node_modules/tinyexec/dist/main.mjs +642 -0
- package/node_modules/tinyexec/package.json +62 -0
- package/package.json +74 -74
- package/CHANGELOG.md +0 -764
- package/bin/maizzle +0 -5
- package/src/commands/build.js +0 -348
- package/src/commands/serve.js +0 -3
- package/src/generators/plaintext.js +0 -222
- package/src/generators/render.js +0 -129
- package/src/index.js +0 -49
- package/src/posthtml/defaultComponentsConfig.js +0 -19
- package/src/posthtml/defaultConfig.js +0 -14
- package/src/posthtml/index.js +0 -102
- package/src/posthtml/plugins/combineMediaQueries.js +0 -42
- package/src/posthtml/plugins/envAttributes.js +0 -32
- package/src/posthtml/plugins/envTags.js +0 -33
- package/src/posthtml/plugins/expandLinkTag.js +0 -59
- package/src/posthtml/plugins/postcss/compileCss.js +0 -129
- package/src/posthtml/plugins/removeRawStyleAttributes.js +0 -30
- package/src/server/client.js +0 -182
- package/src/server/index.js +0 -464
- package/src/server/routes/hmr.js +0 -26
- package/src/server/routes/index.js +0 -77
- package/src/server/views/404.html +0 -59
- package/src/server/views/error.html +0 -83
- package/src/server/views/index.html +0 -172
- package/src/server/websockets.js +0 -27
- package/src/transformers/addAttributes.js +0 -29
- package/src/transformers/attributeToStyle.js +0 -90
- package/src/transformers/baseUrl.js +0 -154
- package/src/transformers/core.js +0 -32
- package/src/transformers/filters/defaultFilters.js +0 -146
- package/src/transformers/filters/index.js +0 -18
- package/src/transformers/index.js +0 -259
- package/src/transformers/inline.js +0 -306
- package/src/transformers/markdown.js +0 -26
- package/src/transformers/minify.js +0 -27
- package/src/transformers/posthtmlMso.js +0 -14
- package/src/transformers/prettify.js +0 -29
- package/src/transformers/preventWidows.js +0 -37
- package/src/transformers/purge.js +0 -56
- package/src/transformers/removeAttributes.js +0 -55
- package/src/transformers/replaceStrings.js +0 -37
- package/src/transformers/safeClassNames.js +0 -29
- package/src/transformers/shorthandCss.js +0 -20
- package/src/transformers/sixHex.js +0 -30
- package/src/transformers/template.js +0 -26
- package/src/transformers/urlParameters.js +0 -20
- package/src/transformers/useAttributeSizes.js +0 -63
- package/src/utils/getConfigByFilePath.js +0 -143
- package/src/utils/node.js +0 -68
- package/src/utils/string.js +0 -186
- package/types/build.d.ts +0 -166
- package/types/config.d.ts +0 -638
- package/types/css/combineMediaQueries.d.ts +0 -90
- package/types/css/inline.d.ts +0 -218
- package/types/css/purge.d.ts +0 -125
- package/types/events.d.ts +0 -153
- package/types/index.d.ts +0 -232
- package/types/markdown.d.ts +0 -33
- package/types/minify.d.ts +0 -138
- package/types/plaintext.d.ts +0 -56
- package/types/posthtml.d.ts +0 -162
- package/types/render.d.ts +0 -13
- package/types/urlParameters.d.ts +0 -40
- package/types/widowWords.d.ts +0 -38
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { parse } from "../utils/ast/parser.mjs";
|
|
2
|
+
import { serialize } from "../utils/ast/serializer.mjs";
|
|
3
|
+
import "../utils/ast/index.mjs";
|
|
4
|
+
import { defu } from "defu";
|
|
5
|
+
import { comb } from "email-comb";
|
|
6
|
+
|
|
7
|
+
//#region src/transformers/purgeCSS.ts
|
|
8
|
+
const DEFAULT_SAFELIST = [
|
|
9
|
+
"*body*",
|
|
10
|
+
".gmail*",
|
|
11
|
+
".apple*",
|
|
12
|
+
".ios*",
|
|
13
|
+
".ox-*",
|
|
14
|
+
".outlook*",
|
|
15
|
+
"[data-ogs*",
|
|
16
|
+
".bloop_container",
|
|
17
|
+
".Singleton",
|
|
18
|
+
".unused",
|
|
19
|
+
".moz-text-html",
|
|
20
|
+
".mail-detail-content",
|
|
21
|
+
"*edo*",
|
|
22
|
+
"#*",
|
|
23
|
+
".lang*"
|
|
24
|
+
];
|
|
25
|
+
const DEFAULT_OPTIONS = {
|
|
26
|
+
backend: [{
|
|
27
|
+
heads: "{{",
|
|
28
|
+
tails: "}}"
|
|
29
|
+
}, {
|
|
30
|
+
heads: "{%",
|
|
31
|
+
tails: "%}"
|
|
32
|
+
}],
|
|
33
|
+
whitelist: [...DEFAULT_SAFELIST]
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Remove unused CSS transformer.
|
|
37
|
+
*
|
|
38
|
+
* Uses `email-comb` to strip CSS selectors and corresponding class/id
|
|
39
|
+
* references that are not matched anywhere in the HTML body.
|
|
40
|
+
*
|
|
41
|
+
* Enable by setting `css.purge: true` (or passing options).
|
|
42
|
+
* The user-supplied options are merged on top of the defaults, so
|
|
43
|
+
* `safelist` values are **appended** to the built-in safelist rather
|
|
44
|
+
* than replacing it.
|
|
45
|
+
*
|
|
46
|
+
* Accepts `ChildNode[]` as input, serializes internally before passing
|
|
47
|
+
* to email-comb (which requires a raw HTML string), then parses the
|
|
48
|
+
* result back to `ChildNode[]` so it fits in the DOM pipeline.
|
|
49
|
+
*/
|
|
50
|
+
function purgeCSS(dom, config = {}) {
|
|
51
|
+
const option = config.purge;
|
|
52
|
+
if (!option) return dom;
|
|
53
|
+
const userOptions = typeof option === "object" ? option : {};
|
|
54
|
+
const userSafelist = Array.isArray(userOptions.safelist) ? userOptions.safelist : [];
|
|
55
|
+
const { safelist: _discard, ...restUserOptions } = userOptions;
|
|
56
|
+
const options = defu({
|
|
57
|
+
...restUserOptions,
|
|
58
|
+
whitelist: [...DEFAULT_SAFELIST, ...userSafelist]
|
|
59
|
+
}, DEFAULT_OPTIONS);
|
|
60
|
+
const { result } = comb(serialize(dom), options);
|
|
61
|
+
return parse(result);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { purgeCSS };
|
|
66
|
+
//# sourceMappingURL=purgeCSS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purgeCSS.mjs","names":["merge"],"sources":["../../src/transformers/purgeCSS.ts"],"sourcesContent":["import { comb } from 'email-comb'\nimport { defu as merge } from 'defu'\nimport type { ChildNode } from 'domhandler'\nimport { parse, serialize } from '../utils/ast/index.ts'\nimport type { CssConfig } from '../types/config.ts'\n\nconst DEFAULT_SAFELIST: string[] = [\n '*body*', // Gmail\n '.gmail*', // Gmail\n '.apple*', // Apple Mail\n '.ios*', // Mail on iOS\n '.ox-*', // Open-Xchange\n '.outlook*', // Outlook.com\n '[data-ogs*', // Outlook.com\n '.bloop_container', // Airmail\n '.Singleton', // Apple Mail 10\n '.unused', // Notes 8\n '.moz-text-html', // Thunderbird\n '.mail-detail-content', // Comcast, Libero webmail\n '*edo*', // Edison (all)\n '#*', // Freenet uses #msgBody\n '.lang*', // Fenced code blocks\n]\n\nconst DEFAULT_OPTIONS = {\n backend: [\n { heads: '{{', tails: '}}' },\n { heads: '{%', tails: '%}' },\n ],\n whitelist: [...DEFAULT_SAFELIST],\n}\n\n/**\n * Remove unused CSS transformer.\n *\n * Uses `email-comb` to strip CSS selectors and corresponding class/id\n * references that are not matched anywhere in the HTML body.\n *\n * Enable by setting `css.purge: true` (or passing options).\n * The user-supplied options are merged on top of the defaults, so\n * `safelist` values are **appended** to the built-in safelist rather\n * than replacing it.\n *\n * Accepts `ChildNode[]` as input, serializes internally before passing\n * to email-comb (which requires a raw HTML string), then parses the\n * result back to `ChildNode[]` so it fits in the DOM pipeline.\n */\nexport function purgeCSS(dom: ChildNode[], config: CssConfig = {}): ChildNode[] {\n const option = config.purge\n\n if (!option) return dom\n\n const userOptions = typeof option === 'object' ? option : {}\n\n // Merge user options on top of defaults.\n // defu merges objects deeply; for arrays it appends user values.\n // We want the user safelist appended to the default safelist,\n // so we build whitelist manually.\n const userSafelist = Array.isArray((userOptions as any).safelist)\n ? (userOptions as any).safelist as string[]\n : []\n\n const { safelist: _discard, ...restUserOptions } = userOptions as any\n\n const options = merge(\n { ...restUserOptions, whitelist: [...DEFAULT_SAFELIST, ...userSafelist] },\n DEFAULT_OPTIONS,\n )\n\n const { result } = comb(serialize(dom), options)\n\n return parse(result)\n}\n"],"mappings":";;;;;;;AAMA,MAAM,mBAA6B;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,kBAAkB;CACtB,SAAS,CACP;EAAE,OAAO;EAAM,OAAO;EAAM,EAC5B;EAAE,OAAO;EAAM,OAAO;EAAM,CAC7B;CACD,WAAW,CAAC,GAAG,iBAAiB;CACjC;;;;;;;;;;;;;;;;AAiBD,SAAgB,SAAS,KAAkB,SAAoB,EAAE,EAAe;CAC9E,MAAM,SAAS,OAAO;AAEtB,KAAI,CAAC,OAAQ,QAAO;CAEpB,MAAM,cAAc,OAAO,WAAW,WAAW,SAAS,EAAE;CAM5D,MAAM,eAAe,MAAM,QAAS,YAAoB,SAAS,GAC5D,YAAoB,WACrB,EAAE;CAEN,MAAM,EAAE,UAAU,UAAU,GAAG,oBAAoB;CAEnD,MAAM,UAAUA,KACd;EAAE,GAAG;EAAiB,WAAW,CAAC,GAAG,kBAAkB,GAAG,aAAa;EAAE,EACzE,gBACD;CAED,MAAM,EAAE,WAAW,KAAK,UAAU,IAAI,EAAE,QAAQ;AAEhD,QAAO,MAAM,OAAO"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AttributesConfig } from "../types/config.mjs";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/removeAttributes.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Remove attributes transformer.
|
|
7
|
+
*
|
|
8
|
+
* Removes specified HTML attributes from elements.
|
|
9
|
+
*
|
|
10
|
+
* By default, removes empty `style` and `class` attributes.
|
|
11
|
+
*
|
|
12
|
+
* Supports:
|
|
13
|
+
* - String: removes attribute when empty (boolean or empty string)
|
|
14
|
+
* - Object with name and value: removes when attribute matches exactly
|
|
15
|
+
* - Object with name and RegExp value: removes when attribute value matches regex
|
|
16
|
+
*
|
|
17
|
+
* Configured via `remove` array:
|
|
18
|
+
* ```js
|
|
19
|
+
* {
|
|
20
|
+
* remove: [
|
|
21
|
+
* 'data-src', // Remove empty data-src attributes
|
|
22
|
+
* { name: 'id', value: 'test' }, // Remove id="test" exactly
|
|
23
|
+
* { name: 'data-id', value: /\d/ } // Remove data-id when value contains digits
|
|
24
|
+
* ]
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare function removeAttributes(dom: ChildNode[], config?: AttributesConfig): ChildNode[];
|
|
29
|
+
//#endregion
|
|
30
|
+
export { removeAttributes };
|
|
31
|
+
//# sourceMappingURL=removeAttributes.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeAttributes.d.mts","names":[],"sources":["../../src/transformers/removeAttributes.ts"],"mappings":";;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;iBAAgB,gBAAA,CAAiB,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,gBAAA,GAAwB,SAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.mjs";
|
|
2
|
+
import "../utils/ast/index.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/removeAttributes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Remove attributes transformer.
|
|
7
|
+
*
|
|
8
|
+
* Removes specified HTML attributes from elements.
|
|
9
|
+
*
|
|
10
|
+
* By default, removes empty `style` and `class` attributes.
|
|
11
|
+
*
|
|
12
|
+
* Supports:
|
|
13
|
+
* - String: removes attribute when empty (boolean or empty string)
|
|
14
|
+
* - Object with name and value: removes when attribute matches exactly
|
|
15
|
+
* - Object with name and RegExp value: removes when attribute value matches regex
|
|
16
|
+
*
|
|
17
|
+
* Configured via `remove` array:
|
|
18
|
+
* ```js
|
|
19
|
+
* {
|
|
20
|
+
* remove: [
|
|
21
|
+
* 'data-src', // Remove empty data-src attributes
|
|
22
|
+
* { name: 'id', value: 'test' }, // Remove id="test" exactly
|
|
23
|
+
* { name: 'data-id', value: /\d/ } // Remove data-id when value contains digits
|
|
24
|
+
* ]
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function removeAttributes(dom, config = {}) {
|
|
29
|
+
const removeOptions = config.remove;
|
|
30
|
+
const alwaysRemove = ["style", "class"];
|
|
31
|
+
let userOptions = [];
|
|
32
|
+
if (Array.isArray(removeOptions)) userOptions = removeOptions;
|
|
33
|
+
const attributesToRemove = [...alwaysRemove, ...userOptions];
|
|
34
|
+
if (attributesToRemove.length === 0) return dom;
|
|
35
|
+
walk(dom, (node) => {
|
|
36
|
+
const el = node;
|
|
37
|
+
if (!el.attribs) return;
|
|
38
|
+
for (const attr of attributesToRemove) {
|
|
39
|
+
let attrName;
|
|
40
|
+
let attrValue;
|
|
41
|
+
if (typeof attr === "string") {
|
|
42
|
+
attrName = attr;
|
|
43
|
+
attrValue = true;
|
|
44
|
+
} else {
|
|
45
|
+
attrName = attr.name;
|
|
46
|
+
attrValue = attr.value;
|
|
47
|
+
}
|
|
48
|
+
const currentValue = el.attribs[attrName];
|
|
49
|
+
if (currentValue === void 0) continue;
|
|
50
|
+
let shouldRemove = false;
|
|
51
|
+
if (typeof attrValue === "boolean") shouldRemove = currentValue === "" || currentValue === true;
|
|
52
|
+
else if (typeof attrValue === "string") shouldRemove = currentValue === attrValue;
|
|
53
|
+
else if (attrValue instanceof RegExp) shouldRemove = attrValue.test(currentValue);
|
|
54
|
+
else shouldRemove = currentValue === "";
|
|
55
|
+
if (shouldRemove) delete el.attribs[attrName];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return dom;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { removeAttributes };
|
|
63
|
+
//# sourceMappingURL=removeAttributes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeAttributes.mjs","names":[],"sources":["../../src/transformers/removeAttributes.ts"],"sourcesContent":["import type { ChildNode, Element } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport type { AttributesConfig } from '../types/config.ts'\n\ninterface RemoveAttributeConfig {\n name: string\n value?: string | RegExp | boolean\n}\n\ntype RemoveAttributeOption = string | RemoveAttributeConfig\n\n/**\n * Remove attributes transformer.\n *\n * Removes specified HTML attributes from elements.\n *\n * By default, removes empty `style` and `class` attributes.\n *\n * Supports:\n * - String: removes attribute when empty (boolean or empty string)\n * - Object with name and value: removes when attribute matches exactly\n * - Object with name and RegExp value: removes when attribute value matches regex\n *\n * Configured via `remove` array:\n * ```js\n * {\n * remove: [\n * 'data-src', // Remove empty data-src attributes\n * { name: 'id', value: 'test' }, // Remove id=\"test\" exactly\n * { name: 'data-id', value: /\\d/ } // Remove data-id when value contains digits\n * ]\n * }\n * ```\n */\nexport function removeAttributes(dom: ChildNode[], config: AttributesConfig = {}): ChildNode[] {\n const removeOptions = config.remove\n\n // Always remove empty style and class attributes by default\n const alwaysRemove: RemoveAttributeOption[] = ['style', 'class']\n\n // Parse user options\n let userOptions: RemoveAttributeOption[] = []\n if (Array.isArray(removeOptions)) {\n userOptions = removeOptions as RemoveAttributeOption[]\n }\n\n // Combine default and user options\n const attributesToRemove: RemoveAttributeOption[] = [...alwaysRemove, ...userOptions]\n\n if (attributesToRemove.length === 0) {\n return dom\n }\n\n walk(dom, (node) => {\n const el = node as Element\n if (!el.attribs) return\n\n for (const attr of attributesToRemove) {\n let attrName: string\n let attrValue: string | RegExp | boolean | undefined\n\n if (typeof attr === 'string') {\n attrName = attr\n attrValue = true // Remove when value is empty (boolean true or empty string)\n } else {\n attrName = attr.name\n attrValue = attr.value\n }\n\n const currentValue = el.attribs[attrName]\n\n // Skip if attribute doesn't exist\n if (currentValue === undefined) continue\n\n let shouldRemove = false\n\n if (typeof attrValue === 'boolean') {\n // Remove if value is empty (boolean true is treated as no-value attribute)\n shouldRemove = currentValue === '' || (currentValue as unknown) === true\n } else if (typeof attrValue === 'string') {\n // Remove if value matches exactly\n shouldRemove = currentValue === attrValue\n } else if (attrValue instanceof RegExp) {\n // Remove if value matches regex\n shouldRemove = attrValue.test(currentValue)\n } else {\n // Default: remove if empty\n shouldRemove = currentValue === ''\n }\n\n if (shouldRemove) {\n delete el.attribs[attrName]\n }\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,iBAAiB,KAAkB,SAA2B,EAAE,EAAe;CAC7F,MAAM,gBAAgB,OAAO;CAG7B,MAAM,eAAwC,CAAC,SAAS,QAAQ;CAGhE,IAAI,cAAuC,EAAE;AAC7C,KAAI,MAAM,QAAQ,cAAc,CAC9B,eAAc;CAIhB,MAAM,qBAA8C,CAAC,GAAG,cAAc,GAAG,YAAY;AAErF,KAAI,mBAAmB,WAAW,EAChC,QAAO;AAGT,MAAK,MAAM,SAAS;EAClB,MAAM,KAAK;AACX,MAAI,CAAC,GAAG,QAAS;AAEjB,OAAK,MAAM,QAAQ,oBAAoB;GACrC,IAAI;GACJ,IAAI;AAEJ,OAAI,OAAO,SAAS,UAAU;AAC5B,eAAW;AACX,gBAAY;UACP;AACL,eAAW,KAAK;AAChB,gBAAY,KAAK;;GAGnB,MAAM,eAAe,GAAG,QAAQ;AAGhC,OAAI,iBAAiB,OAAW;GAEhC,IAAI,eAAe;AAEnB,OAAI,OAAO,cAAc,UAEvB,gBAAe,iBAAiB,MAAO,iBAA6B;YAC3D,OAAO,cAAc,SAE9B,gBAAe,iBAAiB;YACvB,qBAAqB,OAE9B,gBAAe,UAAU,KAAK,aAAa;OAG3C,gBAAe,iBAAiB;AAGlC,OAAI,aACF,QAAO,GAAG,QAAQ;;GAGtB;AAEF,QAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaizzleConfig } from "../types/config.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/replaceStrings.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Replace strings transformer.
|
|
6
|
+
*
|
|
7
|
+
* Replaces strings in the HTML using the key-value pairs defined in
|
|
8
|
+
* `config.replaceStrings`. Each key is treated as a regular expression
|
|
9
|
+
* pattern (case-insensitive, global), and the value is the replacement.
|
|
10
|
+
*
|
|
11
|
+
* Character classes must be escaped in keys, e.g. `\\s` for `\s`.
|
|
12
|
+
*/
|
|
13
|
+
declare function replaceStrings(html: string, config?: MaizzleConfig): string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { replaceStrings };
|
|
16
|
+
//# sourceMappingURL=replaceStrings.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceStrings.d.mts","names":[],"sources":["../../src/transformers/replaceStrings.ts"],"mappings":";;;;;AAWA;;;;;;;iBAAgB,cAAA,CAAe,IAAA,UAAc,MAAA,GAAQ,aAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/transformers/replaceStrings.ts
|
|
2
|
+
/**
|
|
3
|
+
* Replace strings transformer.
|
|
4
|
+
*
|
|
5
|
+
* Replaces strings in the HTML using the key-value pairs defined in
|
|
6
|
+
* `config.replaceStrings`. Each key is treated as a regular expression
|
|
7
|
+
* pattern (case-insensitive, global), and the value is the replacement.
|
|
8
|
+
*
|
|
9
|
+
* Character classes must be escaped in keys, e.g. `\\s` for `\s`.
|
|
10
|
+
*/
|
|
11
|
+
function replaceStrings(html, config = {}) {
|
|
12
|
+
const replacements = config.replaceStrings;
|
|
13
|
+
if (!replacements || Object.keys(replacements).length === 0) return html;
|
|
14
|
+
return Object.entries(replacements).reduce((result, [pattern, replacement]) => result.replace(new RegExp(pattern, "gi"), replacement), html);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { replaceStrings };
|
|
19
|
+
//# sourceMappingURL=replaceStrings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceStrings.mjs","names":[],"sources":["../../src/transformers/replaceStrings.ts"],"sourcesContent":["import type { MaizzleConfig } from '../types/config.ts'\n\n/**\n * Replace strings transformer.\n *\n * Replaces strings in the HTML using the key-value pairs defined in\n * `config.replaceStrings`. Each key is treated as a regular expression\n * pattern (case-insensitive, global), and the value is the replacement.\n *\n * Character classes must be escaped in keys, e.g. `\\\\s` for `\\s`.\n */\nexport function replaceStrings(html: string, config: MaizzleConfig = {}): string {\n const replacements = config.replaceStrings\n\n if (!replacements || Object.keys(replacements).length === 0) return html\n\n return Object.entries(replacements).reduce(\n (result, [pattern, replacement]) => result.replace(new RegExp(pattern, 'gi'), replacement),\n html,\n )\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,eAAe,MAAc,SAAwB,EAAE,EAAU;CAC/E,MAAM,eAAe,OAAO;AAE5B,KAAI,CAAC,gBAAgB,OAAO,KAAK,aAAa,CAAC,WAAW,EAAG,QAAO;AAEpE,QAAO,OAAO,QAAQ,aAAa,CAAC,QACjC,QAAQ,CAAC,SAAS,iBAAiB,OAAO,QAAQ,IAAI,OAAO,SAAS,KAAK,EAAE,YAAY,EAC1F,KACD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CssConfig } from "../types/config.mjs";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/safeClassNames.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Safe class names transformer.
|
|
7
|
+
*
|
|
8
|
+
* Replaces unsafe characters (`:`, `/`, `[`, `]`, etc.) in:
|
|
9
|
+
* - CSS selectors inside `<style>` tags
|
|
10
|
+
* - HTML `class` attributes
|
|
11
|
+
*
|
|
12
|
+
* This makes Tailwind utility classes like `sm:text-base` safe for
|
|
13
|
+
* email clients that cannot handle escaped characters in class names.
|
|
14
|
+
*
|
|
15
|
+
* Enabled by default. Disable by setting `css.safe` to `false`.
|
|
16
|
+
* Customize replacements by passing a `Record<string, string>` — user
|
|
17
|
+
* values are merged on top of the defaults.
|
|
18
|
+
*/
|
|
19
|
+
declare function safeClassNames(dom: ChildNode[], config?: CssConfig): ChildNode[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { safeClassNames };
|
|
22
|
+
//# sourceMappingURL=safeClassNames.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeClassNames.d.mts","names":[],"sources":["../../src/transformers/safeClassNames.ts"],"mappings":";;;;;;AAsGA;;;;;;;;;;;;iBAAgB,cAAA,CAAe,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,SAAA,GAAiB,SAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.mjs";
|
|
2
|
+
import "../utils/ast/index.mjs";
|
|
3
|
+
import postcss from "postcss";
|
|
4
|
+
import safeParser from "postcss-safe-parser";
|
|
5
|
+
|
|
6
|
+
//#region src/transformers/safeClassNames.ts
|
|
7
|
+
const DEFAULT_REPLACEMENTS = {
|
|
8
|
+
":": "-",
|
|
9
|
+
"/": "-",
|
|
10
|
+
"%": "pc",
|
|
11
|
+
".": "_",
|
|
12
|
+
",": "_",
|
|
13
|
+
"#": "_",
|
|
14
|
+
"[": "",
|
|
15
|
+
"]": "",
|
|
16
|
+
"(": "",
|
|
17
|
+
")": "",
|
|
18
|
+
"{": "",
|
|
19
|
+
"}": "",
|
|
20
|
+
"!": "-i",
|
|
21
|
+
"&": "and-",
|
|
22
|
+
"<": "lt-",
|
|
23
|
+
"=": "eq-",
|
|
24
|
+
">": "gt-",
|
|
25
|
+
"|": "or-",
|
|
26
|
+
"@": "at-",
|
|
27
|
+
"?": "q-",
|
|
28
|
+
"\\": "-",
|
|
29
|
+
"\"": "-",
|
|
30
|
+
"'": "-",
|
|
31
|
+
"*": "-",
|
|
32
|
+
"+": "-",
|
|
33
|
+
";": "-",
|
|
34
|
+
"^": "-",
|
|
35
|
+
"`": "-",
|
|
36
|
+
"~": "-",
|
|
37
|
+
"$": "-"
|
|
38
|
+
};
|
|
39
|
+
function escapeForRegex(s) {
|
|
40
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Replace escaped special characters in CSS selectors.
|
|
44
|
+
*
|
|
45
|
+
* Tailwind generates selectors like `.sm\:text-base`. This function
|
|
46
|
+
* replaces the `\:` with `-` (or whatever the configured replacement is)
|
|
47
|
+
* so the selector becomes `.sm-text-base`, which is safe for email clients.
|
|
48
|
+
*/
|
|
49
|
+
function processCssSelectors(css, replacements) {
|
|
50
|
+
const selectorRegex = new RegExp(`\\\\(${Object.keys(replacements).map(escapeForRegex).join("|")})`, "g");
|
|
51
|
+
return postcss([(root) => {
|
|
52
|
+
root.walkRules((rule) => {
|
|
53
|
+
rule.selector = rule.selector.replace(selectorRegex, (_matched, char) => replacements[char] ?? _matched).replaceAll("\\2c ", "_");
|
|
54
|
+
});
|
|
55
|
+
}]).process(css, { parser: safeParser }).css;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Replace unsafe special characters in a class attribute value.
|
|
59
|
+
*
|
|
60
|
+
* Splits on whitespace and replaces each char from the replacements map
|
|
61
|
+
* in each class token individually.
|
|
62
|
+
*/
|
|
63
|
+
function processClassAttr(classStr, replacements) {
|
|
64
|
+
return classStr.split(/\s+/).filter(Boolean).map((cls) => {
|
|
65
|
+
for (const [from, to] of Object.entries(replacements)) cls = cls.split(from).join(to);
|
|
66
|
+
return cls;
|
|
67
|
+
}).join(" ");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Safe class names transformer.
|
|
71
|
+
*
|
|
72
|
+
* Replaces unsafe characters (`:`, `/`, `[`, `]`, etc.) in:
|
|
73
|
+
* - CSS selectors inside `<style>` tags
|
|
74
|
+
* - HTML `class` attributes
|
|
75
|
+
*
|
|
76
|
+
* This makes Tailwind utility classes like `sm:text-base` safe for
|
|
77
|
+
* email clients that cannot handle escaped characters in class names.
|
|
78
|
+
*
|
|
79
|
+
* Enabled by default. Disable by setting `css.safe` to `false`.
|
|
80
|
+
* Customize replacements by passing a `Record<string, string>` — user
|
|
81
|
+
* values are merged on top of the defaults.
|
|
82
|
+
*/
|
|
83
|
+
function safeClassNames(dom, config = {}) {
|
|
84
|
+
const option = config.safe ?? true;
|
|
85
|
+
if (!option) return dom;
|
|
86
|
+
const replacements = option && typeof option === "object" ? {
|
|
87
|
+
...DEFAULT_REPLACEMENTS,
|
|
88
|
+
...option
|
|
89
|
+
} : DEFAULT_REPLACEMENTS;
|
|
90
|
+
walk(dom, (node) => {
|
|
91
|
+
const el = node;
|
|
92
|
+
if (el.name === "style" && el.children?.length) {
|
|
93
|
+
const text = el.children.find((c) => c.type === "text");
|
|
94
|
+
if (text?.data?.trim()) text.data = processCssSelectors(text.data, replacements);
|
|
95
|
+
}
|
|
96
|
+
if ("attribs" in el && el.attribs?.class) el.attribs.class = processClassAttr(el.attribs.class, replacements);
|
|
97
|
+
});
|
|
98
|
+
return dom;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { safeClassNames };
|
|
103
|
+
//# sourceMappingURL=safeClassNames.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeClassNames.mjs","names":[],"sources":["../../src/transformers/safeClassNames.ts"],"sourcesContent":["import postcss from 'postcss'\nimport safeParser from 'postcss-safe-parser'\nimport type { ChildNode, Element } from 'domhandler'\nimport { 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) => replacements[char] ?? _matched)\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 class names 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 */\nexport function safeClassNames(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;CACN;AAED,SAAS,eAAe,GAAmB;AACzC,QAAO,EAAE,QAAQ,uBAAuB,OAAO;;;;;;;;;AAUjD,SAAS,oBAAoB,KAAa,cAA8C;CAEtF,MAAM,gBAAgB,IAAI,OACxB,QAAQ,OAAO,KAAK,aAAa,CAAC,IAAI,eAAe,CAAC,KAAK,IAAI,CAAC,IAChE,IACD;AAED,QAAO,QAAQ,EACZ,SAAuB;AACtB,OAAK,WAAW,SAAuB;AACrC,QAAK,WAAW,KAAK,SAClB,QAAQ,gBAAgB,UAAU,SAAS,aAAa,SAAS,SAAS,CAE1E,WAAW,SAAS,IAAI;IAC3B;GAEL,CAAC,CAAC,QAAQ,KAAK,EAAE,QAAQ,YAAY,CAAC,CAAC;;;;;;;;AAS1C,SAAS,iBAAiB,UAAkB,cAA8C;AACxF,QAAO,SACJ,MAAM,MAAM,CACZ,OAAO,QAAQ,CACf,KAAK,QAAQ;AACZ,OAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,aAAa,CACnD,OAAM,IAAI,MAAM,KAAK,CAAC,KAAK,GAAG;AAEhC,SAAO;GACP,CACD,KAAK,IAAI;;;;;;;;;;;;;;;;AAiBd,SAAgB,eAAe,KAAkB,SAAoB,EAAE,EAAe;CACpF,MAAM,SAAS,OAAO,QAAQ;AAE9B,KAAI,CAAC,OAAQ,QAAO;CAEpB,MAAM,eACJ,UAAU,OAAO,WAAW,WACxB;EAAE,GAAG;EAAsB,GAAG;EAAQ,GACtC;AAEN,MAAK,MAAM,SAAS;EAClB,MAAM,KAAK;AAGX,MAAI,GAAG,SAAS,WAAW,GAAG,UAAU,QAAQ;GAC9C,MAAM,OAAO,GAAG,SAAS,MAAM,MAAM,EAAE,SAAS,OAAO;AACvD,OAAI,MAAM,MAAM,MAAM,CACpB,MAAK,OAAO,oBAAoB,KAAK,MAAM,aAAa;;AAK5D,MAAI,aAAa,MAAM,GAAG,SAAS,MACjC,IAAG,QAAQ,QAAQ,iBAAiB,GAAG,QAAQ,OAAO,aAAa;GAErE;AAEF,QAAO"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CssConfig } from "../types/config.mjs";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/shorthandCSS.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Shorthand CSS transformer.
|
|
7
|
+
*
|
|
8
|
+
* Rewrites longhand CSS inside `style` attributes with shorthand syntax.
|
|
9
|
+
* Works with margin, padding, and border when all sides are specified.
|
|
10
|
+
*
|
|
11
|
+
* For example:
|
|
12
|
+
* `margin-left: 2px; margin-right: 2px; margin-top: 4px; margin-bottom: 4px`
|
|
13
|
+
* becomes:
|
|
14
|
+
* `margin: 4px 2px`
|
|
15
|
+
*
|
|
16
|
+
* Enabled via `css.shorthand`:
|
|
17
|
+
* - `true`: enable for all tags
|
|
18
|
+
* - `{ tags: ['td', 'div'] }`: enable only for specified tags
|
|
19
|
+
* - `false` or omitted: disabled
|
|
20
|
+
*/
|
|
21
|
+
declare function shorthandCSS(dom: ChildNode[], config?: CssConfig): ChildNode[];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { shorthandCSS };
|
|
24
|
+
//# sourceMappingURL=shorthandCSS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthandCSS.d.mts","names":[],"sources":["../../src/transformers/shorthandCSS.ts"],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;iBAAgB,YAAA,CAAa,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,SAAA,GAAiB,SAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.mjs";
|
|
2
|
+
import "../utils/ast/index.mjs";
|
|
3
|
+
import postcss from "postcss";
|
|
4
|
+
import safeParser from "postcss-safe-parser";
|
|
5
|
+
import mergeLonghand from "postcss-merge-longhand";
|
|
6
|
+
|
|
7
|
+
//#region src/transformers/shorthandCSS.ts
|
|
8
|
+
/**
|
|
9
|
+
* Shorthand CSS transformer.
|
|
10
|
+
*
|
|
11
|
+
* Rewrites longhand CSS inside `style` attributes with shorthand syntax.
|
|
12
|
+
* Works with margin, padding, and border when all sides are 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
|
+
* Enabled via `css.shorthand`:
|
|
20
|
+
* - `true`: enable for all tags
|
|
21
|
+
* - `{ tags: ['td', 'div'] }`: enable only for specified tags
|
|
22
|
+
* - `false` or omitted: disabled
|
|
23
|
+
*/
|
|
24
|
+
function shorthandCSS(dom, config = {}) {
|
|
25
|
+
const option = config.shorthand;
|
|
26
|
+
if (!option) return dom;
|
|
27
|
+
const allowedTags = (typeof option === "object" ? option : {}).tags ?? [];
|
|
28
|
+
const hasTagFilter = allowedTags.length > 0;
|
|
29
|
+
walk(dom, (node) => {
|
|
30
|
+
const el = node;
|
|
31
|
+
if (!el.attribs?.style) return;
|
|
32
|
+
if (hasTagFilter && !allowedTags.includes(el.name)) return;
|
|
33
|
+
const styleValue = el.attribs.style;
|
|
34
|
+
try {
|
|
35
|
+
const { css } = postcss().use(mergeLonghand).process(`div { ${styleValue} }`, { parser: safeParser });
|
|
36
|
+
const match = css.match(/div\s*\{\s*([^}]+)\s*\}/);
|
|
37
|
+
if (match && match[1]) {
|
|
38
|
+
const newStyle = match[1].trim();
|
|
39
|
+
if (newStyle !== styleValue) el.attribs.style = newStyle;
|
|
40
|
+
}
|
|
41
|
+
} catch {}
|
|
42
|
+
});
|
|
43
|
+
return dom;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { shorthandCSS };
|
|
48
|
+
//# sourceMappingURL=shorthandCSS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthandCSS.mjs","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 { walk } from '../utils/ast/index.ts'\nimport type { CssConfig } from '../types/config.ts'\n\ninterface ShorthandCssOptions {\n tags?: string[]\n}\n\n/**\n * Shorthand CSS transformer.\n *\n * Rewrites longhand CSS inside `style` attributes with shorthand syntax.\n * Works with margin, padding, and border when all sides are 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 * Enabled via `css.shorthand`:\n * - `true`: enable for all tags\n * - `{ tags: ['td', 'div'] }`: enable only for specified tags\n * - `false` or omitted: disabled\n */\nexport function shorthandCSS(dom: ChildNode[], config: CssConfig = {}): ChildNode[] {\n const option = config.shorthand\n\n // Disabled by default\n if (!option) {\n return dom\n }\n\n // Parse options\n const options: ShorthandCssOptions = typeof option === 'object' ? option : {}\n const allowedTags = options.tags ?? []\n const hasTagFilter = allowedTags.length > 0\n\n walk(dom, (node) => {\n const el = node as Element\n\n // Skip if no attribs or no style\n if (!el.attribs?.style) {\n return\n }\n\n // Skip if tag filter is active and this tag is not allowed\n if (hasTagFilter && !allowedTags.includes(el.name)) {\n return\n }\n\n const styleValue = el.attribs.style\n\n try {\n // Process the style with postcss-merge-longhand\n // Wrap in a dummy selector since postcss needs a rule\n const { css } = postcss()\n .use(mergeLonghand)\n .process(`div { ${styleValue} }`, { parser: safeParser })\n\n // Extract the content between the braces\n const match = css.match(/div\\s*\\{\\s*([^}]+)\\s*\\}/)\n if (match && match[1]) {\n const newStyle = match[1].trim()\n if (newStyle !== styleValue) {\n el.attribs.style = newStyle\n }\n }\n } catch {\n // If processing fails, keep the original style\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,aAAa,KAAkB,SAAoB,EAAE,EAAe;CAClF,MAAM,SAAS,OAAO;AAGtB,KAAI,CAAC,OACH,QAAO;CAKT,MAAM,eAD+B,OAAO,WAAW,WAAW,SAAS,EAAE,EACjD,QAAQ,EAAE;CACtC,MAAM,eAAe,YAAY,SAAS;AAE1C,MAAK,MAAM,SAAS;EAClB,MAAM,KAAK;AAGX,MAAI,CAAC,GAAG,SAAS,MACf;AAIF,MAAI,gBAAgB,CAAC,YAAY,SAAS,GAAG,KAAK,CAChD;EAGF,MAAM,aAAa,GAAG,QAAQ;AAE9B,MAAI;GAGF,MAAM,EAAE,QAAQ,SAAS,CACtB,IAAI,cAAc,CAClB,QAAQ,SAAS,WAAW,KAAK,EAAE,QAAQ,YAAY,CAAC;GAG3D,MAAM,QAAQ,IAAI,MAAM,0BAA0B;AAClD,OAAI,SAAS,MAAM,IAAI;IACrB,MAAM,WAAW,MAAM,GAAG,MAAM;AAChC,QAAI,aAAa,WACf,IAAG,QAAQ,QAAQ;;UAGjB;GAGR;AAEF,QAAO"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MaizzleConfig } from "../types/config.mjs";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/tailwindcss.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Tailwind CSS transformer.
|
|
7
|
+
*
|
|
8
|
+
* Compiles CSS inside <style> tags in the DOM using
|
|
9
|
+
* @tailwindcss/postcss, then lowers modern CSS syntax with lightningcss.
|
|
10
|
+
*
|
|
11
|
+
* Uses the AST walker to find <style> tags and decodes HTML entities
|
|
12
|
+
* that Vue SSR encodes (e.g. ") before CSS processing.
|
|
13
|
+
*
|
|
14
|
+
* Runs as the first transformer in the pipeline so that subsequent
|
|
15
|
+
* transformers (inliner, purge, etc.) work with fully compiled CSS.
|
|
16
|
+
*/
|
|
17
|
+
declare function tailwindcss(dom: ChildNode[], config: MaizzleConfig, filePath?: string): Promise<ChildNode[]>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { tailwindcss };
|
|
20
|
+
//# sourceMappingURL=tailwindcss.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwindcss.d.mts","names":[],"sources":["../../src/transformers/tailwindcss.ts"],"mappings":";;;;;;AA6FA;;;;;;;;;;iBAAsB,WAAA,CAAY,GAAA,EAAK,SAAA,IAAa,MAAA,EAAQ,aAAA,EAAe,QAAA,YAAoB,OAAA,CAAQ,SAAA"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.mjs";
|
|
2
|
+
import "../utils/ast/index.mjs";
|
|
3
|
+
import pruneVars_default from "../plugins/postcss/pruneVars.mjs";
|
|
4
|
+
import { tailwindCleanup } from "../plugins/postcss/tailwindCleanup.mjs";
|
|
5
|
+
import { mergeMediaQueries } from "../plugins/postcss/mergeMediaQueries.mjs";
|
|
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 safeParser from "postcss-safe-parser";
|
|
11
|
+
import { transform } from "lightningcss";
|
|
12
|
+
|
|
13
|
+
//#region src/transformers/tailwindcss.ts
|
|
14
|
+
function createProcessor(config) {
|
|
15
|
+
return postcss([
|
|
16
|
+
tailwindcssPostcss({
|
|
17
|
+
base: config.css?.base,
|
|
18
|
+
transformAssetUrls: false,
|
|
19
|
+
optimize: false
|
|
20
|
+
}),
|
|
21
|
+
customProperties({ preserve: false }),
|
|
22
|
+
pruneVars_default()
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Decode HTML entities that Vue SSR encodes inside <style> tags.
|
|
27
|
+
*
|
|
28
|
+
* Vue's renderToString HTML-encodes quotes and other characters
|
|
29
|
+
* inside <style> tags within templates, breaking CSS like
|
|
30
|
+
* `@import "@maizzle/tailwindcss"` → `@import "..."`
|
|
31
|
+
*/
|
|
32
|
+
function decodeEntities(str) {
|
|
33
|
+
return str.replace(/"/g, "\"").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/'/g, "'");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Lower modern CSS syntax using lightningcss.
|
|
37
|
+
*
|
|
38
|
+
* Targets IE 1 to maximize syntax lowering — converts modern features
|
|
39
|
+
* like nesting, oklch(), color-mix(), @property, etc. into simple CSS
|
|
40
|
+
* that email clients can understand.
|
|
41
|
+
*/
|
|
42
|
+
function lowerSyntax(css) {
|
|
43
|
+
return transform({
|
|
44
|
+
filename: "email.css",
|
|
45
|
+
code: Buffer.from(css),
|
|
46
|
+
minify: false,
|
|
47
|
+
targets: { ie: 128 }
|
|
48
|
+
}).code.toString();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Run cleanup and media query merging on the compiled CSS.
|
|
52
|
+
*
|
|
53
|
+
* Removes unwanted selectors (:host, :lang) and at-rules (@layer, @property),
|
|
54
|
+
* then sorts and merges media queries.
|
|
55
|
+
*/
|
|
56
|
+
async function optimizeCss(css, config) {
|
|
57
|
+
const plugins = [...tailwindCleanup(config)];
|
|
58
|
+
const mediaPlugin = mergeMediaQueries(config);
|
|
59
|
+
if (mediaPlugin) plugins.push(mediaPlugin);
|
|
60
|
+
return (await postcss(plugins).process(css, { from: void 0 })).css;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Tailwind CSS transformer.
|
|
64
|
+
*
|
|
65
|
+
* Compiles CSS inside <style> tags in the DOM using
|
|
66
|
+
* @tailwindcss/postcss, then lowers modern CSS syntax with lightningcss.
|
|
67
|
+
*
|
|
68
|
+
* Uses the AST walker to find <style> tags and decodes HTML entities
|
|
69
|
+
* that Vue SSR encodes (e.g. ") before CSS processing.
|
|
70
|
+
*
|
|
71
|
+
* Runs as the first transformer in the pipeline so that subsequent
|
|
72
|
+
* transformers (inliner, purge, etc.) work with fully compiled CSS.
|
|
73
|
+
*/
|
|
74
|
+
async function tailwindcss(dom, config, filePath) {
|
|
75
|
+
const sourceNotPaths = [resolve(config.output?.path ?? "dist"), ...(config.css?.exclude ?? []).map((p) => resolve(p))];
|
|
76
|
+
const styleTags = [];
|
|
77
|
+
walk(dom, (node) => {
|
|
78
|
+
if (node.name !== "style") return;
|
|
79
|
+
const el = node;
|
|
80
|
+
const attrs = el.attribs || {};
|
|
81
|
+
const markerAttr = [
|
|
82
|
+
"raw",
|
|
83
|
+
"embed",
|
|
84
|
+
"data-embed"
|
|
85
|
+
].find((attr) => attr in attrs);
|
|
86
|
+
if (markerAttr) {
|
|
87
|
+
delete el.attribs[markerAttr];
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const rawContent = el.children.filter((child) => child.type === "text").map((child) => child.data).join("");
|
|
91
|
+
if (!rawContent.trim()) return;
|
|
92
|
+
let cssContent = decodeEntities(rawContent);
|
|
93
|
+
if (filePath) {
|
|
94
|
+
if (sourceNotPaths.length) {
|
|
95
|
+
const fileDir = dirname(filePath);
|
|
96
|
+
const exclusions = sourceNotPaths.map((p) => `@source not "${relative(fileDir, resolve(p))}";`).join("\n");
|
|
97
|
+
cssContent = `${cssContent}\n${exclusions}`;
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
const classes = [];
|
|
101
|
+
walk(dom, (n) => {
|
|
102
|
+
const cls = n.attribs?.class;
|
|
103
|
+
if (cls) classes.push(cls);
|
|
104
|
+
});
|
|
105
|
+
if (classes.length) cssContent = `${cssContent}\n@source inline("${classes.join(" ")}");`;
|
|
106
|
+
}
|
|
107
|
+
styleTags.push({
|
|
108
|
+
node: el,
|
|
109
|
+
cssContent
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
for (let i = 0; i < styleTags.length; i++) {
|
|
113
|
+
const { node, cssContent } = styleTags[i];
|
|
114
|
+
try {
|
|
115
|
+
node.children = [{
|
|
116
|
+
type: "text",
|
|
117
|
+
data: await optimizeCss(lowerSyntax((await createProcessor(config).process(cssContent, {
|
|
118
|
+
from: `${filePath ?? resolve(process.cwd(), "template.vue")}?style=${i}`,
|
|
119
|
+
parser: safeParser
|
|
120
|
+
})).css), config),
|
|
121
|
+
parent: node
|
|
122
|
+
}];
|
|
123
|
+
} catch {
|
|
124
|
+
node.children = [{
|
|
125
|
+
type: "text",
|
|
126
|
+
data: cssContent,
|
|
127
|
+
parent: node
|
|
128
|
+
}];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return dom;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { tailwindcss };
|
|
136
|
+
//# sourceMappingURL=tailwindcss.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwindcss.mjs","names":["pruneVars"],"sources":["../../src/transformers/tailwindcss.ts"],"sourcesContent":["import postcss from 'postcss'\nimport tailwindcssPostcss from '@tailwindcss/postcss'\nimport customProperties from 'postcss-custom-properties'\nimport pruneVars from '../plugins/postcss/pruneVars.ts'\nimport safeParser from 'postcss-safe-parser'\nimport { transform } from 'lightningcss'\nimport { resolve, dirname, relative } from 'node:path'\nimport type { ChildNode, Element } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\nimport { tailwindCleanup } from '../plugins/postcss/tailwindCleanup.ts'\nimport { mergeMediaQueries } from '../plugins/postcss/mergeMediaQueries.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\nfunction createProcessor(config: MaizzleConfig) {\n return postcss([\n tailwindcssPostcss({\n base: config.css?.base,\n transformAssetUrls: false,\n optimize: false, // we run Lightning CSS manually\n }),\n customProperties({\n preserve: false,\n }),\n pruneVars(),\n ])\n}\n\n/**\n * Decode HTML entities that Vue SSR encodes inside <style> tags.\n *\n * Vue's renderToString HTML-encodes quotes and other characters\n * inside <style> tags within templates, breaking CSS like\n * `@import \"@maizzle/tailwindcss\"` → `@import "..."`\n */\nfunction decodeEntities(str: string): string {\n return str\n .replace(/"/g, '\"')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/'/g, \"'\")\n .replace(/'/g, \"'\")\n}\n\n/**\n * Lower modern CSS syntax using lightningcss.\n *\n * Targets IE 1 to maximize syntax lowering — converts modern features\n * like nesting, oklch(), color-mix(), @property, etc. into simple CSS\n * that email clients can understand.\n */\nfunction lowerSyntax(css: string): string {\n const result = transform({\n filename: 'email.css',\n code: Buffer.from(css),\n minify: false,\n targets: {\n ie: 4 << 5,\n },\n })\n\n return result.code.toString()\n}\n\n/**\n * Run cleanup and media query merging on the compiled CSS.\n *\n * Removes unwanted selectors (:host, :lang) and at-rules (@layer, @property),\n * then sorts and merges media queries.\n */\nasync function optimizeCss(css: string, config: MaizzleConfig): Promise<string> {\n const plugins: postcss.Plugin[] = [...tailwindCleanup(config)]\n\n const mediaPlugin = mergeMediaQueries(config)\n if (mediaPlugin) plugins.push(mediaPlugin)\n\n const result = await postcss(plugins).process(css, { from: undefined })\n\n return result.css\n}\n\n/**\n * Tailwind CSS transformer.\n *\n * Compiles CSS inside <style> tags in the DOM using\n * @tailwindcss/postcss, then lowers modern CSS syntax with lightningcss.\n *\n * Uses the AST walker to find <style> tags and decodes HTML entities\n * that Vue SSR encodes (e.g. ") before CSS processing.\n *\n * Runs as the first transformer in the pipeline so that subsequent\n * transformers (inliner, purge, etc.) work with fully compiled CSS.\n */\nexport async function tailwindcss(dom: ChildNode[], config: MaizzleConfig, filePath?: string): Promise<ChildNode[]> {\n const sourceNotPaths = [\n resolve(config.output?.path ?? 'dist'),\n ...(config.css?.exclude ?? []).map(p => resolve(p)),\n ]\n\n const styleTags: { node: Element; cssContent: string }[] = []\n\n walk(dom, (node) => {\n if ((node as Element).name !== 'style') return\n\n const el = node as Element\n const attrs = el.attribs || {}\n\n // Skip marked style tags, but remove the marker attribute first\n const markerAttr = ['raw', 'embed', 'data-embed'].find(attr => attr in attrs)\n if (markerAttr) {\n delete el.attribs[markerAttr]\n return\n }\n\n // Get text content from children and decode HTML entities\n const rawContent = el.children\n .filter(child => child.type === 'text')\n .map(child => (child as any).data)\n .join('')\n\n if (!rawContent.trim()) return\n\n let cssContent = decodeEntities(rawContent)\n\n if (filePath) {\n if (sourceNotPaths.length) {\n const fileDir = dirname(filePath)\n const exclusions = sourceNotPaths\n .map(p => `@source not \"${relative(fileDir, resolve(p))}\";`)\n .join('\\n')\n\n cssContent = `${cssContent}\\n${exclusions}`\n }\n } else {\n // No file path (e.g. component input) — extract classes from the DOM\n // and tell Tailwind to scan them via @source inline()\n const classes: string[] = []\n walk(dom, (n) => {\n const cls = (n as Element).attribs?.class\n if (cls) classes.push(cls)\n })\n\n if (classes.length) {\n cssContent = `${cssContent}\\n@source inline(\"${classes.join(' ')}\");`\n }\n }\n\n styleTags.push({ node: el, cssContent })\n })\n\n for (let i = 0; i < styleTags.length; i++) {\n const { node, cssContent } = styleTags[i]\n try {\n const processor = createProcessor(config)\n const result = await processor.process(\n cssContent,\n {\n from: `${filePath ?? resolve(process.cwd(), 'template.vue')}?style=${i}`,\n parser: safeParser,\n }\n )\n\n const lowered = lowerSyntax(result.css)\n const optimized = await optimizeCss(lowered, config)\n\n // Replace the style tag's children with the compiled CSS\n node.children = [{\n type: 'text',\n data: optimized,\n parent: node,\n } as any]\n } catch {\n // If CSS processing fails, still replace with decoded content\n // so HTML entities don't break the CSS\n node.children = [{\n type: 'text',\n data: cssContent,\n parent: node,\n } as any]\n }\n }\n\n return dom\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,gBAAgB,QAAuB;AAC9C,QAAO,QAAQ;EACb,mBAAmB;GACjB,MAAM,OAAO,KAAK;GAClB,oBAAoB;GACpB,UAAU;GACX,CAAC;EACF,iBAAiB,EACf,UAAU,OACX,CAAC;EACFA,mBAAW;EACZ,CAAC;;;;;;;;;AAUJ,SAAS,eAAe,KAAqB;AAC3C,QAAO,IACJ,QAAQ,WAAW,KAAI,CACvB,QAAQ,UAAU,IAAI,CACtB,QAAQ,SAAS,IAAI,CACrB,QAAQ,SAAS,IAAI,CACrB,QAAQ,UAAU,IAAI,CACtB,QAAQ,WAAW,IAAI;;;;;;;;;AAU5B,SAAS,YAAY,KAAqB;AAUxC,QATe,UAAU;EACvB,UAAU;EACV,MAAM,OAAO,KAAK,IAAI;EACtB,QAAQ;EACR,SAAS,EACP,IAAI,KACL;EACF,CAAC,CAEY,KAAK,UAAU;;;;;;;;AAS/B,eAAe,YAAY,KAAa,QAAwC;CAC9E,MAAM,UAA4B,CAAC,GAAG,gBAAgB,OAAO,CAAC;CAE9D,MAAM,cAAc,kBAAkB,OAAO;AAC7C,KAAI,YAAa,SAAQ,KAAK,YAAY;AAI1C,SAFe,MAAM,QAAQ,QAAQ,CAAC,QAAQ,KAAK,EAAE,MAAM,QAAW,CAAC,EAEzD;;;;;;;;;;;;;;AAehB,eAAsB,YAAY,KAAkB,QAAuB,UAAyC;CAClH,MAAM,iBAAiB,CACrB,QAAQ,OAAO,QAAQ,QAAQ,OAAO,EACtC,IAAI,OAAO,KAAK,WAAW,EAAE,EAAE,KAAI,MAAK,QAAQ,EAAE,CAAC,CACpD;CAED,MAAM,YAAqD,EAAE;AAE7D,MAAK,MAAM,SAAS;AAClB,MAAK,KAAiB,SAAS,QAAS;EAExC,MAAM,KAAK;EACX,MAAM,QAAQ,GAAG,WAAW,EAAE;EAG9B,MAAM,aAAa;GAAC;GAAO;GAAS;GAAa,CAAC,MAAK,SAAQ,QAAQ,MAAM;AAC7E,MAAI,YAAY;AACd,UAAO,GAAG,QAAQ;AAClB;;EAIF,MAAM,aAAa,GAAG,SACnB,QAAO,UAAS,MAAM,SAAS,OAAO,CACtC,KAAI,UAAU,MAAc,KAAK,CACjC,KAAK,GAAG;AAEX,MAAI,CAAC,WAAW,MAAM,CAAE;EAExB,IAAI,aAAa,eAAe,WAAW;AAE3C,MAAI,UACF;OAAI,eAAe,QAAQ;IACzB,MAAM,UAAU,QAAQ,SAAS;IACjC,MAAM,aAAa,eAChB,KAAI,MAAK,gBAAgB,SAAS,SAAS,QAAQ,EAAE,CAAC,CAAC,IAAI,CAC3D,KAAK,KAAK;AAEb,iBAAa,GAAG,WAAW,IAAI;;SAE5B;GAGL,MAAM,UAAoB,EAAE;AAC5B,QAAK,MAAM,MAAM;IACf,MAAM,MAAO,EAAc,SAAS;AACpC,QAAI,IAAK,SAAQ,KAAK,IAAI;KAC1B;AAEF,OAAI,QAAQ,OACV,cAAa,GAAG,WAAW,oBAAoB,QAAQ,KAAK,IAAI,CAAC;;AAIrE,YAAU,KAAK;GAAE,MAAM;GAAI;GAAY,CAAC;GACxC;AAEF,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EACzC,MAAM,EAAE,MAAM,eAAe,UAAU;AACvC,MAAI;AAcF,QAAK,WAAW,CAAC;IACf,MAAM;IACN,MALgB,MAAM,YADR,aARD,MADG,gBAAgB,OAAO,CACV,QAC7B,YACA;KACE,MAAM,GAAG,YAAY,QAAQ,QAAQ,KAAK,EAAE,eAAe,CAAC,SAAS;KACrE,QAAQ;KACT,CACF,EAEkC,IAAI,EACM,OAAO;IAMlD,QAAQ;IACT,CAAQ;UACH;AAGN,QAAK,WAAW,CAAC;IACf,MAAM;IACN,MAAM;IACN,QAAQ;IACT,CAAQ;;;AAIb,QAAO"}
|