rnwind 0.0.1 → 0.0.3
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/lib/cjs/core/parser/animation.cjs +427 -0
- package/lib/cjs/core/parser/animation.cjs.map +1 -0
- package/lib/cjs/core/parser/animation.d.ts +126 -0
- package/lib/cjs/core/parser/border-dispatcher.cjs +180 -0
- package/lib/cjs/core/parser/border-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/border-dispatcher.d.ts +15 -0
- package/lib/cjs/core/parser/case-convert.cjs +15 -0
- package/lib/cjs/core/parser/case-convert.cjs.map +1 -0
- package/lib/cjs/core/parser/case-convert.d.ts +6 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.cjs +84 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.d.ts +19 -0
- package/lib/cjs/core/parser/color.cjs +193 -0
- package/lib/cjs/core/parser/color.cjs.map +1 -0
- package/lib/cjs/core/parser/color.d.ts +12 -0
- package/lib/cjs/core/parser/constants.cjs +21 -0
- package/lib/cjs/core/parser/constants.cjs.map +1 -0
- package/lib/cjs/core/parser/constants.d.ts +8 -0
- package/lib/cjs/core/parser/declaration.cjs +347 -0
- package/lib/cjs/core/parser/declaration.cjs.map +1 -0
- package/lib/cjs/core/parser/declaration.d.ts +15 -0
- package/lib/cjs/core/parser/gradient.cjs +132 -0
- package/lib/cjs/core/parser/gradient.cjs.map +1 -0
- package/lib/cjs/core/parser/gradient.d.ts +59 -0
- package/lib/cjs/core/parser/haptics.cjs +73 -0
- package/lib/cjs/core/parser/haptics.cjs.map +1 -0
- package/lib/cjs/core/parser/haptics.d.ts +47 -0
- package/lib/cjs/core/parser/index.d.ts +8 -0
- package/lib/cjs/core/parser/keyframes.cjs +95 -0
- package/lib/cjs/core/parser/keyframes.cjs.map +1 -0
- package/lib/cjs/core/parser/keyframes.d.ts +26 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs +120 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/layout-dispatcher.d.ts +14 -0
- package/lib/cjs/core/parser/length.cjs +110 -0
- package/lib/cjs/core/parser/length.cjs.map +1 -0
- package/lib/cjs/core/parser/length.d.ts +51 -0
- package/lib/cjs/core/parser/motion-dispatcher.cjs +77 -0
- package/lib/cjs/core/parser/motion-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/motion-dispatcher.d.ts +11 -0
- package/lib/cjs/core/parser/property.cjs +22 -0
- package/lib/cjs/core/parser/property.cjs.map +1 -0
- package/lib/cjs/core/parser/property.d.ts +8 -0
- package/lib/cjs/core/parser/safe-area.cjs +404 -0
- package/lib/cjs/core/parser/safe-area.cjs.map +1 -0
- package/lib/cjs/core/parser/safe-area.d.ts +39 -0
- package/lib/cjs/core/parser/selector.cjs +22 -0
- package/lib/cjs/core/parser/selector.cjs.map +1 -0
- package/lib/cjs/core/parser/selector.d.ts +11 -0
- package/lib/cjs/core/parser/shorthand.cjs +188 -0
- package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
- package/lib/cjs/core/parser/shorthand.d.ts +67 -0
- package/lib/cjs/core/parser/text-truncate.cjs +78 -0
- package/lib/cjs/core/parser/text-truncate.cjs.map +1 -0
- package/lib/cjs/core/parser/text-truncate.d.ts +44 -0
- package/lib/cjs/core/parser/theme-vars.cjs +467 -0
- package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
- package/lib/cjs/core/parser/theme-vars.d.ts +82 -0
- package/lib/cjs/core/parser/tokens.cjs +486 -0
- package/lib/cjs/core/parser/tokens.cjs.map +1 -0
- package/lib/cjs/core/parser/tokens.d.ts +45 -0
- package/lib/cjs/core/parser/transform.cjs +198 -0
- package/lib/cjs/core/parser/transform.cjs.map +1 -0
- package/lib/cjs/core/parser/transform.d.ts +36 -0
- package/lib/cjs/core/parser/tw-parser.cjs +1680 -0
- package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
- package/lib/cjs/core/parser/tw-parser.d.ts +210 -0
- package/lib/cjs/core/parser/types.d.ts +37 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs +108 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/typography-dispatcher.d.ts +11 -0
- package/lib/cjs/core/parser/typography.cjs +97 -0
- package/lib/cjs/core/parser/typography.cjs.map +1 -0
- package/lib/cjs/core/parser/typography.d.ts +43 -0
- package/lib/cjs/core/style-builder/build-style.cjs +444 -0
- package/lib/cjs/core/style-builder/build-style.cjs.map +1 -0
- package/lib/cjs/core/style-builder/build-style.d.ts +54 -0
- package/lib/cjs/core/style-builder/index.d.ts +3 -0
- package/lib/cjs/core/style-builder/union-builder.cjs +326 -0
- package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -0
- package/lib/cjs/core/style-builder/union-builder.d.ts +128 -0
- package/lib/cjs/core/types.d.ts +14 -0
- package/lib/cjs/metro/dts.cjs +127 -0
- package/lib/cjs/metro/dts.cjs.map +1 -0
- package/lib/cjs/metro/dts.d.ts +16 -0
- package/lib/cjs/metro/index.cjs +19 -0
- package/lib/cjs/metro/index.cjs.map +1 -0
- package/lib/cjs/metro/index.d.ts +9 -0
- package/lib/cjs/metro/resolver.cjs +47 -0
- package/lib/cjs/metro/resolver.cjs.map +1 -0
- package/lib/cjs/metro/resolver.d.ts +22 -0
- package/lib/cjs/metro/state.cjs +301 -0
- package/lib/cjs/metro/state.cjs.map +1 -0
- package/lib/cjs/metro/state.d.ts +88 -0
- package/lib/cjs/metro/transform-ast.cjs +1472 -0
- package/lib/cjs/metro/transform-ast.cjs.map +1 -0
- package/lib/cjs/metro/transform-ast.d.ts +88 -0
- package/lib/cjs/metro/transformer.cjs +372 -0
- package/lib/cjs/metro/transformer.cjs.map +1 -0
- package/lib/cjs/metro/transformer.d.ts +47 -0
- package/lib/cjs/metro/warn-unknown-classes.cjs +86 -0
- package/lib/cjs/metro/warn-unknown-classes.cjs.map +1 -0
- package/lib/cjs/metro/warn-unknown-classes.d.ts +21 -0
- package/lib/cjs/metro/with-config.cjs +196 -0
- package/lib/cjs/metro/with-config.cjs.map +1 -0
- package/lib/cjs/metro/with-config.d.ts +79 -0
- package/lib/cjs/runtime/chain-handlers.cjs +37 -0
- package/lib/cjs/runtime/chain-handlers.cjs.map +1 -0
- package/lib/cjs/runtime/chain-handlers.d.ts +33 -0
- package/lib/cjs/runtime/components/rnwind-provider.cjs +98 -0
- package/lib/cjs/runtime/components/rnwind-provider.cjs.map +1 -0
- package/lib/cjs/runtime/components/rnwind-provider.d.ts +84 -0
- package/lib/cjs/runtime/gradient-types.d.ts +58 -0
- package/lib/cjs/runtime/haptics.cjs +113 -0
- package/lib/cjs/runtime/haptics.cjs.map +1 -0
- package/lib/cjs/runtime/haptics.d.ts +48 -0
- package/lib/cjs/runtime/hooks/use-css.cjs +21 -0
- package/lib/cjs/runtime/hooks/use-css.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-css.d.ts +11 -0
- package/lib/cjs/runtime/hooks/use-interact.cjs +46 -0
- package/lib/cjs/runtime/hooks/use-interact.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-interact.d.ts +42 -0
- package/lib/cjs/runtime/hooks/use-scheme.cjs +68 -0
- package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-scheme.d.ts +34 -0
- package/lib/cjs/runtime/index.cjs +45 -0
- package/lib/cjs/runtime/index.cjs.map +1 -0
- package/lib/cjs/runtime/index.d.ts +27 -0
- package/lib/cjs/runtime/interactive-box.cjs +35 -0
- package/lib/cjs/runtime/interactive-box.cjs.map +1 -0
- package/lib/cjs/runtime/interactive-box.d.ts +40 -0
- package/lib/cjs/runtime/lookup-css.cjs +542 -0
- package/lib/cjs/runtime/lookup-css.cjs.map +1 -0
- package/lib/cjs/runtime/lookup-css.d.ts +164 -0
- package/lib/cjs/runtime/types.d.ts +29 -0
- package/lib/cjs/testing/index.cjs +367 -0
- package/lib/cjs/testing/index.cjs.map +1 -0
- package/lib/cjs/testing/index.d.ts +145 -0
- package/lib/esm/core/parser/animation.d.ts +126 -0
- package/lib/esm/core/parser/animation.mjs +408 -0
- package/lib/esm/core/parser/animation.mjs.map +1 -0
- package/lib/esm/core/parser/border-dispatcher.d.ts +15 -0
- package/lib/esm/core/parser/border-dispatcher.mjs +178 -0
- package/lib/esm/core/parser/border-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/case-convert.d.ts +6 -0
- package/lib/esm/core/parser/case-convert.mjs +13 -0
- package/lib/esm/core/parser/case-convert.mjs.map +1 -0
- package/lib/esm/core/parser/color-properties-dispatcher.d.ts +19 -0
- package/lib/esm/core/parser/color-properties-dispatcher.mjs +82 -0
- package/lib/esm/core/parser/color-properties-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/color.d.ts +12 -0
- package/lib/esm/core/parser/color.mjs +191 -0
- package/lib/esm/core/parser/color.mjs.map +1 -0
- package/lib/esm/core/parser/constants.d.ts +8 -0
- package/lib/esm/core/parser/constants.mjs +13 -0
- package/lib/esm/core/parser/constants.mjs.map +1 -0
- package/lib/esm/core/parser/declaration.d.ts +15 -0
- package/lib/esm/core/parser/declaration.mjs +345 -0
- package/lib/esm/core/parser/declaration.mjs.map +1 -0
- package/lib/esm/core/parser/gradient.d.ts +59 -0
- package/lib/esm/core/parser/gradient.mjs +130 -0
- package/lib/esm/core/parser/gradient.mjs.map +1 -0
- package/lib/esm/core/parser/haptics.d.ts +47 -0
- package/lib/esm/core/parser/haptics.mjs +71 -0
- package/lib/esm/core/parser/haptics.mjs.map +1 -0
- package/lib/esm/core/parser/index.d.ts +8 -0
- package/lib/esm/core/parser/keyframes.d.ts +26 -0
- package/lib/esm/core/parser/keyframes.mjs +91 -0
- package/lib/esm/core/parser/keyframes.mjs.map +1 -0
- package/lib/esm/core/parser/layout-dispatcher.d.ts +14 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs +118 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/length.d.ts +51 -0
- package/lib/esm/core/parser/length.mjs +104 -0
- package/lib/esm/core/parser/length.mjs.map +1 -0
- package/lib/esm/core/parser/motion-dispatcher.d.ts +11 -0
- package/lib/esm/core/parser/motion-dispatcher.mjs +75 -0
- package/lib/esm/core/parser/motion-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/property.d.ts +8 -0
- package/lib/esm/core/parser/property.mjs +20 -0
- package/lib/esm/core/parser/property.mjs.map +1 -0
- package/lib/esm/core/parser/safe-area.d.ts +39 -0
- package/lib/esm/core/parser/safe-area.mjs +402 -0
- package/lib/esm/core/parser/safe-area.mjs.map +1 -0
- package/lib/esm/core/parser/selector.d.ts +11 -0
- package/lib/esm/core/parser/selector.mjs +20 -0
- package/lib/esm/core/parser/selector.mjs.map +1 -0
- package/lib/esm/core/parser/shorthand.d.ts +67 -0
- package/lib/esm/core/parser/shorthand.mjs +180 -0
- package/lib/esm/core/parser/shorthand.mjs.map +1 -0
- package/lib/esm/core/parser/text-truncate.d.ts +44 -0
- package/lib/esm/core/parser/text-truncate.mjs +75 -0
- package/lib/esm/core/parser/text-truncate.mjs.map +1 -0
- package/lib/esm/core/parser/theme-vars.d.ts +82 -0
- package/lib/esm/core/parser/theme-vars.mjs +461 -0
- package/lib/esm/core/parser/theme-vars.mjs.map +1 -0
- package/lib/esm/core/parser/tokens.d.ts +45 -0
- package/lib/esm/core/parser/tokens.mjs +480 -0
- package/lib/esm/core/parser/tokens.mjs.map +1 -0
- package/lib/esm/core/parser/transform.d.ts +36 -0
- package/lib/esm/core/parser/transform.mjs +193 -0
- package/lib/esm/core/parser/transform.mjs.map +1 -0
- package/lib/esm/core/parser/tw-parser.d.ts +210 -0
- package/lib/esm/core/parser/tw-parser.mjs +1678 -0
- package/lib/esm/core/parser/tw-parser.mjs.map +1 -0
- package/lib/esm/core/parser/types.d.ts +37 -0
- package/lib/esm/core/parser/typography-dispatcher.d.ts +11 -0
- package/lib/esm/core/parser/typography-dispatcher.mjs +106 -0
- package/lib/esm/core/parser/typography-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/typography.d.ts +43 -0
- package/lib/esm/core/parser/typography.mjs +91 -0
- package/lib/esm/core/parser/typography.mjs.map +1 -0
- package/lib/esm/core/style-builder/build-style.d.ts +54 -0
- package/lib/esm/core/style-builder/build-style.mjs +442 -0
- package/lib/esm/core/style-builder/build-style.mjs.map +1 -0
- package/lib/esm/core/style-builder/index.d.ts +3 -0
- package/lib/esm/core/style-builder/union-builder.d.ts +128 -0
- package/lib/esm/core/style-builder/union-builder.mjs +324 -0
- package/lib/esm/core/style-builder/union-builder.mjs.map +1 -0
- package/lib/esm/core/types.d.ts +14 -0
- package/lib/esm/metro/dts.d.ts +16 -0
- package/lib/esm/metro/dts.mjs +125 -0
- package/lib/esm/metro/dts.mjs.map +1 -0
- package/lib/esm/metro/index.d.ts +9 -0
- package/lib/esm/metro/index.mjs +6 -0
- package/lib/esm/metro/index.mjs.map +1 -0
- package/lib/esm/metro/resolver.d.ts +22 -0
- package/lib/esm/metro/resolver.mjs +43 -0
- package/lib/esm/metro/resolver.mjs.map +1 -0
- package/lib/esm/metro/state.d.ts +88 -0
- package/lib/esm/metro/state.mjs +291 -0
- package/lib/esm/metro/state.mjs.map +1 -0
- package/lib/esm/metro/transform-ast.d.ts +88 -0
- package/lib/esm/metro/transform-ast.mjs +1451 -0
- package/lib/esm/metro/transform-ast.mjs.map +1 -0
- package/lib/esm/metro/transformer.d.ts +47 -0
- package/lib/esm/metro/transformer.mjs +349 -0
- package/lib/esm/metro/transformer.mjs.map +1 -0
- package/lib/esm/metro/warn-unknown-classes.d.ts +21 -0
- package/lib/esm/metro/warn-unknown-classes.mjs +84 -0
- package/lib/esm/metro/warn-unknown-classes.mjs.map +1 -0
- package/lib/esm/metro/with-config.d.ts +79 -0
- package/lib/esm/metro/with-config.mjs +194 -0
- package/lib/esm/metro/with-config.mjs.map +1 -0
- package/lib/esm/runtime/chain-handlers.d.ts +33 -0
- package/lib/esm/runtime/chain-handlers.mjs +34 -0
- package/lib/esm/runtime/chain-handlers.mjs.map +1 -0
- package/lib/esm/runtime/components/rnwind-provider.d.ts +84 -0
- package/lib/esm/runtime/components/rnwind-provider.mjs +94 -0
- package/lib/esm/runtime/components/rnwind-provider.mjs.map +1 -0
- package/lib/esm/runtime/gradient-types.d.ts +58 -0
- package/lib/esm/runtime/haptics.d.ts +48 -0
- package/lib/esm/runtime/haptics.mjs +110 -0
- package/lib/esm/runtime/haptics.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-css.d.ts +11 -0
- package/lib/esm/runtime/hooks/use-css.mjs +19 -0
- package/lib/esm/runtime/hooks/use-css.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-interact.d.ts +42 -0
- package/lib/esm/runtime/hooks/use-interact.mjs +44 -0
- package/lib/esm/runtime/hooks/use-interact.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-scheme.d.ts +34 -0
- package/lib/esm/runtime/hooks/use-scheme.mjs +63 -0
- package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -0
- package/lib/esm/runtime/index.d.ts +27 -0
- package/lib/esm/runtime/index.mjs +18 -0
- package/lib/esm/runtime/index.mjs.map +1 -0
- package/lib/esm/runtime/interactive-box.d.ts +40 -0
- package/lib/esm/runtime/interactive-box.mjs +33 -0
- package/lib/esm/runtime/interactive-box.mjs.map +1 -0
- package/lib/esm/runtime/lookup-css.d.ts +164 -0
- package/lib/esm/runtime/lookup-css.mjs +531 -0
- package/lib/esm/runtime/lookup-css.mjs.map +1 -0
- package/lib/esm/runtime/types.d.ts +29 -0
- package/lib/esm/testing/index.d.ts +145 -0
- package/lib/esm/testing/index.mjs +344 -0
- package/lib/esm/testing/index.mjs.map +1 -0
- package/package.json +80 -13
- package/preset.css +1171 -0
- package/src/core/parser/animation.ts +404 -0
- package/src/core/parser/border-dispatcher.ts +176 -0
- package/src/core/parser/case-convert.ts +10 -0
- package/src/core/parser/color-properties-dispatcher.ts +78 -0
- package/src/core/parser/color.ts +191 -0
- package/src/core/parser/constants.ts +11 -0
- package/src/core/parser/declaration.ts +340 -0
- package/src/core/parser/gradient.ts +148 -0
- package/src/core/parser/haptics.ts +88 -0
- package/src/core/parser/index.ts +8 -0
- package/src/core/parser/keyframes.ts +84 -0
- package/src/core/parser/layout-dispatcher.ts +111 -0
- package/src/core/parser/length.ts +114 -0
- package/src/core/parser/motion-dispatcher.ts +89 -0
- package/src/core/parser/property.ts +15 -0
- package/src/core/parser/safe-area.ts +404 -0
- package/src/core/parser/selector.ts +17 -0
- package/src/core/parser/shorthand.ts +182 -0
- package/src/core/parser/text-truncate.ts +79 -0
- package/src/core/parser/theme-vars.ts +465 -0
- package/src/core/parser/tokens.ts +456 -0
- package/src/core/parser/transform.ts +195 -0
- package/src/core/parser/tw-parser.ts +1828 -0
- package/src/core/parser/types.ts +45 -0
- package/src/core/parser/typography-dispatcher.ts +97 -0
- package/src/core/parser/typography.ts +83 -0
- package/src/core/style-builder/build-style.ts +500 -0
- package/src/core/style-builder/index.ts +3 -0
- package/src/core/style-builder/union-builder.ts +328 -0
- package/src/core/types.ts +15 -0
- package/src/metro/dts.ts +128 -0
- package/src/metro/index.ts +9 -0
- package/src/metro/resolver.ts +42 -0
- package/src/metro/state.ts +305 -0
- package/src/metro/transform-ast.ts +1729 -0
- package/src/metro/transformer.ts +372 -0
- package/src/metro/warn-unknown-classes.ts +79 -0
- package/src/metro/with-config.ts +251 -0
- package/src/runtime/chain-handlers.ts +47 -0
- package/src/runtime/components/rnwind-provider.tsx +144 -0
- package/src/runtime/gradient-types.ts +60 -0
- package/src/runtime/haptics.ts +120 -0
- package/src/runtime/hooks/use-css.ts +16 -0
- package/src/runtime/hooks/use-interact.ts +65 -0
- package/src/runtime/hooks/use-scheme.ts +63 -0
- package/src/runtime/index.ts +54 -0
- package/src/runtime/interactive-box.tsx +57 -0
- package/src/runtime/lookup-css.ts +628 -0
- package/src/runtime/types.ts +32 -0
- package/src/testing/index.ts +507 -0
- package/src/types/tailwindcss-node.d.ts +33 -0
- package/src/index.ts +0 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { REM_TO_PX } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Round a percentage / length float to 4 decimal places so lightningcss's
|
|
5
|
+
* IEEE-754 noise (`0.237 → 0.23700000345…`) doesn't leak into RN style
|
|
6
|
+
* strings. 4 decimals is well below CSS subpixel precision.
|
|
7
|
+
* @param n Raw float.
|
|
8
|
+
* @returns Rounded float with trailing zeros trimmed.
|
|
9
|
+
*/
|
|
10
|
+
function roundFloat(n) {
|
|
11
|
+
return Math.round(n * 10_000) / 10_000;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* "Fully rounded" sentinel — emitted for Tailwind's `rounded-full` (and
|
|
15
|
+
* any other utility expanding to `calc(infinity * 1px)`). RN can't
|
|
16
|
+
* render `Infinity` as a style value (the StyleSheet validator silently
|
|
17
|
+
* drops it), but it accepts a finite large pixel count and renders the
|
|
18
|
+
* same pill / circle shape. 9999 covers every realistic phone screen.
|
|
19
|
+
*/
|
|
20
|
+
const FULLY_ROUNDED_PX = 9999;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a lightningcss `LengthValue` to a pixel number. Handles the
|
|
23
|
+
* units Tailwind emits: px, rem, em. Tailwind v4's "fully rounded"
|
|
24
|
+
* expansion (`calc(infinity * 1px)`) lands here as `value === Infinity`
|
|
25
|
+
* — we clamp to a finite sentinel so RN can render it. Other non-finite
|
|
26
|
+
* values (NaN from a malformed expression) are clamped to 0 rather
|
|
27
|
+
* than leaking through as `null` in the serialized RN style.
|
|
28
|
+
* @param length Typed length value.
|
|
29
|
+
* @returns Finite pixel number.
|
|
30
|
+
*/
|
|
31
|
+
function lengthToPx(length) {
|
|
32
|
+
const raw = length.value;
|
|
33
|
+
if (!Number.isFinite(raw))
|
|
34
|
+
return raw === Number.POSITIVE_INFINITY ? FULLY_ROUNDED_PX : 0;
|
|
35
|
+
switch (length.unit) {
|
|
36
|
+
case 'px': {
|
|
37
|
+
return raw;
|
|
38
|
+
}
|
|
39
|
+
case 'rem':
|
|
40
|
+
case 'em': {
|
|
41
|
+
return raw * REM_TO_PX;
|
|
42
|
+
}
|
|
43
|
+
default: {
|
|
44
|
+
return raw;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Collapse a `DimensionPercentageFor_LengthValue` to a number (pixel) or
|
|
50
|
+
* `'N%'` string. `calc()` variants are not evaluated here — they fall
|
|
51
|
+
* through to `null` so the caller can skip or serialize via tokens.
|
|
52
|
+
* @param value Typed dimension-or-percentage.
|
|
53
|
+
* @returns Number, percent string, or `null` when unrepresentable.
|
|
54
|
+
*/
|
|
55
|
+
function dimensionPercentageToNumber(value) {
|
|
56
|
+
if (value.type === 'dimension')
|
|
57
|
+
return lengthToPx(value.value);
|
|
58
|
+
if (value.type === 'percentage')
|
|
59
|
+
return `${roundFloat(value.value * 100)}%`;
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Convert `LengthPercentageOrAuto` (per-side value type for padding /
|
|
64
|
+
* margin / inset) to an RN scalar. `auto` maps to the string `'auto'`,
|
|
65
|
+
* which RN's margin accepts for centering; non-margin callers can filter
|
|
66
|
+
* it out if they need a number.
|
|
67
|
+
* @param value Typed length-percentage-or-auto.
|
|
68
|
+
* @returns RN scalar or `null` for unrepresentable shapes.
|
|
69
|
+
*/
|
|
70
|
+
function lengthPercentageOrAutoToValue(value) {
|
|
71
|
+
if (value.type === 'auto')
|
|
72
|
+
return 'auto';
|
|
73
|
+
return dimensionPercentageToNumber(value.value);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Convert a lightningcss `Size` (used by width/height) or `MaxSize` (used
|
|
77
|
+
* by max-width/max-height) to an RN scalar. Sizing keywords with no RN
|
|
78
|
+
* analog (`min-content`, `fit-content`, `stretch`, …) fall through to
|
|
79
|
+
* `null` so the caller drops them.
|
|
80
|
+
* @param value Typed size value.
|
|
81
|
+
* @returns RN scalar or `null` when unrepresentable.
|
|
82
|
+
*/
|
|
83
|
+
function sizeLikeToValue(value) {
|
|
84
|
+
if (value.type === 'auto' || value.type === 'none')
|
|
85
|
+
return value.type === 'auto' ? 'auto' : null;
|
|
86
|
+
if (value.type === 'length-percentage')
|
|
87
|
+
return dimensionPercentageToNumber(value.value);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Convert a lightningcss `GapValue` (per-axis gap, used by `row-gap` /
|
|
92
|
+
* `column-gap`) to an RN scalar. The `normal` keyword has no RN analog
|
|
93
|
+
* and falls through to `null`.
|
|
94
|
+
* @param value Typed gap value.
|
|
95
|
+
* @returns Number, percent string, or `null`.
|
|
96
|
+
*/
|
|
97
|
+
function gapValueToValue(value) {
|
|
98
|
+
if (value.type === 'normal')
|
|
99
|
+
return null;
|
|
100
|
+
return dimensionPercentageToNumber(value.value);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { dimensionPercentageToNumber, gapValueToValue, lengthPercentageOrAutoToValue, lengthToPx, sizeLikeToValue };
|
|
104
|
+
//# sourceMappingURL=length.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"length.mjs","sources":["../../../../../src/core/parser/length.ts"],"sourcesContent":["import type {\n DimensionPercentageFor_LengthValue as LcDimensionPercentage,\n GapValue,\n LengthPercentageOrAuto,\n LengthValue,\n MaxSize,\n Size,\n} from 'lightningcss'\nimport { REM_TO_PX } from './constants'\n\n/** Alias for lightningcss's snake_case dimension-or-percentage type. */\ntype DimensionPercentage = LcDimensionPercentage\n\n/** RN-compatible length/percent result, or `null` when unrepresentable. */\ntype LengthResult = number | string | null\n\n/**\n * Round a percentage / length float to 4 decimal places so lightningcss's\n * IEEE-754 noise (`0.237 → 0.23700000345…`) doesn't leak into RN style\n * strings. 4 decimals is well below CSS subpixel precision.\n * @param n Raw float.\n * @returns Rounded float with trailing zeros trimmed.\n */\nfunction roundFloat(n: number): number {\n return Math.round(n * 10_000) / 10_000\n}\n\n/**\n * \"Fully rounded\" sentinel — emitted for Tailwind's `rounded-full` (and\n * any other utility expanding to `calc(infinity * 1px)`). RN can't\n * render `Infinity` as a style value (the StyleSheet validator silently\n * drops it), but it accepts a finite large pixel count and renders the\n * same pill / circle shape. 9999 covers every realistic phone screen.\n */\nconst FULLY_ROUNDED_PX = 9999\n\n/**\n * Convert a lightningcss `LengthValue` to a pixel number. Handles the\n * units Tailwind emits: px, rem, em. Tailwind v4's \"fully rounded\"\n * expansion (`calc(infinity * 1px)`) lands here as `value === Infinity`\n * — we clamp to a finite sentinel so RN can render it. Other non-finite\n * values (NaN from a malformed expression) are clamped to 0 rather\n * than leaking through as `null` in the serialized RN style.\n * @param length Typed length value.\n * @returns Finite pixel number.\n */\nexport function lengthToPx(length: LengthValue): number {\n const raw = length.value\n if (!Number.isFinite(raw)) return raw === Number.POSITIVE_INFINITY ? FULLY_ROUNDED_PX : 0\n switch (length.unit) {\n case 'px': {\n return raw\n }\n case 'rem':\n case 'em': {\n return raw * REM_TO_PX\n }\n default: {\n return raw\n }\n }\n}\n\n/**\n * Collapse a `DimensionPercentageFor_LengthValue` to a number (pixel) or\n * `'N%'` string. `calc()` variants are not evaluated here — they fall\n * through to `null` so the caller can skip or serialize via tokens.\n * @param value Typed dimension-or-percentage.\n * @returns Number, percent string, or `null` when unrepresentable.\n */\nexport function dimensionPercentageToNumber(value: DimensionPercentage): LengthResult {\n if (value.type === 'dimension') return lengthToPx(value.value)\n if (value.type === 'percentage') return `${roundFloat(value.value * 100)}%`\n return null\n}\n\n/**\n * Convert `LengthPercentageOrAuto` (per-side value type for padding /\n * margin / inset) to an RN scalar. `auto` maps to the string `'auto'`,\n * which RN's margin accepts for centering; non-margin callers can filter\n * it out if they need a number.\n * @param value Typed length-percentage-or-auto.\n * @returns RN scalar or `null` for unrepresentable shapes.\n */\nexport function lengthPercentageOrAutoToValue(value: LengthPercentageOrAuto): LengthResult {\n if (value.type === 'auto') return 'auto'\n return dimensionPercentageToNumber(value.value)\n}\n\n/**\n * Convert a lightningcss `Size` (used by width/height) or `MaxSize` (used\n * by max-width/max-height) to an RN scalar. Sizing keywords with no RN\n * analog (`min-content`, `fit-content`, `stretch`, …) fall through to\n * `null` so the caller drops them.\n * @param value Typed size value.\n * @returns RN scalar or `null` when unrepresentable.\n */\nexport function sizeLikeToValue(value: Size | MaxSize): LengthResult {\n if (value.type === 'auto' || value.type === 'none') return value.type === 'auto' ? 'auto' : null\n if (value.type === 'length-percentage') return dimensionPercentageToNumber(value.value)\n return null\n}\n\n/**\n * Convert a lightningcss `GapValue` (per-axis gap, used by `row-gap` /\n * `column-gap`) to an RN scalar. The `normal` keyword has no RN analog\n * and falls through to `null`.\n * @param value Typed gap value.\n * @returns Number, percent string, or `null`.\n */\nexport function gapValueToValue(value: GapValue): LengthResult {\n if (value.type === 'normal') return null\n return dimensionPercentageToNumber(value.value)\n}\n"],"names":[],"mappings":";;AAgBA;;;;;;AAMG;AACH,SAAS,UAAU,CAAC,CAAS,EAAA;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM;AACxC;AAEA;;;;;;AAMG;AACH,MAAM,gBAAgB,GAAG,IAAI;AAE7B;;;;;;;;;AASG;AACG,SAAU,UAAU,CAAC,MAAmB,EAAA;AAC5C,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK;AACxB,IAAA,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;AAAE,QAAA,OAAO,GAAG,KAAK,MAAM,CAAC,iBAAiB,GAAG,gBAAgB,GAAG,CAAC;AACzF,IAAA,QAAQ,MAAM,CAAC,IAAI;QACjB,KAAK,IAAI,EAAE;AACT,YAAA,OAAO,GAAG;QACZ;AACA,QAAA,KAAK,KAAK;QACV,KAAK,IAAI,EAAE;YACT,OAAO,GAAG,GAAG,SAAS;QACxB;QACA,SAAS;AACP,YAAA,OAAO,GAAG;QACZ;;AAEJ;AAEA;;;;;;AAMG;AACG,SAAU,2BAA2B,CAAC,KAA0B,EAAA;AACpE,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;AAAE,QAAA,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;AAC9D,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,CAAA,EAAG,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAA,CAAA,CAAG;AAC3E,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;;AAOG;AACG,SAAU,6BAA6B,CAAC,KAA6B,EAAA;AACzE,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;AAAE,QAAA,OAAO,MAAM;AACxC,IAAA,OAAO,2BAA2B,CAAC,KAAK,CAAC,KAAK,CAAC;AACjD;AAEA;;;;;;;AAOG;AACG,SAAU,eAAe,CAAC,KAAqB,EAAA;IACnD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;AAAE,QAAA,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI;AAChG,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB;AAAE,QAAA,OAAO,2BAA2B,CAAC,KAAK,CAAC,KAAK,CAAC;AACvF,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAAC,KAAe,EAAA;AAC7C,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AACxC,IAAA,OAAO,2BAA2B,CAAC,KAAK,CAAC,KAAK,CAAC;AACjD;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Declaration as LcDeclaration } from 'lightningcss';
|
|
2
|
+
import type { RNEntry } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatch motion-adjacent declarations (animation/transition/transform)
|
|
5
|
+
* to their typed handlers. Returns `null` when the declaration isn't
|
|
6
|
+
* one this dispatcher handles, so the caller can fall through to its
|
|
7
|
+
* main switch.
|
|
8
|
+
* @param decl One lightningcss declaration.
|
|
9
|
+
* @returns RN entries when the property matched, else `null`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dispatchMotionDeclaration(decl: LcDeclaration): readonly RNEntry[] | null;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { transitionDelayEntries, transitionTimingFunctionEntries, transitionDurationEntries, transitionPropertyEntries, transitionShorthandToEntries, animationPlayStateEntries, animationFillModeEntries, animationDirectionEntries, animationDelayEntries, animationIterationCountEntries, animationTimingFunctionEntries, animationDurationEntries, animationNameEntries, animationShorthandToEntries } from './animation.mjs';
|
|
2
|
+
import { scaleToEntries, translateToEntries, rotateToEntries, transformFunctionsToEntries } from './transform.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Dispatch motion-adjacent declarations (animation/transition/transform)
|
|
6
|
+
* to their typed handlers. Returns `null` when the declaration isn't
|
|
7
|
+
* one this dispatcher handles, so the caller can fall through to its
|
|
8
|
+
* main switch.
|
|
9
|
+
* @param decl One lightningcss declaration.
|
|
10
|
+
* @returns RN entries when the property matched, else `null`.
|
|
11
|
+
*/
|
|
12
|
+
function dispatchMotionDeclaration(decl) {
|
|
13
|
+
switch (decl.property) {
|
|
14
|
+
case 'animation': {
|
|
15
|
+
return animationShorthandToEntries(decl.value);
|
|
16
|
+
}
|
|
17
|
+
case 'animation-name': {
|
|
18
|
+
return animationNameEntries(decl.value);
|
|
19
|
+
}
|
|
20
|
+
case 'animation-duration': {
|
|
21
|
+
return animationDurationEntries(decl.value);
|
|
22
|
+
}
|
|
23
|
+
case 'animation-timing-function': {
|
|
24
|
+
return animationTimingFunctionEntries(decl.value);
|
|
25
|
+
}
|
|
26
|
+
case 'animation-iteration-count': {
|
|
27
|
+
return animationIterationCountEntries(decl.value);
|
|
28
|
+
}
|
|
29
|
+
case 'animation-delay': {
|
|
30
|
+
return animationDelayEntries(decl.value);
|
|
31
|
+
}
|
|
32
|
+
case 'animation-direction': {
|
|
33
|
+
return animationDirectionEntries(decl.value);
|
|
34
|
+
}
|
|
35
|
+
case 'animation-fill-mode': {
|
|
36
|
+
return animationFillModeEntries(decl.value);
|
|
37
|
+
}
|
|
38
|
+
case 'animation-play-state': {
|
|
39
|
+
return animationPlayStateEntries(decl.value);
|
|
40
|
+
}
|
|
41
|
+
case 'transition': {
|
|
42
|
+
return transitionShorthandToEntries(decl.value);
|
|
43
|
+
}
|
|
44
|
+
case 'transition-property': {
|
|
45
|
+
return transitionPropertyEntries(decl.value);
|
|
46
|
+
}
|
|
47
|
+
case 'transition-duration': {
|
|
48
|
+
return transitionDurationEntries(decl.value);
|
|
49
|
+
}
|
|
50
|
+
case 'transition-timing-function': {
|
|
51
|
+
return transitionTimingFunctionEntries(decl.value);
|
|
52
|
+
}
|
|
53
|
+
case 'transition-delay': {
|
|
54
|
+
return transitionDelayEntries(decl.value);
|
|
55
|
+
}
|
|
56
|
+
case 'transform': {
|
|
57
|
+
return transformFunctionsToEntries(decl.value);
|
|
58
|
+
}
|
|
59
|
+
case 'rotate': {
|
|
60
|
+
return rotateToEntries(decl.value);
|
|
61
|
+
}
|
|
62
|
+
case 'translate': {
|
|
63
|
+
return translateToEntries(decl.value);
|
|
64
|
+
}
|
|
65
|
+
case 'scale': {
|
|
66
|
+
return scaleToEntries(decl.value);
|
|
67
|
+
}
|
|
68
|
+
default: {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { dispatchMotionDeclaration };
|
|
75
|
+
//# sourceMappingURL=motion-dispatcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-dispatcher.mjs","sources":["../../../../../src/core/parser/motion-dispatcher.ts"],"sourcesContent":["import type { Declaration as LcDeclaration } from 'lightningcss'\nimport {\n animationDelayEntries,\n animationDirectionEntries,\n animationDurationEntries,\n animationFillModeEntries,\n animationIterationCountEntries,\n animationNameEntries,\n animationPlayStateEntries,\n animationShorthandToEntries,\n animationTimingFunctionEntries,\n transitionDelayEntries,\n transitionDurationEntries,\n transitionPropertyEntries,\n transitionShorthandToEntries,\n transitionTimingFunctionEntries,\n} from './animation'\nimport { rotateToEntries, scaleToEntries, transformFunctionsToEntries, translateToEntries } from './transform'\nimport type { RNEntry } from './types'\n\n/**\n * Dispatch motion-adjacent declarations (animation/transition/transform)\n * to their typed handlers. Returns `null` when the declaration isn't\n * one this dispatcher handles, so the caller can fall through to its\n * main switch.\n * @param decl One lightningcss declaration.\n * @returns RN entries when the property matched, else `null`.\n */\nexport function dispatchMotionDeclaration(decl: LcDeclaration): readonly RNEntry[] | null {\n switch (decl.property) {\n case 'animation': {\n return animationShorthandToEntries(decl.value)\n }\n case 'animation-name': {\n return animationNameEntries(decl.value)\n }\n case 'animation-duration': {\n return animationDurationEntries(decl.value)\n }\n case 'animation-timing-function': {\n return animationTimingFunctionEntries(decl.value)\n }\n case 'animation-iteration-count': {\n return animationIterationCountEntries(decl.value)\n }\n case 'animation-delay': {\n return animationDelayEntries(decl.value)\n }\n case 'animation-direction': {\n return animationDirectionEntries(decl.value)\n }\n case 'animation-fill-mode': {\n return animationFillModeEntries(decl.value)\n }\n case 'animation-play-state': {\n return animationPlayStateEntries(decl.value)\n }\n case 'transition': {\n return transitionShorthandToEntries(decl.value)\n }\n case 'transition-property': {\n return transitionPropertyEntries(decl.value)\n }\n case 'transition-duration': {\n return transitionDurationEntries(decl.value)\n }\n case 'transition-timing-function': {\n return transitionTimingFunctionEntries(decl.value)\n }\n case 'transition-delay': {\n return transitionDelayEntries(decl.value)\n }\n case 'transform': {\n return transformFunctionsToEntries(decl.value)\n }\n case 'rotate': {\n return rotateToEntries(decl.value)\n }\n case 'translate': {\n return translateToEntries(decl.value)\n }\n case 'scale': {\n return scaleToEntries(decl.value)\n }\n default: {\n return null\n }\n }\n}\n"],"names":[],"mappings":";;;AAoBA;;;;;;;AAOG;AACG,SAAU,yBAAyB,CAAC,IAAmB,EAAA;AAC3D,IAAA,QAAQ,IAAI,CAAC,QAAQ;QACnB,KAAK,WAAW,EAAE;AAChB,YAAA,OAAO,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC;QAChD;QACA,KAAK,gBAAgB,EAAE;AACrB,YAAA,OAAO,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;QACzC;QACA,KAAK,oBAAoB,EAAE;AACzB,YAAA,OAAO,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7C;QACA,KAAK,2BAA2B,EAAE;AAChC,YAAA,OAAO,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC;QACnD;QACA,KAAK,2BAA2B,EAAE;AAChC,YAAA,OAAO,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC;QACnD;QACA,KAAK,iBAAiB,EAAE;AACtB,YAAA,OAAO,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC1C;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAO,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAO,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7C;QACA,KAAK,sBAAsB,EAAE;AAC3B,YAAA,OAAO,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,YAAY,EAAE;AACjB,YAAA,OAAO,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC;QACjD;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAO,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAO,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,4BAA4B,EAAE;AACjC,YAAA,OAAO,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC;QACpD;QACA,KAAK,kBAAkB,EAAE;AACvB,YAAA,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3C;QACA,KAAK,WAAW,EAAE;AAChB,YAAA,OAAO,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC;QAChD;QACA,KAAK,QAAQ,EAAE;AACb,YAAA,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;QACpC;QACA,KAAK,WAAW,EAAE;AAChB,YAAA,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;QACvC;QACA,KAAK,OAAO,EAAE;AACZ,YAAA,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC;QACnC;QACA,SAAS;AACP,YAAA,OAAO,IAAI;QACb;;AAEJ;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ParsedComponent } from 'lightningcss';
|
|
2
|
+
/**
|
|
3
|
+
* Serialize an `@property --x { initial-value: … }` body to plain text —
|
|
4
|
+
* enough for the downstream var() resolver to use as a fallback.
|
|
5
|
+
* @param initial Parsed-component AST node (or null when absent).
|
|
6
|
+
* @returns CSS-value string, or `null` when missing / unsupported shape.
|
|
7
|
+
*/
|
|
8
|
+
export declare function serializeInitialValue(initial: ParsedComponent | null | undefined): string | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize an `@property --x { initial-value: … }` body to plain text —
|
|
3
|
+
* enough for the downstream var() resolver to use as a fallback.
|
|
4
|
+
* @param initial Parsed-component AST node (or null when absent).
|
|
5
|
+
* @returns CSS-value string, or `null` when missing / unsupported shape.
|
|
6
|
+
*/
|
|
7
|
+
function serializeInitialValue(initial) {
|
|
8
|
+
if (!initial)
|
|
9
|
+
return null;
|
|
10
|
+
if (initial.type === 'literal')
|
|
11
|
+
return initial.value;
|
|
12
|
+
if (initial.type === 'custom-ident')
|
|
13
|
+
return initial.value;
|
|
14
|
+
if (initial.type === 'string')
|
|
15
|
+
return initial.value;
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { serializeInitialValue };
|
|
20
|
+
//# sourceMappingURL=property.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property.mjs","sources":["../../../../../src/core/parser/property.ts"],"sourcesContent":["import type { ParsedComponent } from 'lightningcss'\n\n/**\n * Serialize an `@property --x { initial-value: … }` body to plain text —\n * enough for the downstream var() resolver to use as a fallback.\n * @param initial Parsed-component AST node (or null when absent).\n * @returns CSS-value string, or `null` when missing / unsupported shape.\n */\nexport function serializeInitialValue(initial: ParsedComponent | null | undefined): string | null {\n if (!initial) return null\n if (initial.type === 'literal') return initial.value\n if (initial.type === 'custom-ident') return initial.value\n if (initial.type === 'string') return initial.value\n return null\n}\n"],"names":[],"mappings":"AAEA;;;;;AAKG;AACG,SAAU,qBAAqB,CAAC,OAA2C,EAAA;AAC/E,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,IAAI;AACzB,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,KAAK;AACpD,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc;QAAE,OAAO,OAAO,CAAC,KAAK;AACzD,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC,KAAK;AACnD,IAAA,OAAO,IAAI;AACb;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect `env(safe-area-inset-*)` usage in a lightningcss TokenOrValue
|
|
3
|
+
* tree and convert the containing declaration into a runtime-resolved
|
|
4
|
+
* {@link SafeAreaMarker}.
|
|
5
|
+
*
|
|
6
|
+
* Three shapes the NativeWind-compatible `*-safe` utilities produce
|
|
7
|
+
* through Tailwind v4's compiler:
|
|
8
|
+
* - Pure `env(safe-area-inset-top)` → `{ __safe: 't' }`
|
|
9
|
+
* - `max(env(safe-area-inset-top), 16px)` → `{ __safe: 't', or: 16 }`
|
|
10
|
+
* - `calc(env(safe-area-inset-top) + 16px)` → `{ __safe: 't', offset: 16 }`
|
|
11
|
+
*
|
|
12
|
+
* The `h-screen-safe` / `min-h-screen-safe` / `max-h-screen-safe` shape
|
|
13
|
+
* — `calc(100vh - (env(top) + env(bottom)))` — reports as
|
|
14
|
+
* `{ __safe: 'screen-minus-y' }`; the runtime resolves against
|
|
15
|
+
* `Dimensions.get('window').height` minus the current top + bottom
|
|
16
|
+
* insets.
|
|
17
|
+
*
|
|
18
|
+
* Unrecognised compound shapes (e.g. `env(safe-area-inset-top, 12px)`
|
|
19
|
+
* with a fallback) return `null` so the caller falls back to the
|
|
20
|
+
* regular token-serialisation path.
|
|
21
|
+
*/
|
|
22
|
+
import type { TokenOrValue } from 'lightningcss';
|
|
23
|
+
import type { SafeAreaMarker } from './types';
|
|
24
|
+
/**
|
|
25
|
+
* Theme-var lookup table we optionally receive. Values are stored as
|
|
26
|
+
* raw CSS value strings (`'0.25rem'`, `'#fff'`, …); the safe-area
|
|
27
|
+
* detector only needs the ones that resolve to lengths.
|
|
28
|
+
*/
|
|
29
|
+
type ThemeVars = ReadonlyMap<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Try to compile a token list into a {@link SafeAreaMarker}. Returns
|
|
32
|
+
* `null` when the tokens don't match any recognised safe-area pattern
|
|
33
|
+
* — the caller should fall back to the regular unparsed-value path.
|
|
34
|
+
* @param tokens Declaration value token list from lightningcss.
|
|
35
|
+
* @param themeVars
|
|
36
|
+
* @returns Marker object, or `null`.
|
|
37
|
+
*/
|
|
38
|
+
declare function detectSafeAreaMarker(tokens: readonly TokenOrValue[], themeVars?: ThemeVars): SafeAreaMarker | null;
|
|
39
|
+
export { detectSafeAreaMarker };
|