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 @@
|
|
|
1
|
+
{"version":3,"file":"animation.mjs","sources":["../../../../../src/core/parser/animation.ts"],"sourcesContent":["import type {\n Animation,\n AnimationDirection,\n AnimationFillMode,\n AnimationIterationCount,\n AnimationName,\n AnimationPlayState,\n EasingFunction,\n PropertyId,\n Time,\n Transition,\n} from 'lightningcss'\nimport { kebabToCamel } from './case-convert'\nimport type { RNEntry } from './types'\n\n/**\n * Convert one PropertyId ident into the camelCase RN style key\n * Reanimated v4's CSS engine matches against. Tailwind emits CSS names\n * in kebab-case (`background-color`); RN stores `backgroundColor` in\n * the actual style object, and Reanimated only fires a transition when\n * the watched key matches the changed key — so kebab-case here would\n * silently no-op every multi-word color/border transition.\n *\n * Special cases:\n * - `'all'` passes through unchanged.\n * - `--tw-*` Tailwind internal custom props are dropped — they have\n * no RN equivalent and Reanimated can't watch them.\n * - Other `--user-defined` custom props pass through verbatim.\n * @param property Typed property identifier.\n * @returns RN-style key, or null when the property has no RN equivalent.\n */\nfunction propertyIdToString(property: PropertyId): string | null {\n // Custom properties surface in two shapes: either as `{property:\n // 'custom', value: {name: '--x'}}` or — when lightningcss recognises\n // the leading `--` directly in propertyId — as `{property: '--x'}`.\n // Handle both, drop Tailwind internals, keep user customs verbatim.\n if (property.property === 'custom' && 'value' in property) {\n const { value } = property\n const customName = value && typeof value === 'object' && 'name' in value && typeof value.name === 'string' ? value.name : null\n if (!customName) return null\n return customName.startsWith('--tw-') ? null : customName\n }\n if (typeof property.property === 'string' && property.property.startsWith('--')) {\n return property.property.startsWith('--tw-') ? null : property.property\n }\n if (property.property === 'all') return 'all'\n return kebabToCamel(property.property)\n}\n\n/**\n * Collapse a single-element list into its scalar, otherwise return the\n * list unchanged. Reanimated accepts both forms; the scalar is the\n * common case.\n * @param values Values to collapse.\n * @returns A scalar when the list has one element, otherwise the list.\n */\nfunction singleOrArray<T>(values: readonly T[]): T | readonly T[] {\n if (values.length === 1) return values[0]!\n return values\n}\n\n/**\n * Render a number without trailing noise (strips IEEE drift beyond 4\n * decimals, then removes trailing zeros).\n * @param value Number to format.\n * @returns Compact string form.\n */\nfunction formatNumber(value: number): string {\n const rounded = Math.round(value * 10_000) / 10_000\n return String(rounded)\n}\n\n/**\n * Reanimated v4's CSS engine doesn't accept `cubic-bezier(...)` as a\n * string — only the predefined keywords `linear`, `ease`, `ease-in`,\n * `ease-out`, `ease-in-out`, `step-start`, `step-end`. Tailwind's\n * `transition-colors` / `ease-in-out` / etc. emit the CSS-standard\n * Material curves as cubic-bezier; we snap those to the closest\n * predefined keyword by matching the well-known control-point shapes,\n * falling back to `ease-in-out` (the most common Tailwind default).\n *\n * Direct matches:\n * - `cubic-bezier(0.25, 0.1, 0.25, 1)` → `ease` (CSS spec default)\n * - `cubic-bezier(0.4, 0, 1, 1)` → `ease-in`\n * - `cubic-bezier(0, 0, 0.2, 1)` → `ease-out`\n * - `cubic-bezier(0.4, 0, 0.2, 1)` → `ease-in-out` (Material standard)\n * - linear shape (`x1=y1=0, x2=y2=1`) → `linear`\n *\n * Anything else: classify by control-point shape — front-loaded curves\n * → `ease-in`, back-loaded → `ease-out`, both → `ease-in-out`.\n * @param x1 First control-point x (0–1).\n * @param y1 First control-point y (0–1).\n * @param x2 Second control-point x (0–1).\n * @param y2 Second control-point y (0–1).\n * @returns Closest matching CSS easing keyword.\n */\nfunction snapCubicBezierToKeyword(x1: number, y1: number, x2: number, y2: number): string {\n if (matchesBezier(x1, y1, x2, y2, 0, 0, 1, 1)) return 'linear'\n if (matchesBezier(x1, y1, x2, y2, 0.25, 0.1, 0.25, 1)) return 'ease'\n if (matchesBezier(x1, y1, x2, y2, 0.4, 0, 1, 1)) return 'ease-in'\n if (matchesBezier(x1, y1, x2, y2, 0, 0, 0.2, 1)) return 'ease-out'\n if (matchesBezier(x1, y1, x2, y2, 0.4, 0, 0.2, 1)) return 'ease-in-out'\n // Heuristic for unknown bezier shapes:\n // - x1 ≈ 0 → starts straight (decelerates) → ease-out\n // - x2 ≈ 1 → ends straight (accelerates) → ease-in\n // - both small, both medium → ease-in-out\n const startsFlat = x1 < 0.1\n const endsFlat = x2 > 0.9\n if (startsFlat && !endsFlat) return 'ease-out'\n if (!startsFlat && endsFlat) return 'ease-in'\n return 'ease-in-out'\n}\n\n/**\n * Approximate equality of two cubic-bezier control-point sets — IEEE\n * float noise from lightningcss / culori means literal `===` rarely\n * holds, so we tolerate a tiny epsilon.\n * @param ax1 Actual first x.\n * @param ay1 Actual first y.\n * @param ax2 Actual second x.\n * @param ay2 Actual second y.\n * @param tx1 Target first x.\n * @param ty1 Target first y.\n * @param tx2 Target second x.\n * @param ty2 Target second y.\n * @returns Whether the two beziers are component-wise within 0.01 of each other.\n */\nfunction matchesBezier(\n ax1: number,\n ay1: number,\n ax2: number,\n ay2: number,\n tx1: number,\n ty1: number,\n tx2: number,\n ty2: number,\n): boolean {\n const tolerance = 0.01\n return (\n Math.abs(ax1 - tx1) < tolerance &&\n Math.abs(ay1 - ty1) < tolerance &&\n Math.abs(ax2 - tx2) < tolerance &&\n Math.abs(ay2 - ty2) < tolerance\n )\n}\n\n/**\n * Serialize a lightningcss `EasingFunction` into a CSS string Reanimated\n * v4's CSS engine understands. Reanimated accepts the same timing-function\n * strings as CSS transitions/animations, so we emit the canonical CSS\n * form.\n * @param fn Typed easing function.\n * @returns CSS string, e.g. `'linear'` / `'ease-in-out'` / `'cubic-bezier(0.4, 0, 0.2, 1)'`.\n */\nexport function easingFunctionToString(fn: EasingFunction): string {\n switch (fn.type) {\n case 'linear': {\n return 'linear'\n }\n case 'ease':\n case 'ease-in':\n case 'ease-out':\n case 'ease-in-out': {\n return fn.type\n }\n case 'cubic-bezier': {\n return snapCubicBezierToKeyword(fn.x1, fn.y1, fn.x2, fn.y2)\n }\n case 'steps': {\n const pos = fn.position?.type ?? 'end'\n return `steps(${fn.count}, ${pos})`\n }\n default: {\n return 'ease'\n }\n }\n}\n\n/**\n * Format a `Time` value into a CSS string (`150ms`, `1s`). Reanimated's\n * CSS engine accepts either `ms` or `s`; we pick `ms` unless the value\n * is a whole-second multiple for readability.\n * @param time Typed time value.\n * @returns CSS time string.\n */\nexport function timeToString(time: Time): string {\n if (time.type === 'milliseconds') return `${formatNumber(time.value)}ms`\n return `${formatNumber(time.value)}s`\n}\n\n/**\n * Convert a single `animation-name` value to a string. Tailwind's\n * `animate-none` produces `{ type: 'none' }` which we drop.\n * @param name Typed animation name.\n * @returns Keyframe identifier, or null when `none`.\n */\nexport function animationNameToString(name: AnimationName): string | null {\n if (name.type === 'none') return null\n if (name.type === 'ident') return name.value\n if (name.type === 'string') return name.value\n return null\n}\n\n/**\n * Convert a single `animation-iteration-count` value to the CSS shape\n * Reanimated wants: either a finite integer or the `'infinite'` string.\n * @param count Typed iteration count.\n * @returns Number or `'infinite'`.\n */\nexport function iterationCountToValue(count: AnimationIterationCount): number | string {\n if (count.type === 'infinite') return 'infinite'\n return count.value\n}\n\n/**\n * Decompose the `animation: <name> <duration> <timing> <iteration> …`\n * shorthand into the per-property RN entries Reanimated consumes. A single\n * `animation` declaration can name multiple animations — we emit the first\n * one (Tailwind's `animate-*` utilities always emit exactly one).\n * @param animations Parsed animation list from lightningcss.\n * @returns RN entries, empty when the shorthand names `none`.\n */\nexport function animationShorthandToEntries(animations: readonly Animation[]): readonly RNEntry[] {\n const [first] = animations\n if (!first) return []\n const name = animationNameToString(first.name)\n if (!name) return []\n const entries: RNEntry[] = [['animationName', name]]\n if (first.duration) entries.push(['animationDuration', timeToString(first.duration)])\n if (first.timingFunction) entries.push(['animationTimingFunction', easingFunctionToString(first.timingFunction)])\n if (first.iterationCount) entries.push(['animationIterationCount', iterationCountToValue(first.iterationCount)])\n if (first.direction && first.direction !== 'normal') entries.push(['animationDirection', first.direction])\n if (first.fillMode && first.fillMode !== 'none') entries.push(['animationFillMode', first.fillMode])\n if (first.delay && first.delay.value !== 0) entries.push(['animationDelay', timeToString(first.delay)])\n if (first.playState && first.playState !== 'running') entries.push(['animationPlayState', first.playState])\n return entries\n}\n\n/**\n * Emit `animationName` for a standalone `animation-name: spin` declaration.\n * @param names Typed `animation-name` list.\n * @returns Single-entry `animationName` or empty when `none`.\n */\nexport function animationNameEntries(names: readonly AnimationName[]): readonly RNEntry[] {\n const [first] = names\n if (!first) return []\n const name = animationNameToString(first)\n if (!name) return []\n return [['animationName', name]]\n}\n\n/**\n * Emit `animationDuration` for a standalone `animation-duration` declaration.\n * @param durations Typed duration list.\n * @returns Single-entry list.\n */\nexport function animationDurationEntries(durations: readonly Time[]): readonly RNEntry[] {\n const [first] = durations\n if (!first) return []\n return [['animationDuration', timeToString(first)]]\n}\n\n/**\n * Emit `animationTimingFunction` for a standalone `animation-timing-function`.\n * @param fns Typed timing-function list.\n * @returns Single-entry list.\n */\nexport function animationTimingFunctionEntries(fns: readonly EasingFunction[]): readonly RNEntry[] {\n const [first] = fns\n if (!first) return []\n return [['animationTimingFunction', easingFunctionToString(first)]]\n}\n\n/**\n * Emit `animationIterationCount` for a standalone declaration.\n * @param counts Typed iteration-count list.\n * @returns Single-entry list.\n */\nexport function animationIterationCountEntries(counts: readonly AnimationIterationCount[]): readonly RNEntry[] {\n const [first] = counts\n if (!first) return []\n return [['animationIterationCount', iterationCountToValue(first)]]\n}\n\n/**\n * Emit `animationDelay` for a standalone declaration.\n * @param delays Typed delay list.\n * @returns Single-entry list.\n */\nexport function animationDelayEntries(delays: readonly Time[]): readonly RNEntry[] {\n const [first] = delays\n if (!first) return []\n return [['animationDelay', timeToString(first)]]\n}\n\n/**\n * Emit `animationDirection` for a standalone declaration.\n * @param directions Typed direction list.\n * @returns Single-entry list.\n */\nexport function animationDirectionEntries(directions: readonly AnimationDirection[]): readonly RNEntry[] {\n const [first] = directions\n if (!first) return []\n return [['animationDirection', first]]\n}\n\n/**\n * Emit `animationFillMode` for a standalone declaration.\n * @param modes Typed fill-mode list.\n * @returns Single-entry list.\n */\nexport function animationFillModeEntries(modes: readonly AnimationFillMode[]): readonly RNEntry[] {\n const [first] = modes\n if (!first) return []\n return [['animationFillMode', first]]\n}\n\n/**\n * Emit `animationPlayState` for a standalone declaration.\n * @param states Typed play-state list.\n * @returns Single-entry list.\n */\nexport function animationPlayStateEntries(states: readonly AnimationPlayState[]): readonly RNEntry[] {\n const [first] = states\n if (!first) return []\n return [['animationPlayState', first]]\n}\n\n/**\n * Convert the `transition-property` list into an RN-consumable form.\n * Reanimated accepts either a string (`'all'`, `'opacity'`) or an array\n * of property names. We emit the array shape even for singletons so the\n * runtime can handle it uniformly.\n * @param properties Typed transition-property list.\n * @returns Single-entry list with `transitionProperty`.\n */\nexport function transitionPropertyEntries(properties: readonly PropertyId[]): readonly RNEntry[] {\n const names = properties.map((p) => propertyIdToString(p)).filter((name): name is string => name !== null)\n if (names.length === 0) return []\n if (names.length === 1) return [['transitionProperty', names[0]!]]\n return [['transitionProperty', names]]\n}\n\n/**\n * Decompose the `transition: <prop> <duration> <timing> <delay>` shorthand\n * into the per-property RN entries Reanimated consumes. A declaration can\n * name multiple transitions; we emit one entry per slot, collapsing\n * identical slots into a scalar.\n * @param transitions Parsed transition list from lightningcss.\n * @returns RN entries — zero or more.\n */\nexport function transitionShorthandToEntries(transitions: readonly Transition[]): readonly RNEntry[] {\n if (transitions.length === 0) return []\n const properties: string[] = []\n const durations: string[] = []\n const timings: string[] = []\n const delays: string[] = []\n for (const t of transitions) {\n const name = propertyIdToString(t.property)\n if (name) properties.push(name)\n if (t.duration) durations.push(timeToString(t.duration))\n if (t.timingFunction) timings.push(easingFunctionToString(t.timingFunction))\n if (t.delay) delays.push(timeToString(t.delay))\n }\n const entries: RNEntry[] = []\n if (properties.length > 0) entries.push(['transitionProperty', singleOrArray(properties)])\n if (durations.length > 0) entries.push(['transitionDuration', singleOrArray(durations)])\n if (timings.length > 0) entries.push(['transitionTimingFunction', singleOrArray(timings)])\n if (delays.some((d) => d !== '0s')) entries.push(['transitionDelay', singleOrArray(delays)])\n return entries\n}\n\n/**\n * Emit `transitionDuration` for a standalone declaration.\n * @param durations Typed duration list.\n * @returns Single-entry list.\n */\nexport function transitionDurationEntries(durations: readonly Time[]): readonly RNEntry[] {\n if (durations.length === 0) return []\n const strings = durations.map((d) => timeToString(d))\n return [['transitionDuration', singleOrArray(strings)]]\n}\n\n/**\n * Emit `transitionTimingFunction` for a standalone declaration.\n * @param fns Typed timing-function list.\n * @returns Single-entry list.\n */\nexport function transitionTimingFunctionEntries(fns: readonly EasingFunction[]): readonly RNEntry[] {\n if (fns.length === 0) return []\n const strings = fns.map((f) => easingFunctionToString(f))\n return [['transitionTimingFunction', singleOrArray(strings)]]\n}\n\n/**\n * Emit `transitionDelay` for a standalone declaration.\n * @param delays Typed delay list.\n * @returns Single-entry list.\n */\nexport function transitionDelayEntries(delays: readonly Time[]): readonly RNEntry[] {\n if (delays.length === 0) return []\n const strings = delays.map((d) => timeToString(d))\n return [['transitionDelay', singleOrArray(strings)]]\n}\n"],"names":[],"mappings":";;AAeA;;;;;;;;;;;;;;;AAeG;AACH,SAAS,kBAAkB,CAAC,QAAoB,EAAA;;;;;IAK9C,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,IAAI,QAAQ,EAAE;AACzD,QAAA,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ;AAC1B,QAAA,MAAM,UAAU,GAAG,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,GAAG,KAAK,CAAC,IAAI,GAAG,IAAI;AAC9H,QAAA,IAAI,CAAC,UAAU;AAAE,YAAA,OAAO,IAAI;AAC5B,QAAA,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,UAAU;IAC3D;AACA,IAAA,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,QAAQ,IA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D;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Declaration as LcDeclaration } from 'lightningcss';
|
|
2
|
+
import type { RNEntry } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatch border-* longhands and their logical-direction variants to
|
|
5
|
+
* RN style entries. Returns `null` for any property the dispatcher
|
|
6
|
+
* doesn't handle so the caller can fall through.
|
|
7
|
+
*
|
|
8
|
+
* Logical-direction inputs (`border-inline-*`, `border-block-*`,
|
|
9
|
+
* `border-inline-start-*`, …) lower to RN's physical pairs
|
|
10
|
+
* (`borderLeft*` / `borderRight*` / `borderTop*` / `borderBottom*`)
|
|
11
|
+
* since RN doesn't honor logical directions at the style level.
|
|
12
|
+
* @param decl One lightningcss declaration.
|
|
13
|
+
* @returns RN entries when the property matched, else `null`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function dispatchBorderDeclaration(decl: LcDeclaration): readonly RNEntry[] | null;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { kebabToCamel } from './case-convert.mjs';
|
|
2
|
+
import { cssColorToString } from './color.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Build an inline-color pair from a `{start, end}`-shaped value.
|
|
6
|
+
* @param leftKey RN key for the start side.
|
|
7
|
+
* @param rightKey RN key for the end side.
|
|
8
|
+
* @param value Typed `{start, end}` color value.
|
|
9
|
+
* @returns Two RN entries.
|
|
10
|
+
*/
|
|
11
|
+
function colorPair(leftKey, rightKey, value) {
|
|
12
|
+
const tagged = value;
|
|
13
|
+
return [
|
|
14
|
+
[leftKey, cssColorToString(tagged.start)],
|
|
15
|
+
[rightKey, cssColorToString(tagged.end)],
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Coerce a border-width-shaped length to a pixel number. Drops
|
|
20
|
+
* percentages — RN borders don't accept them.
|
|
21
|
+
* @param value Typed length value (`{type: 'length', value: {unit, value}}`).
|
|
22
|
+
* @returns Pixel number, or null when unrepresentable.
|
|
23
|
+
*/
|
|
24
|
+
function lengthToPxValue(value) {
|
|
25
|
+
if (typeof value !== 'object' || value === null)
|
|
26
|
+
return null;
|
|
27
|
+
const tagged = value;
|
|
28
|
+
const inner = tagged.type === 'length'
|
|
29
|
+
? tagged.value?.value
|
|
30
|
+
: tagged.value;
|
|
31
|
+
if (!inner || typeof inner.value !== 'number')
|
|
32
|
+
return null;
|
|
33
|
+
const dim = inner;
|
|
34
|
+
if (dim.unit === 'px')
|
|
35
|
+
return dim.value;
|
|
36
|
+
if (dim.unit === 'rem' || dim.unit === 'em')
|
|
37
|
+
return dim.value * 16;
|
|
38
|
+
return dim.value;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Build an inline-width pair from a `{start, end}`-shaped value.
|
|
42
|
+
* @param leftKey RN key for the start side.
|
|
43
|
+
* @param rightKey RN key for the end side.
|
|
44
|
+
* @param value Typed `{start, end}` length value.
|
|
45
|
+
* @returns Two RN entries, or empty when either side is unrepresentable.
|
|
46
|
+
*/
|
|
47
|
+
function widthPair(leftKey, rightKey, value) {
|
|
48
|
+
const tagged = value;
|
|
49
|
+
const start = lengthToPxValue(tagged.start);
|
|
50
|
+
const end = lengthToPxValue(tagged.end);
|
|
51
|
+
if (start === null || end === null)
|
|
52
|
+
return [];
|
|
53
|
+
return [
|
|
54
|
+
[leftKey, start],
|
|
55
|
+
[rightKey, end],
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Expand a `border-width` shorthand to RN longhands. Collapses to the
|
|
60
|
+
* `borderWidth` shorthand when all four sides match.
|
|
61
|
+
* @param value Typed border-width value with `{top, right, bottom, left}`.
|
|
62
|
+
* @returns RN entries.
|
|
63
|
+
*/
|
|
64
|
+
function borderWidthShorthand(value) {
|
|
65
|
+
const tagged = value;
|
|
66
|
+
const top = lengthToPxValue(tagged.top);
|
|
67
|
+
const right = lengthToPxValue(tagged.right);
|
|
68
|
+
const bottom = lengthToPxValue(tagged.bottom);
|
|
69
|
+
const left = lengthToPxValue(tagged.left);
|
|
70
|
+
if (top === null || right === null || bottom === null || left === null)
|
|
71
|
+
return [];
|
|
72
|
+
if (top === right && right === bottom && bottom === left)
|
|
73
|
+
return [['borderWidth', top]];
|
|
74
|
+
return [
|
|
75
|
+
['borderTopWidth', top],
|
|
76
|
+
['borderRightWidth', right],
|
|
77
|
+
['borderBottomWidth', bottom],
|
|
78
|
+
['borderLeftWidth', left],
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Map CSS `border-style` keywords to the strings RN accepts. RN
|
|
83
|
+
* supports only `solid` / `dashed` / `dotted` / `none` — fall back to
|
|
84
|
+
* `solid` for everything else.
|
|
85
|
+
* @param css CSS border-style keyword.
|
|
86
|
+
* @returns RN border-style.
|
|
87
|
+
*/
|
|
88
|
+
function mapBorderStyle(css) {
|
|
89
|
+
if (css === 'dashed' || css === 'dotted' || css === 'none')
|
|
90
|
+
return css;
|
|
91
|
+
return 'solid';
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Dispatch border-* longhands and their logical-direction variants to
|
|
95
|
+
* RN style entries. Returns `null` for any property the dispatcher
|
|
96
|
+
* doesn't handle so the caller can fall through.
|
|
97
|
+
*
|
|
98
|
+
* Logical-direction inputs (`border-inline-*`, `border-block-*`,
|
|
99
|
+
* `border-inline-start-*`, …) lower to RN's physical pairs
|
|
100
|
+
* (`borderLeft*` / `borderRight*` / `borderTop*` / `borderBottom*`)
|
|
101
|
+
* since RN doesn't honor logical directions at the style level.
|
|
102
|
+
* @param decl One lightningcss declaration.
|
|
103
|
+
* @returns RN entries when the property matched, else `null`.
|
|
104
|
+
*/
|
|
105
|
+
function dispatchBorderDeclaration(decl) {
|
|
106
|
+
switch (decl.property) {
|
|
107
|
+
case 'border-inline-color': {
|
|
108
|
+
return colorPair('borderLeftColor', 'borderRightColor', decl.value);
|
|
109
|
+
}
|
|
110
|
+
case 'border-block-color': {
|
|
111
|
+
return colorPair('borderTopColor', 'borderBottomColor', decl.value);
|
|
112
|
+
}
|
|
113
|
+
case 'border-inline-start-color': {
|
|
114
|
+
return [['borderLeftColor', cssColorToString(decl.value)]];
|
|
115
|
+
}
|
|
116
|
+
case 'border-inline-end-color': {
|
|
117
|
+
return [['borderRightColor', cssColorToString(decl.value)]];
|
|
118
|
+
}
|
|
119
|
+
case 'border-block-start-color': {
|
|
120
|
+
return [['borderTopColor', cssColorToString(decl.value)]];
|
|
121
|
+
}
|
|
122
|
+
case 'border-block-end-color': {
|
|
123
|
+
return [['borderBottomColor', cssColorToString(decl.value)]];
|
|
124
|
+
}
|
|
125
|
+
case 'border-width': {
|
|
126
|
+
return borderWidthShorthand(decl.value);
|
|
127
|
+
}
|
|
128
|
+
case 'border-top-width':
|
|
129
|
+
case 'border-right-width':
|
|
130
|
+
case 'border-bottom-width':
|
|
131
|
+
case 'border-left-width': {
|
|
132
|
+
const v = lengthToPxValue(decl.value);
|
|
133
|
+
return v === null ? [] : [[kebabToCamel(decl.property), v]];
|
|
134
|
+
}
|
|
135
|
+
case 'border-inline-width': {
|
|
136
|
+
return widthPair('borderLeftWidth', 'borderRightWidth', decl.value);
|
|
137
|
+
}
|
|
138
|
+
case 'border-block-width': {
|
|
139
|
+
return widthPair('borderTopWidth', 'borderBottomWidth', decl.value);
|
|
140
|
+
}
|
|
141
|
+
case 'border-inline-start-width': {
|
|
142
|
+
const v = lengthToPxValue(decl.value);
|
|
143
|
+
return v === null ? [] : [['borderLeftWidth', v]];
|
|
144
|
+
}
|
|
145
|
+
case 'border-inline-end-width': {
|
|
146
|
+
const v = lengthToPxValue(decl.value);
|
|
147
|
+
return v === null ? [] : [['borderRightWidth', v]];
|
|
148
|
+
}
|
|
149
|
+
case 'border-block-start-width': {
|
|
150
|
+
const v = lengthToPxValue(decl.value);
|
|
151
|
+
return v === null ? [] : [['borderTopWidth', v]];
|
|
152
|
+
}
|
|
153
|
+
case 'border-block-end-width': {
|
|
154
|
+
const v = lengthToPxValue(decl.value);
|
|
155
|
+
return v === null ? [] : [['borderBottomWidth', v]];
|
|
156
|
+
}
|
|
157
|
+
case 'border-style': {
|
|
158
|
+
const styleValue = decl.value.top;
|
|
159
|
+
if (typeof styleValue !== 'string')
|
|
160
|
+
return [];
|
|
161
|
+
return [['borderStyle', mapBorderStyle(styleValue)]];
|
|
162
|
+
}
|
|
163
|
+
case 'border-top-style':
|
|
164
|
+
case 'border-right-style':
|
|
165
|
+
case 'border-bottom-style':
|
|
166
|
+
case 'border-left-style': {
|
|
167
|
+
if (typeof decl.value !== 'string')
|
|
168
|
+
return [];
|
|
169
|
+
return [['borderStyle', mapBorderStyle(decl.value)]];
|
|
170
|
+
}
|
|
171
|
+
default: {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export { dispatchBorderDeclaration };
|
|
178
|
+
//# sourceMappingURL=border-dispatcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"border-dispatcher.mjs","sources":["../../../../../src/core/parser/border-dispatcher.ts"],"sourcesContent":["import type { Declaration as LcDeclaration } from 'lightningcss'\nimport { kebabToCamel } from './case-convert'\nimport { cssColorToString } from './color'\nimport type { RNEntry } from './types'\n\n/**\n * Build an inline-color pair from a `{start, end}`-shaped value.\n * @param leftKey RN key for the start side.\n * @param rightKey RN key for the end side.\n * @param value Typed `{start, end}` color value.\n * @returns Two RN entries.\n */\nfunction colorPair(leftKey: string, rightKey: string, value: unknown): readonly RNEntry[] {\n const tagged = value as { start?: unknown; end?: unknown }\n return [\n [leftKey, cssColorToString(tagged.start as never)],\n [rightKey, cssColorToString(tagged.end as never)],\n ]\n}\n\n/**\n * Coerce a border-width-shaped length to a pixel number. Drops\n * percentages — RN borders don't accept them.\n * @param value Typed length value (`{type: 'length', value: {unit, value}}`).\n * @returns Pixel number, or null when unrepresentable.\n */\nfunction lengthToPxValue(value: unknown): number | null {\n if (typeof value !== 'object' || value === null) return null\n const tagged = value as {\n type?: string\n value?: { type?: string; value?: { unit?: string; value?: number } } | { unit?: string; value?: number }\n }\n const inner =\n tagged.type === 'length'\n ? (tagged.value as { type?: string; value?: { unit?: string; value?: number } })?.value\n : tagged.value\n if (!inner || typeof (inner as { value?: number }).value !== 'number') return null\n const dim = inner as { unit?: string; value: number }\n if (dim.unit === 'px') return dim.value\n if (dim.unit === 'rem' || dim.unit === 'em') return dim.value * 16\n return dim.value\n}\n\n/**\n * Build an inline-width pair from a `{start, end}`-shaped value.\n * @param leftKey RN key for the start side.\n * @param rightKey RN key for the end side.\n * @param value Typed `{start, end}` length value.\n * @returns Two RN entries, or empty when either side is unrepresentable.\n */\nfunction widthPair(leftKey: string, rightKey: string, value: unknown): readonly RNEntry[] {\n const tagged = value as { start?: unknown; end?: unknown }\n const start = lengthToPxValue(tagged.start)\n const end = lengthToPxValue(tagged.end)\n if (start === null || end === null) return []\n return [\n [leftKey, start],\n [rightKey, end],\n ]\n}\n\n/**\n * Expand a `border-width` shorthand to RN longhands. Collapses to the\n * `borderWidth` shorthand when all four sides match.\n * @param value Typed border-width value with `{top, right, bottom, left}`.\n * @returns RN entries.\n */\nfunction borderWidthShorthand(value: unknown): readonly RNEntry[] {\n const tagged = value as { top?: unknown; right?: unknown; bottom?: unknown; left?: unknown }\n const top = lengthToPxValue(tagged.top)\n const right = lengthToPxValue(tagged.right)\n const bottom = lengthToPxValue(tagged.bottom)\n const left = lengthToPxValue(tagged.left)\n if (top === null || right === null || bottom === null || left === null) return []\n if (top === right && right === bottom && bottom === left) return [['borderWidth', top]]\n return [\n ['borderTopWidth', top],\n ['borderRightWidth', right],\n ['borderBottomWidth', bottom],\n ['borderLeftWidth', left],\n ]\n}\n\n/**\n * Map CSS `border-style` keywords to the strings RN accepts. RN\n * supports only `solid` / `dashed` / `dotted` / `none` — fall back to\n * `solid` for everything else.\n * @param css CSS border-style keyword.\n * @returns RN border-style.\n */\nfunction mapBorderStyle(css: string): string {\n if (css === 'dashed' || css === 'dotted' || css === 'none') return css\n return 'solid'\n}\n\n/**\n * Dispatch border-* longhands and their logical-direction variants to\n * RN style entries. Returns `null` for any property the dispatcher\n * doesn't handle so the caller can fall through.\n *\n * Logical-direction inputs (`border-inline-*`, `border-block-*`,\n * `border-inline-start-*`, …) lower to RN's physical pairs\n * (`borderLeft*` / `borderRight*` / `borderTop*` / `borderBottom*`)\n * since RN doesn't honor logical directions at the style level.\n * @param decl One lightningcss declaration.\n * @returns RN entries when the property matched, else `null`.\n */\nexport function dispatchBorderDeclaration(decl: LcDeclaration): readonly RNEntry[] | null {\n switch (decl.property) {\n case 'border-inline-color': {\n return colorPair('borderLeftColor', 'borderRightColor', decl.value)\n }\n case 'border-block-color': {\n return colorPair('borderTopColor', 'borderBottomColor', decl.value)\n }\n case 'border-inline-start-color': {\n return [['borderLeftColor', cssColorToString(decl.value)]]\n }\n case 'border-inline-end-color': {\n return [['borderRightColor', cssColorToString(decl.value)]]\n }\n case 'border-block-start-color': {\n return [['borderTopColor', cssColorToString(decl.value)]]\n }\n case 'border-block-end-color': {\n return [['borderBottomColor', cssColorToString(decl.value)]]\n }\n case 'border-width': {\n return borderWidthShorthand(decl.value)\n }\n case 'border-top-width':\n case 'border-right-width':\n case 'border-bottom-width':\n case 'border-left-width': {\n const v = lengthToPxValue(decl.value)\n return v === null ? [] : [[kebabToCamel(decl.property), v]]\n }\n case 'border-inline-width': {\n return widthPair('borderLeftWidth', 'borderRightWidth', decl.value)\n }\n case 'border-block-width': {\n return widthPair('borderTopWidth', 'borderBottomWidth', decl.value)\n }\n case 'border-inline-start-width': {\n const v = lengthToPxValue(decl.value)\n return v === null ? [] : [['borderLeftWidth', v]]\n }\n case 'border-inline-end-width': {\n const v = lengthToPxValue(decl.value)\n return v === null ? [] : [['borderRightWidth', v]]\n }\n case 'border-block-start-width': {\n const v = lengthToPxValue(decl.value)\n return v === null ? [] : [['borderTopWidth', v]]\n }\n case 'border-block-end-width': {\n const v = lengthToPxValue(decl.value)\n return v === null ? [] : [['borderBottomWidth', v]]\n }\n case 'border-style': {\n const styleValue = (decl.value as { top?: string }).top\n if (typeof styleValue !== 'string') return []\n return [['borderStyle', mapBorderStyle(styleValue)]]\n }\n case 'border-top-style':\n case 'border-right-style':\n case 'border-bottom-style':\n case 'border-left-style': {\n if (typeof decl.value !== 'string') return []\n return [['borderStyle', mapBorderStyle(decl.value)]]\n }\n default: {\n return null\n }\n }\n}\n"],"names":[],"mappings":";;;AAKA;;;;;;AAMG;AACH,SAAS,SAAS,CAAC,OAAe,EAAE,QAAgB,EAAE,KAAc,EAAA;IAClE,MAAM,MAAM,GAAG,KAA2C;IAC1D,OAAO;QACL,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAc,CAAC,CAAC;QAClD,CAAC,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAY,CAAC,CAAC;KAClD;AACH;AAEA;;;;;AAKG;AACH,SAAS,eAAe,CAAC,KAAc,EAAA;AACrC,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;AAAE,QAAA,OAAO,IAAI;IAC5D,MAAM,MAAM,GAAG,KAGd;AACD,IAAA,MAAM,KAAK,GACT,MAAM,CAAC,IAAI,KAAK;AACd,UAAG,MAAM,CAAC,KAAsE,EAAE;AAClF,UAAE,MAAM,CAAC,KAAK;IAClB,IAAI,CAAC,KAAK,IAAI,OAAQ,KAA4B,CAAC,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;IAClF,MAAM,GAAG,GAAG,KAAyC;AACrD,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK;IACvC,IAAI,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI;AAAE,QAAA,OAAO,GAAG,CAAC,KAAK,GAAG,EAAE;IAClE,OAAO,GAAG,CAAC,KAAK;AAClB;AA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;AAAE,gBAAA,OAAO,EAAE;YAC7C,OAAO,CAAC,CAAC,aAAa,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;QACtD;AACA,QAAA,KAAK,kBAAkB;AACvB,QAAA,KAAK,oBAAoB;AACzB,QAAA,KAAK,qBAAqB;QAC1B,KAAK,mBAAmB,EAAE;AACxB,YAAA,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;AAAE,gBAAA,OAAO,EAAE;AAC7C,YAAA,OAAO,CAAC,CAAC,aAAa,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACtD;QACA,SAAS;AACP,YAAA,OAAO,IAAI;QACb;;AAEJ;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KEBAB_BOUNDARY_REGEX } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Kebab-case to camelCase — `border-radius` → `borderRadius`.
|
|
5
|
+
* @param name Kebab-case CSS property name.
|
|
6
|
+
* @returns camelCase RN key.
|
|
7
|
+
*/
|
|
8
|
+
function kebabToCamel(name) {
|
|
9
|
+
return name.replaceAll(KEBAB_BOUNDARY_REGEX, (_, c) => c.toUpperCase());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { kebabToCamel };
|
|
13
|
+
//# sourceMappingURL=case-convert.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"case-convert.mjs","sources":["../../../../../src/core/parser/case-convert.ts"],"sourcesContent":["import { KEBAB_BOUNDARY_REGEX } from './constants'\n\n/**\n * Kebab-case to camelCase — `border-radius` → `borderRadius`.\n * @param name Kebab-case CSS property name.\n * @returns camelCase RN key.\n */\nexport function kebabToCamel(name: string): string {\n return name.replaceAll(KEBAB_BOUNDARY_REGEX, (_, c: string) => c.toUpperCase())\n}\n"],"names":[],"mappings":";;AAEA;;;;AAIG;AACG,SAAU,YAAY,CAAC,IAAY,EAAA;AACvC,IAAA,OAAO,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACjF;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Declaration as LcDeclaration } from 'lightningcss';
|
|
2
|
+
import type { RNEntry } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatch color-typed CSS properties (text-decoration-color, fill,
|
|
5
|
+
* stroke, caret-color, outline-color, …) to RN-compatible style entries.
|
|
6
|
+
*
|
|
7
|
+
* lightningcss emits two shapes for color properties:
|
|
8
|
+
* - bare `CssColor` value (e.g. `text-decoration-color`, `outline-color`)
|
|
9
|
+
* - wrapped `{type: 'color', value: CssColor}` (e.g. `fill`, `stroke`,
|
|
10
|
+
* `caret-color`, `accent-color`)
|
|
11
|
+
* We unwrap both and run them through {@link cssColorToString} to land
|
|
12
|
+
* at hex/rgba.
|
|
13
|
+
*
|
|
14
|
+
* Returns `null` for any property the dispatcher doesn't handle so the
|
|
15
|
+
* caller can fall through to the next dispatcher.
|
|
16
|
+
* @param decl One lightningcss declaration.
|
|
17
|
+
* @returns RN entries when the property matched, else `null`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function dispatchColorPropertyDeclaration(decl: LcDeclaration): readonly RNEntry[] | null;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { cssColorToString } from './color.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build a `[key, hex]` entry from a typed CssColor. Drops keyword colors
|
|
5
|
+
* (e.g. `'currentcolor'` strings — RN can't render them).
|
|
6
|
+
* @param key RN style key (camelCase).
|
|
7
|
+
* @param value Typed `CssColor`-shaped value.
|
|
8
|
+
* @returns Single-entry list or empty.
|
|
9
|
+
*/
|
|
10
|
+
function colorEntry(key, value) {
|
|
11
|
+
if (value === null || value === undefined)
|
|
12
|
+
return [];
|
|
13
|
+
if (typeof value === 'string')
|
|
14
|
+
return [[key, value]];
|
|
15
|
+
const hex = cssColorToString(value);
|
|
16
|
+
if (!hex || hex === 'transparent' || hex === 'currentColor')
|
|
17
|
+
return [[key, hex]];
|
|
18
|
+
return [[key, hex]];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Several typed color properties wrap their `CssColor` payload inside a
|
|
22
|
+
* `{type: 'color', value: CssColor}` envelope. Unwrap so the inner color
|
|
23
|
+
* reaches {@link cssColorToString}.
|
|
24
|
+
* @param value Either a `CssColor` directly or a `{type: 'color', value}` wrapper.
|
|
25
|
+
* @returns Unwrapped `CssColor` (or the input untouched).
|
|
26
|
+
*/
|
|
27
|
+
function unwrapTaggedColor(value) {
|
|
28
|
+
if (typeof value !== 'object' || value === null)
|
|
29
|
+
return value;
|
|
30
|
+
const tagged = value;
|
|
31
|
+
if (tagged.type === 'color')
|
|
32
|
+
return tagged.value;
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Dispatch color-typed CSS properties (text-decoration-color, fill,
|
|
37
|
+
* stroke, caret-color, outline-color, …) to RN-compatible style entries.
|
|
38
|
+
*
|
|
39
|
+
* lightningcss emits two shapes for color properties:
|
|
40
|
+
* - bare `CssColor` value (e.g. `text-decoration-color`, `outline-color`)
|
|
41
|
+
* - wrapped `{type: 'color', value: CssColor}` (e.g. `fill`, `stroke`,
|
|
42
|
+
* `caret-color`, `accent-color`)
|
|
43
|
+
* We unwrap both and run them through {@link cssColorToString} to land
|
|
44
|
+
* at hex/rgba.
|
|
45
|
+
*
|
|
46
|
+
* Returns `null` for any property the dispatcher doesn't handle so the
|
|
47
|
+
* caller can fall through to the next dispatcher.
|
|
48
|
+
* @param decl One lightningcss declaration.
|
|
49
|
+
* @returns RN entries when the property matched, else `null`.
|
|
50
|
+
*/
|
|
51
|
+
function dispatchColorPropertyDeclaration(decl) {
|
|
52
|
+
switch (decl.property) {
|
|
53
|
+
case 'text-decoration-color': {
|
|
54
|
+
return colorEntry('textDecorationColor', decl.value);
|
|
55
|
+
}
|
|
56
|
+
case 'caret-color': {
|
|
57
|
+
return colorEntry('caretColor', unwrapTaggedColor(decl.value));
|
|
58
|
+
}
|
|
59
|
+
case 'fill': {
|
|
60
|
+
return colorEntry('fill', unwrapTaggedColor(decl.value));
|
|
61
|
+
}
|
|
62
|
+
case 'stroke': {
|
|
63
|
+
return colorEntry('stroke', unwrapTaggedColor(decl.value));
|
|
64
|
+
}
|
|
65
|
+
case 'outline-color': {
|
|
66
|
+
// RN doesn't render outlines, but tooling like react-native-web /
|
|
67
|
+
// a11y overlays read it — keep so cross-platform code carries the
|
|
68
|
+
// value through.
|
|
69
|
+
return colorEntry('outlineColor', decl.value);
|
|
70
|
+
}
|
|
71
|
+
case 'accent-color': {
|
|
72
|
+
// RN has no native accent color; skip silently.
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
default: {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { dispatchColorPropertyDeclaration };
|
|
82
|
+
//# sourceMappingURL=color-properties-dispatcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-properties-dispatcher.mjs","sources":["../../../../../src/core/parser/color-properties-dispatcher.ts"],"sourcesContent":["import type { Declaration as LcDeclaration } from 'lightningcss'\nimport { cssColorToString } from './color'\nimport type { RNEntry } from './types'\n\n/**\n * Build a `[key, hex]` entry from a typed CssColor. Drops keyword colors\n * (e.g. `'currentcolor'` strings — RN can't render them).\n * @param key RN style key (camelCase).\n * @param value Typed `CssColor`-shaped value.\n * @returns Single-entry list or empty.\n */\nfunction colorEntry(key: string, value: unknown): readonly RNEntry[] {\n if (value === null || value === undefined) return []\n if (typeof value === 'string') return [[key, value]]\n const hex = cssColorToString(value as never)\n if (!hex || hex === 'transparent' || hex === 'currentColor') return [[key, hex]]\n return [[key, hex]]\n}\n\n/**\n * Several typed color properties wrap their `CssColor` payload inside a\n * `{type: 'color', value: CssColor}` envelope. Unwrap so the inner color\n * reaches {@link cssColorToString}.\n * @param value Either a `CssColor` directly or a `{type: 'color', value}` wrapper.\n * @returns Unwrapped `CssColor` (or the input untouched).\n */\nfunction unwrapTaggedColor(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) return value\n const tagged = value as { type?: string; value?: unknown }\n if (tagged.type === 'color') return tagged.value\n return value\n}\n\n/**\n * Dispatch color-typed CSS properties (text-decoration-color, fill,\n * stroke, caret-color, outline-color, …) to RN-compatible style entries.\n *\n * lightningcss emits two shapes for color properties:\n * - bare `CssColor` value (e.g. `text-decoration-color`, `outline-color`)\n * - wrapped `{type: 'color', value: CssColor}` (e.g. `fill`, `stroke`,\n * `caret-color`, `accent-color`)\n * We unwrap both and run them through {@link cssColorToString} to land\n * at hex/rgba.\n *\n * Returns `null` for any property the dispatcher doesn't handle so the\n * caller can fall through to the next dispatcher.\n * @param decl One lightningcss declaration.\n * @returns RN entries when the property matched, else `null`.\n */\nexport function dispatchColorPropertyDeclaration(decl: LcDeclaration): readonly RNEntry[] | null {\n switch (decl.property) {\n case 'text-decoration-color': {\n return colorEntry('textDecorationColor', decl.value)\n }\n case 'caret-color': {\n return colorEntry('caretColor', unwrapTaggedColor(decl.value))\n }\n case 'fill': {\n return colorEntry('fill', unwrapTaggedColor(decl.value))\n }\n case 'stroke': {\n return colorEntry('stroke', unwrapTaggedColor(decl.value))\n }\n case 'outline-color': {\n // RN doesn't render outlines, but tooling like react-native-web /\n // a11y overlays read it — keep so cross-platform code carries the\n // value through.\n return colorEntry('outlineColor', decl.value)\n }\n case 'accent-color': {\n // RN has no native accent color; skip silently.\n return []\n }\n default: {\n return null\n }\n }\n}\n"],"names":[],"mappings":";;AAIA;;;;;;AAMG;AACH,SAAS,UAAU,CAAC,GAAW,EAAE,KAAc,EAAA;AAC7C,IAAA,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,EAAE;IACpD,IAAI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,CAAC,KAAK,CAAC;QAC/C;QACA,KAAK,cAAc,EAAE;;AAEnB,YAAA,OAAO,EAAE;QACX;QACA,SAAS;AACP,YAAA,OAAO,IAAI;QACb;;AAEJ;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CssColor } from 'lightningcss';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a lightningcss `CssColor` to an RN-safe color string. RGB
|
|
4
|
+
* passes through unchanged. LAB / LCH / OKLAB / OKLCH / `color(xyz-…)`
|
|
5
|
+
* forms go through culori to reach sRGB — RN's native view manager only
|
|
6
|
+
* understands sRGB-family strings. SystemColor keywords (`'background'`,
|
|
7
|
+
* `'canvas'`, …) pass through untouched; they have no RN analog and the
|
|
8
|
+
* runtime ignores unknown color strings gracefully.
|
|
9
|
+
* @param color Typed color value.
|
|
10
|
+
* @returns Color string RN accepts.
|
|
11
|
+
*/
|
|
12
|
+
export declare function cssColorToString(color: CssColor): string;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { formatHex, rgb } from 'culori';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Clamp a 0-255 float to the integer byte range RN color strings accept.
|
|
5
|
+
* @param value Unclamped float (may be negative or above 255).
|
|
6
|
+
* @returns Integer in `[0, 255]`.
|
|
7
|
+
*/
|
|
8
|
+
function clampByte(value) {
|
|
9
|
+
if (value < 0)
|
|
10
|
+
return 0;
|
|
11
|
+
if (value > 255)
|
|
12
|
+
return 255;
|
|
13
|
+
return Math.round(value);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Two-digit hex encoding of a 0-255 byte.
|
|
17
|
+
* @param byte Byte value (may be out-of-range — clamped).
|
|
18
|
+
* @returns Zero-padded two-char hex string.
|
|
19
|
+
*/
|
|
20
|
+
function byteToHex(byte) {
|
|
21
|
+
const hex = clampByte(byte).toString(16);
|
|
22
|
+
return hex.length === 1 ? `0${hex}` : hex;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Format an integer-RGB triple + alpha as `#rrggbb` or `rgba(r, g, b, a)`.
|
|
26
|
+
* @param r 0-255 red.
|
|
27
|
+
* @param g 0-255 green.
|
|
28
|
+
* @param b 0-255 blue.
|
|
29
|
+
* @param alpha 0-1 alpha.
|
|
30
|
+
* @returns Color string.
|
|
31
|
+
*/
|
|
32
|
+
function rgbIntsToString(r, g, b, alpha) {
|
|
33
|
+
if (alpha >= 1)
|
|
34
|
+
return `#${byteToHex(r)}${byteToHex(g)}${byteToHex(b)}`;
|
|
35
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Format a float-RGB triple + alpha (CSS `color(srgb …)` forms) as
|
|
39
|
+
* hex/rgba.
|
|
40
|
+
* @param r 0-1 red.
|
|
41
|
+
* @param g 0-1 green.
|
|
42
|
+
* @param b 0-1 blue.
|
|
43
|
+
* @param alpha 0-1 alpha.
|
|
44
|
+
* @returns Color string.
|
|
45
|
+
*/
|
|
46
|
+
function floatRgbToString(r, g, b, alpha) {
|
|
47
|
+
return rgbIntsToString(clampByte(r * 255), clampByte(g * 255), clampByte(b * 255), alpha);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Dispatch a LAB-family color through culori's hex formatter.
|
|
51
|
+
* @param color Typed LAB-family color.
|
|
52
|
+
* @returns `#rrggbb` string, or `null` when culori couldn't convert.
|
|
53
|
+
*/
|
|
54
|
+
function culoriHexFor(color) {
|
|
55
|
+
switch (color.type) {
|
|
56
|
+
case 'oklch': {
|
|
57
|
+
return formatHex({ mode: 'oklch', l: color.l, c: color.c, h: color.h }) ?? null;
|
|
58
|
+
}
|
|
59
|
+
case 'oklab': {
|
|
60
|
+
return formatHex({ mode: 'oklab', l: color.l, a: color.a, b: color.b }) ?? null;
|
|
61
|
+
}
|
|
62
|
+
case 'lab': {
|
|
63
|
+
return formatHex({ mode: 'lab', l: color.l, a: color.a, b: color.b }) ?? null;
|
|
64
|
+
}
|
|
65
|
+
case 'lch': {
|
|
66
|
+
return formatHex({ mode: 'lch', l: color.l, c: color.c, h: color.h }) ?? null;
|
|
67
|
+
}
|
|
68
|
+
default: {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Composite a culori-produced sRGB hex with the source alpha into the RN
|
|
75
|
+
* color string. Shared tail for every culori-backed conversion (lab
|
|
76
|
+
* family, XYZ, wide-gamut RGB): opaque → the hex as-is; translucent →
|
|
77
|
+
* `rgba(...)` rebuilt from the hex channels.
|
|
78
|
+
* @param hex sRGB hex from culori, or `null` when culori rejected the color.
|
|
79
|
+
* @param alpha Source alpha (0–1).
|
|
80
|
+
* @returns RN color string.
|
|
81
|
+
*/
|
|
82
|
+
function withAlpha(hex, alpha) {
|
|
83
|
+
if (!hex)
|
|
84
|
+
return alpha < 1 ? 'rgba(0, 0, 0, 0)' : 'transparent';
|
|
85
|
+
if (alpha >= 1)
|
|
86
|
+
return hex;
|
|
87
|
+
const back = rgb(hex);
|
|
88
|
+
if (!back)
|
|
89
|
+
return hex;
|
|
90
|
+
return rgbIntsToString(clampByte(back.r * 255), clampByte(back.g * 255), clampByte(back.b * 255), alpha);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Convert a LAB / LCH / OKLAB / OKLCH color to sRGB hex via culori. RN
|
|
94
|
+
* can't evaluate these modern color spaces at paint time; compile-time
|
|
95
|
+
* lowering to sRGB is the only portable path.
|
|
96
|
+
* @param color Typed lab-family color.
|
|
97
|
+
* @returns Hex or rgba string in sRGB.
|
|
98
|
+
*/
|
|
99
|
+
function labFamilyToHex(color) {
|
|
100
|
+
return withAlpha(culoriHexFor(color), color.alpha);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Convert a wide-gamut `color(<space> r g b)` triple to sRGB hex via
|
|
104
|
+
* culori. The channels are NOT sRGB — each space (display-p3, rec2020,
|
|
105
|
+
* a98-rgb, prophoto-rgb, srgb-linear) carries its own primaries / transfer
|
|
106
|
+
* function, so a bare `channel * 255` would mis-paint. culori does the
|
|
107
|
+
* gamut + gamma conversion to sRGB.
|
|
108
|
+
* @param mode culori mode key for the source space.
|
|
109
|
+
* @param r Source red (0–1).
|
|
110
|
+
* @param g Source green (0–1).
|
|
111
|
+
* @param b Source blue (0–1).
|
|
112
|
+
* @param alpha Alpha channel (0–1).
|
|
113
|
+
* @returns sRGB color string RN accepts.
|
|
114
|
+
*/
|
|
115
|
+
function wideGamutToHex(mode, r, g, b, alpha) {
|
|
116
|
+
return withAlpha(formatHex({ mode, r, g, b }) ?? null, alpha);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Convert a CSS `color(xyz-d50 …)` / `color(xyz-d65 …)` value to sRGB hex
|
|
120
|
+
* via culori.
|
|
121
|
+
* @param color Typed XYZ color (discriminated by `type`).
|
|
122
|
+
* @param color.type Whether the color is in the D50 or D65 XYZ space.
|
|
123
|
+
* @param color.x CIE X component (0–1).
|
|
124
|
+
* @param color.y CIE Y component (0–1).
|
|
125
|
+
* @param color.z CIE Z component (0–1).
|
|
126
|
+
* @param color.alpha Alpha channel (0–1).
|
|
127
|
+
* @returns `#rrggbb` string, or `'transparent'` when culori rejects it.
|
|
128
|
+
*/
|
|
129
|
+
function xyzToHex(color) {
|
|
130
|
+
const mode = color.type === 'xyz-d50' ? 'xyz50' : 'xyz65';
|
|
131
|
+
return withAlpha(formatHex({ mode, x: color.x, y: color.y, z: color.z }) ?? null, color.alpha);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert a lightningcss `CssColor` to an RN-safe color string. RGB
|
|
135
|
+
* passes through unchanged. LAB / LCH / OKLAB / OKLCH / `color(xyz-…)`
|
|
136
|
+
* forms go through culori to reach sRGB — RN's native view manager only
|
|
137
|
+
* understands sRGB-family strings. SystemColor keywords (`'background'`,
|
|
138
|
+
* `'canvas'`, …) pass through untouched; they have no RN analog and the
|
|
139
|
+
* runtime ignores unknown color strings gracefully.
|
|
140
|
+
* @param color Typed color value.
|
|
141
|
+
* @returns Color string RN accepts.
|
|
142
|
+
*/
|
|
143
|
+
function cssColorToString(color) {
|
|
144
|
+
if (typeof color === 'string')
|
|
145
|
+
return color;
|
|
146
|
+
switch (color.type) {
|
|
147
|
+
case 'rgb': {
|
|
148
|
+
return rgbIntsToString(color.r, color.g, color.b, color.alpha);
|
|
149
|
+
}
|
|
150
|
+
case 'lab':
|
|
151
|
+
case 'lch':
|
|
152
|
+
case 'oklab':
|
|
153
|
+
case 'oklch': {
|
|
154
|
+
return labFamilyToHex(color);
|
|
155
|
+
}
|
|
156
|
+
case 'srgb': {
|
|
157
|
+
return floatRgbToString(color.r, color.g, color.b, color.alpha);
|
|
158
|
+
}
|
|
159
|
+
case 'srgb-linear': {
|
|
160
|
+
return wideGamutToHex('lrgb', color.r, color.g, color.b, color.alpha);
|
|
161
|
+
}
|
|
162
|
+
case 'display-p3': {
|
|
163
|
+
return wideGamutToHex('p3', color.r, color.g, color.b, color.alpha);
|
|
164
|
+
}
|
|
165
|
+
case 'a98-rgb': {
|
|
166
|
+
return wideGamutToHex('a98', color.r, color.g, color.b, color.alpha);
|
|
167
|
+
}
|
|
168
|
+
case 'prophoto-rgb': {
|
|
169
|
+
return wideGamutToHex('prophoto', color.r, color.g, color.b, color.alpha);
|
|
170
|
+
}
|
|
171
|
+
case 'rec2020': {
|
|
172
|
+
return wideGamutToHex('rec2020', color.r, color.g, color.b, color.alpha);
|
|
173
|
+
}
|
|
174
|
+
case 'xyz-d50':
|
|
175
|
+
case 'xyz-d65': {
|
|
176
|
+
return xyzToHex(color);
|
|
177
|
+
}
|
|
178
|
+
case 'currentcolor': {
|
|
179
|
+
return 'currentColor';
|
|
180
|
+
}
|
|
181
|
+
case 'light-dark': {
|
|
182
|
+
return cssColorToString(color.light);
|
|
183
|
+
}
|
|
184
|
+
default: {
|
|
185
|
+
return 'transparent';
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { cssColorToString };
|
|
191
|
+
//# sourceMappingURL=color.mjs.map
|