@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,88 @@
|
|
|
1
|
+
import { generate, parse, walk } from "css-tree/dist/csstree.esm";
|
|
2
|
+
//#region src/components/tailwind/utils/css/resolve-all-css-variables.ts
|
|
3
|
+
function doSelectorsIntersect(first, second) {
|
|
4
|
+
if (generate(first) === generate(second)) return true;
|
|
5
|
+
let hasSomeUniversal = false;
|
|
6
|
+
const walker = (node, _parentListItem, parentList) => {
|
|
7
|
+
if (hasSomeUniversal) return;
|
|
8
|
+
if (node.type === "PseudoClassSelector" && node.name === "root") hasSomeUniversal = true;
|
|
9
|
+
if (node.type === "TypeSelector" && node.name === "*" && parentList.size === 1) hasSomeUniversal = true;
|
|
10
|
+
};
|
|
11
|
+
walk(first, walker);
|
|
12
|
+
walk(second, walker);
|
|
13
|
+
if (hasSomeUniversal) return true;
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
function resolveAllCssVariables(node) {
|
|
17
|
+
const variableDefinitions = /* @__PURE__ */ new Set();
|
|
18
|
+
const variableUses = /* @__PURE__ */ new Set();
|
|
19
|
+
const path = [];
|
|
20
|
+
walk(node, {
|
|
21
|
+
leave() {
|
|
22
|
+
path.shift();
|
|
23
|
+
},
|
|
24
|
+
enter(node) {
|
|
25
|
+
if (node.type === "Declaration") {
|
|
26
|
+
const declaration = node;
|
|
27
|
+
if (path.some((ancestor) => ancestor.type === "Atrule" && ancestor.name === "layer" && ancestor.prelude !== null && generate(ancestor.prelude).includes("properties"))) {
|
|
28
|
+
path.unshift(node);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (/--[\S]+/.test(declaration.property)) variableDefinitions.add({
|
|
32
|
+
declaration,
|
|
33
|
+
path: [...path],
|
|
34
|
+
variableName: declaration.property,
|
|
35
|
+
definition: generate(declaration.value)
|
|
36
|
+
});
|
|
37
|
+
else {
|
|
38
|
+
function parseVariableUsesFrom(node) {
|
|
39
|
+
walk(node, {
|
|
40
|
+
visit: "Function",
|
|
41
|
+
enter(funcNode) {
|
|
42
|
+
if (funcNode.name === "var") {
|
|
43
|
+
const children = funcNode.children.toArray();
|
|
44
|
+
const name = generate(children[0]);
|
|
45
|
+
const fallback = children[2] ? generate(children[2]) : void 0;
|
|
46
|
+
variableUses.add({
|
|
47
|
+
declaration,
|
|
48
|
+
path: [...path],
|
|
49
|
+
fallback,
|
|
50
|
+
variableName: name,
|
|
51
|
+
raw: generate(funcNode)
|
|
52
|
+
});
|
|
53
|
+
if (fallback?.includes("var(")) parseVariableUsesFrom(parse(fallback, { context: "value" }));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
parseVariableUsesFrom(declaration.value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
path.unshift(node);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
for (const use of variableUses) {
|
|
65
|
+
let hasReplaced = false;
|
|
66
|
+
for (const definition of variableDefinitions) {
|
|
67
|
+
if (use.variableName !== definition.variableName) continue;
|
|
68
|
+
if (use.path[0]?.type === "Block" && use.path[1]?.type === "Atrule" && use.path[2]?.type === "Block" && use.path[3]?.type === "Rule" && definition.path[0].type === "Block" && definition.path[1].type === "Rule" && doSelectorsIntersect(use.path[3].prelude, definition.path[1].prelude)) {
|
|
69
|
+
use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
|
|
70
|
+
hasReplaced = true;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (use.path[0]?.type === "Block" && use.path[1]?.type === "Rule" && definition.path[0]?.type === "Block" && definition.path[1]?.type === "Rule" && doSelectorsIntersect(use.path[1].prelude, definition.path[1].prelude)) {
|
|
74
|
+
use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
|
|
75
|
+
hasReplaced = true;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
if (use.path[0]?.type === "Block" && use.path[1]?.type === "Atrule" && use.path[2]?.type === "Block" && use.path[3]?.type === "Rule" && definition.path[0]?.type === "Block" && definition.path[1]?.type === "Atrule" && definition.path[2]?.type === "Block" && definition.path[3]?.type === "Rule" && use.path[1].name === definition.path[1].name && (use.path[1].prelude ? definition.path[1].prelude ? generate(use.path[1].prelude) === generate(definition.path[1].prelude) : false : definition.path[1].prelude === null) && doSelectorsIntersect(use.path[3].prelude, definition.path[3].prelude)) {
|
|
79
|
+
use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, definition.definition), { context: "value" });
|
|
80
|
+
hasReplaced = true;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!hasReplaced && use.fallback) use.declaration.value = parse(generate(use.declaration.value).replaceAll(use.raw, use.fallback), { context: "value" });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { resolveAllCssVariables };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let css_tree = require("css-tree");
|
|
3
|
+
//#region src/components/tailwind/utils/css/resolve-calc-expressions.ts
|
|
4
|
+
/**
|
|
5
|
+
* Intentionally only resolves `*` and `/` operations without dealing with parenthesis, because this is the only thing required to run Tailwind v4
|
|
6
|
+
*/
|
|
7
|
+
function resolveCalcExpressions(node) {
|
|
8
|
+
(0, css_tree.walk)(node, {
|
|
9
|
+
visit: "Function",
|
|
10
|
+
enter(func, funcListItem) {
|
|
11
|
+
if (func.name === "calc") {
|
|
12
|
+
func.children.forEach((child, item) => {
|
|
13
|
+
const left = item.prev;
|
|
14
|
+
const right = item.next;
|
|
15
|
+
if (left && right && child.type === "Operator" && (left.data.type === "Dimension" || left.data.type === "Number" || left.data.type === "Percentage") && (right.data.type === "Dimension" || right.data.type === "Number" || right.data.type === "Percentage")) {
|
|
16
|
+
if (child.value === "*" || child.value === "/") {
|
|
17
|
+
const value = (() => {
|
|
18
|
+
if (child.value === "*") return String(Number.parseFloat(left.data.value) * Number.parseFloat(right.data.value));
|
|
19
|
+
if (right.data.value === "0") return "0";
|
|
20
|
+
return String(Number.parseFloat(left.data.value) / Number.parseFloat(right.data.value));
|
|
21
|
+
})();
|
|
22
|
+
if (left.data.type === "Dimension" && right.data.type === "Number") {
|
|
23
|
+
item.data = {
|
|
24
|
+
type: "Dimension",
|
|
25
|
+
unit: left.data.unit,
|
|
26
|
+
value
|
|
27
|
+
};
|
|
28
|
+
func.children.remove(left);
|
|
29
|
+
func.children.remove(right);
|
|
30
|
+
} else if (left.data.type === "Number" && right.data.type === "Dimension") {
|
|
31
|
+
item.data = {
|
|
32
|
+
type: "Dimension",
|
|
33
|
+
unit: right.data.unit,
|
|
34
|
+
value
|
|
35
|
+
};
|
|
36
|
+
func.children.remove(left);
|
|
37
|
+
func.children.remove(right);
|
|
38
|
+
} else if (left.data.type === "Number" && right.data.type === "Number") {
|
|
39
|
+
item.data = {
|
|
40
|
+
type: "Number",
|
|
41
|
+
value
|
|
42
|
+
};
|
|
43
|
+
func.children.remove(left);
|
|
44
|
+
func.children.remove(right);
|
|
45
|
+
} else if (left.data.type === "Dimension" && right.data.type === "Dimension" && left.data.unit === right.data.unit) {
|
|
46
|
+
if (child.value === "/") item.data = {
|
|
47
|
+
type: "Number",
|
|
48
|
+
value
|
|
49
|
+
};
|
|
50
|
+
else item.data = {
|
|
51
|
+
type: "Dimension",
|
|
52
|
+
unit: left.data.unit,
|
|
53
|
+
value
|
|
54
|
+
};
|
|
55
|
+
func.children.remove(left);
|
|
56
|
+
func.children.remove(right);
|
|
57
|
+
} else if (left.data.type === "Percentage" && right.data.type === "Number") {
|
|
58
|
+
item.data = {
|
|
59
|
+
type: "Percentage",
|
|
60
|
+
value
|
|
61
|
+
};
|
|
62
|
+
func.children.remove(left);
|
|
63
|
+
func.children.remove(right);
|
|
64
|
+
} else if (left.data.type === "Number" && right.data.type === "Percentage") {
|
|
65
|
+
item.data = {
|
|
66
|
+
type: "Percentage",
|
|
67
|
+
value
|
|
68
|
+
};
|
|
69
|
+
func.children.remove(left);
|
|
70
|
+
func.children.remove(right);
|
|
71
|
+
} else if (left.data.type === "Percentage" && right.data.type === "Percentage") {
|
|
72
|
+
if (child.value === "/") item.data = {
|
|
73
|
+
type: "Number",
|
|
74
|
+
value
|
|
75
|
+
};
|
|
76
|
+
else item.data = {
|
|
77
|
+
type: "Percentage",
|
|
78
|
+
value
|
|
79
|
+
};
|
|
80
|
+
func.children.remove(left);
|
|
81
|
+
func.children.remove(right);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (func.children.size === 1 && func.children.first) funcListItem.data = func.children.first;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
exports.resolveCalcExpressions = resolveCalcExpressions;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { walk } from "css-tree/dist/csstree.esm";
|
|
2
|
+
//#region src/components/tailwind/utils/css/resolve-calc-expressions.ts
|
|
3
|
+
/**
|
|
4
|
+
* Intentionally only resolves `*` and `/` operations without dealing with parenthesis, because this is the only thing required to run Tailwind v4
|
|
5
|
+
*/
|
|
6
|
+
function resolveCalcExpressions(node) {
|
|
7
|
+
walk(node, {
|
|
8
|
+
visit: "Function",
|
|
9
|
+
enter(func, funcListItem) {
|
|
10
|
+
if (func.name === "calc") {
|
|
11
|
+
func.children.forEach((child, item) => {
|
|
12
|
+
const left = item.prev;
|
|
13
|
+
const right = item.next;
|
|
14
|
+
if (left && right && child.type === "Operator" && (left.data.type === "Dimension" || left.data.type === "Number" || left.data.type === "Percentage") && (right.data.type === "Dimension" || right.data.type === "Number" || right.data.type === "Percentage")) {
|
|
15
|
+
if (child.value === "*" || child.value === "/") {
|
|
16
|
+
const value = (() => {
|
|
17
|
+
if (child.value === "*") return String(Number.parseFloat(left.data.value) * Number.parseFloat(right.data.value));
|
|
18
|
+
if (right.data.value === "0") return "0";
|
|
19
|
+
return String(Number.parseFloat(left.data.value) / Number.parseFloat(right.data.value));
|
|
20
|
+
})();
|
|
21
|
+
if (left.data.type === "Dimension" && right.data.type === "Number") {
|
|
22
|
+
item.data = {
|
|
23
|
+
type: "Dimension",
|
|
24
|
+
unit: left.data.unit,
|
|
25
|
+
value
|
|
26
|
+
};
|
|
27
|
+
func.children.remove(left);
|
|
28
|
+
func.children.remove(right);
|
|
29
|
+
} else if (left.data.type === "Number" && right.data.type === "Dimension") {
|
|
30
|
+
item.data = {
|
|
31
|
+
type: "Dimension",
|
|
32
|
+
unit: right.data.unit,
|
|
33
|
+
value
|
|
34
|
+
};
|
|
35
|
+
func.children.remove(left);
|
|
36
|
+
func.children.remove(right);
|
|
37
|
+
} else if (left.data.type === "Number" && right.data.type === "Number") {
|
|
38
|
+
item.data = {
|
|
39
|
+
type: "Number",
|
|
40
|
+
value
|
|
41
|
+
};
|
|
42
|
+
func.children.remove(left);
|
|
43
|
+
func.children.remove(right);
|
|
44
|
+
} else if (left.data.type === "Dimension" && right.data.type === "Dimension" && left.data.unit === right.data.unit) {
|
|
45
|
+
if (child.value === "/") item.data = {
|
|
46
|
+
type: "Number",
|
|
47
|
+
value
|
|
48
|
+
};
|
|
49
|
+
else item.data = {
|
|
50
|
+
type: "Dimension",
|
|
51
|
+
unit: left.data.unit,
|
|
52
|
+
value
|
|
53
|
+
};
|
|
54
|
+
func.children.remove(left);
|
|
55
|
+
func.children.remove(right);
|
|
56
|
+
} else if (left.data.type === "Percentage" && right.data.type === "Number") {
|
|
57
|
+
item.data = {
|
|
58
|
+
type: "Percentage",
|
|
59
|
+
value
|
|
60
|
+
};
|
|
61
|
+
func.children.remove(left);
|
|
62
|
+
func.children.remove(right);
|
|
63
|
+
} else if (left.data.type === "Number" && right.data.type === "Percentage") {
|
|
64
|
+
item.data = {
|
|
65
|
+
type: "Percentage",
|
|
66
|
+
value
|
|
67
|
+
};
|
|
68
|
+
func.children.remove(left);
|
|
69
|
+
func.children.remove(right);
|
|
70
|
+
} else if (left.data.type === "Percentage" && right.data.type === "Percentage") {
|
|
71
|
+
if (child.value === "/") item.data = {
|
|
72
|
+
type: "Number",
|
|
73
|
+
value
|
|
74
|
+
};
|
|
75
|
+
else item.data = {
|
|
76
|
+
type: "Percentage",
|
|
77
|
+
value
|
|
78
|
+
};
|
|
79
|
+
func.children.remove(left);
|
|
80
|
+
func.children.remove(right);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (func.children.size === 1 && func.children.first) funcListItem.data = func.children.first;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { resolveCalcExpressions };
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let css_tree = require("css-tree");
|
|
3
|
+
//#region src/components/tailwind/utils/css/sanitize-declarations.ts
|
|
4
|
+
function rgbNode(r, g, b, alpha) {
|
|
5
|
+
const children = new css_tree.List();
|
|
6
|
+
children.appendData({
|
|
7
|
+
type: "Number",
|
|
8
|
+
value: r.toFixed(0)
|
|
9
|
+
});
|
|
10
|
+
children.appendData({
|
|
11
|
+
type: "Operator",
|
|
12
|
+
value: ","
|
|
13
|
+
});
|
|
14
|
+
children.appendData({
|
|
15
|
+
type: "Number",
|
|
16
|
+
value: g.toFixed(0)
|
|
17
|
+
});
|
|
18
|
+
children.appendData({
|
|
19
|
+
type: "Operator",
|
|
20
|
+
value: ","
|
|
21
|
+
});
|
|
22
|
+
children.appendData({
|
|
23
|
+
type: "Number",
|
|
24
|
+
value: b.toFixed(0)
|
|
25
|
+
});
|
|
26
|
+
if (alpha !== 1 && alpha !== void 0) {
|
|
27
|
+
children.appendData({
|
|
28
|
+
type: "Operator",
|
|
29
|
+
value: ","
|
|
30
|
+
});
|
|
31
|
+
children.appendData({
|
|
32
|
+
type: "Number",
|
|
33
|
+
value: alpha.toString()
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
type: "Function",
|
|
38
|
+
name: "rgb",
|
|
39
|
+
children
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const LAB_TO_LMS = {
|
|
43
|
+
l: [.3963377773761749, .2158037573099136],
|
|
44
|
+
m: [-.1055613458156586, -.0638541728258133],
|
|
45
|
+
s: [-.0894841775298119, -1.2914855480194092]
|
|
46
|
+
};
|
|
47
|
+
const LSM_TO_RGB = {
|
|
48
|
+
r: [
|
|
49
|
+
4.076741636075958,
|
|
50
|
+
-3.307711539258063,
|
|
51
|
+
.2309699031821043
|
|
52
|
+
],
|
|
53
|
+
g: [
|
|
54
|
+
-1.2684379732850315,
|
|
55
|
+
2.609757349287688,
|
|
56
|
+
-.341319376002657
|
|
57
|
+
],
|
|
58
|
+
b: [
|
|
59
|
+
-.0041960761386756,
|
|
60
|
+
-.7034186179359362,
|
|
61
|
+
1.7076146940746117
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
function lrgbToRgb(input) {
|
|
65
|
+
const absoluteNumber = Math.abs(input);
|
|
66
|
+
const sign = input < 0 ? -1 : 1;
|
|
67
|
+
if (absoluteNumber > .0031308) return sign * (absoluteNumber ** (1 / 2.4) * 1.055 - .055);
|
|
68
|
+
return input * 12.92;
|
|
69
|
+
}
|
|
70
|
+
function clamp(value, min, max) {
|
|
71
|
+
return Math.min(Math.max(value, min), max);
|
|
72
|
+
}
|
|
73
|
+
function oklchToOklab(oklch) {
|
|
74
|
+
return {
|
|
75
|
+
l: oklch.l,
|
|
76
|
+
a: oklch.c * Math.cos(oklch.h / 180 * Math.PI),
|
|
77
|
+
b: oklch.c * Math.sin(oklch.h / 180 * Math.PI)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Convert oklab to RGB */
|
|
81
|
+
function oklchToRgb(oklch) {
|
|
82
|
+
const oklab = oklchToOklab(oklch);
|
|
83
|
+
const l = (oklab.l + LAB_TO_LMS.l[0] * oklab.a + LAB_TO_LMS.l[1] * oklab.b) ** 3;
|
|
84
|
+
const m = (oklab.l + LAB_TO_LMS.m[0] * oklab.a + LAB_TO_LMS.m[1] * oklab.b) ** 3;
|
|
85
|
+
const s = (oklab.l + LAB_TO_LMS.s[0] * oklab.a + LAB_TO_LMS.s[1] * oklab.b) ** 3;
|
|
86
|
+
const r = 255 * lrgbToRgb(LSM_TO_RGB.r[0] * l + LSM_TO_RGB.r[1] * m + LSM_TO_RGB.r[2] * s);
|
|
87
|
+
const g = 255 * lrgbToRgb(LSM_TO_RGB.g[0] * l + LSM_TO_RGB.g[1] * m + LSM_TO_RGB.g[2] * s);
|
|
88
|
+
const b = 255 * lrgbToRgb(LSM_TO_RGB.b[0] * l + LSM_TO_RGB.b[1] * m + LSM_TO_RGB.b[2] * s);
|
|
89
|
+
return {
|
|
90
|
+
r: clamp(r, 0, 255),
|
|
91
|
+
g: clamp(g, 0, 255),
|
|
92
|
+
b: clamp(b, 0, 255)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function separteShorthandDeclaration(shorthandToReplace, [start, end]) {
|
|
96
|
+
shorthandToReplace.property = start;
|
|
97
|
+
const values = shorthandToReplace.value.type === "Value" ? shorthandToReplace.value.children.toArray().filter((child) => child.type !== "Operator" && child.type !== "WhiteSpace") : [shorthandToReplace.value];
|
|
98
|
+
let endValue = shorthandToReplace.value;
|
|
99
|
+
if (values.length === 2) {
|
|
100
|
+
endValue = {
|
|
101
|
+
type: "Value",
|
|
102
|
+
children: new css_tree.List().fromArray([values[1]])
|
|
103
|
+
};
|
|
104
|
+
shorthandToReplace.value = {
|
|
105
|
+
type: "Value",
|
|
106
|
+
children: new css_tree.List().fromArray([values[0]])
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
type: "Declaration",
|
|
111
|
+
property: end,
|
|
112
|
+
value: endValue,
|
|
113
|
+
important: shorthandToReplace.important
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Meant to do all the things necessary, in a per-declaration basis, to have the best email client
|
|
118
|
+
* support possible.
|
|
119
|
+
*
|
|
120
|
+
* Here's the transformations it does so far:
|
|
121
|
+
* - convert all `rgb` with space-based syntax into a comma based one;
|
|
122
|
+
* - convert all `oklch` values into `rgb`;
|
|
123
|
+
* - convert all hex values into `rgb`;
|
|
124
|
+
* - convert `padding-inline` into `padding-left` and `padding-right`;
|
|
125
|
+
* - convert `padding-block` into `padding-top` and `padding-bottom`;
|
|
126
|
+
* - convert `margin-inline` into `margin-left` and `margin-right`;
|
|
127
|
+
* - convert `margin-block` into `margin-top` and `margin-bottom`.
|
|
128
|
+
*/
|
|
129
|
+
function sanitizeDeclarations(nodeContainingDeclarations) {
|
|
130
|
+
(0, css_tree.walk)(nodeContainingDeclarations, {
|
|
131
|
+
visit: "Declaration",
|
|
132
|
+
enter(declaration, item, list) {
|
|
133
|
+
if (declaration.value.type === "Raw") declaration.value = (0, css_tree.parse)(declaration.value.value, { context: "value" });
|
|
134
|
+
if (/border-(?:[a-z]+-){0,2}radius\s*:\s*calc\s*\(\s*infinity\s*\*\s*1px\s*\)/i.test((0, css_tree.generate)(declaration))) declaration.value = (0, css_tree.parse)("9999px", { context: "value" });
|
|
135
|
+
(0, css_tree.walk)(declaration, {
|
|
136
|
+
visit: "Function",
|
|
137
|
+
enter(func, funcParentListItem) {
|
|
138
|
+
const children = func.children.toArray();
|
|
139
|
+
if (func.name === "oklch") {
|
|
140
|
+
let l;
|
|
141
|
+
let c;
|
|
142
|
+
let h;
|
|
143
|
+
let a;
|
|
144
|
+
for (const child of children) {
|
|
145
|
+
if (child.type === "Number") {
|
|
146
|
+
if (l === void 0) {
|
|
147
|
+
l = Number.parseFloat(child.value);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (c === void 0) {
|
|
151
|
+
c = Number.parseFloat(child.value);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (h === void 0) {
|
|
155
|
+
h = Number.parseFloat(child.value);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (a === void 0) {
|
|
159
|
+
a = Number.parseFloat(child.value);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (child.type === "Dimension" && child.unit === "deg") {
|
|
164
|
+
if (h === void 0) {
|
|
165
|
+
h = Number.parseFloat(child.value);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (child.type === "Percentage") {
|
|
170
|
+
if (l === void 0) {
|
|
171
|
+
l = Number.parseFloat(child.value) / 100;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (a === void 0) a = Number.parseFloat(child.value) / 100;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (l === void 0 || c === void 0 || h === void 0) throw new Error("Could not determine the parameters of an oklch() function.", { cause: declaration });
|
|
178
|
+
const rgb = oklchToRgb({
|
|
179
|
+
l,
|
|
180
|
+
c,
|
|
181
|
+
h
|
|
182
|
+
});
|
|
183
|
+
funcParentListItem.data = rgbNode(rgb.r, rgb.g, rgb.b, a);
|
|
184
|
+
}
|
|
185
|
+
if (func.name === "rgb" || func.name === "rgba") {
|
|
186
|
+
let r;
|
|
187
|
+
let g;
|
|
188
|
+
let b;
|
|
189
|
+
let a;
|
|
190
|
+
for (const child of children) {
|
|
191
|
+
if (child.type === "Number") {
|
|
192
|
+
if (r === void 0) {
|
|
193
|
+
r = Number.parseFloat(child.value);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (g === void 0) {
|
|
197
|
+
g = Number.parseFloat(child.value);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (b === void 0) {
|
|
201
|
+
b = Number.parseFloat(child.value);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (a === void 0) {
|
|
205
|
+
a = Number.parseFloat(child.value);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (child.type === "Percentage") {
|
|
210
|
+
if (r === void 0) {
|
|
211
|
+
r = Number.parseFloat(child.value) * 255 / 100;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (g === void 0) {
|
|
215
|
+
g = Number.parseFloat(child.value) * 255 / 100;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (b === void 0) {
|
|
219
|
+
b = Number.parseFloat(child.value) * 255 / 100;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (a === void 0) a = Number.parseFloat(child.value) / 100;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (r === void 0 || g === void 0 || b === void 0) throw new Error("Could not determine the parameters of an rgb() function.", { cause: declaration });
|
|
226
|
+
if (a === void 0 || a === 1) funcParentListItem.data = rgbNode(r, g, b);
|
|
227
|
+
else funcParentListItem.data = rgbNode(r, g, b, a);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
(0, css_tree.walk)(declaration, {
|
|
232
|
+
visit: "Hash",
|
|
233
|
+
enter(hash, hashParentListItem) {
|
|
234
|
+
const hex = hash.value.trim();
|
|
235
|
+
if (hex.length === 3) {
|
|
236
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.charAt(0) + hex.charAt(0), 16), Number.parseInt(hex.charAt(1) + hex.charAt(1), 16), Number.parseInt(hex.charAt(2) + hex.charAt(2), 16));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (hex.length === 4) {
|
|
240
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.charAt(0) + hex.charAt(0), 16), Number.parseInt(hex.charAt(1) + hex.charAt(1), 16), Number.parseInt(hex.charAt(2) + hex.charAt(2), 16), Number.parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (hex.length === 5) {
|
|
244
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.charAt(2) + hex.charAt(2), 16), Number.parseInt(hex.charAt(3) + hex.charAt(3), 16), Number.parseInt(hex.charAt(4) + hex.charAt(4), 16) / 255);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (hex.length === 6) {
|
|
248
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.slice(2, 4), 16), Number.parseInt(hex.slice(4, 6), 16));
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (hex.length === 7) {
|
|
252
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.slice(2, 4), 16), Number.parseInt(hex.slice(4, 6), 16), Number.parseInt(hex.charAt(6) + hex.charAt(6), 16) / 255);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
hashParentListItem.data = rgbNode(Number.parseInt(hex.slice(0, 2), 16), Number.parseInt(hex.slice(2, 4), 16), Number.parseInt(hex.slice(4, 6), 16), Number.parseInt(hex.slice(6, 8), 16) / 255);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
(0, css_tree.walk)(declaration, {
|
|
259
|
+
visit: "Function",
|
|
260
|
+
enter(func, parentListItem) {
|
|
261
|
+
if (func.name === "color-mix") {
|
|
262
|
+
const children = func.children.toArray();
|
|
263
|
+
const color = children[3];
|
|
264
|
+
const opacity = children[4];
|
|
265
|
+
if (func.children.last?.type === "Identifier" && func.children.last.name === "transparent" && color?.type === "Function" && color?.name === "rgb" && opacity) {
|
|
266
|
+
if (opacity.type === "Percentage") {
|
|
267
|
+
const alpha = Number.parseFloat(opacity.value) / 100;
|
|
268
|
+
if (alpha < 1) {
|
|
269
|
+
color.children.appendData({
|
|
270
|
+
type: "Operator",
|
|
271
|
+
value: ","
|
|
272
|
+
});
|
|
273
|
+
color.children.appendData({
|
|
274
|
+
type: "Number",
|
|
275
|
+
value: alpha.toString()
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
color.children.appendData({
|
|
280
|
+
type: "Operator",
|
|
281
|
+
value: ","
|
|
282
|
+
});
|
|
283
|
+
color.children.appendData(opacity);
|
|
284
|
+
}
|
|
285
|
+
parentListItem.data = color;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
if (declaration.property === "padding-inline") {
|
|
291
|
+
const paddingRight = separteShorthandDeclaration(declaration, ["padding-left", "padding-right"]);
|
|
292
|
+
list.insertData(paddingRight, item);
|
|
293
|
+
}
|
|
294
|
+
if (declaration.property === "padding-block") {
|
|
295
|
+
const paddingBottom = separteShorthandDeclaration(declaration, ["padding-top", "padding-bottom"]);
|
|
296
|
+
list.insertData(paddingBottom, item);
|
|
297
|
+
}
|
|
298
|
+
if (declaration.property === "margin-inline") {
|
|
299
|
+
const marginRight = separteShorthandDeclaration(declaration, ["margin-left", "margin-right"]);
|
|
300
|
+
list.insertData(marginRight, item);
|
|
301
|
+
}
|
|
302
|
+
if (declaration.property === "margin-block") {
|
|
303
|
+
const paddingBottom = separteShorthandDeclaration(declaration, ["margin-top", "margin-bottom"]);
|
|
304
|
+
list.insertData(paddingBottom, item);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
exports.sanitizeDeclarations = sanitizeDeclarations;
|