@depup/react-email 5.2.10-depup.1 → 6.9.0-depup.1
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/CHANGELOG.md +313 -0
- package/README.md +11 -10
- package/changes.json +21 -17
- package/dev/CHANGELOG.md +2 -0
- package/dev/index.js +1 -1
- package/dev/package.json +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cli/index.mjs +7801 -0
- package/dist/components/body/body.cjs +39 -0
- package/dist/components/body/body.d.cts +7 -0
- package/dist/components/body/body.d.mts +7 -0
- package/dist/components/body/body.mjs +37 -0
- package/dist/components/body/index.d.cts +1 -0
- package/dist/components/body/index.d.mts +1 -0
- package/dist/components/body/margin-properties.cjs +30 -0
- package/dist/components/body/margin-properties.mjs +29 -0
- package/dist/components/button/button.cjs +64 -0
- package/dist/components/button/button.d.cts +13 -0
- package/dist/components/button/button.d.mts +13 -0
- package/dist/components/button/button.mjs +62 -0
- package/dist/components/button/index.d.cts +1 -0
- package/dist/components/button/index.d.mts +1 -0
- package/dist/components/button/utils/parse-padding.cjs +90 -0
- package/dist/components/button/utils/parse-padding.mjs +90 -0
- package/dist/components/button/utils/px-to-pt.cjs +4 -0
- package/dist/components/button/utils/px-to-pt.mjs +4 -0
- package/dist/components/code-block/code-block.cjs +79 -0
- package/dist/components/code-block/code-block.d.cts +20 -0
- package/dist/components/code-block/code-block.d.mts +20 -0
- package/dist/components/code-block/code-block.mjs +77 -0
- package/dist/components/code-block/index.d.cts +3 -0
- package/dist/components/code-block/index.d.mts +3 -0
- package/dist/components/code-block/languages-available.d.cts +4 -0
- package/dist/components/code-block/languages-available.d.mts +4 -0
- package/dist/components/code-block/prism.cjs +14564 -0
- package/dist/components/code-block/prism.mjs +14562 -0
- package/dist/components/code-block/themes.cjs +2578 -0
- package/dist/components/code-block/themes.d.cts +4877 -0
- package/dist/components/code-block/themes.d.mts +4877 -0
- package/dist/components/code-block/themes.mjs +2541 -0
- package/dist/components/code-inline/code-inline.cjs +43 -0
- package/dist/components/code-inline/code-inline.d.cts +12 -0
- package/dist/components/code-inline/code-inline.d.mts +12 -0
- package/dist/components/code-inline/code-inline.mjs +41 -0
- package/dist/components/code-inline/index.d.cts +1 -0
- package/dist/components/code-inline/index.d.mts +1 -0
- package/dist/components/column/column.cjs +19 -0
- package/dist/components/column/column.d.cts +7 -0
- package/dist/components/column/column.d.mts +7 -0
- package/dist/components/column/column.mjs +17 -0
- package/dist/components/column/index.d.cts +1 -0
- package/dist/components/column/index.d.mts +1 -0
- package/dist/components/container/container.cjs +42 -0
- package/dist/components/container/container.d.cts +7 -0
- package/dist/components/container/container.d.mts +7 -0
- package/dist/components/container/container.mjs +40 -0
- package/dist/components/container/index.d.cts +1 -0
- package/dist/components/container/index.d.mts +1 -0
- package/dist/components/element-marker.cjs +8 -0
- package/dist/components/element-marker.mjs +7 -0
- package/dist/components/font/font.cjs +22 -0
- package/dist/components/font/font.d.cts +26 -0
- package/dist/components/font/font.d.mts +26 -0
- package/dist/components/font/font.mjs +21 -0
- package/dist/components/font/index.d.cts +1 -0
- package/dist/components/font/index.d.mts +1 -0
- package/dist/components/head/head.cjs +20 -0
- package/dist/components/head/head.d.cts +7 -0
- package/dist/components/head/head.d.mts +7 -0
- package/dist/components/head/head.mjs +18 -0
- package/dist/components/head/index.d.cts +1 -0
- package/dist/components/head/index.d.mts +1 -0
- package/dist/components/heading/heading.cjs +30 -0
- package/dist/components/heading/heading.d.cts +22 -0
- package/dist/components/heading/heading.d.mts +22 -0
- package/dist/components/heading/heading.mjs +28 -0
- package/dist/components/heading/index.d.cts +1 -0
- package/dist/components/heading/index.d.mts +1 -0
- package/dist/components/heading/utils/as.d.cts +16 -0
- package/dist/components/heading/utils/as.d.mts +16 -0
- package/dist/components/heading/utils/spaces.cjs +24 -0
- package/dist/components/heading/utils/spaces.d.cts +14 -0
- package/dist/components/heading/utils/spaces.d.mts +14 -0
- package/dist/components/heading/utils/spaces.mjs +24 -0
- package/dist/components/hr/hr.cjs +21 -0
- package/dist/components/hr/hr.d.cts +7 -0
- package/dist/components/hr/hr.d.mts +7 -0
- package/dist/components/hr/hr.mjs +19 -0
- package/dist/components/hr/index.d.cts +1 -0
- package/dist/components/hr/index.d.mts +1 -0
- package/dist/components/html/html.cjs +15 -0
- package/dist/components/html/html.d.cts +7 -0
- package/dist/components/html/html.d.mts +7 -0
- package/dist/components/html/html.mjs +13 -0
- package/dist/components/html/index.d.cts +1 -0
- package/dist/components/html/index.d.mts +1 -0
- package/dist/components/img/img.cjs +25 -0
- package/dist/components/img/img.d.cts +7 -0
- package/dist/components/img/img.d.mts +7 -0
- package/dist/components/img/img.mjs +23 -0
- package/dist/components/img/index.d.cts +1 -0
- package/dist/components/img/index.d.mts +1 -0
- package/dist/components/index.d.cts +24 -0
- package/dist/components/index.d.mts +24 -0
- package/dist/components/link/index.d.cts +1 -0
- package/dist/components/link/index.d.mts +1 -0
- package/dist/components/link/link.cjs +21 -0
- package/dist/components/link/link.d.cts +7 -0
- package/dist/components/link/link.d.mts +7 -0
- package/dist/components/link/link.mjs +19 -0
- package/dist/components/markdown/index.d.cts +1 -0
- package/dist/components/markdown/index.d.mts +1 -0
- package/dist/components/markdown/markdown.cjs +101 -0
- package/dist/components/markdown/markdown.d.cts +16 -0
- package/dist/components/markdown/markdown.d.mts +16 -0
- package/dist/components/markdown/markdown.mjs +99 -0
- package/dist/components/markdown/styles.cjs +92 -0
- package/dist/components/markdown/styles.d.cts +31 -0
- package/dist/components/markdown/styles.d.mts +31 -0
- package/dist/components/markdown/styles.mjs +92 -0
- package/dist/components/markdown/utils/parse-css-in-js-to-inline-css.cjs +60 -0
- package/dist/components/markdown/utils/parse-css-in-js-to-inline-css.mjs +60 -0
- package/dist/components/preview/index.d.cts +1 -0
- package/dist/components/preview/index.d.mts +1 -0
- package/dist/components/preview/preview.cjs +34 -0
- package/dist/components/preview/preview.d.cts +21 -0
- package/dist/components/preview/preview.d.mts +21 -0
- package/dist/components/preview/preview.mjs +31 -0
- package/dist/components/row/index.d.cts +1 -0
- package/dist/components/row/index.d.mts +1 -0
- package/dist/components/row/row.cjs +30 -0
- package/dist/components/row/row.d.cts +11 -0
- package/dist/components/row/row.d.mts +11 -0
- package/dist/components/row/row.mjs +28 -0
- package/dist/components/section/index.d.cts +1 -0
- package/dist/components/section/index.d.mts +1 -0
- package/dist/components/section/section.cjs +36 -0
- package/dist/components/section/section.d.cts +7 -0
- package/dist/components/section/section.d.mts +7 -0
- package/dist/components/section/section.mjs +34 -0
- package/dist/components/tailwind/hooks/use-suspended-promise.cjs +15 -0
- package/dist/components/tailwind/hooks/use-suspended-promise.mjs +15 -0
- package/dist/components/tailwind/index.d.cts +4 -0
- package/dist/components/tailwind/index.d.mts +4 -0
- package/dist/components/tailwind/inline-styles.cjs +11 -0
- package/dist/components/tailwind/inline-styles.d.cts +6 -0
- package/dist/components/tailwind/inline-styles.d.mts +6 -0
- package/dist/components/tailwind/inline-styles.mjs +11 -0
- package/dist/components/tailwind/sanitize-stylesheet.cjs +11 -0
- package/dist/components/tailwind/sanitize-stylesheet.d.cts +6 -0
- package/dist/components/tailwind/sanitize-stylesheet.d.mts +6 -0
- package/dist/components/tailwind/sanitize-stylesheet.mjs +11 -0
- package/dist/components/tailwind/tailwind.cjs +120 -0
- package/dist/components/tailwind/tailwind.d.cts +25 -0
- package/dist/components/tailwind/tailwind.d.mts +25 -0
- package/dist/components/tailwind/tailwind.mjs +117 -0
- package/dist/components/tailwind/utils/compatibility/get-react-property.cjs +10 -0
- package/dist/components/tailwind/utils/compatibility/get-react-property.mjs +10 -0
- package/dist/components/tailwind/utils/compatibility/sanitize-class-name.cjs +26 -0
- package/dist/components/tailwind/utils/compatibility/sanitize-class-name.mjs +26 -0
- package/dist/components/tailwind/utils/css/downlevel-for-email-clients.cjs +126 -0
- package/dist/components/tailwind/utils/css/downlevel-for-email-clients.mjs +125 -0
- package/dist/components/tailwind/utils/css/extract-rules-per-class.cjs +45 -0
- package/dist/components/tailwind/utils/css/extract-rules-per-class.mjs +44 -0
- package/dist/components/tailwind/utils/css/get-custom-properties.cjs +35 -0
- package/dist/components/tailwind/utils/css/get-custom-properties.mjs +34 -0
- package/dist/components/tailwind/utils/css/is-part-inlinable.cjs +10 -0
- package/dist/components/tailwind/utils/css/is-part-inlinable.mjs +9 -0
- package/dist/components/tailwind/utils/css/is-rule-inlinable.cjs +10 -0
- package/dist/components/tailwind/utils/css/is-rule-inlinable.mjs +9 -0
- package/dist/components/tailwind/utils/css/make-inline-styles-for.cjs +52 -0
- package/dist/components/tailwind/utils/css/make-inline-styles-for.mjs +51 -0
- package/dist/components/tailwind/utils/css/resolve-all-css-variables.cjs +89 -0
- package/dist/components/tailwind/utils/css/resolve-all-css-variables.mjs +88 -0
- package/dist/components/tailwind/utils/css/resolve-calc-expressions.cjs +92 -0
- package/dist/components/tailwind/utils/css/resolve-calc-expressions.mjs +91 -0
- package/dist/components/tailwind/utils/css/sanitize-declarations.cjs +310 -0
- package/dist/components/tailwind/utils/css/sanitize-declarations.mjs +309 -0
- package/dist/components/tailwind/utils/css/sanitize-non-inlinable-rules.cjs +46 -0
- package/dist/components/tailwind/utils/css/sanitize-non-inlinable-rules.mjs +45 -0
- package/dist/components/tailwind/utils/css/split-mixed-rule.cjs +41 -0
- package/dist/components/tailwind/utils/css/split-mixed-rule.mjs +40 -0
- package/dist/components/tailwind/utils/css/strip-empty-tailwind-vars.cjs +52 -0
- package/dist/components/tailwind/utils/css/strip-empty-tailwind-vars.mjs +51 -0
- package/dist/components/tailwind/utils/css/unwrap-value.cjs +7 -0
- package/dist/components/tailwind/utils/css/unwrap-value.mjs +7 -0
- package/dist/components/tailwind/utils/react/is-component.cjs +7 -0
- package/dist/components/tailwind/utils/react/is-component.mjs +7 -0
- package/dist/components/tailwind/utils/react/map-react-tree.cjs +32 -0
- package/dist/components/tailwind/utils/react/map-react-tree.mjs +30 -0
- package/dist/components/tailwind/utils/tailwindcss/clone-element-with-inlined-styles.cjs +37 -0
- package/dist/components/tailwind/utils/tailwindcss/clone-element-with-inlined-styles.mjs +35 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.cjs +77 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.d.cts +19 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.d.mts +19 -0
- package/dist/components/tailwind/utils/tailwindcss/setup-tailwind.mjs +76 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/index.cjs +901 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/index.mjs +901 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/preflight.cjs +398 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/preflight.mjs +398 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/theme.cjs +467 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/theme.mjs +467 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/utilities.cjs +6 -0
- package/dist/components/tailwind/utils/tailwindcss/tailwind-stylesheets/utilities.mjs +6 -0
- package/dist/components/tailwind/utils/text/from-dash-case-to-camel-case.cjs +6 -0
- package/dist/components/tailwind/utils/text/from-dash-case-to-camel-case.mjs +6 -0
- package/dist/components/text/index.d.cts +1 -0
- package/dist/components/text/index.d.mts +1 -0
- package/dist/components/text/text.cjs +43 -0
- package/dist/components/text/text.d.cts +7 -0
- package/dist/components/text/text.d.mts +7 -0
- package/dist/components/text/text.mjs +41 -0
- package/dist/components/text/utils/compute-margins.cjs +62 -0
- package/dist/components/text/utils/compute-margins.mjs +62 -0
- package/dist/index.cjs +95 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.mjs +25 -7326
- package/package.json +64 -32
- package/src/components/body/__snapshots__/body.spec.tsx.snap +23 -0
- package/src/components/body/body.spec.tsx +78 -0
- package/src/components/body/body.tsx +62 -0
- package/src/components/body/index.ts +1 -0
- package/src/components/body/margin-properties.ts +27 -0
- package/src/components/button/button.spec.tsx +53 -0
- package/src/components/button/button.tsx +114 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button/utils/parse-padding.ts +137 -0
- package/src/components/button/utils/px-to-pt.ts +4 -0
- package/src/components/button/utils/utils.spec.ts +153 -0
- package/src/components/code-block/code-block.tsx +136 -0
- package/src/components/code-block/index.ts +3 -0
- package/src/components/code-block/languages-available.ts +402 -0
- package/src/components/code-block/prism.ts +15618 -0
- package/src/components/code-block/themes.ts +4929 -0
- package/src/components/code-inline/code-inline.tsx +60 -0
- package/src/components/code-inline/index.ts +1 -0
- package/src/components/column/column.spec.tsx +28 -0
- package/src/components/column/column.tsx +17 -0
- package/src/components/column/index.ts +1 -0
- package/src/components/container/container.spec.tsx +33 -0
- package/src/components/container/container.tsx +59 -0
- package/src/components/container/index.ts +1 -0
- package/src/components/element-marker.ts +5 -0
- package/src/components/font/font.spec.tsx +63 -0
- package/src/components/font/font.tsx +76 -0
- package/src/components/font/index.ts +1 -0
- package/src/components/head/head.spec.tsx +34 -0
- package/src/components/head/head.tsx +15 -0
- package/src/components/head/index.ts +1 -0
- package/src/components/heading/heading.spec.tsx +32 -0
- package/src/components/heading/heading.tsx +31 -0
- package/src/components/heading/index.ts +1 -0
- package/src/components/heading/utils/as.ts +26 -0
- package/src/components/heading/utils/spaces.ts +64 -0
- package/src/components/heading/utils/utils.spec.ts +70 -0
- package/src/components/hr/hr.spec.tsx +22 -0
- package/src/components/hr/hr.tsx +23 -0
- package/src/components/hr/index.ts +1 -0
- package/src/components/html/html.spec.tsx +26 -0
- package/src/components/html/html.tsx +13 -0
- package/src/components/html/index.ts +1 -0
- package/src/components/img/img.spec.tsx +30 -0
- package/src/components/img/img.tsx +27 -0
- package/src/components/img/index.ts +1 -0
- package/src/components/index.ts +19 -0
- package/src/components/link/index.ts +1 -0
- package/src/components/link/link.spec.tsx +37 -0
- package/src/components/link/link.tsx +24 -0
- package/src/components/markdown/index.ts +1 -0
- package/src/components/markdown/markdown.spec.tsx +221 -0
- package/src/components/markdown/markdown.tsx +239 -0
- package/src/components/markdown/styles.ts +130 -0
- package/src/components/markdown/utils/parse-css-in-js-to-inline-css.spec.ts +42 -0
- package/src/components/markdown/utils/parse-css-in-js-to-inline-css.ts +73 -0
- package/src/components/preview/index.ts +1 -0
- package/src/components/preview/preview.spec.tsx +49 -0
- package/src/components/preview/preview.tsx +56 -0
- package/src/components/row/index.ts +1 -0
- package/src/components/row/row.spec.tsx +28 -0
- package/src/components/row/row.tsx +33 -0
- package/src/components/section/index.ts +1 -0
- package/src/components/section/section.spec.tsx +58 -0
- package/src/components/section/section.tsx +59 -0
- package/src/components/tailwind/e2e/integrations.spec.ts +44 -0
- package/src/components/tailwind/e2e/nextjs/README.md +9 -0
- package/src/components/tailwind/e2e/nextjs/emails/vercel-invite-user.tsx +151 -0
- package/src/components/tailwind/e2e/nextjs/next.config.mjs +6 -0
- package/src/components/tailwind/e2e/nextjs/package.json +24 -0
- package/src/components/tailwind/e2e/nextjs/src/app/favicon.ico +0 -0
- package/src/components/tailwind/e2e/nextjs/src/app/layout.tsx +23 -0
- package/src/components/tailwind/e2e/nextjs/src/app/page.tsx +7 -0
- package/src/components/tailwind/e2e/nextjs/tsconfig.json +27 -0
- package/src/components/tailwind/e2e/vite/README.md +9 -0
- package/src/components/tailwind/e2e/vite/emails/vercel-invite-user.tsx +151 -0
- package/src/components/tailwind/e2e/vite/index.html +13 -0
- package/src/components/tailwind/e2e/vite/package.json +25 -0
- package/src/components/tailwind/e2e/vite/public/vite.svg +1 -0
- package/src/components/tailwind/e2e/vite/src/App.tsx +10 -0
- package/src/components/tailwind/e2e/vite/src/main.tsx +9 -0
- package/src/components/tailwind/e2e/vite/src/vite-env.d.ts +1 -0
- package/src/components/tailwind/e2e/vite/tsconfig.json +25 -0
- package/src/components/tailwind/e2e/vite/tsconfig.node.json +11 -0
- package/src/components/tailwind/e2e/vite/vite.config.ts +7 -0
- package/src/components/tailwind/hooks/use-suspended-promise.ts +34 -0
- package/src/components/tailwind/hooks/use-suspensed-promise.spec.ts +263 -0
- package/src/components/tailwind/index.ts +4 -0
- package/src/components/tailwind/inline-styles.spec.ts +49 -0
- package/src/components/tailwind/inline-styles.ts +21 -0
- package/src/components/tailwind/sanitize-stylesheet.ts +10 -0
- package/src/components/tailwind/tailwind.spec.tsx +1390 -0
- package/src/components/tailwind/tailwind.tsx +178 -0
- package/src/components/tailwind/utils/__snapshots__/quick-safe-render-to-string.spec.tsx.snap +3 -0
- package/src/components/tailwind/utils/compatibility/escape-class-name.spec.ts +17 -0
- package/src/components/tailwind/utils/compatibility/escape-class-name.ts +18 -0
- package/src/components/tailwind/utils/compatibility/get-react-property.ts +15 -0
- package/src/components/tailwind/utils/compatibility/sanitize-class-name.spec.ts +7 -0
- package/src/components/tailwind/utils/compatibility/sanitize-class-name.ts +36 -0
- package/src/components/tailwind/utils/compatibility/unescape-class.ts +3 -0
- package/src/components/tailwind/utils/css/__snapshots__/extract-rules-matching-classes.spec.ts.snap +23 -0
- package/src/components/tailwind/utils/css/__snapshots__/remove-rule-duplicates-from-root.spec.ts.snap +3 -0
- package/src/components/tailwind/utils/css/__snapshots__/sanitize-non-inlinable-classes.spec.ts.snap +7 -0
- package/src/components/tailwind/utils/css/downlevel-for-email-clients.spec.ts +119 -0
- package/src/components/tailwind/utils/css/downlevel-for-email-clients.ts +244 -0
- package/src/components/tailwind/utils/css/extract-rules-per-class.spec.ts +232 -0
- package/src/components/tailwind/utils/css/extract-rules-per-class.ts +76 -0
- package/src/components/tailwind/utils/css/get-custom-properties.ts +49 -0
- package/src/components/tailwind/utils/css/is-part-inlinable.ts +15 -0
- package/src/components/tailwind/utils/css/is-rule-inlinable.ts +15 -0
- package/src/components/tailwind/utils/css/make-inline-styles-for.spec.ts +124 -0
- package/src/components/tailwind/utils/css/make-inline-styles-for.ts +73 -0
- package/src/components/tailwind/utils/css/resolve-all-css-variables.spec.ts +296 -0
- package/src/components/tailwind/utils/css/resolve-all-css-variables.ts +236 -0
- package/src/components/tailwind/utils/css/resolve-calc-expressions.spec.ts +36 -0
- package/src/components/tailwind/utils/css/resolve-calc-expressions.ts +147 -0
- package/src/components/tailwind/utils/css/sanitize-declarations.spec.ts +491 -0
- package/src/components/tailwind/utils/css/sanitize-declarations.ts +443 -0
- package/src/components/tailwind/utils/css/sanitize-non-inlinable-rules.spec.ts +72 -0
- package/src/components/tailwind/utils/css/sanitize-non-inlinable-rules.ts +48 -0
- package/src/components/tailwind/utils/css/split-mixed-rule.ts +68 -0
- package/src/components/tailwind/utils/css/strip-empty-tailwind-vars.spec.ts +128 -0
- package/src/components/tailwind/utils/css/strip-empty-tailwind-vars.ts +70 -0
- package/src/components/tailwind/utils/css/unwrap-value.ts +9 -0
- package/src/components/tailwind/utils/react/is-component.ts +12 -0
- package/src/components/tailwind/utils/react/map-react-tree.spec.tsx +58 -0
- package/src/components/tailwind/utils/react/map-react-tree.ts +58 -0
- package/src/components/tailwind/utils/tailwindcss/clone-element-with-inlined-styles.ts +61 -0
- package/src/components/tailwind/utils/tailwindcss/setup-tailwind.spec.ts +25 -0
- package/src/components/tailwind/utils/tailwindcss/setup-tailwind.ts +121 -0
- package/src/components/tailwind/utils/tailwindcss/tailwind-stylesheets/index.ts +900 -0
- package/src/components/tailwind/utils/tailwindcss/tailwind-stylesheets/preflight.ts +397 -0
- package/src/components/tailwind/utils/tailwindcss/tailwind-stylesheets/theme.ts +466 -0
- package/src/components/tailwind/utils/tailwindcss/tailwind-stylesheets/utilities.ts +5 -0
- package/src/components/tailwind/utils/text/from-dash-case-to-camel-case.ts +3 -0
- package/src/components/text/index.ts +1 -0
- package/src/components/text/text.spec.tsx +35 -0
- package/src/components/text/text.tsx +50 -0
- package/src/components/text/utils/compute-margins.spec.ts +67 -0
- package/src/components/text/utils/compute-margins.ts +102 -0
- package/src/index.ts +2 -110
- package/tsconfig.json +9 -4
- package/tsdown.config.ts +51 -6
- package/vitest.config.ts +1 -0
- package/vitest.e2e.config.ts +17 -0
- package/src/commands/build.ts +0 -269
- package/src/commands/dev.ts +0 -27
- package/src/commands/export.ts +0 -204
- package/src/commands/resend/reset.ts +0 -8
- package/src/commands/resend/setup.ts +0 -29
- package/src/commands/start.ts +0 -38
- package/src/utils/conf.ts +0 -9
- package/src/utils/esbuild/escape-string-for-regex.ts +0 -3
- package/src/utils/esbuild/renderring-utilities-exporter.ts +0 -63
- package/src/utils/get-emails-directory-metadata.spec.ts +0 -82
- package/src/utils/get-emails-directory-metadata.ts +0 -140
- package/src/utils/get-preview-server-location.ts +0 -50
- package/src/utils/index.ts +0 -2
- package/src/utils/packageJson.ts +0 -4
- package/src/utils/preview/get-env-variables-for-preview-app.ts +0 -20
- package/src/utils/preview/hot-reloading/create-dependency-graph.spec.ts +0 -226
- package/src/utils/preview/hot-reloading/create-dependency-graph.ts +0 -343
- package/src/utils/preview/hot-reloading/get-imported-modules.spec.ts +0 -151
- package/src/utils/preview/hot-reloading/get-imported-modules.ts +0 -49
- package/src/utils/preview/hot-reloading/resolve-path-aliases.spec.ts +0 -11
- package/src/utils/preview/hot-reloading/resolve-path-aliases.ts +0 -32
- package/src/utils/preview/hot-reloading/setup-hot-reloading.ts +0 -121
- package/src/utils/preview/hot-reloading/test/dependency-graph/inner/data-to-import.json +0 -1
- package/src/utils/preview/hot-reloading/test/dependency-graph/inner/file-a.ts +0 -5
- package/src/utils/preview/hot-reloading/test/dependency-graph/inner/file-b.ts +0 -5
- package/src/utils/preview/hot-reloading/test/dependency-graph/inner/general-importing-file.ts +0 -9
- package/src/utils/preview/hot-reloading/test/dependency-graph/inner/outer-dependency.ts +0 -3
- package/src/utils/preview/hot-reloading/test/dependency-graph/inner/path-aliases.ts +0 -1
- package/src/utils/preview/hot-reloading/test/dependency-graph/outer.ts +0 -5
- package/src/utils/preview/hot-reloading/test/some-file.ts +0 -0
- package/src/utils/preview/hot-reloading/test/tsconfig.json +0 -8
- package/src/utils/preview/index.ts +0 -2
- package/src/utils/preview/serve-static-file.ts +0 -51
- package/src/utils/preview/start-dev-server.ts +0 -252
- package/src/utils/register-spinner-autostopping.ts +0 -28
- package/src/utils/style-text.ts +0 -11
- package/src/utils/tree.spec.ts +0 -29
- package/src/utils/tree.ts +0 -76
- package/src/utils/types/hot-reload-change.ts +0 -6
- package/src/utils/types/hot-reload-event.ts +0 -3
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CssNode,
|
|
3
|
+
type Declaration,
|
|
4
|
+
type FunctionNode,
|
|
5
|
+
generate,
|
|
6
|
+
List,
|
|
7
|
+
parse,
|
|
8
|
+
type Raw,
|
|
9
|
+
type Value,
|
|
10
|
+
walk,
|
|
11
|
+
} from 'css-tree';
|
|
12
|
+
|
|
13
|
+
function rgbNode(
|
|
14
|
+
r: number,
|
|
15
|
+
g: number,
|
|
16
|
+
b: number,
|
|
17
|
+
alpha?: number,
|
|
18
|
+
): FunctionNode {
|
|
19
|
+
const children = new List<CssNode>();
|
|
20
|
+
children.appendData({
|
|
21
|
+
type: 'Number',
|
|
22
|
+
value: r.toFixed(0),
|
|
23
|
+
});
|
|
24
|
+
children.appendData({
|
|
25
|
+
type: 'Operator',
|
|
26
|
+
value: ',',
|
|
27
|
+
});
|
|
28
|
+
children.appendData({
|
|
29
|
+
type: 'Number',
|
|
30
|
+
value: g.toFixed(0),
|
|
31
|
+
});
|
|
32
|
+
children.appendData({
|
|
33
|
+
type: 'Operator',
|
|
34
|
+
value: ',',
|
|
35
|
+
});
|
|
36
|
+
children.appendData({
|
|
37
|
+
type: 'Number',
|
|
38
|
+
value: b.toFixed(0),
|
|
39
|
+
});
|
|
40
|
+
if (alpha !== 1 && alpha !== undefined) {
|
|
41
|
+
children.appendData({
|
|
42
|
+
type: 'Operator',
|
|
43
|
+
value: ',',
|
|
44
|
+
});
|
|
45
|
+
children.appendData({
|
|
46
|
+
type: 'Number',
|
|
47
|
+
value: alpha.toString(),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
type: 'Function',
|
|
53
|
+
name: 'rgb',
|
|
54
|
+
children,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const LAB_TO_LMS = {
|
|
59
|
+
l: [0.3963377773761749, 0.2158037573099136],
|
|
60
|
+
m: [-0.1055613458156586, -0.0638541728258133],
|
|
61
|
+
s: [-0.0894841775298119, -1.2914855480194092],
|
|
62
|
+
};
|
|
63
|
+
const LSM_TO_RGB = {
|
|
64
|
+
r: [4.0767416360759583, -3.3077115392580629, 0.2309699031821043],
|
|
65
|
+
g: [-1.2684379732850315, 2.6097573492876882, -0.341319376002657],
|
|
66
|
+
b: [-0.0041960761386756, -0.7034186179359362, 1.7076146940746117],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
function lrgbToRgb(input: number) {
|
|
70
|
+
const absoluteNumber = Math.abs(input);
|
|
71
|
+
const sign = input < 0 ? -1 : 1;
|
|
72
|
+
|
|
73
|
+
if (absoluteNumber > 0.0031308) {
|
|
74
|
+
return sign * (absoluteNumber ** (1 / 2.4) * 1.055 - 0.055);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return input * 12.92;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function clamp(value: number, min: number, max: number) {
|
|
81
|
+
return Math.min(Math.max(value, min), max);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function oklchToOklab(oklch: { l: number; c: number; h: number }) {
|
|
85
|
+
return {
|
|
86
|
+
l: oklch.l,
|
|
87
|
+
a: oklch.c * Math.cos((oklch.h / 180) * Math.PI),
|
|
88
|
+
b: oklch.c * Math.sin((oklch.h / 180) * Math.PI),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Convert oklab to RGB */
|
|
93
|
+
function oklchToRgb(oklch: { l: number; c: number; h: number }) {
|
|
94
|
+
const oklab = oklchToOklab(oklch);
|
|
95
|
+
|
|
96
|
+
const l =
|
|
97
|
+
(oklab.l + LAB_TO_LMS.l[0]! * oklab.a + LAB_TO_LMS.l[1]! * oklab.b) ** 3;
|
|
98
|
+
const m =
|
|
99
|
+
(oklab.l + LAB_TO_LMS.m[0]! * oklab.a + LAB_TO_LMS.m[1]! * oklab.b) ** 3;
|
|
100
|
+
const s =
|
|
101
|
+
(oklab.l + LAB_TO_LMS.s[0]! * oklab.a + LAB_TO_LMS.s[1]! * oklab.b) ** 3;
|
|
102
|
+
|
|
103
|
+
const r =
|
|
104
|
+
255 *
|
|
105
|
+
lrgbToRgb(
|
|
106
|
+
LSM_TO_RGB.r[0]! * l + LSM_TO_RGB.r[1]! * m + LSM_TO_RGB.r[2]! * s,
|
|
107
|
+
);
|
|
108
|
+
const g =
|
|
109
|
+
255 *
|
|
110
|
+
lrgbToRgb(
|
|
111
|
+
LSM_TO_RGB.g[0]! * l + LSM_TO_RGB.g[1]! * m + LSM_TO_RGB.g[2]! * s,
|
|
112
|
+
);
|
|
113
|
+
const b =
|
|
114
|
+
255 *
|
|
115
|
+
lrgbToRgb(
|
|
116
|
+
LSM_TO_RGB.b[0]! * l + LSM_TO_RGB.b[1]! * m + LSM_TO_RGB.b[2]! * s,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
r: clamp(r, 0, 255),
|
|
121
|
+
g: clamp(g, 0, 255),
|
|
122
|
+
b: clamp(b, 0, 255),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function separteShorthandDeclaration(
|
|
127
|
+
shorthandToReplace: Declaration,
|
|
128
|
+
[start, end]: [string, string],
|
|
129
|
+
): Declaration {
|
|
130
|
+
shorthandToReplace.property = start;
|
|
131
|
+
|
|
132
|
+
const values =
|
|
133
|
+
shorthandToReplace.value.type === 'Value'
|
|
134
|
+
? shorthandToReplace.value.children
|
|
135
|
+
.toArray()
|
|
136
|
+
// Count every real value component, not just numeric ones, so a
|
|
137
|
+
// two-value shorthand with `auto`/`var()`/`calc()` (e.g.
|
|
138
|
+
// `margin-inline: 1rem auto`) still splits into two longhands.
|
|
139
|
+
.filter(
|
|
140
|
+
(child) => child.type !== 'Operator' && child.type !== 'WhiteSpace',
|
|
141
|
+
)
|
|
142
|
+
: [shorthandToReplace.value];
|
|
143
|
+
let endValue = shorthandToReplace.value;
|
|
144
|
+
if (values.length === 2) {
|
|
145
|
+
endValue = {
|
|
146
|
+
type: 'Value',
|
|
147
|
+
children: new List<CssNode>().fromArray([values[1]!]),
|
|
148
|
+
};
|
|
149
|
+
shorthandToReplace.value = {
|
|
150
|
+
type: 'Value',
|
|
151
|
+
children: new List<CssNode>().fromArray([values[0]!]),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
type: 'Declaration',
|
|
157
|
+
property: end,
|
|
158
|
+
value: endValue,
|
|
159
|
+
important: shorthandToReplace.important,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Meant to do all the things necessary, in a per-declaration basis, to have the best email client
|
|
165
|
+
* support possible.
|
|
166
|
+
*
|
|
167
|
+
* Here's the transformations it does so far:
|
|
168
|
+
* - convert all `rgb` with space-based syntax into a comma based one;
|
|
169
|
+
* - convert all `oklch` values into `rgb`;
|
|
170
|
+
* - convert all hex values into `rgb`;
|
|
171
|
+
* - convert `padding-inline` into `padding-left` and `padding-right`;
|
|
172
|
+
* - convert `padding-block` into `padding-top` and `padding-bottom`;
|
|
173
|
+
* - convert `margin-inline` into `margin-left` and `margin-right`;
|
|
174
|
+
* - convert `margin-block` into `margin-top` and `margin-bottom`.
|
|
175
|
+
*/
|
|
176
|
+
export function sanitizeDeclarations(nodeContainingDeclarations: CssNode) {
|
|
177
|
+
walk(nodeContainingDeclarations, {
|
|
178
|
+
visit: 'Declaration',
|
|
179
|
+
enter(declaration, item, list) {
|
|
180
|
+
if (declaration.value.type === 'Raw') {
|
|
181
|
+
declaration.value = parse(declaration.value.value, {
|
|
182
|
+
context: 'value',
|
|
183
|
+
}) as Value | Raw;
|
|
184
|
+
}
|
|
185
|
+
if (
|
|
186
|
+
/border-(?:[a-z]+-){0,2}radius\s*:\s*calc\s*\(\s*infinity\s*\*\s*1px\s*\)/i.test(
|
|
187
|
+
generate(declaration),
|
|
188
|
+
)
|
|
189
|
+
) {
|
|
190
|
+
declaration.value = parse('9999px', { context: 'value' }) as Value;
|
|
191
|
+
}
|
|
192
|
+
walk(declaration, {
|
|
193
|
+
visit: 'Function',
|
|
194
|
+
enter(func, funcParentListItem) {
|
|
195
|
+
const children = func.children.toArray();
|
|
196
|
+
if (func.name === 'oklch') {
|
|
197
|
+
let l: number | undefined;
|
|
198
|
+
let c: number | undefined;
|
|
199
|
+
let h: number | undefined;
|
|
200
|
+
let a: number | undefined;
|
|
201
|
+
for (const child of children) {
|
|
202
|
+
if (child.type === 'Number') {
|
|
203
|
+
if (l === undefined) {
|
|
204
|
+
l = Number.parseFloat(child.value);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (c === undefined) {
|
|
208
|
+
c = Number.parseFloat(child.value);
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (h === undefined) {
|
|
212
|
+
h = Number.parseFloat(child.value);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (a === undefined) {
|
|
216
|
+
a = Number.parseFloat(child.value);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (child.type === 'Dimension' && child.unit === 'deg') {
|
|
221
|
+
if (h === undefined) {
|
|
222
|
+
h = Number.parseFloat(child.value);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (child.type === 'Percentage') {
|
|
227
|
+
if (l === undefined) {
|
|
228
|
+
l = Number.parseFloat(child.value) / 100;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (a === undefined) {
|
|
232
|
+
a = Number.parseFloat(child.value) / 100;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (l === undefined || c === undefined || h === undefined) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
'Could not determine the parameters of an oklch() function.',
|
|
240
|
+
{
|
|
241
|
+
cause: declaration,
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const rgb = oklchToRgb({
|
|
247
|
+
l,
|
|
248
|
+
c,
|
|
249
|
+
h,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
funcParentListItem.data = rgbNode(rgb.r, rgb.g, rgb.b, a);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (func.name === 'rgb' || func.name === 'rgba') {
|
|
256
|
+
let r: number | undefined;
|
|
257
|
+
let g: number | undefined;
|
|
258
|
+
let b: number | undefined;
|
|
259
|
+
let a: number | undefined;
|
|
260
|
+
for (const child of children) {
|
|
261
|
+
if (child.type === 'Number') {
|
|
262
|
+
if (r === undefined) {
|
|
263
|
+
r = Number.parseFloat(child.value);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (g === undefined) {
|
|
267
|
+
g = Number.parseFloat(child.value);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (b === undefined) {
|
|
271
|
+
b = Number.parseFloat(child.value);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (a === undefined) {
|
|
275
|
+
a = Number.parseFloat(child.value);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (child.type === 'Percentage') {
|
|
280
|
+
if (r === undefined) {
|
|
281
|
+
r = (Number.parseFloat(child.value) * 255) / 100;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (g === undefined) {
|
|
285
|
+
g = (Number.parseFloat(child.value) * 255) / 100;
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (b === undefined) {
|
|
289
|
+
b = (Number.parseFloat(child.value) * 255) / 100;
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (a === undefined) {
|
|
293
|
+
a = Number.parseFloat(child.value) / 100;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (r === undefined || g === undefined || b === undefined) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
'Could not determine the parameters of an rgb() function.',
|
|
301
|
+
{
|
|
302
|
+
cause: declaration,
|
|
303
|
+
},
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (a === undefined || a === 1) {
|
|
308
|
+
funcParentListItem.data = rgbNode(r, g, b);
|
|
309
|
+
} else {
|
|
310
|
+
funcParentListItem.data = rgbNode(r, g, b, a);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
walk(declaration, {
|
|
316
|
+
visit: 'Hash',
|
|
317
|
+
enter(hash, hashParentListItem) {
|
|
318
|
+
const hex = hash.value.trim();
|
|
319
|
+
if (hex.length === 3) {
|
|
320
|
+
const r = Number.parseInt(hex.charAt(0) + hex.charAt(0), 16);
|
|
321
|
+
const g = Number.parseInt(hex.charAt(1) + hex.charAt(1), 16);
|
|
322
|
+
const b = Number.parseInt(hex.charAt(2) + hex.charAt(2), 16);
|
|
323
|
+
hashParentListItem.data = rgbNode(r, g, b);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (hex.length === 4) {
|
|
327
|
+
const r = Number.parseInt(hex.charAt(0) + hex.charAt(0), 16);
|
|
328
|
+
const g = Number.parseInt(hex.charAt(1) + hex.charAt(1), 16);
|
|
329
|
+
const b = Number.parseInt(hex.charAt(2) + hex.charAt(2), 16);
|
|
330
|
+
const a = Number.parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255;
|
|
331
|
+
hashParentListItem.data = rgbNode(r, g, b, a);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (hex.length === 5) {
|
|
335
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
336
|
+
const g = Number.parseInt(hex.charAt(2) + hex.charAt(2), 16);
|
|
337
|
+
const b = Number.parseInt(hex.charAt(3) + hex.charAt(3), 16);
|
|
338
|
+
const a = Number.parseInt(hex.charAt(4) + hex.charAt(4), 16) / 255;
|
|
339
|
+
hashParentListItem.data = rgbNode(r, g, b, a);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (hex.length === 6) {
|
|
343
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
344
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
345
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
346
|
+
hashParentListItem.data = rgbNode(r, g, b);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (hex.length === 7) {
|
|
350
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
351
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
352
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
353
|
+
const a = Number.parseInt(hex.charAt(6) + hex.charAt(6), 16) / 255;
|
|
354
|
+
hashParentListItem.data = rgbNode(r, g, b, a);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
358
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
359
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
360
|
+
const a = Number.parseInt(hex.slice(6, 8), 16) / 255;
|
|
361
|
+
hashParentListItem.data = rgbNode(r, g, b, a);
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
walk(declaration, {
|
|
366
|
+
visit: 'Function',
|
|
367
|
+
enter(func, parentListItem) {
|
|
368
|
+
if (func.name === 'color-mix') {
|
|
369
|
+
const children = func.children.toArray();
|
|
370
|
+
// We're expecting the children here to be something like:
|
|
371
|
+
// Identifier (in)
|
|
372
|
+
// Identifier (oklab)
|
|
373
|
+
// Operator (,)
|
|
374
|
+
// FunctionNode (rgb(...))
|
|
375
|
+
// Node (opacity)
|
|
376
|
+
// Operator (,)
|
|
377
|
+
// Identifier (transparent)
|
|
378
|
+
const color: CssNode | undefined = children[3];
|
|
379
|
+
const opacity: CssNode | undefined = children[4];
|
|
380
|
+
if (
|
|
381
|
+
func.children.last?.type === 'Identifier' &&
|
|
382
|
+
func.children.last.name === 'transparent' &&
|
|
383
|
+
color?.type === 'Function' &&
|
|
384
|
+
color?.name === 'rgb' &&
|
|
385
|
+
opacity
|
|
386
|
+
) {
|
|
387
|
+
if (opacity.type === 'Percentage') {
|
|
388
|
+
const alpha = Number.parseFloat(opacity.value) / 100;
|
|
389
|
+
if (alpha < 1) {
|
|
390
|
+
color.children.appendData({
|
|
391
|
+
type: 'Operator',
|
|
392
|
+
value: ',',
|
|
393
|
+
});
|
|
394
|
+
color.children.appendData({
|
|
395
|
+
type: 'Number',
|
|
396
|
+
value: alpha.toString(),
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
color.children.appendData({
|
|
401
|
+
type: 'Operator',
|
|
402
|
+
value: ',',
|
|
403
|
+
});
|
|
404
|
+
color.children.appendData(opacity);
|
|
405
|
+
}
|
|
406
|
+
parentListItem.data = color;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
if (declaration.property === 'padding-inline') {
|
|
413
|
+
const paddingRight = separteShorthandDeclaration(declaration, [
|
|
414
|
+
'padding-left',
|
|
415
|
+
'padding-right',
|
|
416
|
+
]);
|
|
417
|
+
list.insertData(paddingRight, item);
|
|
418
|
+
}
|
|
419
|
+
if (declaration.property === 'padding-block') {
|
|
420
|
+
const paddingBottom = separteShorthandDeclaration(declaration, [
|
|
421
|
+
'padding-top',
|
|
422
|
+
'padding-bottom',
|
|
423
|
+
]);
|
|
424
|
+
list.insertData(paddingBottom, item);
|
|
425
|
+
}
|
|
426
|
+
if (declaration.property === 'margin-inline') {
|
|
427
|
+
const marginRight = separteShorthandDeclaration(declaration, [
|
|
428
|
+
'margin-left',
|
|
429
|
+
'margin-right',
|
|
430
|
+
]);
|
|
431
|
+
list.insertData(marginRight, item);
|
|
432
|
+
}
|
|
433
|
+
if (declaration.property === 'margin-block') {
|
|
434
|
+
const paddingBottom = separteShorthandDeclaration(declaration, [
|
|
435
|
+
'margin-top',
|
|
436
|
+
'margin-bottom',
|
|
437
|
+
]);
|
|
438
|
+
|
|
439
|
+
list.insertData(paddingBottom, item);
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { generate } from 'css-tree';
|
|
2
|
+
import { sanitizeStyleSheet } from '../../sanitize-stylesheet.js';
|
|
3
|
+
import { setupTailwind } from '../tailwindcss/setup-tailwind.js';
|
|
4
|
+
import { sanitizeNonInlinableRules } from './sanitize-non-inlinable-rules.js';
|
|
5
|
+
|
|
6
|
+
describe('sanitizeNonInlinableRules()', () => {
|
|
7
|
+
it('inlines rules that can be inlined', async () => {
|
|
8
|
+
const tailwind = await setupTailwind({});
|
|
9
|
+
tailwind.addUtilities(['bg-gray-900', 'text-red-300', 'text-lg']);
|
|
10
|
+
const stylesheet = tailwind.getStyleSheet();
|
|
11
|
+
|
|
12
|
+
sanitizeNonInlinableRules(stylesheet);
|
|
13
|
+
expect(generate(stylesheet)).toMatchInlineSnapshot(
|
|
14
|
+
`"/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer theme,base,components,utilities;@layer theme{:root,:host{--color-red-300: oklch(80.8% 0.114 19.571)!important;--color-gray-900: oklch(21% 0.034 264.665)!important;--text-lg: 1.125rem!important;--text-lg--line-height: calc(1.75 / 1.125)!important}}@layer utilities{.bg-gray-900{background-color:var(--color-gray-900)}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading, var(--text-lg--line-height))}.text-red-300{color:var(--color-red-300)}}"`,
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('handles CSS nesting in hover pseudo styles', async () => {
|
|
19
|
+
const tailwind = await setupTailwind({});
|
|
20
|
+
tailwind.addUtilities([
|
|
21
|
+
'hover:text-sky-600',
|
|
22
|
+
'sm:focus:outline-none',
|
|
23
|
+
'md:hover:bg-gray-100',
|
|
24
|
+
'lg:focus:underline',
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const stylesheet = tailwind.getStyleSheet();
|
|
28
|
+
|
|
29
|
+
sanitizeNonInlinableRules(stylesheet);
|
|
30
|
+
expect(generate(stylesheet)).toMatchInlineSnapshot(
|
|
31
|
+
`"/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer theme,base,components,utilities;@layer theme{:root,:host{--color-sky-600: oklch(58.8% 0.158 241.966)!important;--color-gray-100: oklch(96.7% 0.003 264.542)!important}}@layer utilities{.hover_text-sky-600{&:hover{@media (hover:hover){color:var(--color-sky-600)!important}}}.sm_focus_outline-none{@media (width>=40rem){&:focus{outline-style:none!important}}}.md_hover_bg-gray-100{@media (width>=48rem){&:hover{@media (hover:hover){background-color:var(--color-gray-100)!important}}}}.lg_focus_underline{@media (width>=64rem){&:focus{text-decoration-line:underline!important}}}}"`,
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('strips Tailwind v4 variant-stacking var() refs with empty fallbacks inside print: media queries', async () => {
|
|
36
|
+
// Mirrors the inline-style behavior asserted in make-inline-styles-for.spec.ts.
|
|
37
|
+
// `print:invert` compiles to a filter value that is a chain of var(--tw-...,)
|
|
38
|
+
// with empty fallbacks. After resolveAllCssVariables the filter is concrete;
|
|
39
|
+
// sanitizeNonInlinableRules then drops the leftover --tw-* declarations and
|
|
40
|
+
// any remaining empty-fallback var() refs.
|
|
41
|
+
const tailwind = await setupTailwind({});
|
|
42
|
+
tailwind.addUtilities(['md:block', 'print:invert']);
|
|
43
|
+
const stylesheet = tailwind.getStyleSheet();
|
|
44
|
+
|
|
45
|
+
sanitizeStyleSheet(stylesheet);
|
|
46
|
+
sanitizeNonInlinableRules(stylesheet);
|
|
47
|
+
const result = generate(stylesheet);
|
|
48
|
+
|
|
49
|
+
expect(result).not.toMatch(/var\(--tw-[^,()]+,\s*\)/);
|
|
50
|
+
expect(result).toMatchInlineSnapshot(
|
|
51
|
+
`"/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer theme,base,components,utilities;@layer utilities{.md_block{@media (width>=48rem){display:block!important}}.print_invert{@media print{filter:invert(100%)!important}}}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}"`,
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('supports basic media query rules', async () => {
|
|
56
|
+
const tailwind = await setupTailwind({});
|
|
57
|
+
tailwind.addUtilities([
|
|
58
|
+
'sm:mx-auto',
|
|
59
|
+
'sm:max-w-lg',
|
|
60
|
+
'sm:rounded-lg',
|
|
61
|
+
'md:px-10',
|
|
62
|
+
'md:py-12',
|
|
63
|
+
]);
|
|
64
|
+
const stylesheet = tailwind.getStyleSheet();
|
|
65
|
+
|
|
66
|
+
sanitizeNonInlinableRules(stylesheet);
|
|
67
|
+
|
|
68
|
+
expect(generate(stylesheet)).toMatchInlineSnapshot(
|
|
69
|
+
`"/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer theme,base,components,utilities;@layer theme{:root,:host{--spacing: 0.25rem!important;--container-lg: 32rem!important;--radius-lg: 0.5rem!important}}@layer utilities{.sm_mx-auto{@media (width>=40rem){margin-inline:auto!important}}.sm_max-w-lg{@media (width>=40rem){max-width:var(--container-lg)!important}}.sm_rounded-lg{@media (width>=40rem){border-radius:var(--radius-lg)!important}}.md_px-10{@media (width>=48rem){padding-inline:calc(var(--spacing)*10)!important}}.md_py-12{@media (width>=48rem){padding-block:calc(var(--spacing)*12)!important}}}"`,
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type CssNode, string, walk } from 'css-tree';
|
|
2
|
+
import { sanitizeClassName } from '../compatibility/sanitize-class-name.js';
|
|
3
|
+
import { isRuleInlinable } from './is-rule-inlinable.js';
|
|
4
|
+
import { stripEmptyTailwindVars } from './strip-empty-tailwind-vars.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This function goes through a few steps to ensure the best email client support and
|
|
8
|
+
* to ensure that media queries and pseudo classes are applied correctly alongside
|
|
9
|
+
* the inline styles.
|
|
10
|
+
*
|
|
11
|
+
* What it does:
|
|
12
|
+
* 1. Converts all declarations in all rules into important ones
|
|
13
|
+
* 2. Sanitizes class selectors of all non-inlinable rules
|
|
14
|
+
* 3. Removes --tw-* custom property declarations — by this point all CSS
|
|
15
|
+
* variables have been resolved, so these are dead weight in email HTML.
|
|
16
|
+
* 4. Strips empty-fallback var(--tw-*,) refs that Tailwind v4 emits for
|
|
17
|
+
* variant-stacking idioms (filter, font-variant-numeric, etc.) — email
|
|
18
|
+
* clients can't resolve CSS custom properties reliably, so any --tw-*
|
|
19
|
+
* left as a bare empty-fallback ref would reach the client broken.
|
|
20
|
+
*/
|
|
21
|
+
export function sanitizeNonInlinableRules(node: CssNode) {
|
|
22
|
+
walk(node, {
|
|
23
|
+
visit: 'Rule',
|
|
24
|
+
enter(rule) {
|
|
25
|
+
if (!isRuleInlinable(rule)) {
|
|
26
|
+
walk(rule.prelude, (node) => {
|
|
27
|
+
if (node.type === 'ClassSelector') {
|
|
28
|
+
const unescapedClassName = string.decode(node.name);
|
|
29
|
+
node.name = sanitizeClassName(unescapedClassName);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
walk(rule, {
|
|
34
|
+
visit: 'Declaration',
|
|
35
|
+
enter(declaration, item, list) {
|
|
36
|
+
if (declaration.property.startsWith('--tw-')) {
|
|
37
|
+
list.remove(item);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declaration.important = true;
|
|
42
|
+
stripEmptyTailwindVars(declaration.value);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type CssNode, clone, find, List, type Rule } from 'css-tree';
|
|
2
|
+
import { isPartInlinable } from './is-part-inlinable.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Split a rule into inlinable and non-inlinable parts. Caller must only pass rules
|
|
6
|
+
* for which isRuleInlinable(rule) is false. Returns clones so the original stylesheet is never mutated.
|
|
7
|
+
*
|
|
8
|
+
* @returns inlinablePart: rule with only inlinable block children, or null if none.
|
|
9
|
+
* nonInlinablePart: rule with only non-inlinable block children, or null if none.
|
|
10
|
+
*/
|
|
11
|
+
export function splitMixedRule(rule: Rule): {
|
|
12
|
+
inlinablePart: Rule | null;
|
|
13
|
+
nonInlinablePart: Rule | null;
|
|
14
|
+
} {
|
|
15
|
+
// If the selector itself contains pseudo-selectors, every declaration in the
|
|
16
|
+
// block only applies in that pseudo context — splitting would incorrectly
|
|
17
|
+
// inline them as base styles. Return the whole rule as non-inlinable.
|
|
18
|
+
const selectorHasPseudo =
|
|
19
|
+
rule.prelude !== null &&
|
|
20
|
+
find(
|
|
21
|
+
rule.prelude,
|
|
22
|
+
(node) =>
|
|
23
|
+
node.type === 'PseudoClassSelector' ||
|
|
24
|
+
node.type === 'PseudoElementSelector',
|
|
25
|
+
) !== null;
|
|
26
|
+
|
|
27
|
+
if (selectorHasPseudo) {
|
|
28
|
+
return { inlinablePart: null, nonInlinablePart: clone(rule) as Rule };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ruleCloneInlinable = clone(rule) as Rule;
|
|
32
|
+
const ruleCloneNonInlinable = clone(rule) as Rule;
|
|
33
|
+
|
|
34
|
+
const inlinableParts: CssNode[] = [];
|
|
35
|
+
const nonInlinableParts: CssNode[] = [];
|
|
36
|
+
|
|
37
|
+
for (const part of ruleCloneInlinable.block.children.toArray()) {
|
|
38
|
+
if (isPartInlinable(part)) {
|
|
39
|
+
inlinableParts.push(part);
|
|
40
|
+
} else {
|
|
41
|
+
nonInlinableParts.push(part);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const inlinablePart =
|
|
46
|
+
inlinableParts.length > 0
|
|
47
|
+
? {
|
|
48
|
+
...ruleCloneInlinable,
|
|
49
|
+
block: {
|
|
50
|
+
type: 'Block' as const,
|
|
51
|
+
children: new List<CssNode>().fromArray(inlinableParts),
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
: null;
|
|
55
|
+
|
|
56
|
+
const nonInlinablePart =
|
|
57
|
+
nonInlinableParts.length > 0
|
|
58
|
+
? {
|
|
59
|
+
...ruleCloneNonInlinable,
|
|
60
|
+
block: {
|
|
61
|
+
type: 'Block' as const,
|
|
62
|
+
children: new List<CssNode>().fromArray(nonInlinableParts),
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
: null;
|
|
66
|
+
|
|
67
|
+
return { inlinablePart, nonInlinablePart };
|
|
68
|
+
}
|