rnwind 0.0.1 → 0.0.2
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 +164 -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 +100 -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 +96 -0
- package/lib/cjs/core/parser/length.cjs.map +1 -0
- package/lib/cjs/core/parser/length.d.ts +48 -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 +156 -0
- package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
- package/lib/cjs/core/parser/shorthand.d.ts +61 -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 +414 -0
- package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
- package/lib/cjs/core/parser/theme-vars.d.ts +61 -0
- package/lib/cjs/core/parser/tokens.cjs +304 -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 +1567 -0
- package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
- package/lib/cjs/core/parser/tw-parser.d.ts +194 -0
- package/lib/cjs/core/parser/types.d.ts +37 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs +93 -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 +397 -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 +251 -0
- package/lib/cjs/metro/state.cjs.map +1 -0
- package/lib/cjs/metro/state.d.ts +72 -0
- package/lib/cjs/metro/transform-ast.cjs +1255 -0
- package/lib/cjs/metro/transform-ast.cjs.map +1 -0
- package/lib/cjs/metro/transform-ast.d.ts +73 -0
- package/lib/cjs/metro/transformer.cjs +345 -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 +57 -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 +162 -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 +98 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/length.d.ts +48 -0
- package/lib/esm/core/parser/length.mjs +90 -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 +61 -0
- package/lib/esm/core/parser/shorthand.mjs +148 -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 +61 -0
- package/lib/esm/core/parser/theme-vars.mjs +409 -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 +298 -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 +194 -0
- package/lib/esm/core/parser/tw-parser.mjs +1565 -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 +91 -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 +395 -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 +72 -0
- package/lib/esm/metro/state.mjs +243 -0
- package/lib/esm/metro/state.mjs.map +1 -0
- package/lib/esm/metro/transform-ast.d.ts +73 -0
- package/lib/esm/metro/transform-ast.mjs +1234 -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 +322 -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 +57 -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 +79 -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 +157 -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 +92 -0
- package/src/core/parser/length.ts +100 -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 +152 -0
- package/src/core/parser/text-truncate.ts +79 -0
- package/src/core/parser/theme-vars.ts +412 -0
- package/src/core/parser/tokens.ts +286 -0
- package/src/core/parser/transform.ts +195 -0
- package/src/core/parser/tw-parser.ts +1709 -0
- package/src/core/parser/types.ts +45 -0
- package/src/core/parser/typography-dispatcher.ts +83 -0
- package/src/core/parser/typography.ts +83 -0
- package/src/core/style-builder/build-style.ts +442 -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 +257 -0
- package/src/metro/transform-ast.ts +1498 -0
- package/src/metro/transformer.ts +347 -0
- package/src/metro/warn-unknown-classes.ts +79 -0
- package/src/metro/with-config.ts +229 -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 @@
|
|
|
1
|
+
{"version":3,"file":"motion-dispatcher.cjs","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":["animationShorthandToEntries","animationNameEntries","animationDurationEntries","animationTimingFunctionEntries","animationIterationCountEntries","animationDelayEntries","animationDirectionEntries","animationFillModeEntries","animationPlayStateEntries","transitionShorthandToEntries","transitionPropertyEntries","transitionDurationEntries","transitionTimingFunctionEntries","transitionDelayEntries","transformFunctionsToEntries","rotateToEntries","translateToEntries","scaleToEntries"],"mappings":";;;;;AAoBA;;;;;;;AAOG;AACG,SAAU,yBAAyB,CAAC,IAAmB,EAAA;AAC3D,IAAA,QAAQ,IAAI,CAAC,QAAQ;QACnB,KAAK,WAAW,EAAE;AAChB,YAAA,OAAOA,qCAA2B,CAAC,IAAI,CAAC,KAAK,CAAC;QAChD;QACA,KAAK,gBAAgB,EAAE;AACrB,YAAA,OAAOC,8BAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;QACzC;QACA,KAAK,oBAAoB,EAAE;AACzB,YAAA,OAAOC,kCAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7C;QACA,KAAK,2BAA2B,EAAE;AAChC,YAAA,OAAOC,wCAA8B,CAAC,IAAI,CAAC,KAAK,CAAC;QACnD;QACA,KAAK,2BAA2B,EAAE;AAChC,YAAA,OAAOC,wCAA8B,CAAC,IAAI,CAAC,KAAK,CAAC;QACnD;QACA,KAAK,iBAAiB,EAAE;AACtB,YAAA,OAAOC,+BAAqB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC1C;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAOC,mCAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAOC,kCAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7C;QACA,KAAK,sBAAsB,EAAE;AAC3B,YAAA,OAAOC,mCAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,YAAY,EAAE;AACjB,YAAA,OAAOC,sCAA4B,CAAC,IAAI,CAAC,KAAK,CAAC;QACjD;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAOC,mCAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,qBAAqB,EAAE;AAC1B,YAAA,OAAOC,mCAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C;QACA,KAAK,4BAA4B,EAAE;AACjC,YAAA,OAAOC,yCAA+B,CAAC,IAAI,CAAC,KAAK,CAAC;QACpD;QACA,KAAK,kBAAkB,EAAE;AACvB,YAAA,OAAOC,gCAAsB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3C;QACA,KAAK,WAAW,EAAE;AAChB,YAAA,OAAOC,qCAA2B,CAAC,IAAI,CAAC,KAAK,CAAC;QAChD;QACA,KAAK,QAAQ,EAAE;AACb,YAAA,OAAOC,yBAAe,CAAC,IAAI,CAAC,KAAK,CAAC;QACpC;QACA,KAAK,WAAW,EAAE;AAChB,YAAA,OAAOC,4BAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;QACvC;QACA,KAAK,OAAO,EAAE;AACZ,YAAA,OAAOC,wBAAc,CAAC,IAAI,CAAC,KAAK,CAAC;QACnC;QACA,SAAS;AACP,YAAA,OAAO,IAAI;QACb;;AAEJ;;;;"}
|
|
@@ -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,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Serialize an `@property --x { initial-value: … }` body to plain text —
|
|
5
|
+
* enough for the downstream var() resolver to use as a fallback.
|
|
6
|
+
* @param initial Parsed-component AST node (or null when absent).
|
|
7
|
+
* @returns CSS-value string, or `null` when missing / unsupported shape.
|
|
8
|
+
*/
|
|
9
|
+
function serializeInitialValue(initial) {
|
|
10
|
+
if (!initial)
|
|
11
|
+
return null;
|
|
12
|
+
if (initial.type === 'literal')
|
|
13
|
+
return initial.value;
|
|
14
|
+
if (initial.type === 'custom-ident')
|
|
15
|
+
return initial.value;
|
|
16
|
+
if (initial.type === 'string')
|
|
17
|
+
return initial.value;
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.serializeInitialValue = serializeInitialValue;
|
|
22
|
+
//# sourceMappingURL=property.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property.cjs","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,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,404 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Detect `env(safe-area-inset-*)` usage in a lightningcss TokenOrValue
|
|
5
|
+
* tree and convert the containing declaration into a runtime-resolved
|
|
6
|
+
* {@link SafeAreaMarker}.
|
|
7
|
+
*
|
|
8
|
+
* Three shapes the NativeWind-compatible `*-safe` utilities produce
|
|
9
|
+
* through Tailwind v4's compiler:
|
|
10
|
+
* - Pure `env(safe-area-inset-top)` → `{ __safe: 't' }`
|
|
11
|
+
* - `max(env(safe-area-inset-top), 16px)` → `{ __safe: 't', or: 16 }`
|
|
12
|
+
* - `calc(env(safe-area-inset-top) + 16px)` → `{ __safe: 't', offset: 16 }`
|
|
13
|
+
*
|
|
14
|
+
* The `h-screen-safe` / `min-h-screen-safe` / `max-h-screen-safe` shape
|
|
15
|
+
* — `calc(100vh - (env(top) + env(bottom)))` — reports as
|
|
16
|
+
* `{ __safe: 'screen-minus-y' }`; the runtime resolves against
|
|
17
|
+
* `Dimensions.get('window').height` minus the current top + bottom
|
|
18
|
+
* insets.
|
|
19
|
+
*
|
|
20
|
+
* Unrecognised compound shapes (e.g. `env(safe-area-inset-top, 12px)`
|
|
21
|
+
* with a fallback) return `null` so the caller falls back to the
|
|
22
|
+
* regular token-serialisation path.
|
|
23
|
+
*/
|
|
24
|
+
/** Map UA env names to the compact side tag used in the marker. */
|
|
25
|
+
const SIDE_TAG = {
|
|
26
|
+
'safe-area-inset-top': 't',
|
|
27
|
+
'safe-area-inset-right': 'r',
|
|
28
|
+
'safe-area-inset-bottom': 'b',
|
|
29
|
+
'safe-area-inset-left': 'l',
|
|
30
|
+
};
|
|
31
|
+
/** Rem → px factor used across the parser (matches `tokens.ts`). */
|
|
32
|
+
const REM_TO_PX = 16;
|
|
33
|
+
/**
|
|
34
|
+
* Try to compile a token list into a {@link SafeAreaMarker}. Returns
|
|
35
|
+
* `null` when the tokens don't match any recognised safe-area pattern
|
|
36
|
+
* — the caller should fall back to the regular unparsed-value path.
|
|
37
|
+
* @param tokens Declaration value token list from lightningcss.
|
|
38
|
+
* @param themeVars
|
|
39
|
+
* @returns Marker object, or `null`.
|
|
40
|
+
*/
|
|
41
|
+
function detectSafeAreaMarker(tokens, themeVars) {
|
|
42
|
+
const nonWs = stripWhitespace(tokens);
|
|
43
|
+
if (nonWs.length === 0)
|
|
44
|
+
return null;
|
|
45
|
+
// Shape 1: pure env(safe-area-inset-*)
|
|
46
|
+
if (nonWs.length === 1) {
|
|
47
|
+
const side = envSide(nonWs[0]);
|
|
48
|
+
if (side !== null)
|
|
49
|
+
return { __safe: side };
|
|
50
|
+
}
|
|
51
|
+
// Shape 2 / 3: max(env(...), n) or calc(env(...) + n)
|
|
52
|
+
if (nonWs.length === 1 && isFunction(nonWs[0])) {
|
|
53
|
+
const inner = functionInner(nonWs[0]);
|
|
54
|
+
if (inner) {
|
|
55
|
+
const marker = tryFromFunction(inner.name, inner.args, themeVars);
|
|
56
|
+
if (marker)
|
|
57
|
+
return marker;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Short-circuit whether this token is a `function` token.
|
|
64
|
+
* @param token
|
|
65
|
+
*/
|
|
66
|
+
function isFunction(token) {
|
|
67
|
+
return token.type === 'function';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Pull `(name, args-without-whitespace)` out of a function token.
|
|
71
|
+
* @param token A function-type TokenOrValue.
|
|
72
|
+
* @returns Inner record, or null when the shape is unexpected.
|
|
73
|
+
*/
|
|
74
|
+
function functionInner(token) {
|
|
75
|
+
if (token.type !== 'function')
|
|
76
|
+
return null;
|
|
77
|
+
return { name: token.value.name, args: token.value.arguments };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Pattern-match `max(env(...), n)` / `calc(env(...) + n)` / nested
|
|
81
|
+
* screen-minus-y calc. Operates on the function's already-whitespace-
|
|
82
|
+
* trimmed arg list so every branch can index by position.
|
|
83
|
+
* @param name Function name (`max` / `calc`).
|
|
84
|
+
* @param args Raw argument tokens (whitespace still present).
|
|
85
|
+
* @param themeVars
|
|
86
|
+
* @returns Marker, or null when not recognised.
|
|
87
|
+
*/
|
|
88
|
+
function tryFromFunction(name, args, themeVars) {
|
|
89
|
+
if (name === 'max')
|
|
90
|
+
return tryMax(args, themeVars);
|
|
91
|
+
if (name === 'calc')
|
|
92
|
+
return tryCalc(args, themeVars);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `max(env(safe-area-inset-*), <length>)` — Tailwind v4's `*-safe-or-n`
|
|
97
|
+
* shape. Optionally `max(env(...), calc(var(--spacing) * n))` — the
|
|
98
|
+
* calc inside has already been resolved to a bare length by Tailwind's
|
|
99
|
+
* compiler step.
|
|
100
|
+
* @param args Whitespace-preserving argument tokens.
|
|
101
|
+
* @param themeVars
|
|
102
|
+
* @returns Marker, or null.
|
|
103
|
+
*/
|
|
104
|
+
function tryMax(args, themeVars) {
|
|
105
|
+
const parts = splitTopLevelComma(args);
|
|
106
|
+
if (parts.length !== 2)
|
|
107
|
+
return null;
|
|
108
|
+
const firstToken = onlyNonWhitespace(parts[0]);
|
|
109
|
+
if (!firstToken)
|
|
110
|
+
return null;
|
|
111
|
+
const firstSide = envSide(firstToken);
|
|
112
|
+
if (firstSide === null)
|
|
113
|
+
return null;
|
|
114
|
+
const rhs = coerceLengthPx(parts[1], themeVars);
|
|
115
|
+
if (rhs === null)
|
|
116
|
+
return null;
|
|
117
|
+
return { __safe: firstSide, or: rhs };
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Recognise:
|
|
121
|
+
* - `calc(env(safe-area-inset-*) + n)` — `*-safe-offset-n`
|
|
122
|
+
* - `calc(100vh - (env(...-top) + env(...-bottom)))` — `h-screen-safe`
|
|
123
|
+
* @param args Whitespace-preserving calc argument tokens.
|
|
124
|
+
* @param themeVars
|
|
125
|
+
* @returns Marker, or null.
|
|
126
|
+
*/
|
|
127
|
+
function tryCalc(args, themeVars) {
|
|
128
|
+
const [signIndex, sign] = findTopLevelPlusOrMinus(args);
|
|
129
|
+
if (signIndex === -1)
|
|
130
|
+
return reduceNestedCalc(args, themeVars);
|
|
131
|
+
const lhs = stripWhitespace(args.slice(0, signIndex));
|
|
132
|
+
const rhs = stripWhitespace(args.slice(signIndex + 1));
|
|
133
|
+
const offset = matchOffset(lhs, rhs, sign, themeVars);
|
|
134
|
+
if (offset)
|
|
135
|
+
return offset;
|
|
136
|
+
if (sign === '-' && isViewportHeightHundred(lhs) && isParenthesisedTopBottomSum(rhs))
|
|
137
|
+
return { __safe: 'screen-minus-y' };
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Fall-through arm of {@link tryCalc}: when there's no +/− at the calc
|
|
142
|
+
* body's top level, try to interpret the whole body as a nested
|
|
143
|
+
* function (e.g. a bare `calc(max(...))`).
|
|
144
|
+
* @param args Calc arguments.
|
|
145
|
+
* @param themeVars Optional theme-vars table for length resolution.
|
|
146
|
+
* @returns Marker or null.
|
|
147
|
+
*/
|
|
148
|
+
function reduceNestedCalc(args, themeVars) {
|
|
149
|
+
const inner = onlyNonWhitespace(args);
|
|
150
|
+
if (!inner)
|
|
151
|
+
return null;
|
|
152
|
+
return detectSafeAreaMarker([inner], themeVars);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Try to match `calc(env(side) ± amount)` against the two-side split of
|
|
156
|
+
* the calc body. Returns a marker with positive / negative `offset`
|
|
157
|
+
* based on the sign, or null when the shape doesn't fit.
|
|
158
|
+
* @param lhs Left-hand tokens (whitespace already stripped).
|
|
159
|
+
* @param rhs Right-hand tokens (whitespace already stripped).
|
|
160
|
+
* @param sign The `+` or `-` delim captured between them.
|
|
161
|
+
* @param themeVars Optional theme-vars table.
|
|
162
|
+
* @returns Offset marker, or null.
|
|
163
|
+
*/
|
|
164
|
+
function matchOffset(lhs, rhs, sign, themeVars) {
|
|
165
|
+
if (!sign || lhs.length !== 1 || rhs.length !== 1)
|
|
166
|
+
return null;
|
|
167
|
+
const side = envSide(lhs[0]);
|
|
168
|
+
if (side === null)
|
|
169
|
+
return null;
|
|
170
|
+
const amount = coerceLengthPx([rhs[0]], themeVars);
|
|
171
|
+
if (amount === null)
|
|
172
|
+
return null;
|
|
173
|
+
return { __safe: side, offset: sign === '+' ? amount : -amount };
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Check whether a token is the env() that names one of the four safe-area sides.
|
|
177
|
+
* @param token One TokenOrValue.
|
|
178
|
+
* @returns The compact side tag, or `null` when the token isn't a safe-area env reference.
|
|
179
|
+
*/
|
|
180
|
+
function envSide(token) {
|
|
181
|
+
if (token.type !== 'env')
|
|
182
|
+
return null;
|
|
183
|
+
const { name } = token.value;
|
|
184
|
+
if (name.type !== 'ua')
|
|
185
|
+
return null;
|
|
186
|
+
return SIDE_TAG[name.value] ?? null;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Drop whitespace / comment tokens from a list so downstream branches
|
|
190
|
+
* can pattern-match by index without counting spaces.
|
|
191
|
+
* @param tokens Raw token list.
|
|
192
|
+
* @returns Copy with whitespace tokens removed.
|
|
193
|
+
*/
|
|
194
|
+
function stripWhitespace(tokens) {
|
|
195
|
+
const out = [];
|
|
196
|
+
for (const token of tokens) {
|
|
197
|
+
if (isWhitespaceToken(token))
|
|
198
|
+
continue;
|
|
199
|
+
out.push(token);
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Like {@link stripWhitespace} but returns the single non-whitespace
|
|
205
|
+
* token (or null when there's zero or more than one).
|
|
206
|
+
* @param tokens Raw token list.
|
|
207
|
+
* @returns The single meaningful token, or null.
|
|
208
|
+
*/
|
|
209
|
+
function onlyNonWhitespace(tokens) {
|
|
210
|
+
const stripped = stripWhitespace(tokens);
|
|
211
|
+
return stripped.length === 1 ? stripped[0] : null;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Whether the token is pure whitespace / comment — ignorable when
|
|
215
|
+
* matching by position.
|
|
216
|
+
* @param token One TokenOrValue.
|
|
217
|
+
* @returns True when the token carries no semantic value.
|
|
218
|
+
*/
|
|
219
|
+
function isWhitespaceToken(token) {
|
|
220
|
+
if (token.type !== 'token')
|
|
221
|
+
return false;
|
|
222
|
+
const { value } = token;
|
|
223
|
+
return value.type === 'white-space' || value.type === 'comment';
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Split `a, b` top-level argument lists into their slices. Respects
|
|
227
|
+
* nested function/paren groups so commas inside an inner `calc(a, b)`
|
|
228
|
+
* don't cause an outer split.
|
|
229
|
+
* @param args Raw argument token list.
|
|
230
|
+
* @returns Array of slices (one per top-level comma-separated segment).
|
|
231
|
+
*/
|
|
232
|
+
function splitTopLevelComma(args) {
|
|
233
|
+
// Functions already arrive as atomic `{type:'function', value}` nodes,
|
|
234
|
+
// so commas inside them are never in `args` — a flat scan for the
|
|
235
|
+
// raw `comma` token is enough.
|
|
236
|
+
const parts = [[]];
|
|
237
|
+
for (const token of args) {
|
|
238
|
+
if (token.type === 'token' && token.value.type === 'comma') {
|
|
239
|
+
parts.push([]);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
parts.at(-1).push(token);
|
|
243
|
+
}
|
|
244
|
+
return parts;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Find the first top-level `+` / `-` delim in a calc body.
|
|
248
|
+
* @param args Raw argument token list.
|
|
249
|
+
* @returns Tuple of `[index, sign]` or `[-1, null]` when not found.
|
|
250
|
+
*/
|
|
251
|
+
function findTopLevelPlusOrMinus(args) {
|
|
252
|
+
for (const [index, argument] of args.entries()) {
|
|
253
|
+
const token = argument;
|
|
254
|
+
if (token.type !== 'token')
|
|
255
|
+
continue;
|
|
256
|
+
if (token.value.type !== 'delim')
|
|
257
|
+
continue;
|
|
258
|
+
const delim = token.value.value;
|
|
259
|
+
if (delim === '+' || delim === '-')
|
|
260
|
+
return [index, delim];
|
|
261
|
+
}
|
|
262
|
+
return [-1, null];
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Coerce a token list that should represent a CSS length (px / rem /
|
|
266
|
+
* integer-number with no unit) into a px value.
|
|
267
|
+
* @param tokens Tokens for the length fragment.
|
|
268
|
+
* @param themeVars
|
|
269
|
+
* @returns Px value, or null when the shape is unrecognised.
|
|
270
|
+
*/
|
|
271
|
+
function coerceLengthPx(tokens, themeVars) {
|
|
272
|
+
const stripped = stripWhitespace(tokens);
|
|
273
|
+
if (stripped.length !== 1)
|
|
274
|
+
return null;
|
|
275
|
+
return coerceTokenToPx(stripped[0], themeVars);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Convert one token to a px number, handling the lengths Tailwind v4
|
|
279
|
+
* commonly emits after compile: `length` (px/rem), bare numbers,
|
|
280
|
+
* `calc(0.25rem * 4)` nested functions.
|
|
281
|
+
* @param token One TokenOrValue.
|
|
282
|
+
* @param themeVars
|
|
283
|
+
* @returns Px value, or null.
|
|
284
|
+
*/
|
|
285
|
+
function coerceTokenToPx(token, themeVars) {
|
|
286
|
+
if (token.type === 'length') {
|
|
287
|
+
const { unit, value } = token.value;
|
|
288
|
+
if (unit === 'px')
|
|
289
|
+
return value;
|
|
290
|
+
if (unit === 'rem' || unit === 'em')
|
|
291
|
+
return value * REM_TO_PX;
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
if (token.type === 'token' && token.value.type === 'number') {
|
|
295
|
+
return token.value.value;
|
|
296
|
+
}
|
|
297
|
+
if (token.type === 'function' && token.value.name === 'calc') {
|
|
298
|
+
return evaluateSimpleCalc(token.value.arguments, themeVars);
|
|
299
|
+
}
|
|
300
|
+
if (token.type === 'var')
|
|
301
|
+
return resolveVariableToPx(token.value.name.ident, themeVars);
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Evaluate a trivial `calc(A * B)` where A / B are lengths or numbers
|
|
306
|
+
* Tailwind compiles down to — the exact shape `var(--spacing)` resolves
|
|
307
|
+
* to after `theme(inline)` substitution.
|
|
308
|
+
* @param args Raw calc argument token list.
|
|
309
|
+
* @param themeVars
|
|
310
|
+
* @returns Px value, or null.
|
|
311
|
+
*/
|
|
312
|
+
function evaluateSimpleCalc(args, themeVars) {
|
|
313
|
+
const stripped = stripWhitespace(args);
|
|
314
|
+
if (stripped.length === 3) {
|
|
315
|
+
const mul = stripped[1];
|
|
316
|
+
if (mul.type === 'token' && mul.value.type === 'delim' && mul.value.value === '*') {
|
|
317
|
+
const left = coerceTokenToPx(stripped[0], themeVars);
|
|
318
|
+
const right = coerceTokenToPx(stripped[2], themeVars);
|
|
319
|
+
if (left !== null && right !== null)
|
|
320
|
+
return left * right;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (stripped.length === 1)
|
|
324
|
+
return coerceTokenToPx(stripped[0], themeVars);
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Resolve a `var(--name)` reference to a px value using the supplied
|
|
329
|
+
* theme-var table. Returns null when the name isn't registered or the
|
|
330
|
+
* value isn't a recognisable length.
|
|
331
|
+
* @param name Custom-property name (with leading `--`).
|
|
332
|
+
* @param themeVars Lookup table (or undefined).
|
|
333
|
+
* @returns Px value, or null.
|
|
334
|
+
*/
|
|
335
|
+
function resolveVariableToPx(name, themeVars) {
|
|
336
|
+
if (!themeVars)
|
|
337
|
+
return null;
|
|
338
|
+
const raw = themeVars.get(name);
|
|
339
|
+
if (raw === undefined)
|
|
340
|
+
return null;
|
|
341
|
+
const trimmed = raw.trim();
|
|
342
|
+
if (trimmed.endsWith('rem')) {
|
|
343
|
+
const n = Number(trimmed.slice(0, -3));
|
|
344
|
+
return Number.isFinite(n) ? n * REM_TO_PX : null;
|
|
345
|
+
}
|
|
346
|
+
if (trimmed.endsWith('em')) {
|
|
347
|
+
const n = Number(trimmed.slice(0, -2));
|
|
348
|
+
return Number.isFinite(n) ? n * REM_TO_PX : null;
|
|
349
|
+
}
|
|
350
|
+
if (trimmed.endsWith('px')) {
|
|
351
|
+
const n = Number(trimmed.slice(0, -2));
|
|
352
|
+
return Number.isFinite(n) ? n : null;
|
|
353
|
+
}
|
|
354
|
+
const n = Number(trimmed);
|
|
355
|
+
return Number.isFinite(n) ? n : null;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Whether the token list represents `100vh`.
|
|
359
|
+
* @param tokens Whitespace-stripped token list.
|
|
360
|
+
* @returns True when the only meaningful token is the length `100vh`.
|
|
361
|
+
*/
|
|
362
|
+
function isViewportHeightHundred(tokens) {
|
|
363
|
+
if (tokens.length !== 1)
|
|
364
|
+
return false;
|
|
365
|
+
const token = tokens[0];
|
|
366
|
+
if (token.type !== 'length')
|
|
367
|
+
return false;
|
|
368
|
+
return token.value.unit === 'vh' && token.value.value === 100;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Whether the rhs of `calc(100vh - <rhs>)` is the nested `(env(top) + env(bottom))`
|
|
372
|
+
* parenthesised sum Tailwind emits for `h-screen-safe` and siblings.
|
|
373
|
+
* @param tokens Whitespace-stripped rhs token list.
|
|
374
|
+
* @returns True on match.
|
|
375
|
+
*/
|
|
376
|
+
function isParenthesisedTopBottomSum(tokens) {
|
|
377
|
+
// lightningcss emits bare `(...)` as a `parenthesis-block` token
|
|
378
|
+
// followed by the inner tokens inline, then a `close-parenthesis`
|
|
379
|
+
// token at the matching depth. Strip whitespace + the grouping tokens
|
|
380
|
+
// and check that what remains is exactly `env(top) + env(bottom)`
|
|
381
|
+
// (either order).
|
|
382
|
+
const meaningful = [];
|
|
383
|
+
for (const token of tokens) {
|
|
384
|
+
if (isWhitespaceToken(token))
|
|
385
|
+
continue;
|
|
386
|
+
if (token.type === 'token') {
|
|
387
|
+
const t = token.value.type;
|
|
388
|
+
if (t === 'parenthesis-block' || t === 'close-parenthesis')
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
meaningful.push(token);
|
|
392
|
+
}
|
|
393
|
+
if (meaningful.length !== 3)
|
|
394
|
+
return false;
|
|
395
|
+
const plus = meaningful[1];
|
|
396
|
+
if (plus.type !== 'token' || plus.value.type !== 'delim' || plus.value.value !== '+')
|
|
397
|
+
return false;
|
|
398
|
+
const first = envSide(meaningful[0]);
|
|
399
|
+
const last = envSide(meaningful[2]);
|
|
400
|
+
return (first === 't' && last === 'b') || (first === 'b' && last === 't');
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
exports.detectSafeAreaMarker = detectSafeAreaMarker;
|
|
404
|
+
//# sourceMappingURL=safe-area.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-area.cjs","sources":["../../../../../src/core/parser/safe-area.ts"],"sourcesContent":["/**\n * Detect `env(safe-area-inset-*)` usage in a lightningcss TokenOrValue\n * tree and convert the containing declaration into a runtime-resolved\n * {@link SafeAreaMarker}.\n *\n * Three shapes the NativeWind-compatible `*-safe` utilities produce\n * through Tailwind v4's compiler:\n * - Pure `env(safe-area-inset-top)` → `{ __safe: 't' }`\n * - `max(env(safe-area-inset-top), 16px)` → `{ __safe: 't', or: 16 }`\n * - `calc(env(safe-area-inset-top) + 16px)` → `{ __safe: 't', offset: 16 }`\n *\n * The `h-screen-safe` / `min-h-screen-safe` / `max-h-screen-safe` shape\n * — `calc(100vh - (env(top) + env(bottom)))` — reports as\n * `{ __safe: 'screen-minus-y' }`; the runtime resolves against\n * `Dimensions.get('window').height` minus the current top + bottom\n * insets.\n *\n * Unrecognised compound shapes (e.g. `env(safe-area-inset-top, 12px)`\n * with a fallback) return `null` so the caller falls back to the\n * regular token-serialisation path.\n */\n\nimport type { TokenOrValue } from 'lightningcss'\nimport type { SafeAreaMarker } from './types'\n\n/** Map UA env names to the compact side tag used in the marker. */\nconst SIDE_TAG: Record<string, SafeAreaMarker['__safe']> = {\n 'safe-area-inset-top': 't',\n 'safe-area-inset-right': 'r',\n 'safe-area-inset-bottom': 'b',\n 'safe-area-inset-left': 'l',\n}\n\n/** Rem → px factor used across the parser (matches `tokens.ts`). */\nconst REM_TO_PX = 16\n\n/**\n * Theme-var lookup table we optionally receive. Values are stored as\n * raw CSS value strings (`'0.25rem'`, `'#fff'`, …); the safe-area\n * detector only needs the ones that resolve to lengths.\n */\ntype ThemeVars = ReadonlyMap<string, string>\n\n/**\n * Try to compile a token list into a {@link SafeAreaMarker}. Returns\n * `null` when the tokens don't match any recognised safe-area pattern\n * — the caller should fall back to the regular unparsed-value path.\n * @param tokens Declaration value token list from lightningcss.\n * @param themeVars\n * @returns Marker object, or `null`.\n */\nfunction detectSafeAreaMarker(tokens: readonly TokenOrValue[], themeVars?: ThemeVars): SafeAreaMarker | null {\n const nonWs = stripWhitespace(tokens)\n if (nonWs.length === 0) return null\n\n // Shape 1: pure env(safe-area-inset-*)\n if (nonWs.length === 1) {\n const side = envSide(nonWs[0]!)\n if (side !== null) return { __safe: side }\n }\n\n // Shape 2 / 3: max(env(...), n) or calc(env(...) + n)\n if (nonWs.length === 1 && isFunction(nonWs[0]!)) {\n const inner = functionInner(nonWs[0]!)\n if (inner) {\n const marker = tryFromFunction(inner.name, inner.args, themeVars)\n if (marker) return marker\n }\n }\n\n return null\n}\n\n/**\n * Short-circuit whether this token is a `function` token.\n * @param token\n */\nfunction isFunction(token: TokenOrValue): boolean {\n return token.type === 'function'\n}\n\n/**\n * Pull `(name, args-without-whitespace)` out of a function token.\n * @param token A function-type TokenOrValue.\n * @returns Inner record, or null when the shape is unexpected.\n */\nfunction functionInner(token: TokenOrValue): { name: string; args: readonly TokenOrValue[] } | null {\n if (token.type !== 'function') return null\n return { name: token.value.name, args: token.value.arguments }\n}\n\n/**\n * Pattern-match `max(env(...), n)` / `calc(env(...) + n)` / nested\n * screen-minus-y calc. Operates on the function's already-whitespace-\n * trimmed arg list so every branch can index by position.\n * @param name Function name (`max` / `calc`).\n * @param args Raw argument tokens (whitespace still present).\n * @param themeVars\n * @returns Marker, or null when not recognised.\n */\nfunction tryFromFunction(name: string, args: readonly TokenOrValue[], themeVars: ThemeVars | undefined): SafeAreaMarker | null {\n if (name === 'max') return tryMax(args, themeVars)\n if (name === 'calc') return tryCalc(args, themeVars)\n return null\n}\n\n/**\n * `max(env(safe-area-inset-*), <length>)` — Tailwind v4's `*-safe-or-n`\n * shape. Optionally `max(env(...), calc(var(--spacing) * n))` — the\n * calc inside has already been resolved to a bare length by Tailwind's\n * compiler step.\n * @param args Whitespace-preserving argument tokens.\n * @param themeVars\n * @returns Marker, or null.\n */\nfunction tryMax(args: readonly TokenOrValue[], themeVars: ThemeVars | undefined): SafeAreaMarker | null {\n const parts = splitTopLevelComma(args)\n if (parts.length !== 2) return null\n const firstToken = onlyNonWhitespace(parts[0]!)\n if (!firstToken) return null\n const firstSide = envSide(firstToken)\n if (firstSide === null) return null\n const rhs = coerceLengthPx(parts[1]!, themeVars)\n if (rhs === null) return null\n return { __safe: firstSide, or: rhs }\n}\n\n/**\n * Recognise:\n * - `calc(env(safe-area-inset-*) + n)` — `*-safe-offset-n`\n * - `calc(100vh - (env(...-top) + env(...-bottom)))` — `h-screen-safe`\n * @param args Whitespace-preserving calc argument tokens.\n * @param themeVars\n * @returns Marker, or null.\n */\nfunction tryCalc(args: readonly TokenOrValue[], themeVars: ThemeVars | undefined): SafeAreaMarker | null {\n const [signIndex, sign] = findTopLevelPlusOrMinus(args)\n if (signIndex === -1) return reduceNestedCalc(args, themeVars)\n const lhs = stripWhitespace(args.slice(0, signIndex))\n const rhs = stripWhitespace(args.slice(signIndex + 1))\n const offset = matchOffset(lhs, rhs, sign, themeVars)\n if (offset) return offset\n if (sign === '-' && isViewportHeightHundred(lhs) && isParenthesisedTopBottomSum(rhs)) return { __safe: 'screen-minus-y' }\n return null\n}\n\n/**\n * Fall-through arm of {@link tryCalc}: when there's no +/− at the calc\n * body's top level, try to interpret the whole body as a nested\n * function (e.g. a bare `calc(max(...))`).\n * @param args Calc arguments.\n * @param themeVars Optional theme-vars table for length resolution.\n * @returns Marker or null.\n */\nfunction reduceNestedCalc(args: readonly TokenOrValue[], themeVars: ThemeVars | undefined): SafeAreaMarker | null {\n const inner = onlyNonWhitespace(args)\n if (!inner) return null\n return detectSafeAreaMarker([inner], themeVars)\n}\n\n/**\n * Try to match `calc(env(side) ± amount)` against the two-side split of\n * the calc body. Returns a marker with positive / negative `offset`\n * based on the sign, or null when the shape doesn't fit.\n * @param lhs Left-hand tokens (whitespace already stripped).\n * @param rhs Right-hand tokens (whitespace already stripped).\n * @param sign The `+` or `-` delim captured between them.\n * @param themeVars Optional theme-vars table.\n * @returns Offset marker, or null.\n */\nfunction matchOffset(\n lhs: readonly TokenOrValue[],\n rhs: readonly TokenOrValue[],\n sign: '+' | '-' | null,\n themeVars: ThemeVars | undefined,\n): SafeAreaMarker | null {\n if (!sign || lhs.length !== 1 || rhs.length !== 1) return null\n const side = envSide(lhs[0]!)\n if (side === null) return null\n const amount = coerceLengthPx([rhs[0]!], themeVars)\n if (amount === null) return null\n return { __safe: side, offset: sign === '+' ? amount : -amount }\n}\n\n/**\n * Check whether a token is the env() that names one of the four safe-area sides.\n * @param token One TokenOrValue.\n * @returns The compact side tag, or `null` when the token isn't a safe-area env reference.\n */\nfunction envSide(token: TokenOrValue): SafeAreaMarker['__safe'] | null {\n if (token.type !== 'env') return null\n const { name } = token.value\n if (name.type !== 'ua') return null\n return SIDE_TAG[name.value] ?? null\n}\n\n/**\n * Drop whitespace / comment tokens from a list so downstream branches\n * can pattern-match by index without counting spaces.\n * @param tokens Raw token list.\n * @returns Copy with whitespace tokens removed.\n */\nfunction stripWhitespace(tokens: readonly TokenOrValue[]): readonly TokenOrValue[] {\n const out: TokenOrValue[] = []\n for (const token of tokens) {\n if (isWhitespaceToken(token)) continue\n out.push(token)\n }\n return out\n}\n\n/**\n * Like {@link stripWhitespace} but returns the single non-whitespace\n * token (or null when there's zero or more than one).\n * @param tokens Raw token list.\n * @returns The single meaningful token, or null.\n */\nfunction onlyNonWhitespace(tokens: readonly TokenOrValue[]): TokenOrValue | null {\n const stripped = stripWhitespace(tokens)\n return stripped.length === 1 ? stripped[0]! : null\n}\n\n/**\n * Whether the token is pure whitespace / comment — ignorable when\n * matching by position.\n * @param token One TokenOrValue.\n * @returns True when the token carries no semantic value.\n */\nfunction isWhitespaceToken(token: TokenOrValue): boolean {\n if (token.type !== 'token') return false\n const { value } = token\n return value.type === 'white-space' || value.type === 'comment'\n}\n\n/**\n * Split `a, b` top-level argument lists into their slices. Respects\n * nested function/paren groups so commas inside an inner `calc(a, b)`\n * don't cause an outer split.\n * @param args Raw argument token list.\n * @returns Array of slices (one per top-level comma-separated segment).\n */\nfunction splitTopLevelComma(args: readonly TokenOrValue[]): readonly TokenOrValue[][] {\n // Functions already arrive as atomic `{type:'function', value}` nodes,\n // so commas inside them are never in `args` — a flat scan for the\n // raw `comma` token is enough.\n const parts: TokenOrValue[][] = [[]]\n for (const token of args) {\n if (token.type === 'token' && token.value.type === 'comma') {\n parts.push([])\n continue\n }\n parts.at(-1)!.push(token)\n }\n return parts\n}\n\n/**\n * Find the first top-level `+` / `-` delim in a calc body.\n * @param args Raw argument token list.\n * @returns Tuple of `[index, sign]` or `[-1, null]` when not found.\n */\nfunction findTopLevelPlusOrMinus(args: readonly TokenOrValue[]): [number, '+' | '-' | null] {\n for (const [index, argument] of args.entries()) {\n const token = argument!\n if (token.type !== 'token') continue\n if (token.value.type !== 'delim') continue\n const delim = token.value.value as string\n if (delim === '+' || delim === '-') return [index, delim]\n }\n return [-1, null]\n}\n\n/**\n * Coerce a token list that should represent a CSS length (px / rem /\n * integer-number with no unit) into a px value.\n * @param tokens Tokens for the length fragment.\n * @param themeVars\n * @returns Px value, or null when the shape is unrecognised.\n */\nfunction coerceLengthPx(tokens: readonly TokenOrValue[], themeVars: ThemeVars | undefined): number | null {\n const stripped = stripWhitespace(tokens)\n if (stripped.length !== 1) return null\n return coerceTokenToPx(stripped[0]!, themeVars)\n}\n\n/**\n * Convert one token to a px number, handling the lengths Tailwind v4\n * commonly emits after compile: `length` (px/rem), bare numbers,\n * `calc(0.25rem * 4)` nested functions.\n * @param token One TokenOrValue.\n * @param themeVars\n * @returns Px value, or null.\n */\nfunction coerceTokenToPx(token: TokenOrValue, themeVars: ThemeVars | undefined): number | null {\n if (token.type === 'length') {\n const { unit, value } = token.value\n if (unit === 'px') return value\n if (unit === 'rem' || unit === 'em') return value * REM_TO_PX\n return null\n }\n if (token.type === 'token' && token.value.type === 'number') {\n return token.value.value\n }\n if (token.type === 'function' && token.value.name === 'calc') {\n return evaluateSimpleCalc(token.value.arguments, themeVars)\n }\n if (token.type === 'var') return resolveVariableToPx(token.value.name.ident, themeVars)\n return null\n}\n\n/**\n * Evaluate a trivial `calc(A * B)` where A / B are lengths or numbers\n * Tailwind compiles down to — the exact shape `var(--spacing)` resolves\n * to after `theme(inline)` substitution.\n * @param args Raw calc argument token list.\n * @param themeVars\n * @returns Px value, or null.\n */\nfunction evaluateSimpleCalc(args: readonly TokenOrValue[], themeVars: ThemeVars | undefined): number | null {\n const stripped = stripWhitespace(args)\n if (stripped.length === 3) {\n const mul = stripped[1]!\n if (mul.type === 'token' && mul.value.type === 'delim' && (mul.value.value as string) === '*') {\n const left = coerceTokenToPx(stripped[0]!, themeVars)\n const right = coerceTokenToPx(stripped[2]!, themeVars)\n if (left !== null && right !== null) return left * right\n }\n }\n if (stripped.length === 1) return coerceTokenToPx(stripped[0]!, themeVars)\n return null\n}\n\n/**\n * Resolve a `var(--name)` reference to a px value using the supplied\n * theme-var table. Returns null when the name isn't registered or the\n * value isn't a recognisable length.\n * @param name Custom-property name (with leading `--`).\n * @param themeVars Lookup table (or undefined).\n * @returns Px value, or null.\n */\nfunction resolveVariableToPx(name: string, themeVars: ThemeVars | undefined): number | null {\n if (!themeVars) return null\n const raw = themeVars.get(name)\n if (raw === undefined) return null\n const trimmed = raw.trim()\n if (trimmed.endsWith('rem')) {\n const n = Number(trimmed.slice(0, -3))\n return Number.isFinite(n) ? n * REM_TO_PX : null\n }\n if (trimmed.endsWith('em')) {\n const n = Number(trimmed.slice(0, -2))\n return Number.isFinite(n) ? n * REM_TO_PX : null\n }\n if (trimmed.endsWith('px')) {\n const n = Number(trimmed.slice(0, -2))\n return Number.isFinite(n) ? n : null\n }\n const n = Number(trimmed)\n return Number.isFinite(n) ? n : null\n}\n\n/**\n * Whether the token list represents `100vh`.\n * @param tokens Whitespace-stripped token list.\n * @returns True when the only meaningful token is the length `100vh`.\n */\nfunction isViewportHeightHundred(tokens: readonly TokenOrValue[]): boolean {\n if (tokens.length !== 1) return false\n const token = tokens[0]!\n if (token.type !== 'length') return false\n return token.value.unit === 'vh' && token.value.value === 100\n}\n\n/**\n * Whether the rhs of `calc(100vh - <rhs>)` is the nested `(env(top) + env(bottom))`\n * parenthesised sum Tailwind emits for `h-screen-safe` and siblings.\n * @param tokens Whitespace-stripped rhs token list.\n * @returns True on match.\n */\nfunction isParenthesisedTopBottomSum(tokens: readonly TokenOrValue[]): boolean {\n // lightningcss emits bare `(...)` as a `parenthesis-block` token\n // followed by the inner tokens inline, then a `close-parenthesis`\n // token at the matching depth. Strip whitespace + the grouping tokens\n // and check that what remains is exactly `env(top) + env(bottom)`\n // (either order).\n const meaningful: TokenOrValue[] = []\n for (const token of tokens) {\n if (isWhitespaceToken(token)) continue\n if (token.type === 'token') {\n const t = token.value.type\n if (t === 'parenthesis-block' || t === 'close-parenthesis') continue\n }\n meaningful.push(token)\n }\n if (meaningful.length !== 3) return false\n const plus = meaningful[1]!\n if (plus.type !== 'token' || plus.value.type !== 'delim' || (plus.value.value as string) !== '+') return false\n const first = envSide(meaningful[0]!)\n const last = envSide(meaningful[2]!)\n return (first === 't' && last === 'b') || (first === 'b' && last === 't')\n}\n\nexport { detectSafeAreaMarker }\n\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;AAKH;AACA,MAAM,QAAQ,GAA6C;AACzD,IAAA,qBAAqB,EAAE,GAAG;AAC1B,IAAA,uBAAuB,EAAE,GAAG;AAC5B,IAAA,wBAAwB,EAAE,GAAG;AAC7B,IAAA,sBAAsB,EAAE,GAAG;CAC5B;AAED;AACA,MAAM,SAAS,GAAG,EAAE;AASpB;;;;;;;AAOG;AACH,SAAS,oBAAoB,CAAC,MAA+B,EAAE,SAAqB,EAAA;AAClF,IAAA,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC;AACrC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;;AAGnC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,IAAI;AAAE,YAAA,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
+
/**
|
|
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 };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pull a bare class name out of a lightningcss selector-part array. Accepts
|
|
5
|
+
* only the simple shape — one `{type: 'class', name}` component — since
|
|
6
|
+
* Tailwind utility rules land as flat single-class selectors once variants
|
|
7
|
+
* are folded in. Compound or pseudo selectors return `null` so the caller
|
|
8
|
+
* skips them.
|
|
9
|
+
* @param selector One selector's component array.
|
|
10
|
+
* @returns Bare class name, or `null` when the selector is anything more complex.
|
|
11
|
+
*/
|
|
12
|
+
function classNameFromSelector(selector) {
|
|
13
|
+
if (selector.length !== 1)
|
|
14
|
+
return null;
|
|
15
|
+
const [head] = selector;
|
|
16
|
+
if (head?.type !== 'class')
|
|
17
|
+
return null;
|
|
18
|
+
return head.name;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.classNameFromSelector = classNameFromSelector;
|
|
22
|
+
//# sourceMappingURL=selector.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.cjs","sources":["../../../../../src/core/parser/selector.ts"],"sourcesContent":["import type { SelectorComponent } from 'lightningcss'\n\n/**\n * Pull a bare class name out of a lightningcss selector-part array. Accepts\n * only the simple shape — one `{type: 'class', name}` component — since\n * Tailwind utility rules land as flat single-class selectors once variants\n * are folded in. Compound or pseudo selectors return `null` so the caller\n * skips them.\n * @param selector One selector's component array.\n * @returns Bare class name, or `null` when the selector is anything more complex.\n */\nexport function classNameFromSelector(selector: readonly SelectorComponent[]): string | null {\n if (selector.length !== 1) return null\n const [head] = selector\n if (head?.type !== 'class') return null\n return head.name\n}\n"],"names":[],"mappings":";;AAEA;;;;;;;;AAQG;AACG,SAAU,qBAAqB,CAAC,QAAsC,EAAA;AAC1E,IAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACtC,IAAA,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ;AACvB,IAAA,IAAI,IAAI,EAAE,IAAI,KAAK,OAAO;AAAE,QAAA,OAAO,IAAI;IACvC,OAAO,IAAI,CAAC,IAAI;AAClB;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SelectorComponent } from 'lightningcss';
|
|
2
|
+
/**
|
|
3
|
+
* Pull a bare class name out of a lightningcss selector-part array. Accepts
|
|
4
|
+
* only the simple shape — one `{type: 'class', name}` component — since
|
|
5
|
+
* Tailwind utility rules land as flat single-class selectors once variants
|
|
6
|
+
* are folded in. Compound or pseudo selectors return `null` so the caller
|
|
7
|
+
* skips them.
|
|
8
|
+
* @param selector One selector's component array.
|
|
9
|
+
* @returns Bare class name, or `null` when the selector is anything more complex.
|
|
10
|
+
*/
|
|
11
|
+
export declare function classNameFromSelector(selector: readonly SelectorComponent[]): string | null;
|