@maizzle/framework 6.0.0-9 → 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 -73
- package/CHANGELOG.md +0 -770
- 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 -125
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"base.mjs","names":[],"sources":["../../src/transformers/base.ts"],"sourcesContent":["import postcss from 'postcss'\nimport safeParser from 'postcss-safe-parser'\nimport valueParser from 'postcss-value-parser'\nimport { walk, serialize, parse } from '../utils/ast/index.ts'\nimport { isAbsoluteUrl, defaultTags, processSrcset } from '../utils/url.ts'\nimport type { ChildNode, Element } from 'domhandler'\nimport type { UrlConfig } from '../types/config.ts'\n\ninterface BaseUrlOptions {\n url: string\n tags?: string[] | Record<string, Record<string, string | boolean>>\n attributes?: Record<string, string>\n styleTag?: boolean\n inlineCss?: boolean\n}\n\nconst sourceAttributes = ['src', 'href', 'srcset', 'poster', 'background', 'data']\n\n/**\n * Convert the shared `defaultTags` (tag → string[]) into the richer format\n * the transformer needs (tag → Record<attr, true>).\n */\nconst defaultTagConfig: Record<string, Record<string, string | boolean>> = Object.fromEntries(\n Object.entries(defaultTags).map(([tag, attrs]) => [\n tag,\n Object.fromEntries(attrs.map(attr => [attr, true])),\n ]),\n)\n\nconst postcssBaseUrl: postcss.PluginCreator<{ url: string }> = (opts) => {\n return {\n postcssPlugin: 'postcss-base-url',\n Declaration(decl) {\n if (!decl.value.includes('url(')) return\n\n const parsed = valueParser(decl.value)\n let changed = false\n\n parsed.walk(node => {\n if (node.type !== 'function' || node.value !== 'url') return\n\n const urlNode = node.nodes[0]\n if (!urlNode) return\n\n if (isAbsoluteUrl(urlNode.value)) return\n\n urlNode.value = opts!.url + urlNode.value\n changed = true\n })\n\n if (changed) {\n decl.value = parsed.toString()\n }\n }\n }\n}\npostcssBaseUrl.postcss = true\n\nfunction processCss(css: string, url: string): string {\n const { css: result } = postcss([postcssBaseUrl({ url })]).process(css, { parser: safeParser, from: undefined })\n return result\n}\n\nfunction processInlineStyle(style: string, url: string): string {\n try {\n const { css } = postcss([postcssBaseUrl({ url })]).process(`a{${style}}`, { parser: safeParser, from: undefined })\n const match = css.match(/a\\s*\\{\\s*([\\s\\S]*?)\\s*\\}/)\n return match?.[1]?.trim() ?? style\n } catch {\n return style\n }\n}\n\nfunction getBaseUrl(config: UrlConfig): string | BaseUrlOptions | undefined {\n const baseUrlConfig = config.base\n if (!baseUrlConfig || baseUrlConfig === '') {\n return undefined\n }\n return baseUrlConfig as string | BaseUrlOptions | undefined\n}\n\nfunction resolveOptions(baseUrlConfig: string | BaseUrlOptions | undefined): BaseUrlOptions | undefined {\n if (!baseUrlConfig) return undefined\n if (typeof baseUrlConfig === 'string') {\n return { url: baseUrlConfig, styleTag: true, inlineCss: true }\n }\n if (typeof baseUrlConfig === 'object' && 'url' in baseUrlConfig) {\n return {\n url: baseUrlConfig.url ?? '',\n tags: baseUrlConfig.tags,\n attributes: baseUrlConfig.attributes,\n styleTag: baseUrlConfig.styleTag ?? true,\n inlineCss: baseUrlConfig.inlineCss ?? true,\n }\n }\n return undefined\n}\n\nfunction getTagConfig(\n tagName: string,\n options: BaseUrlOptions\n): Record<string, string | boolean> | undefined {\n const { tags } = options\n\n if (tags === undefined) {\n return defaultTagConfig[tagName]\n }\n\n if (Array.isArray(tags)) {\n if (!tags.includes(tagName)) return undefined\n return defaultTagConfig[tagName]\n }\n\n if (typeof tags === 'object') {\n return tags[tagName]\n }\n\n return undefined\n}\n\nexport function base(dom: ChildNode[], config: UrlConfig = {}): ChildNode[] {\n const baseUrlConfig = getBaseUrl(config)\n const options = resolveOptions(baseUrlConfig)\n\n if (!options || !options.url) {\n return dom\n }\n\n const { url: baseUrl, styleTag = true, inlineCss = true, attributes = {} } = options\n\n walk(dom, (node) => {\n const el = node as Element\n if (!el.name) return\n\n // Process <style> tag content with PostCSS\n if (el.name === 'style' && styleTag && el.children) {\n for (const child of el.children) {\n if (child.type === 'text') {\n const textNode = child as unknown as { data: string }\n const processed = processCss(textNode.data, baseUrl)\n if (processed !== textNode.data) {\n textNode.data = processed\n }\n }\n }\n return\n }\n\n if (!el.attribs) return\n\n // Process tag-specific attributes (respects tags filter)\n const tagConfig = getTagConfig(el.name, options)\n\n if (tagConfig || options.tags === undefined) {\n for (const [attr, value] of Object.entries(el.attribs)) {\n if (!value) continue\n\n const attrConfig = tagConfig?.[attr]\n if (!attrConfig && attr !== 'style') continue\n\n if (attr === 'srcset' && (attrConfig === true || typeof attrConfig === 'string')) {\n const newSrcset = processSrcset(value, typeof attrConfig === 'string' ? attrConfig : baseUrl)\n if (newSrcset !== value) {\n el.attribs.srcset = newSrcset\n }\n } else if (attr === 'style' && inlineCss && value.includes('url(')) {\n const newStyle = processInlineStyle(value, baseUrl)\n if (newStyle !== value) {\n el.attribs.style = newStyle\n }\n } else if (attrConfig === true && !isAbsoluteUrl(value)) {\n el.attribs[attr] = baseUrl + value\n } else if (typeof attrConfig === 'string' && !isAbsoluteUrl(value)) {\n el.attribs[attr] = attrConfig + value\n }\n }\n }\n\n // Process custom attributes (not affected by tags filter)\n for (const [attr, url] of Object.entries(attributes)) {\n if (el.attribs[attr] && !isAbsoluteUrl(el.attribs[attr])) {\n el.attribs[attr] = url + el.attribs[attr]\n }\n }\n })\n\n // VML and MSO comment rewrites require operating on serialized HTML\n // (HTML comments are not represented as traversable DOM nodes)\n const serialized = serialize(dom)\n const rewritten = rewriteMsoComments(rewriteVMLs(serialized, baseUrl), baseUrl)\n\n // Only re-parse if the regex passes actually changed anything\n if (rewritten !== serialized) {\n return parse(rewritten)\n }\n\n return dom\n}\n\nfunction rewriteVMLs(html: string, url: string): string {\n html = html.replace(/<v:image[^>]+src=\"?([^\"\\s]+)\"/gi, (match, src) => {\n if (isAbsoluteUrl(src)) return match\n return match.replace(src, url + src)\n })\n\n html = html.replace(/<v:fill[^>]+src=\"?([^\"\\s]+)\"/gi, (match, src) => {\n if (isAbsoluteUrl(src)) return match\n return match.replace(src, url + src)\n })\n\n return html\n}\n\nfunction rewriteMsoComments(html: string, url: string): string {\n return html.replace(/<!--\\[if [^\\]]+\\]>[\\s\\S]*?<!\\[endif\\]-->/g, (msoBlock) => {\n let result = msoBlock\n\n for (const attr of sourceAttributes) {\n const attrRegex = new RegExp(`\\\\b${attr}=\"([^\"]+)\"`, 'gi')\n result = result.replace(attrRegex, (match, value) => {\n if (isAbsoluteUrl(value)) return match\n\n if (attr === 'srcset') {\n return `srcset=\"${processSrcset(value, url)}\"`\n }\n\n return `${attr}=\"${url}${value}\"`\n })\n }\n\n // Use PostCSS for style attribute url() rewriting inside MSO comments\n result = result.replace(/style=\"([^\"]+)\"/gi, (match, style) => {\n if (!style.includes('url(')) return match\n const processed = processInlineStyle(style, url)\n return `style=\"${processed}\"`\n })\n\n return result\n })\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EntitiesConfig } from "../types/config.mjs";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/entities.d.ts
|
|
5
|
+
declare function entities(dom: ChildNode[], config?: EntitiesConfig): ChildNode[];
|
|
6
|
+
//#endregion
|
|
7
|
+
export { entities };
|
|
8
|
+
//# sourceMappingURL=entities.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.mts","names":[],"sources":["../../src/transformers/entities.ts"],"mappings":";;;;iBA2BgB,QAAA,CAAS,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,cAAA,GAAwB,SAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.mjs";
|
|
2
|
+
import "../utils/ast/index.mjs";
|
|
3
|
+
import { defu } from "defu";
|
|
4
|
+
|
|
5
|
+
//#region src/transformers/entities.ts
|
|
6
|
+
const DEFAULT_ENTITIES = {
|
|
7
|
+
"": "‍",
|
|
8
|
+
"": "‌",
|
|
9
|
+
"\xA0": " ",
|
|
10
|
+
"": "​",
|
|
11
|
+
" ": " ",
|
|
12
|
+
"\u2028": "&LineSeparator;",
|
|
13
|
+
"\u2029": "&ParagraphSeparator;",
|
|
14
|
+
"·": "·",
|
|
15
|
+
"–": "–",
|
|
16
|
+
"—": "—",
|
|
17
|
+
"‘": "‘",
|
|
18
|
+
"’": "’",
|
|
19
|
+
"“": "“",
|
|
20
|
+
"”": "”",
|
|
21
|
+
"«": "«",
|
|
22
|
+
"»": "»",
|
|
23
|
+
"•": "•",
|
|
24
|
+
"‹": "‹",
|
|
25
|
+
"›": "›"
|
|
26
|
+
};
|
|
27
|
+
function entities(dom, config = true) {
|
|
28
|
+
if (!config) return dom;
|
|
29
|
+
const map = typeof config === "object" ? defu(config, DEFAULT_ENTITIES) : DEFAULT_ENTITIES;
|
|
30
|
+
walk(dom, (node) => {
|
|
31
|
+
if (node.type === "text") for (const [char, entity] of Object.entries(map)) node.data = node.data.split(char).join(entity);
|
|
32
|
+
});
|
|
33
|
+
return dom;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { entities };
|
|
38
|
+
//# sourceMappingURL=entities.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.mjs","names":["merge"],"sources":["../../src/transformers/entities.ts"],"sourcesContent":["import { defu as merge } from 'defu'\nimport { walk } from '../utils/ast/index.ts'\nimport type { ChildNode } from 'domhandler'\nimport type { EntitiesConfig } from '../types/index.ts'\n\nconst DEFAULT_ENTITIES: Record<string, string> = {\n '\\u200D': '‍',\n '\\u200C': '‌',\n '\\u00A0': ' ',\n '\\u200B': '​',\n '\\u2003': ' ',\n '\\u2028': '&LineSeparator;',\n '\\u2029': '&ParagraphSeparator;',\n '\\u00B7': '·',\n '\\u2013': '–',\n '\\u2014': '—',\n '\\u2018': '‘',\n '\\u2019': '’',\n '\\u201C': '“',\n '\\u201D': '”',\n '\\u00AB': '«',\n '\\u00BB': '»',\n '\\u2022': '•',\n '\\u2039': '‹',\n '\\u203A': '›'\n}\n\nexport function entities(dom: ChildNode[], config: EntitiesConfig = true): ChildNode[] {\n if (!config) return dom\n\n const map = typeof config === 'object'\n ? merge(config as Record<string, string>, DEFAULT_ENTITIES)\n : DEFAULT_ENTITIES\n\n walk(dom, (node) => {\n if (node.type === 'text') {\n for (const [char, entity] of Object.entries(map)) {\n node.data = node.data.split(char).join(entity)\n }\n }\n })\n\n return dom\n}\n"],"mappings":";;;;;AAKA,MAAM,mBAA2C;CAC/C,KAAU;CACV,KAAU;CACV,QAAU;CACV,KAAU;CACV,KAAU;CACV,UAAU;CACV,UAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACV,KAAU;CACX;AAED,SAAgB,SAAS,KAAkB,SAAyB,MAAmB;AACrF,KAAI,CAAC,OAAQ,QAAO;CAEpB,MAAM,MAAM,OAAO,WAAW,WAC1BA,KAAM,QAAkC,iBAAiB,GACzD;AAEJ,MAAK,MAAM,SAAS;AAClB,MAAI,KAAK,SAAS,OAChB,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,IAAI,CAC9C,MAAK,OAAO,KAAK,KAAK,MAAM,KAAK,CAAC,KAAK,OAAO;GAGlD;AAEF,QAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MaizzleConfig } from "../types/config.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/format.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Format transformer.
|
|
6
|
+
*
|
|
7
|
+
* Formats the HTML string using `oxfmt`. Accepts all oxfmt `FormatOptions`.
|
|
8
|
+
*
|
|
9
|
+
* Enable by setting `html.format: true` (or passing options).
|
|
10
|
+
* User options are merged on top of the defaults.
|
|
11
|
+
*/
|
|
12
|
+
declare function format(html: string, config?: MaizzleConfig): Promise<string>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { format };
|
|
15
|
+
//# sourceMappingURL=format.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.mts","names":[],"sources":["../../src/transformers/format.ts"],"mappings":";;;;;AAmBA;;;;;;iBAAsB,MAAA,CAAO,IAAA,UAAc,MAAA,GAAQ,aAAA,GAAqB,OAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defu } from "defu";
|
|
2
|
+
import { format as format$1 } from "oxfmt";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/format.ts
|
|
5
|
+
const DEFAULT_OPTIONS = {
|
|
6
|
+
printWidth: 320,
|
|
7
|
+
htmlWhitespaceSensitivity: "ignore",
|
|
8
|
+
embeddedLanguageFormatting: "off"
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Format transformer.
|
|
12
|
+
*
|
|
13
|
+
* Formats the HTML string using `oxfmt`. Accepts all oxfmt `FormatOptions`.
|
|
14
|
+
*
|
|
15
|
+
* Enable by setting `html.format: true` (or passing options).
|
|
16
|
+
* User options are merged on top of the defaults.
|
|
17
|
+
*/
|
|
18
|
+
async function format(html, config = {}) {
|
|
19
|
+
const option = config.html?.format;
|
|
20
|
+
if (!option) return html;
|
|
21
|
+
return (await format$1("input.html", html, defu(typeof option === "object" ? option : {}, DEFAULT_OPTIONS))).code;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { format };
|
|
26
|
+
//# sourceMappingURL=format.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.mjs","names":["oxfmt","merge"],"sources":["../../src/transformers/format.ts"],"sourcesContent":["import { format as oxfmt } from 'oxfmt'\nimport { defu as merge } from 'defu'\nimport type { FormatOptions } from 'oxfmt'\nimport type { MaizzleConfig } from '../types/config.ts'\n\nconst DEFAULT_OPTIONS: FormatOptions = {\n printWidth: 320,\n htmlWhitespaceSensitivity: 'ignore',\n embeddedLanguageFormatting: 'off',\n}\n\n/**\n * Format transformer.\n *\n * Formats the HTML string using `oxfmt`. Accepts all oxfmt `FormatOptions`.\n *\n * Enable by setting `html.format: true` (or passing options).\n * User options are merged on top of the defaults.\n */\nexport async function format(html: string, config: MaizzleConfig = {}): Promise<string> {\n const option = config.html?.format\n\n if (!option) return html\n\n const userOptions: FormatOptions = typeof option === 'object' ? option : {}\n const options = merge(userOptions, DEFAULT_OPTIONS)\n\n const result = await oxfmt('input.html', html, options)\n\n return result.code\n}\n"],"mappings":";;;;AAKA,MAAM,kBAAiC;CACrC,YAAY;CACZ,2BAA2B;CAC3B,4BAA4B;CAC7B;;;;;;;;;AAUD,eAAsB,OAAO,MAAc,SAAwB,EAAE,EAAmB;CACtF,MAAM,SAAS,OAAO,MAAM;AAE5B,KAAI,CAAC,OAAQ,QAAO;AAOpB,SAFe,MAAMA,SAAM,cAAc,MAFzBC,KADmB,OAAO,WAAW,WAAW,SAAS,EAAE,EACxC,gBAAgB,CAEI,EAEzC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MaizzleConfig } from "../types/config.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Run all Maizzle transformers on the rendered HTML.
|
|
6
|
+
*
|
|
7
|
+
* The HTML is parsed into a DOM once at the start and passed through all
|
|
8
|
+
* DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers
|
|
9
|
+
* complete, the DOM is serialized back to a string exactly once.
|
|
10
|
+
*
|
|
11
|
+
* String-only transformers (those that rely on external tools that require a
|
|
12
|
+
* raw HTML string) then run on the serialized output.
|
|
13
|
+
*
|
|
14
|
+
* Transformers run in a specific order:
|
|
15
|
+
* 0. Inline link stylesheets — replace `<link rel="stylesheet">` with `<style>` tags
|
|
16
|
+
* 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)
|
|
17
|
+
* 2. Safe class names
|
|
18
|
+
* 3. Attribute to style
|
|
19
|
+
* 4. CSS inliner
|
|
20
|
+
* 5. Remove attributes
|
|
21
|
+
* 6. Shorthand CSS
|
|
22
|
+
* 7. Add attributes
|
|
23
|
+
* 8. Base URL
|
|
24
|
+
* 9. URL query
|
|
25
|
+
* 10. Purge CSS (serializes/parses internally around email-comb)
|
|
26
|
+
* 11. Entities
|
|
27
|
+
* + Vue-generated comments stripped here (on serialized string)
|
|
28
|
+
* 12. Replace strings
|
|
29
|
+
* 13. Prettify
|
|
30
|
+
* 14. Minify
|
|
31
|
+
*/
|
|
32
|
+
declare function runTransformers(html: string, config: MaizzleConfig, filePath?: string): Promise<string>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { runTransformers };
|
|
35
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/transformers/index.ts"],"mappings":";;;;;AA8CA;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsB,eAAA,CACpB,IAAA,UACA,MAAA,EAAQ,aAAA,EACR,QAAA,YACC,OAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { parse } from "../utils/ast/parser.mjs";
|
|
2
|
+
import { serialize } from "../utils/ast/serializer.mjs";
|
|
3
|
+
import "../utils/ast/index.mjs";
|
|
4
|
+
import { inlineLink } from "./inlineLink.mjs";
|
|
5
|
+
import { tailwindcss } from "./tailwindcss.mjs";
|
|
6
|
+
import { safeClassNames } from "./safeClassNames.mjs";
|
|
7
|
+
import { attributeToStyle } from "./attributeToStyle.mjs";
|
|
8
|
+
import { inlineCSS } from "./inlineCSS.mjs";
|
|
9
|
+
import { removeAttributes } from "./removeAttributes.mjs";
|
|
10
|
+
import { shorthandCSS } from "./shorthandCSS.mjs";
|
|
11
|
+
import { addAttributes } from "./addAttributes.mjs";
|
|
12
|
+
import { base } from "./base.mjs";
|
|
13
|
+
import { entities } from "./entities.mjs";
|
|
14
|
+
import { urlQuery } from "./urlQuery.mjs";
|
|
15
|
+
import { purgeCSS } from "./purgeCSS.mjs";
|
|
16
|
+
import { replaceStrings } from "./replaceStrings.mjs";
|
|
17
|
+
import { format } from "./format.mjs";
|
|
18
|
+
import { minify } from "./minify.mjs";
|
|
19
|
+
|
|
20
|
+
//#region src/transformers/index.ts
|
|
21
|
+
/**
|
|
22
|
+
* Run all Maizzle transformers on the rendered HTML.
|
|
23
|
+
*
|
|
24
|
+
* The HTML is parsed into a DOM once at the start and passed through all
|
|
25
|
+
* DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers
|
|
26
|
+
* complete, the DOM is serialized back to a string exactly once.
|
|
27
|
+
*
|
|
28
|
+
* String-only transformers (those that rely on external tools that require a
|
|
29
|
+
* raw HTML string) then run on the serialized output.
|
|
30
|
+
*
|
|
31
|
+
* Transformers run in a specific order:
|
|
32
|
+
* 0. Inline link stylesheets — replace `<link rel="stylesheet">` with `<style>` tags
|
|
33
|
+
* 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)
|
|
34
|
+
* 2. Safe class names
|
|
35
|
+
* 3. Attribute to style
|
|
36
|
+
* 4. CSS inliner
|
|
37
|
+
* 5. Remove attributes
|
|
38
|
+
* 6. Shorthand CSS
|
|
39
|
+
* 7. Add attributes
|
|
40
|
+
* 8. Base URL
|
|
41
|
+
* 9. URL query
|
|
42
|
+
* 10. Purge CSS (serializes/parses internally around email-comb)
|
|
43
|
+
* 11. Entities
|
|
44
|
+
* + Vue-generated comments stripped here (on serialized string)
|
|
45
|
+
* 12. Replace strings
|
|
46
|
+
* 13. Prettify
|
|
47
|
+
* 14. Minify
|
|
48
|
+
*/
|
|
49
|
+
async function runTransformers(html, config, filePath) {
|
|
50
|
+
let dom = parse(html);
|
|
51
|
+
dom = await inlineLink(dom, filePath);
|
|
52
|
+
dom = await tailwindcss(dom, config, filePath);
|
|
53
|
+
dom = safeClassNames(dom, config.css);
|
|
54
|
+
dom = attributeToStyle(dom, config.css);
|
|
55
|
+
dom = inlineCSS(dom, config.css);
|
|
56
|
+
dom = removeAttributes(dom, config.html?.attributes);
|
|
57
|
+
dom = shorthandCSS(dom, config.css);
|
|
58
|
+
dom = addAttributes(dom, config.html?.attributes);
|
|
59
|
+
dom = base(dom, config.url);
|
|
60
|
+
dom = urlQuery(dom, config.url);
|
|
61
|
+
dom = purgeCSS(dom, config.css);
|
|
62
|
+
dom = entities(dom, config.html?.decodeEntities);
|
|
63
|
+
let result = serialize(dom);
|
|
64
|
+
result = result.replaceAll("<!--[-->", "").replaceAll("<!--]-->", "");
|
|
65
|
+
result = replaceStrings(result, config);
|
|
66
|
+
result = await format(result, config);
|
|
67
|
+
result = minify(result, config);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { runTransformers };
|
|
73
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/transformers/index.ts"],"sourcesContent":["import { parse, serialize } from '../utils/ast/index.ts'\nimport { inlineLink } from './inlineLink.ts'\nimport { tailwindcss } from './tailwindcss.ts'\nimport { safeClassNames } from './safeClassNames.ts'\nimport { attributeToStyle } from './attributeToStyle.ts'\nimport { inlineCSS } from './inlineCSS.ts'\nimport { removeAttributes } from './removeAttributes.ts'\nimport { shorthandCSS } from './shorthandCSS.ts'\nimport { addAttributes } from './addAttributes.ts'\nimport { base } from './base.ts'\nimport { entities } from './entities.ts'\nimport { urlQuery } from './urlQuery.ts'\nimport { purgeCSS } from './purgeCSS.ts'\nimport { replaceStrings } from './replaceStrings.ts'\nimport { format } from './format.ts'\nimport { minify } from './minify.ts'\nimport type { MaizzleConfig } from '../types/config.ts'\n\n/**\n * Run all Maizzle transformers on the rendered HTML.\n *\n * The HTML is parsed into a DOM once at the start and passed through all\n * DOM-based transformers as a shared `ChildNode[]`. After all DOM transformers\n * complete, the DOM is serialized back to a string exactly once.\n *\n * String-only transformers (those that rely on external tools that require a\n * raw HTML string) then run on the serialized output.\n *\n * Transformers run in a specific order:\n * 0. Inline link stylesheets — replace `<link rel=\"stylesheet\">` with `<style>` tags\n * 1. Tailwind CSS — compile CSS, lower syntax, optimize (cleanup + merge media queries)\n * 2. Safe class names\n * 3. Attribute to style\n * 4. CSS inliner\n * 5. Remove attributes\n * 6. Shorthand CSS\n * 7. Add attributes\n * 8. Base URL\n * 9. URL query\n * 10. Purge CSS (serializes/parses internally around email-comb)\n * 11. Entities\n * + Vue-generated comments stripped here (on serialized string)\n * 12. Replace strings\n * 13. Prettify\n * 14. Minify\n */\nexport async function runTransformers(\n html: string,\n config: MaizzleConfig,\n filePath?: string,\n): Promise<string> {\n // Parse once — all DOM transformers share this array\n let dom = parse(html)\n\n // 0. Inline <link> stylesheets\n dom = await inlineLink(dom, filePath)\n\n // 1. Tailwind CSS — always runs first\n dom = await tailwindcss(dom, config, filePath)\n\n // 2. Safe class names\n dom = safeClassNames(dom, config.css)\n\n // 3. Attribute to style\n dom = attributeToStyle(dom, config.css)\n\n // 4. CSS inliner (serializes/parses internally around juice)\n dom = inlineCSS(dom, config.css)\n\n // 5. Remove attributes\n dom = removeAttributes(dom, config.html?.attributes)\n\n // 6. Shorthand CSS\n dom = shorthandCSS(dom, config.css)\n\n // 7. Add attributes\n dom = addAttributes(dom, config.html?.attributes)\n\n // 8. Base URL (serializes/parses internally for VML/MSO regex passes)\n dom = base(dom, config.url)\n\n // 9. URL query\n dom = urlQuery(dom, config.url)\n\n // 10. Purge CSS (serializes/parses internally around email-comb)\n dom = purgeCSS(dom, config.css)\n\n // 11. Entities\n dom = entities(dom, config.html?.decodeEntities)\n\n // Serialize once — remaining transformers operate on the HTML string\n let result = serialize(dom)\n\n // Remove Vue-generated comments after serializing\n result = result\n .replaceAll('<!--[-->', '')\n .replaceAll('<!--]-->', '')\n\n // 12. Replace strings\n result = replaceStrings(result, config)\n\n // 13. Format\n result = await format(result, config)\n\n // 14. Minify\n result = minify(result, config)\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,eAAsB,gBACpB,MACA,QACA,UACiB;CAEjB,IAAI,MAAM,MAAM,KAAK;AAGrB,OAAM,MAAM,WAAW,KAAK,SAAS;AAGrC,OAAM,MAAM,YAAY,KAAK,QAAQ,SAAS;AAG9C,OAAM,eAAe,KAAK,OAAO,IAAI;AAGrC,OAAM,iBAAiB,KAAK,OAAO,IAAI;AAGvC,OAAM,UAAU,KAAK,OAAO,IAAI;AAGhC,OAAM,iBAAiB,KAAK,OAAO,MAAM,WAAW;AAGpD,OAAM,aAAa,KAAK,OAAO,IAAI;AAGnC,OAAM,cAAc,KAAK,OAAO,MAAM,WAAW;AAGjD,OAAM,KAAK,KAAK,OAAO,IAAI;AAG3B,OAAM,SAAS,KAAK,OAAO,IAAI;AAG/B,OAAM,SAAS,KAAK,OAAO,IAAI;AAG/B,OAAM,SAAS,KAAK,OAAO,MAAM,eAAe;CAGhD,IAAI,SAAS,UAAU,IAAI;AAG3B,UAAS,OACN,WAAW,YAAY,GAAG,CAC1B,WAAW,YAAY,GAAG;AAG7B,UAAS,eAAe,QAAQ,OAAO;AAGvC,UAAS,MAAM,OAAO,QAAQ,OAAO;AAGrC,UAAS,OAAO,QAAQ,OAAO;AAE/B,QAAO"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CssConfig } from "../types/config.mjs";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/inlineCSS.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Inline CSS transformer.
|
|
7
|
+
*
|
|
8
|
+
* Inlines CSS from `<style>` tags into inline style attributes on HTML elements.
|
|
9
|
+
* This is important for email client compatibility (especially Outlook on Windows).
|
|
10
|
+
*
|
|
11
|
+
* Enabled when `css.inline` is set to `true` or an object with options.
|
|
12
|
+
*
|
|
13
|
+
* Options:
|
|
14
|
+
* - removeStyleTags: Remove style tags after inlining (default: false)
|
|
15
|
+
* - removeInlinedSelectors: Remove classes after they've been inlined (default: true)
|
|
16
|
+
* - preferUnitlessValues: Convert 0px, 0em, etc. to 0 (default: true)
|
|
17
|
+
* - safelist: Selectors that should not be removed after inlining
|
|
18
|
+
* - styleToAttribute: Map CSS properties to HTML attributes (e.g., background-color -> bgcolor)
|
|
19
|
+
* - applyWidthAttributes: Add width attributes based on inline CSS (default: true)
|
|
20
|
+
* - applyHeightAttributes: Add height attributes based on inline CSS (default: true)
|
|
21
|
+
* - widthElements: Elements that can receive width attributes (default: ['img', 'video'])
|
|
22
|
+
* - heightElements: Elements that can receive height attributes (default: ['img', 'video'])
|
|
23
|
+
* - excludedProperties: CSS properties to exclude from inlining
|
|
24
|
+
* - codeBlocks: Fenced code blocks to ignore (default: { EJS: { start: '<%', end: '%>' }, HBS: { start: '{{', end: '}}' } })
|
|
25
|
+
* - customCSS: Additional CSS to inline
|
|
26
|
+
*/
|
|
27
|
+
declare function inlineCSS(dom: ChildNode[], config?: CssConfig): ChildNode[];
|
|
28
|
+
//#endregion
|
|
29
|
+
export { inlineCSS };
|
|
30
|
+
//# sourceMappingURL=inlineCSS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineCSS.d.mts","names":[],"sources":["../../src/transformers/inlineCSS.ts"],"mappings":";;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;iBAAgB,SAAA,CAAU,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,SAAA,GAAiB,SAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { parse } from "../utils/ast/parser.mjs";
|
|
2
|
+
import { walk } from "../utils/ast/walker.mjs";
|
|
3
|
+
import { serialize } from "../utils/ast/serializer.mjs";
|
|
4
|
+
import "../utils/ast/index.mjs";
|
|
5
|
+
import juice from "juice";
|
|
6
|
+
|
|
7
|
+
//#region src/transformers/inlineCSS.ts
|
|
8
|
+
/**
|
|
9
|
+
* Inline CSS transformer.
|
|
10
|
+
*
|
|
11
|
+
* Inlines CSS from `<style>` tags into inline style attributes on HTML elements.
|
|
12
|
+
* This is important for email client compatibility (especially Outlook on Windows).
|
|
13
|
+
*
|
|
14
|
+
* Enabled when `css.inline` is set to `true` or an object with options.
|
|
15
|
+
*
|
|
16
|
+
* Options:
|
|
17
|
+
* - removeStyleTags: Remove style tags after inlining (default: false)
|
|
18
|
+
* - removeInlinedSelectors: Remove classes after they've been inlined (default: true)
|
|
19
|
+
* - preferUnitlessValues: Convert 0px, 0em, etc. to 0 (default: true)
|
|
20
|
+
* - safelist: Selectors that should not be removed after inlining
|
|
21
|
+
* - styleToAttribute: Map CSS properties to HTML attributes (e.g., background-color -> bgcolor)
|
|
22
|
+
* - applyWidthAttributes: Add width attributes based on inline CSS (default: true)
|
|
23
|
+
* - applyHeightAttributes: Add height attributes based on inline CSS (default: true)
|
|
24
|
+
* - widthElements: Elements that can receive width attributes (default: ['img', 'video'])
|
|
25
|
+
* - heightElements: Elements that can receive height attributes (default: ['img', 'video'])
|
|
26
|
+
* - excludedProperties: CSS properties to exclude from inlining
|
|
27
|
+
* - codeBlocks: Fenced code blocks to ignore (default: { EJS: { start: '<%', end: '%>' }, HBS: { start: '{{', end: '}}' } })
|
|
28
|
+
* - customCSS: Additional CSS to inline
|
|
29
|
+
*/
|
|
30
|
+
function inlineCSS(dom, config = {}) {
|
|
31
|
+
const inline = config.inline;
|
|
32
|
+
if (!inline) return dom;
|
|
33
|
+
const options = typeof inline === "object" ? inline : {};
|
|
34
|
+
const removeStyleTags = options.removeStyleTags ?? false;
|
|
35
|
+
const customCSS = options.customCSS ?? "";
|
|
36
|
+
juice.styleToAttribute = options.styleToAttribute ?? {};
|
|
37
|
+
juice.excludedProperties = ["--tw-shadow", ...options.excludedProperties ?? []];
|
|
38
|
+
juice.widthElements = (options.widthElements ?? ["img", "video"]).map((i) => i.toUpperCase());
|
|
39
|
+
juice.heightElements = (options.heightElements ?? ["img", "video"]).map((i) => i.toUpperCase());
|
|
40
|
+
if (options.codeBlocks && typeof options.codeBlocks === "object") Object.entries(options.codeBlocks).forEach(([key, value]) => {
|
|
41
|
+
if (value.start && value.end) juice.codeBlocks[key] = value;
|
|
42
|
+
});
|
|
43
|
+
walk(dom, (node) => {
|
|
44
|
+
const el = node;
|
|
45
|
+
if (el.name === "style" && el.attribs) {
|
|
46
|
+
if (el.attribs.embed && !("data-embed" in el.attribs)) el.attribs["data-embed"] = "";
|
|
47
|
+
if (el.attribs["data-embed"] && !("embed" in el.attribs)) el.attribs.embed = "";
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const serialized = serialize(dom);
|
|
51
|
+
let inlinedHtml;
|
|
52
|
+
try {
|
|
53
|
+
const juiceOptions = {
|
|
54
|
+
removeStyleTags,
|
|
55
|
+
removeInlinedSelectors: options.removeInlinedSelectors ?? true,
|
|
56
|
+
preservedSelectors: options.safelist ?? [],
|
|
57
|
+
applyWidthAttributes: options.applyWidthAttributes ?? true,
|
|
58
|
+
applyHeightAttributes: options.applyHeightAttributes ?? true
|
|
59
|
+
};
|
|
60
|
+
if (customCSS) inlinedHtml = juice(serialized, {
|
|
61
|
+
...juiceOptions,
|
|
62
|
+
extraCss: customCSS
|
|
63
|
+
});
|
|
64
|
+
else inlinedHtml = juice(serialized, juiceOptions);
|
|
65
|
+
} catch {
|
|
66
|
+
return dom;
|
|
67
|
+
}
|
|
68
|
+
const preferUnitlessValues = options.preferUnitlessValues ?? true;
|
|
69
|
+
const result = parse(inlinedHtml);
|
|
70
|
+
if (preferUnitlessValues) walk(result, (node) => {
|
|
71
|
+
const el = node;
|
|
72
|
+
if (el.attribs?.style) el.attribs.style = el.attribs.style.replace(/\b0(px|rem|em|%|vh|vw|vmin|vmax|in|cm|mm|pt|pc|ex|ch)\b/g, "0");
|
|
73
|
+
});
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
export { inlineCSS };
|
|
79
|
+
//# sourceMappingURL=inlineCSS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineCSS.mjs","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'\nimport type { CssConfig } from '../types/config.ts'\n\ninterface InlineCssOptions {\n removeStyleTags?: boolean\n removeInlinedSelectors?: boolean\n preferUnitlessValues?: boolean\n safelist?: string[]\n styleToAttribute?: Record<string, string>\n applyWidthAttributes?: boolean\n applyHeightAttributes?: boolean\n widthElements?: string[]\n heightElements?: string[]\n excludedProperties?: string[]\n codeBlocks?: Record<string, { start: string; end: string }>\n customCSS?: string\n}\n\n/**\n * Inline CSS transformer.\n *\n * Inlines CSS from `<style>` tags into inline style attributes on HTML elements.\n * This is important for email client compatibility (especially Outlook on Windows).\n *\n * Enabled when `css.inline` is set to `true` or an object with options.\n *\n * Options:\n * - removeStyleTags: Remove style tags after inlining (default: false)\n * - removeInlinedSelectors: Remove classes after they've been inlined (default: true)\n * - preferUnitlessValues: Convert 0px, 0em, etc. to 0 (default: true)\n * - safelist: Selectors that should not be removed after inlining\n * - styleToAttribute: Map CSS properties to HTML attributes (e.g., background-color -> bgcolor)\n * - applyWidthAttributes: Add width attributes based on inline CSS (default: true)\n * - applyHeightAttributes: Add height attributes based on inline CSS (default: true)\n * - widthElements: Elements that can receive width attributes (default: ['img', 'video'])\n * - heightElements: Elements that can receive height attributes (default: ['img', 'video'])\n * - excludedProperties: CSS properties to exclude from inlining\n * - codeBlocks: Fenced code blocks to ignore (default: { EJS: { start: '<%', end: '%>' }, HBS: { start: '{{', end: '}}' } })\n * - customCSS: Additional CSS to inline\n */\nexport function inlineCSS(dom: ChildNode[], config: CssConfig = {}): ChildNode[] {\n const inline = config.inline\n\n // Disabled when inline is falsy or not an object/truthy\n if (!inline) {\n return dom\n }\n\n // Build options from config\n const options: InlineCssOptions = typeof inline === 'object' ? inline : {}\n\n const removeStyleTags = options.removeStyleTags ?? false\n const customCSS = options.customCSS ?? ''\n\n // Configure Juice static properties\n juice.styleToAttribute = options.styleToAttribute ?? {}\n juice.excludedProperties = ['--tw-shadow', ...(options.excludedProperties ?? [])]\n juice.widthElements = (options.widthElements ?? ['img', 'video']).map(i => i.toUpperCase()) as unknown as HTMLElement[]\n juice.heightElements = (options.heightElements ?? ['img', 'video']).map(i => i.toUpperCase()) as unknown as HTMLElement[]\n\n // Add custom code blocks\n if (options.codeBlocks && typeof options.codeBlocks === 'object') {\n Object.entries(options.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 walk(dom, (node) => {\n const el = node as Element\n if (el.name === 'style' && el.attribs) {\n // Add data-embed to style tags with embed attribute\n if (el.attribs.embed && !('data-embed' in el.attribs)) {\n el.attribs['data-embed'] = ''\n }\n // Add embed to style tags with data-embed attribute\n if (el.attribs['data-embed'] && !('embed' in el.attribs)) {\n el.attribs.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,\n removeInlinedSelectors: options.removeInlinedSelectors ?? true,\n preservedSelectors: options.safelist ?? [],\n applyWidthAttributes: options.applyWidthAttributes ?? true,\n applyHeightAttributes: options.applyHeightAttributes ?? true,\n }\n\n if (customCSS) {\n inlinedHtml = juice(serialized, { ...juiceOptions, extraCss: customCSS })\n } else {\n inlinedHtml = juice(serialized, juiceOptions)\n }\n } catch {\n // If Juice fails, return the dom unchanged\n return dom\n }\n\n // Post-process for preferUnitlessValues\n const preferUnitlessValues = options.preferUnitlessValues ?? true\n const result = parse(inlinedHtml)\n\n if (preferUnitlessValues) {\n walk(result, (node) => {\n const el = node as Element\n if (el.attribs?.style) {\n el.attribs.style = el.attribs.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 }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,UAAU,KAAkB,SAAoB,EAAE,EAAe;CAC/E,MAAM,SAAS,OAAO;AAGtB,KAAI,CAAC,OACH,QAAO;CAIT,MAAM,UAA4B,OAAO,WAAW,WAAW,SAAS,EAAE;CAE1E,MAAM,kBAAkB,QAAQ,mBAAmB;CACnD,MAAM,YAAY,QAAQ,aAAa;AAGvC,OAAM,mBAAmB,QAAQ,oBAAoB,EAAE;AACvD,OAAM,qBAAqB,CAAC,eAAe,GAAI,QAAQ,sBAAsB,EAAE,CAAE;AACjF,OAAM,iBAAiB,QAAQ,iBAAiB,CAAC,OAAO,QAAQ,EAAE,KAAI,MAAK,EAAE,aAAa,CAAC;AAC3F,OAAM,kBAAkB,QAAQ,kBAAkB,CAAC,OAAO,QAAQ,EAAE,KAAI,MAAK,EAAE,aAAa,CAAC;AAG7F,KAAI,QAAQ,cAAc,OAAO,QAAQ,eAAe,SACtD,QAAO,QAAQ,QAAQ,WAAW,CAAC,SAAS,CAAC,KAAK,WAAW;AAC3D,MAAI,MAAM,SAAS,MAAM,IACvB,OAAM,WAAW,OAAO;GAE1B;AAIJ,MAAK,MAAM,SAAS;EAClB,MAAM,KAAK;AACX,MAAI,GAAG,SAAS,WAAW,GAAG,SAAS;AAErC,OAAI,GAAG,QAAQ,SAAS,EAAE,gBAAgB,GAAG,SAC3C,IAAG,QAAQ,gBAAgB;AAG7B,OAAI,GAAG,QAAQ,iBAAiB,EAAE,WAAW,GAAG,SAC9C,IAAG,QAAQ,QAAQ;;GAGvB;CAGF,MAAM,aAAa,UAAU,IAAI;CAEjC,IAAI;AAEJ,KAAI;EACF,MAAM,eAA6B;GACjC;GACA,wBAAwB,QAAQ,0BAA0B;GAC1D,oBAAoB,QAAQ,YAAY,EAAE;GAC1C,sBAAsB,QAAQ,wBAAwB;GACtD,uBAAuB,QAAQ,yBAAyB;GACzD;AAED,MAAI,UACF,eAAc,MAAM,YAAY;GAAE,GAAG;GAAc,UAAU;GAAW,CAAC;MAEzE,eAAc,MAAM,YAAY,aAAa;SAEzC;AAEN,SAAO;;CAIT,MAAM,uBAAuB,QAAQ,wBAAwB;CAC7D,MAAM,SAAS,MAAM,YAAY;AAEjC,KAAI,qBACF,MAAK,SAAS,SAAS;EACrB,MAAM,KAAK;AACX,MAAI,GAAG,SAAS,MACd,IAAG,QAAQ,QAAQ,GAAG,QAAQ,MAAM,QAClC,4DACA,IACD;GAEH;AAGJ,QAAO"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 always inlined (resolved relative to the template)
|
|
8
|
+
* - Remote URLs (http/https) are only inlined if the `inline` attribute is present
|
|
9
|
+
* - Runs before the tailwindcss transformer so CSS is compiled normally
|
|
10
|
+
*/
|
|
11
|
+
declare function inlineLink(dom: ChildNode[], filePath?: string): Promise<ChildNode[]>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { inlineLink };
|
|
14
|
+
//# sourceMappingURL=inlineLink.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineLink.d.mts","names":[],"sources":["../../src/transformers/inlineLink.ts"],"mappings":";;;;;AAYA;;;;;iBAAsB,UAAA,CAAW,GAAA,EAAK,SAAA,IAAa,QAAA,YAAoB,OAAA,CAAQ,SAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.mjs";
|
|
2
|
+
import "../utils/ast/index.mjs";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
//#region src/transformers/inlineLink.ts
|
|
7
|
+
/**
|
|
8
|
+
* Inline `<link rel="stylesheet">` tags as `<style>` tags.
|
|
9
|
+
*
|
|
10
|
+
* - Local file paths are always inlined (resolved relative to the template)
|
|
11
|
+
* - Remote URLs (http/https) are only inlined if the `inline` attribute is present
|
|
12
|
+
* - Runs before the tailwindcss transformer so CSS is compiled normally
|
|
13
|
+
*/
|
|
14
|
+
async function inlineLink(dom, filePath) {
|
|
15
|
+
const links = [];
|
|
16
|
+
walk(dom, (node) => {
|
|
17
|
+
if (node.name !== "link") return;
|
|
18
|
+
const el = node;
|
|
19
|
+
const attrs = el.attribs || {};
|
|
20
|
+
if (attrs.rel !== "stylesheet" || !attrs.href) return;
|
|
21
|
+
const parent = el.parent;
|
|
22
|
+
if (parent && "children" in parent) {
|
|
23
|
+
const index = parent.children.indexOf(el);
|
|
24
|
+
if (index !== -1) links.push({
|
|
25
|
+
node: el,
|
|
26
|
+
parent,
|
|
27
|
+
index
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
const index = dom.indexOf(el);
|
|
31
|
+
if (index !== -1) links.push({
|
|
32
|
+
node: el,
|
|
33
|
+
parent: null,
|
|
34
|
+
index
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
for (const { node, parent, index } of links) {
|
|
39
|
+
const href = node.attribs.href;
|
|
40
|
+
const isRemote = href.startsWith("http://") || href.startsWith("https://");
|
|
41
|
+
let css;
|
|
42
|
+
if (isRemote) {
|
|
43
|
+
if (!("inline" in node.attribs)) continue;
|
|
44
|
+
try {
|
|
45
|
+
css = await (await fetch(href)).text();
|
|
46
|
+
} catch {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
if (!filePath) continue;
|
|
51
|
+
try {
|
|
52
|
+
css = readFileSync(resolve(dirname(filePath), href), "utf8");
|
|
53
|
+
} catch {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const styleNode = {
|
|
58
|
+
type: "tag",
|
|
59
|
+
name: "style",
|
|
60
|
+
attribs: {},
|
|
61
|
+
children: [{
|
|
62
|
+
type: "text",
|
|
63
|
+
data: css,
|
|
64
|
+
parent: null
|
|
65
|
+
}],
|
|
66
|
+
parent: parent || null
|
|
67
|
+
};
|
|
68
|
+
styleNode.children[0].parent = styleNode;
|
|
69
|
+
(parent && "children" in parent ? parent.children : dom).splice(index, 1, styleNode);
|
|
70
|
+
}
|
|
71
|
+
return dom;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { inlineLink };
|
|
76
|
+
//# sourceMappingURL=inlineLink.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineLink.mjs","names":[],"sources":["../../src/transformers/inlineLink.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport type { ChildNode, Element } from 'domhandler'\nimport { walk } from '../utils/ast/index.ts'\n\n/**\n * Inline `<link rel=\"stylesheet\">` tags as `<style>` tags.\n *\n * - Local file paths are always inlined (resolved relative to the template)\n * - Remote URLs (http/https) are only inlined if the `inline` attribute is present\n * - Runs before the tailwindcss transformer so CSS is compiled normally\n */\nexport async function inlineLink(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":";;;;;;;;;;;;;AAYA,eAAsB,WAAW,KAAkB,UAAyC;CAC1F,MAAM,QAA+D,EAAE;AAEvE,MAAK,MAAM,SAAS;AAClB,MAAK,KAAiB,SAAS,OAAQ;EAEvC,MAAM,KAAK;EACX,MAAM,QAAQ,GAAG,WAAW,EAAE;AAE9B,MAAI,MAAM,QAAQ,gBAAgB,CAAC,MAAM,KAAM;EAE/C,MAAM,SAAS,GAAG;AAElB,MAAI,UAAU,cAAc,QAAQ;GAClC,MAAM,QAAS,OAAO,SAAyB,QAAQ,GAAG;AAC1D,OAAI,UAAU,GACZ,OAAM,KAAK;IAAE,MAAM;IAAI;IAAQ;IAAO,CAAC;SAEpC;GAEL,MAAM,QAAQ,IAAI,QAAQ,GAAG;AAC7B,OAAI,UAAU,GACZ,OAAM,KAAK;IAAE,MAAM;IAAI,QAAQ;IAAa;IAAO,CAAC;;GAGxD;AAEF,MAAK,MAAM,EAAE,MAAM,QAAQ,WAAW,OAAO;EAC3C,MAAM,OAAO,KAAK,QAAQ;EAC1B,MAAM,WAAW,KAAK,WAAW,UAAU,IAAI,KAAK,WAAW,WAAW;EAE1E,IAAI;AAEJ,MAAI,UAAU;AACZ,OAAI,EAAE,YAAY,KAAK,SAAU;AAEjC,OAAI;AAEF,UAAM,OADW,MAAM,MAAM,KAAK,EACb,MAAM;WACrB;AACN;;SAEG;AACL,OAAI,CAAC,SAAU;AAEf,OAAI;AAEF,UAAM,aADe,QAAQ,QAAQ,SAAS,EAAE,KAAK,EACpB,OAAO;WAClC;AACN;;;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;AAGD,YAAU,SAAS,GAAG,SAAS;AAM/B,GAJiB,UAAU,cAAc,SACrC,OAAO,WACP,KAEK,OAAO,OAAO,GAAG,UAAU;;AAGtC,QAAO"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MaizzleConfig } from "../types/config.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/minify.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Minify transformer.
|
|
6
|
+
*
|
|
7
|
+
* Minifies HTML using the `html-crush` package.
|
|
8
|
+
* Enabled by setting `minify: true` (or passing options object).
|
|
9
|
+
* User options are merged on top of the defaults.
|
|
10
|
+
*
|
|
11
|
+
* The only Maizzle default that differs from html-crush's own defaults
|
|
12
|
+
* is `removeLineBreaks: true`.
|
|
13
|
+
*/
|
|
14
|
+
declare function minify(html: string, config?: MaizzleConfig): string;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { minify };
|
|
17
|
+
//# sourceMappingURL=minify.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minify.d.mts","names":[],"sources":["../../src/transformers/minify.ts"],"mappings":";;;;;AAmBA;;;;;;;;iBAAgB,MAAA,CAAO,IAAA,UAAc,MAAA,GAAQ,aAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defu } from "defu";
|
|
2
|
+
import { crush } from "html-crush";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/minify.ts
|
|
5
|
+
const DEFAULT_OPTIONS = { removeLineBreaks: true };
|
|
6
|
+
/**
|
|
7
|
+
* Minify transformer.
|
|
8
|
+
*
|
|
9
|
+
* Minifies HTML using the `html-crush` package.
|
|
10
|
+
* Enabled by setting `minify: true` (or passing options object).
|
|
11
|
+
* User options are merged on top of the defaults.
|
|
12
|
+
*
|
|
13
|
+
* The only Maizzle default that differs from html-crush's own defaults
|
|
14
|
+
* is `removeLineBreaks: true`.
|
|
15
|
+
*/
|
|
16
|
+
function minify(html, config = {}) {
|
|
17
|
+
const option = config.html?.minify;
|
|
18
|
+
if (!option) return html;
|
|
19
|
+
return crush(html, defu(typeof option === "object" ? option : {}, DEFAULT_OPTIONS)).result;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { minify };
|
|
24
|
+
//# sourceMappingURL=minify.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minify.mjs","names":["merge"],"sources":["../../src/transformers/minify.ts"],"sourcesContent":["import { crush } from 'html-crush'\nimport { defu as merge } from 'defu'\nimport type { Opts } from 'html-crush'\nimport type { MaizzleConfig } from '../types/config.ts'\n\nconst DEFAULT_OPTIONS = {\n removeLineBreaks: true,\n}\n\n/**\n * Minify transformer.\n *\n * Minifies HTML using the `html-crush` package.\n * Enabled by setting `minify: true` (or passing options object).\n * User options are merged on top of the defaults.\n *\n * The only Maizzle default that differs from html-crush's own defaults\n * is `removeLineBreaks: true`.\n */\nexport function minify(html: string, config: MaizzleConfig = {}): string {\n const option = config.html?.minify\n\n if (!option) return html\n\n const userOptions = typeof option === 'object' ? option : {}\n const options = merge(userOptions, DEFAULT_OPTIONS) as Partial<Opts>\n\n return crush(html, options).result\n}\n"],"mappings":";;;;AAKA,MAAM,kBAAkB,EACtB,kBAAkB,MACnB;;;;;;;;;;;AAYD,SAAgB,OAAO,MAAc,SAAwB,EAAE,EAAU;CACvE,MAAM,SAAS,OAAO,MAAM;AAE5B,KAAI,CAAC,OAAQ,QAAO;AAKpB,QAAO,MAAM,MAFGA,KADI,OAAO,WAAW,WAAW,SAAS,EAAE,EACzB,gBAAgB,CAExB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CssConfig } from "../types/config.mjs";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/purgeCSS.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Remove unused CSS transformer.
|
|
7
|
+
*
|
|
8
|
+
* Uses `email-comb` to strip CSS selectors and corresponding class/id
|
|
9
|
+
* references that are not matched anywhere in the HTML body.
|
|
10
|
+
*
|
|
11
|
+
* Enable by setting `css.purge: true` (or passing options).
|
|
12
|
+
* The user-supplied options are merged on top of the defaults, so
|
|
13
|
+
* `safelist` values are **appended** to the built-in safelist rather
|
|
14
|
+
* than replacing it.
|
|
15
|
+
*
|
|
16
|
+
* Accepts `ChildNode[]` as input, serializes internally before passing
|
|
17
|
+
* to email-comb (which requires a raw HTML string), then parses the
|
|
18
|
+
* result back to `ChildNode[]` so it fits in the DOM pipeline.
|
|
19
|
+
*/
|
|
20
|
+
declare function purgeCSS(dom: ChildNode[], config?: CssConfig): ChildNode[];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { purgeCSS };
|
|
23
|
+
//# sourceMappingURL=purgeCSS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purgeCSS.d.mts","names":[],"sources":["../../src/transformers/purgeCSS.ts"],"mappings":";;;;;;AA+CA;;;;;;;;;;;;;iBAAgB,QAAA,CAAS,GAAA,EAAK,SAAA,IAAa,MAAA,GAAQ,SAAA,GAAiB,SAAA"}
|