@depup/react-email 5.2.10-depup.0 → 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,124 @@
|
|
|
1
|
+
import { parse, type StyleSheet } from 'css-tree';
|
|
2
|
+
import { getCustomProperties } from './get-custom-properties.js';
|
|
3
|
+
import { makeInlineStylesFor } from './make-inline-styles-for.js';
|
|
4
|
+
|
|
5
|
+
describe('makeInlineStylesFor()', async () => {
|
|
6
|
+
it('works in simple use case', () => {
|
|
7
|
+
const tailwindStyles = parse(`
|
|
8
|
+
.bg-red-500 { background-color: #f56565; }
|
|
9
|
+
.w-full { width: 100%; }
|
|
10
|
+
`) as StyleSheet;
|
|
11
|
+
|
|
12
|
+
expect(
|
|
13
|
+
makeInlineStylesFor(
|
|
14
|
+
tailwindStyles.children.toArray(),
|
|
15
|
+
getCustomProperties(tailwindStyles),
|
|
16
|
+
),
|
|
17
|
+
).toMatchInlineSnapshot(`
|
|
18
|
+
{
|
|
19
|
+
"backgroundColor": "#f56565",
|
|
20
|
+
"width": "100%",
|
|
21
|
+
}
|
|
22
|
+
`);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('does basic local variable resolution', () => {
|
|
26
|
+
const tailwindStyles = parse(`
|
|
27
|
+
.btn {
|
|
28
|
+
--btn-bg: #3490dc;
|
|
29
|
+
--btn-text: #fff;
|
|
30
|
+
background-color: var(--btn-bg);
|
|
31
|
+
color: var(--btn-text);
|
|
32
|
+
padding: 0.5rem 1rem;
|
|
33
|
+
border-radius: 0.25rem;
|
|
34
|
+
}
|
|
35
|
+
`) as StyleSheet;
|
|
36
|
+
|
|
37
|
+
expect(
|
|
38
|
+
makeInlineStylesFor(
|
|
39
|
+
tailwindStyles.children.toArray(),
|
|
40
|
+
getCustomProperties(tailwindStyles),
|
|
41
|
+
),
|
|
42
|
+
).toMatchInlineSnapshot(`
|
|
43
|
+
{
|
|
44
|
+
"backgroundColor": "#3490dc",
|
|
45
|
+
"borderRadius": "0.25rem",
|
|
46
|
+
"color": "#fff",
|
|
47
|
+
"padding": "0.5rem 1rem",
|
|
48
|
+
}
|
|
49
|
+
`);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('strips Tailwind v4 variant-stacking var() refs with empty fallbacks', () => {
|
|
53
|
+
// Tailwind v4 compiles `tabular-nums` to a font-variant-numeric value
|
|
54
|
+
// where every optional variant slot is represented by an unresolved
|
|
55
|
+
// var(--tw-..., ) with an empty fallback. Email clients do not support
|
|
56
|
+
// CSS custom properties reliably, so these must collapse at inline time
|
|
57
|
+
// (per CSS spec, an empty fallback resolves to empty string).
|
|
58
|
+
const tailwindStyles = parse(`
|
|
59
|
+
.tabular-nums {
|
|
60
|
+
font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) tabular-nums var(--tw-numeric-fraction,);
|
|
61
|
+
}
|
|
62
|
+
`) as StyleSheet;
|
|
63
|
+
|
|
64
|
+
expect(
|
|
65
|
+
makeInlineStylesFor(
|
|
66
|
+
tailwindStyles.children.toArray(),
|
|
67
|
+
getCustomProperties(tailwindStyles),
|
|
68
|
+
),
|
|
69
|
+
).toMatchInlineSnapshot(`
|
|
70
|
+
{
|
|
71
|
+
"fontVariantNumeric": "tabular-nums",
|
|
72
|
+
}
|
|
73
|
+
`);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('preserves user-authored empty-fallback var() refs (non --tw- prefix)', () => {
|
|
77
|
+
// The collapse is scoped to Tailwind's --tw-* variant-stacking idiom.
|
|
78
|
+
// A user-authored var(--my-color,) with an empty fallback must pass
|
|
79
|
+
// through unchanged even though it syntactically matches the idiom --
|
|
80
|
+
// the user opted into that semantic and the render target may define
|
|
81
|
+
// --my-color at a higher scope.
|
|
82
|
+
const userStyles = parse(`
|
|
83
|
+
.thing {
|
|
84
|
+
color: var(--my-color,);
|
|
85
|
+
background: var(--brand,) var(--tw-custom,);
|
|
86
|
+
}
|
|
87
|
+
`) as StyleSheet;
|
|
88
|
+
|
|
89
|
+
expect(
|
|
90
|
+
makeInlineStylesFor(
|
|
91
|
+
userStyles.children.toArray(),
|
|
92
|
+
getCustomProperties(userStyles),
|
|
93
|
+
),
|
|
94
|
+
).toMatchInlineSnapshot(`
|
|
95
|
+
{
|
|
96
|
+
"background": "var(--brand,)",
|
|
97
|
+
"color": "var(--my-color,)",
|
|
98
|
+
}
|
|
99
|
+
`);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('collapses outer --tw-* var() that becomes empty after inner --tw-* var() collapses', () => {
|
|
103
|
+
// Regression test for cubic-dev-ai P2 review on PR #3359:
|
|
104
|
+
// pre-order traversal misses outer var(--tw-X, var(--tw-Y,)) because the
|
|
105
|
+
// outer's fallback only becomes empty AFTER the inner collapses. Post-order
|
|
106
|
+
// traversal fixes this.
|
|
107
|
+
const tailwindStyles = parse(`
|
|
108
|
+
.nested {
|
|
109
|
+
font-variant-numeric: var(--tw-outer, var(--tw-inner,)) tabular-nums;
|
|
110
|
+
}
|
|
111
|
+
`) as StyleSheet;
|
|
112
|
+
|
|
113
|
+
expect(
|
|
114
|
+
makeInlineStylesFor(
|
|
115
|
+
tailwindStyles.children.toArray(),
|
|
116
|
+
getCustomProperties(tailwindStyles),
|
|
117
|
+
),
|
|
118
|
+
).toMatchInlineSnapshot(`
|
|
119
|
+
{
|
|
120
|
+
"fontVariantNumeric": "tabular-nums",
|
|
121
|
+
}
|
|
122
|
+
`);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type CssNode, type Declaration, generate, walk } from 'css-tree';
|
|
2
|
+
import { getReactProperty } from '../compatibility/get-react-property.js';
|
|
3
|
+
import type { CustomProperties } from './get-custom-properties.js';
|
|
4
|
+
import { stripEmptyTailwindVars } from './strip-empty-tailwind-vars.js';
|
|
5
|
+
import { unwrapValue } from './unwrap-value.js';
|
|
6
|
+
|
|
7
|
+
export function makeInlineStylesFor(
|
|
8
|
+
inlinableRules: CssNode[],
|
|
9
|
+
customProperties: CustomProperties,
|
|
10
|
+
) {
|
|
11
|
+
const styles: Record<string, string> = {};
|
|
12
|
+
|
|
13
|
+
const localVariableDeclarations = new Map<string, Declaration>();
|
|
14
|
+
for (const rule of inlinableRules) {
|
|
15
|
+
walk(rule, {
|
|
16
|
+
visit: 'Declaration',
|
|
17
|
+
enter(declaration) {
|
|
18
|
+
if (declaration.property.startsWith('--')) {
|
|
19
|
+
localVariableDeclarations.set(declaration.property, declaration);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const rule of inlinableRules) {
|
|
26
|
+
walk(rule, {
|
|
27
|
+
visit: 'Function',
|
|
28
|
+
enter(func, funcParentListItem) {
|
|
29
|
+
if (func.name === 'var') {
|
|
30
|
+
let variableName: string | undefined;
|
|
31
|
+
walk(func, {
|
|
32
|
+
visit: 'Identifier',
|
|
33
|
+
enter(identifier) {
|
|
34
|
+
variableName = identifier.name;
|
|
35
|
+
return this.break;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (variableName) {
|
|
39
|
+
const definition = localVariableDeclarations.get(variableName);
|
|
40
|
+
if (definition) {
|
|
41
|
+
funcParentListItem.data = unwrapValue(definition.value);
|
|
42
|
+
} else {
|
|
43
|
+
// For most variables tailwindcss defines, they also define a custom
|
|
44
|
+
// property for them with an initial value that we can inline here
|
|
45
|
+
const customProperty = customProperties.get(variableName);
|
|
46
|
+
if (customProperty?.initialValue) {
|
|
47
|
+
funcParentListItem.data = unwrapValue(
|
|
48
|
+
customProperty.initialValue.value,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
walk(rule, {
|
|
58
|
+
visit: 'Declaration',
|
|
59
|
+
enter(declaration) {
|
|
60
|
+
if (declaration.property.startsWith('--')) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
stripEmptyTailwindVars(declaration.value);
|
|
64
|
+
|
|
65
|
+
styles[getReactProperty(declaration.property)] =
|
|
66
|
+
generate(declaration.value).trim() +
|
|
67
|
+
(declaration.important ? '!important' : '');
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return styles;
|
|
73
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { generate, parse } from 'css-tree';
|
|
2
|
+
import { resolveAllCssVariables } from './resolve-all-css-variables.js';
|
|
3
|
+
|
|
4
|
+
describe('resolveAllCSSVariables', () => {
|
|
5
|
+
it('ignores @layer (properties) defined for browser compatibility', () => {
|
|
6
|
+
const root =
|
|
7
|
+
parse(`/*! tailwindcss v4.1.12 | MIT License | https://tailwindcss.com */
|
|
8
|
+
@layer properties;
|
|
9
|
+
@layer theme, base, components, utilities;
|
|
10
|
+
@layer theme {
|
|
11
|
+
:root, :host {
|
|
12
|
+
--color-red-500: oklch(63.7% 0.237 25.331);
|
|
13
|
+
--color-blue-400: oklch(70.7% 0.165 254.624);
|
|
14
|
+
--color-blue-600: oklch(54.6% 0.245 262.881);
|
|
15
|
+
--color-gray-200: oklch(92.8% 0.006 264.531);
|
|
16
|
+
--color-black: #000;
|
|
17
|
+
--color-white: #fff;
|
|
18
|
+
--spacing: 0.25rem;
|
|
19
|
+
--text-sm: 0.875rem;
|
|
20
|
+
--text-sm--line-height: calc(1.25 / 0.875);
|
|
21
|
+
--radius-md: 0.375rem;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
@layer utilities {
|
|
25
|
+
.mt-8 {
|
|
26
|
+
margin-top: calc(var(--spacing) * 8);
|
|
27
|
+
}
|
|
28
|
+
.rounded-md {
|
|
29
|
+
border-radius: var(--radius-md);
|
|
30
|
+
}
|
|
31
|
+
.bg-blue-600 {
|
|
32
|
+
background-color: var(--color-blue-600);
|
|
33
|
+
}
|
|
34
|
+
.bg-red-500 {
|
|
35
|
+
background-color: var(--color-red-500);
|
|
36
|
+
}
|
|
37
|
+
.bg-white {
|
|
38
|
+
background-color: var(--color-white);
|
|
39
|
+
}
|
|
40
|
+
.p-4 {
|
|
41
|
+
padding: calc(var(--spacing) * 4);
|
|
42
|
+
}
|
|
43
|
+
.px-3 {
|
|
44
|
+
padding-inline: calc(var(--spacing) * 3);
|
|
45
|
+
}
|
|
46
|
+
.py-2 {
|
|
47
|
+
padding-block: calc(var(--spacing) * 2);
|
|
48
|
+
}
|
|
49
|
+
.text-sm {
|
|
50
|
+
font-size: var(--text-sm);
|
|
51
|
+
line-height: var(--tw-leading, var(--text-sm--line-height));
|
|
52
|
+
}
|
|
53
|
+
.text-\\\\[14px\\\\] {
|
|
54
|
+
font-size: 14px;
|
|
55
|
+
}
|
|
56
|
+
.leading-\\\\[24px\\\\] {
|
|
57
|
+
--tw-leading: 24px;
|
|
58
|
+
line-height: 24px;
|
|
59
|
+
}
|
|
60
|
+
.text-black {
|
|
61
|
+
color: var(--color-black);
|
|
62
|
+
}
|
|
63
|
+
.text-blue-400 {
|
|
64
|
+
color: var(--color-blue-400);
|
|
65
|
+
}
|
|
66
|
+
.text-blue-600 {
|
|
67
|
+
color: var(--color-blue-600);
|
|
68
|
+
}
|
|
69
|
+
.text-gray-200 {
|
|
70
|
+
color: var(--color-gray-200);
|
|
71
|
+
}
|
|
72
|
+
.no-underline {
|
|
73
|
+
text-decoration-line: none;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
@property --tw-leading {
|
|
77
|
+
syntax: "*";
|
|
78
|
+
inherits: false;
|
|
79
|
+
}
|
|
80
|
+
@layer properties {
|
|
81
|
+
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
82
|
+
*, ::before, ::after, ::backdrop {
|
|
83
|
+
--tw-leading: initial;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`);
|
|
88
|
+
resolveAllCssVariables(root);
|
|
89
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
90
|
+
`"/*! tailwindcss v4.1.12 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;@layer theme{:root,:host{--color-red-500: oklch(63.7% 0.237 25.331);--color-blue-400: oklch(70.7% 0.165 254.624);--color-blue-600: oklch(54.6% 0.245 262.881);--color-gray-200: oklch(92.8% 0.006 264.531);--color-black: #000;--color-white: #fff;--spacing: 0.25rem;--text-sm: 0.875rem;--text-sm--line-height: calc(1.25 / 0.875);--radius-md: 0.375rem}}@layer utilities{.mt-8{margin-top:calc(0.25rem*8)}.rounded-md{border-radius:0.375rem}.bg-blue-600{background-color:oklch(54.6%0.245 262.881)}.bg-red-500{background-color:oklch(63.7%0.237 25.331)}.bg-white{background-color:#fff}.p-4{padding:calc(0.25rem*4)}.px-3{padding-inline:calc(0.25rem*3)}.py-2{padding-block:calc(0.25rem*2)}.text-sm{font-size:0.875rem;line-height:calc(1.25/0.875)}.text-\\\\[14px\\\\]{font-size:14px}.leading-\\\\[24px\\\\]{--tw-leading: 24px;line-height:24px}.text-black{color:#000}.text-blue-400{color:oklch(70.7%0.165 254.624)}.text-blue-600{color:oklch(54.6%0.245 262.881)}.text-gray-200{color:oklch(92.8%0.006 264.531)}.no-underline{text-decoration-line:none}}@property --tw-leading{syntax:"*";inherits:false}@layer properties{@supports ((-webkit-hyphens:none) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::before,::after,::backdrop{--tw-leading: initial}}}"`,
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('works with simple css variables on a :root', () => {
|
|
95
|
+
const root = parse(`:root {
|
|
96
|
+
--width: 100px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.box {
|
|
100
|
+
width: var(--width);
|
|
101
|
+
}`);
|
|
102
|
+
resolveAllCssVariables(root);
|
|
103
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
104
|
+
`":root{--width: 100px}.box{width:100px}"`,
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('works for variables across different CSS layers', () => {
|
|
109
|
+
const root = parse(`@layer base {
|
|
110
|
+
:root {
|
|
111
|
+
--width: 100px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@layer utilities {
|
|
116
|
+
.box {
|
|
117
|
+
width: var(--width);
|
|
118
|
+
}
|
|
119
|
+
}`);
|
|
120
|
+
resolveAllCssVariables(root);
|
|
121
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
122
|
+
`"@layer base{:root{--width: 100px}}@layer utilities{.box{width:100px}}"`,
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('works with multiple variables in the same declaration', () => {
|
|
127
|
+
const root = parse(`:root {
|
|
128
|
+
--top: 101px;
|
|
129
|
+
--bottom: 102px;
|
|
130
|
+
--right: 103px;
|
|
131
|
+
--left: 104px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.box {
|
|
135
|
+
margin: var(--top) var(--right) var(--bottom) var(--left);
|
|
136
|
+
}`);
|
|
137
|
+
|
|
138
|
+
resolveAllCssVariables(root);
|
|
139
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
140
|
+
`":root{--top: 101px;--bottom: 102px;--right: 103px;--left: 104px}.box{margin:101px 103px 102px 104px}"`,
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('keeps variable usages if it cant find their declaration', () => {
|
|
145
|
+
const root = parse(`.box {
|
|
146
|
+
width: var(--width);
|
|
147
|
+
}`);
|
|
148
|
+
resolveAllCssVariables(root);
|
|
149
|
+
expect(generate(root)).toMatchInlineSnapshot(`".box{width:var(--width)}"`);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('works with variables set in the same rule', () => {
|
|
153
|
+
const root = parse(`.box {
|
|
154
|
+
--width: 200px;
|
|
155
|
+
width: var(--width);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@media (min-width: 1280px) {
|
|
159
|
+
.xl\\\\:bg-green-500 {
|
|
160
|
+
--tw-bg-opacity: 1;
|
|
161
|
+
background-color: rgb(34 197 94 / var(--tw-bg-opacity))
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
`);
|
|
165
|
+
resolveAllCssVariables(root);
|
|
166
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
167
|
+
`".box{--width: 200px;width:200px}@media (min-width:1280px){.xl\\\\:bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94/1)}}"`,
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('works with a variable set in a layer, and used in another through a media query', () => {
|
|
172
|
+
const root = parse(`@layer theme {
|
|
173
|
+
:root {
|
|
174
|
+
--color-blue-300: blue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@layer utilities {
|
|
179
|
+
.sm\\\\:bg-blue-300 {
|
|
180
|
+
@media (width >= 40rem) {
|
|
181
|
+
background-color: var(--color-blue-300);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}`);
|
|
185
|
+
resolveAllCssVariables(root);
|
|
186
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
187
|
+
`"@layer theme{:root{--color-blue-300: blue}}@layer utilities{.sm\\\\:bg-blue-300{@media (width>=40rem){background-color:blue}}}"`,
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('uses fallback values when variable definition is not found', () => {
|
|
192
|
+
const root = parse(`.box {
|
|
193
|
+
width: var(--undefined-width, 150px);
|
|
194
|
+
height: var(--undefined-height, 200px);
|
|
195
|
+
margin: var(--undefined-margin, 10px 20px);
|
|
196
|
+
}`);
|
|
197
|
+
resolveAllCssVariables(root);
|
|
198
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
199
|
+
`".box{width:150px;height:200px;margin:10px 20px}"`,
|
|
200
|
+
);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('handles nested var() functions in fallbacks', () => {
|
|
204
|
+
const root = parse(`:root {
|
|
205
|
+
--fallback-width: 300px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.box {
|
|
209
|
+
width: var(--undefined-width, var(--fallback-width));
|
|
210
|
+
height: var(--undefined-height, var(--also-undefined, 250px));
|
|
211
|
+
}`);
|
|
212
|
+
resolveAllCssVariables(root);
|
|
213
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
214
|
+
`":root{--fallback-width: 300px}.box{width:300px;height:250px}"`,
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('handles deeply nested var() functions with complex parentheses', () => {
|
|
219
|
+
const root = parse(`:root {
|
|
220
|
+
--primary: blue;
|
|
221
|
+
--secondary: red;
|
|
222
|
+
--fallback: green;
|
|
223
|
+
--size: 20px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.box {
|
|
227
|
+
color: var(--primary, var(--secondary, var(--fallback)));
|
|
228
|
+
width: var(--size, calc(100px + var(--size, 20px)));
|
|
229
|
+
border: var(--border-width, var(--border-style, var(--border-color, 1px solid black)));
|
|
230
|
+
--r: 100;
|
|
231
|
+
--b: 10;
|
|
232
|
+
background: var(--bg-color, rgb(var(--r, 255), var(--g, 0), var(--b, 0)));
|
|
233
|
+
}`);
|
|
234
|
+
resolveAllCssVariables(root);
|
|
235
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
236
|
+
`":root{--primary: blue;--secondary: red;--fallback: green;--size: 20px}.box{color:blue;width:20px;border:1px solid black;--r: 100;--b: 10;background:rgb(100,0,10)}"`,
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('does not leak variables across sibling nested at-rules within the same rule', () => {
|
|
241
|
+
const root = parse(`.print_invert {
|
|
242
|
+
@media print {
|
|
243
|
+
--tw-invert: invert(100%);
|
|
244
|
+
filter: var(--tw-invert, none);
|
|
245
|
+
}
|
|
246
|
+
@media screen {
|
|
247
|
+
filter: var(--tw-invert, none);
|
|
248
|
+
}
|
|
249
|
+
}`);
|
|
250
|
+
resolveAllCssVariables(root);
|
|
251
|
+
expect(generate(root)).toMatchInlineSnapshot(
|
|
252
|
+
`".print_invert{@media print{--tw-invert: invert(100%);filter:invert(100%)}@media screen{filter:none}}"`,
|
|
253
|
+
);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('handles selectors with asterisks in attribute selectors and pseudo-functions', () => {
|
|
257
|
+
const root = parse(`* {
|
|
258
|
+
--global-color: red;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
input[type="*"]:hover {
|
|
262
|
+
color: var(--global-color);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
div:nth-child(2*n+1) {
|
|
266
|
+
background: var(--global-color);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.test[data-attr="value*test"] {
|
|
270
|
+
border-color: var(--global-color);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.universal-with-class-* {
|
|
274
|
+
--class-color: blue;
|
|
275
|
+
text-decoration: var(--class-color);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.normal {
|
|
279
|
+
color: var(--class-color);
|
|
280
|
+
}`);
|
|
281
|
+
|
|
282
|
+
resolveAllCssVariables(root);
|
|
283
|
+
const result = generate(root);
|
|
284
|
+
|
|
285
|
+
// Variables from universal selector (*) should resolve to other selectors with actual universal selector
|
|
286
|
+
expect(result).toContain('input[type="*"]:hover{color:red}');
|
|
287
|
+
expect(result).toContain('div:nth-child(2*n+1){background:red}');
|
|
288
|
+
expect(result).toContain('.test[data-attr="value*test"]{border-color:red}');
|
|
289
|
+
|
|
290
|
+
// Variables from *.universal-with-class should resolve within the same selector and to .normal
|
|
291
|
+
expect(result).toContain(
|
|
292
|
+
'.universal-with-class-*{--class-color: blue;text-decoration:blue}',
|
|
293
|
+
);
|
|
294
|
+
expect(result).toContain('.normal{color:var(--class-color)}');
|
|
295
|
+
});
|
|
296
|
+
});
|