react-native-css 2.1.2 → 3.0.0-nightly.19372e8
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/{LICENSE.md → LICENSE} +6 -8
- package/README.md +177 -70
- package/dist/commonjs/babel/allowedModules.js +23 -0
- package/dist/commonjs/babel/allowedModules.js.map +1 -0
- package/dist/commonjs/babel/helpers.js +25 -0
- package/dist/commonjs/babel/helpers.js.map +1 -0
- package/dist/commonjs/babel/import-plugin.js +101 -0
- package/dist/commonjs/babel/import-plugin.js.map +1 -0
- package/dist/commonjs/babel/index.js +9 -0
- package/dist/commonjs/babel/index.js.map +1 -0
- package/dist/commonjs/babel/react-native-web.js +118 -0
- package/dist/commonjs/babel/react-native-web.js.map +1 -0
- package/dist/commonjs/babel/react-native.js +118 -0
- package/dist/commonjs/babel/react-native.js.map +1 -0
- package/dist/commonjs/compiler/atRules.js +114 -0
- package/dist/commonjs/compiler/atRules.js.map +1 -0
- package/dist/commonjs/compiler/compiler.js +281 -0
- package/dist/commonjs/compiler/compiler.js.map +1 -0
- package/dist/commonjs/compiler/compiler.types.js +4 -0
- package/dist/commonjs/compiler/compiler.types.js.map +1 -0
- package/dist/commonjs/compiler/container-query.js +63 -0
- package/dist/commonjs/compiler/container-query.js.map +1 -0
- package/dist/commonjs/compiler/declarations.js +2166 -0
- package/dist/commonjs/compiler/declarations.js.map +1 -0
- package/dist/commonjs/compiler/functions-web.js +44 -0
- package/dist/commonjs/compiler/functions-web.js.map +1 -0
- package/dist/commonjs/compiler/functions.js +59 -0
- package/dist/commonjs/compiler/functions.js.map +1 -0
- package/dist/commonjs/compiler/index.js +17 -0
- package/dist/commonjs/compiler/index.js.map +1 -0
- package/dist/commonjs/compiler/inheritance.test.js +78 -0
- package/dist/commonjs/compiler/inheritance.test.js.map +1 -0
- package/dist/commonjs/compiler/keyframes.js +60 -0
- package/dist/commonjs/compiler/keyframes.js.map +1 -0
- package/dist/commonjs/compiler/media-query.js +172 -0
- package/dist/commonjs/compiler/media-query.js.map +1 -0
- package/dist/commonjs/compiler/pseudo-elements.js +49 -0
- package/dist/commonjs/compiler/pseudo-elements.js.map +1 -0
- package/dist/commonjs/compiler/selector-builder.js +501 -0
- package/dist/commonjs/compiler/selector-builder.js.map +1 -0
- package/dist/commonjs/compiler/selectors.js +414 -0
- package/dist/commonjs/compiler/selectors.js.map +1 -0
- package/dist/commonjs/compiler/split-by-delimiter.js +21 -0
- package/dist/commonjs/compiler/split-by-delimiter.js.map +1 -0
- package/dist/commonjs/compiler/stylesheet.js +476 -0
- package/dist/commonjs/compiler/stylesheet.js.map +1 -0
- package/dist/commonjs/compiler/supports.js +27 -0
- package/dist/commonjs/compiler/supports.js.map +1 -0
- package/dist/commonjs/components/ActivityIndicator.js +22 -0
- package/dist/commonjs/components/ActivityIndicator.js.map +1 -0
- package/dist/commonjs/components/Button.js +22 -0
- package/dist/commonjs/components/Button.js.map +1 -0
- package/dist/commonjs/components/FlatList.js +19 -0
- package/dist/commonjs/components/FlatList.js.map +1 -0
- package/dist/commonjs/components/Image.js +17 -0
- package/dist/commonjs/components/Image.js.map +1 -0
- package/dist/commonjs/components/Switch.js +17 -0
- package/dist/commonjs/components/Switch.js.map +1 -0
- package/dist/commonjs/components/Text.js +17 -0
- package/dist/commonjs/components/Text.js.map +1 -0
- package/dist/commonjs/components/TextInput.js +17 -0
- package/dist/commonjs/components/TextInput.js.map +1 -0
- package/dist/commonjs/components/View.js +17 -0
- package/dist/commonjs/components/View.js.map +1 -0
- package/dist/commonjs/components/index.js +84 -0
- package/dist/commonjs/components/index.js.map +1 -0
- package/dist/commonjs/doctor/index.js +6 -0
- package/dist/commonjs/doctor/index.js.map +1 -0
- package/dist/commonjs/index.js +28 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/jest/expect.d.js +2 -0
- package/dist/commonjs/jest/expect.d.js.map +1 -0
- package/dist/commonjs/jest/index.js +56 -0
- package/dist/commonjs/jest/index.js.map +1 -0
- package/dist/commonjs/jest/setup.js +3 -0
- package/dist/commonjs/jest/setup.js.map +1 -0
- package/dist/commonjs/jest/setupAfterEnv.js +15 -0
- package/dist/commonjs/jest/setupAfterEnv.js.map +1 -0
- package/dist/commonjs/metro/index.js +167 -0
- package/dist/commonjs/metro/index.js.map +1 -0
- package/dist/commonjs/metro/injection-code.js +32 -0
- package/dist/commonjs/metro/injection-code.js.map +1 -0
- package/dist/commonjs/metro/metro-transformer.js +21 -0
- package/dist/commonjs/metro/metro-transformer.js.map +1 -0
- package/dist/commonjs/metro/picocolors.js +71 -0
- package/dist/commonjs/metro/picocolors.js.map +1 -0
- package/dist/commonjs/metro/resolver.js +62 -0
- package/dist/commonjs/metro/resolver.js.map +1 -0
- package/dist/commonjs/metro/stringify.js +59 -0
- package/dist/commonjs/metro/stringify.js.map +1 -0
- package/dist/commonjs/metro/typescript.js +47 -0
- package/dist/commonjs/metro/typescript.js.map +1 -0
- package/dist/commonjs/package.json +1 -0
- package/dist/commonjs/poison.pill.js +39 -0
- package/dist/commonjs/poison.pill.js.map +1 -0
- package/dist/commonjs/runtime/index.js +17 -0
- package/dist/commonjs/runtime/index.js.map +1 -0
- package/dist/commonjs/runtime/native/api.js +90 -0
- package/dist/commonjs/runtime/native/api.js.map +1 -0
- package/dist/commonjs/runtime/native/conditions/attributes.js +42 -0
- package/dist/commonjs/runtime/native/conditions/attributes.js.map +1 -0
- package/dist/commonjs/runtime/native/conditions/container-query.js +123 -0
- package/dist/commonjs/runtime/native/conditions/container-query.js.map +1 -0
- package/dist/commonjs/runtime/native/conditions/guards.js +33 -0
- package/dist/commonjs/runtime/native/conditions/guards.js.map +1 -0
- package/dist/commonjs/runtime/native/conditions/index.js +40 -0
- package/dist/commonjs/runtime/native/conditions/index.js.map +1 -0
- package/dist/commonjs/runtime/native/conditions/media-query.js +98 -0
- package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -0
- package/dist/commonjs/runtime/native/index.js +28 -0
- package/dist/commonjs/runtime/native/index.js.map +1 -0
- package/dist/commonjs/runtime/native/injection.js +100 -0
- package/dist/commonjs/runtime/native/injection.js.map +1 -0
- package/dist/commonjs/runtime/native/metro.js +6 -0
- package/dist/commonjs/runtime/native/metro.js.map +1 -0
- package/dist/commonjs/runtime/native/react/interaction.js +63 -0
- package/dist/commonjs/runtime/native/react/interaction.js.map +1 -0
- package/dist/commonjs/runtime/native/react/rules.js +255 -0
- package/dist/commonjs/runtime/native/react/rules.js.map +1 -0
- package/dist/commonjs/runtime/native/react/useNativeCss.js +159 -0
- package/dist/commonjs/runtime/native/react/useNativeCss.js.map +1 -0
- package/dist/commonjs/runtime/native/react/usePassthrough.js +50 -0
- package/dist/commonjs/runtime/native/react/usePassthrough.js.map +1 -0
- package/dist/commonjs/runtime/native/reactivity.js +178 -0
- package/dist/commonjs/runtime/native/reactivity.js.map +1 -0
- package/dist/commonjs/runtime/native/reanimated.js +17 -0
- package/dist/commonjs/runtime/native/reanimated.js.map +1 -0
- package/dist/commonjs/runtime/native/root.js +28 -0
- package/dist/commonjs/runtime/native/root.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/calculate-props.js +148 -0
- package/dist/commonjs/runtime/native/styles/calculate-props.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/constants.js +9 -0
- package/dist/commonjs/runtime/native/styles/constants.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/defaults.js +69 -0
- package/dist/commonjs/runtime/native/styles/defaults.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/functions/animation-timing.js +34 -0
- package/dist/commonjs/runtime/native/styles/functions/animation-timing.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/functions/calc.js +125 -0
- package/dist/commonjs/runtime/native/styles/functions/calc.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/functions/filters.js +84 -0
- package/dist/commonjs/runtime/native/styles/functions/filters.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/functions/index.js +61 -0
- package/dist/commonjs/runtime/native/styles/functions/index.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/functions/platform-functions.js +46 -0
- package/dist/commonjs/runtime/native/styles/functions/platform-functions.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/functions/transform-functions.js +121 -0
- package/dist/commonjs/runtime/native/styles/functions/transform-functions.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/index.js +115 -0
- package/dist/commonjs/runtime/native/styles/index.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/resolve.js +106 -0
- package/dist/commonjs/runtime/native/styles/resolve.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/shorthands/_handler.js +79 -0
- package/dist/commonjs/runtime/native/styles/shorthands/_handler.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/shorthands/animation.js +57 -0
- package/dist/commonjs/runtime/native/styles/shorthands/animation.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/shorthands/border.js +12 -0
- package/dist/commonjs/runtime/native/styles/shorthands/border.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/shorthands/box-shadow.js +40 -0
- package/dist/commonjs/runtime/native/styles/shorthands/box-shadow.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/shorthands/index.js +61 -0
- package/dist/commonjs/runtime/native/styles/shorthands/index.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/shorthands/text-shadow.js +13 -0
- package/dist/commonjs/runtime/native/styles/shorthands/text-shadow.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/shorthands/transform.js +23 -0
- package/dist/commonjs/runtime/native/styles/shorthands/transform.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/units.js +52 -0
- package/dist/commonjs/runtime/native/styles/units.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/variables.js +79 -0
- package/dist/commonjs/runtime/native/styles/variables.js.map +1 -0
- package/dist/commonjs/runtime/runtime.js +17 -0
- package/dist/commonjs/runtime/runtime.js.map +1 -0
- package/dist/commonjs/runtime/runtime.native.js +17 -0
- package/dist/commonjs/runtime/runtime.native.js.map +1 -0
- package/dist/commonjs/runtime/runtime.types.js +6 -0
- package/dist/commonjs/runtime/runtime.types.js.map +1 -0
- package/dist/commonjs/runtime/utils/components.js +18 -0
- package/dist/commonjs/runtime/utils/components.js.map +1 -0
- package/dist/commonjs/runtime/utils/dot-notation.types.js +2 -0
- package/dist/commonjs/runtime/utils/dot-notation.types.js.map +1 -0
- package/dist/commonjs/runtime/utils/index.js +61 -0
- package/dist/commonjs/runtime/utils/index.js.map +1 -0
- package/dist/commonjs/runtime/utils/objects.js +92 -0
- package/dist/commonjs/runtime/utils/objects.js.map +1 -0
- package/dist/commonjs/runtime/utils/specificity.js +44 -0
- package/dist/commonjs/runtime/utils/specificity.js.map +1 -0
- package/dist/commonjs/runtime/utils/style-value.js +21 -0
- package/dist/commonjs/runtime/utils/style-value.js.map +1 -0
- package/dist/commonjs/runtime/utils/utils.types.js +6 -0
- package/dist/commonjs/runtime/utils/utils.types.js.map +1 -0
- package/dist/commonjs/runtime/web/api.js +68 -0
- package/dist/commonjs/runtime/web/api.js.map +1 -0
- package/dist/commonjs/runtime/web/assign-style.js +27 -0
- package/dist/commonjs/runtime/web/assign-style.js.map +1 -0
- package/dist/commonjs/runtime/web/index.js +18 -0
- package/dist/commonjs/runtime/web/index.js.map +1 -0
- package/dist/commonjs/runtime/web/metro.js +6 -0
- package/dist/commonjs/runtime/web/metro.js.map +1 -0
- package/dist/module/babel/allowedModules.js +19 -0
- package/dist/module/babel/allowedModules.js.map +1 -0
- package/dist/module/babel/helpers.js +21 -0
- package/dist/module/babel/helpers.js.map +1 -0
- package/dist/module/babel/import-plugin.js +97 -0
- package/dist/module/babel/import-plugin.js.map +1 -0
- package/dist/module/babel/index.js +9 -0
- package/dist/module/babel/index.js.map +1 -0
- package/dist/module/babel/react-native-web.js +112 -0
- package/dist/module/babel/react-native-web.js.map +1 -0
- package/dist/module/babel/react-native.js +112 -0
- package/dist/module/babel/react-native.js.map +1 -0
- package/dist/module/compiler/atRules.js +110 -0
- package/dist/module/compiler/atRules.js.map +1 -0
- package/dist/module/compiler/compiler.js +276 -0
- package/dist/module/compiler/compiler.js.map +1 -0
- package/dist/module/compiler/compiler.types.js +60 -0
- package/dist/module/compiler/compiler.types.js.map +1 -0
- package/dist/module/compiler/container-query.js +59 -0
- package/dist/module/compiler/container-query.js.map +1 -0
- package/dist/module/compiler/declarations.js +2091 -0
- package/dist/module/compiler/declarations.js.map +1 -0
- package/dist/module/compiler/functions-web.js +32 -0
- package/dist/module/compiler/functions-web.js.map +1 -0
- package/dist/module/compiler/functions.js +47 -0
- package/dist/module/compiler/functions.js.map +1 -0
- package/dist/module/compiler/index.js +9 -0
- package/dist/module/compiler/index.js.map +1 -0
- package/dist/module/compiler/inheritance.test.js +78 -0
- package/dist/module/compiler/inheritance.test.js.map +1 -0
- package/dist/module/compiler/keyframes.js +54 -0
- package/dist/module/compiler/keyframes.js.map +1 -0
- package/dist/module/compiler/media-query.js +166 -0
- package/dist/module/compiler/media-query.js.map +1 -0
- package/dist/module/compiler/pseudo-elements.js +44 -0
- package/dist/module/compiler/pseudo-elements.js.map +1 -0
- package/dist/module/compiler/selector-builder.js +496 -0
- package/dist/module/compiler/selector-builder.js.map +1 -0
- package/dist/module/compiler/selectors.js +409 -0
- package/dist/module/compiler/selectors.js.map +1 -0
- package/dist/module/compiler/split-by-delimiter.js +17 -0
- package/dist/module/compiler/split-by-delimiter.js.map +1 -0
- package/dist/module/compiler/stylesheet.js +471 -0
- package/dist/module/compiler/stylesheet.js.map +1 -0
- package/dist/module/compiler/supports.js +23 -0
- package/dist/module/compiler/supports.js.map +1 -0
- package/dist/module/components/ActivityIndicator.js +17 -0
- package/dist/module/components/ActivityIndicator.js.map +1 -0
- package/dist/module/components/Button.js +17 -0
- package/dist/module/components/Button.js.map +1 -0
- package/dist/module/components/FlatList.js +14 -0
- package/dist/module/components/FlatList.js.map +1 -0
- package/dist/module/components/Image.js +12 -0
- package/dist/module/components/Image.js.map +1 -0
- package/dist/module/components/Switch.js +12 -0
- package/dist/module/components/Switch.js.map +1 -0
- package/dist/module/components/Text.js +12 -0
- package/dist/module/components/Text.js.map +1 -0
- package/dist/module/components/TextInput.js +12 -0
- package/dist/module/components/TextInput.js.map +1 -0
- package/dist/module/components/View.js +12 -0
- package/dist/module/components/View.js.map +1 -0
- package/dist/module/components/index.js +12 -0
- package/dist/module/components/index.js.map +1 -0
- package/dist/module/doctor/index.js +4 -0
- package/dist/module/doctor/index.js.map +1 -0
- package/dist/module/index.js +5 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/jest/expect.d.js +2 -0
- package/dist/module/jest/expect.d.js.map +1 -0
- package/dist/module/jest/index.js +50 -0
- package/dist/module/jest/index.js.map +1 -0
- package/dist/module/jest/setup.js +3 -0
- package/dist/module/jest/setup.js.map +1 -0
- package/dist/module/jest/setupAfterEnv.js +15 -0
- package/dist/module/jest/setupAfterEnv.js.map +1 -0
- package/dist/module/metro/index.js +161 -0
- package/dist/module/metro/index.js.map +1 -0
- package/dist/module/metro/injection-code.js +27 -0
- package/dist/module/metro/injection-code.js.map +1 -0
- package/dist/module/metro/metro-transformer.js +17 -0
- package/dist/module/metro/metro-transformer.js.map +1 -0
- package/dist/module/metro/picocolors.js +67 -0
- package/dist/module/metro/picocolors.js.map +1 -0
- package/dist/module/metro/resolver.js +57 -0
- package/dist/module/metro/resolver.js.map +1 -0
- package/dist/module/metro/stringify.js +55 -0
- package/dist/module/metro/stringify.js.map +1 -0
- package/dist/module/metro/typescript.js +42 -0
- package/dist/module/metro/typescript.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/poison.pill.js +37 -0
- package/dist/module/poison.pill.js.map +1 -0
- package/dist/module/runtime/index.js +9 -0
- package/dist/module/runtime/index.js.map +1 -0
- package/dist/module/runtime/native/api.js +75 -0
- package/dist/module/runtime/native/api.js.map +1 -0
- package/dist/module/runtime/native/conditions/attributes.js +38 -0
- package/dist/module/runtime/native/conditions/attributes.js.map +1 -0
- package/dist/module/runtime/native/conditions/container-query.js +117 -0
- package/dist/module/runtime/native/conditions/container-query.js.map +1 -0
- package/dist/module/runtime/native/conditions/guards.js +29 -0
- package/dist/module/runtime/native/conditions/guards.js.map +1 -0
- package/dist/module/runtime/native/conditions/index.js +36 -0
- package/dist/module/runtime/native/conditions/index.js.map +1 -0
- package/dist/module/runtime/native/conditions/media-query.js +93 -0
- package/dist/module/runtime/native/conditions/media-query.js.map +1 -0
- package/dist/module/runtime/native/index.js +5 -0
- package/dist/module/runtime/native/index.js.map +1 -0
- package/dist/module/runtime/native/injection.js +95 -0
- package/dist/module/runtime/native/injection.js.map +1 -0
- package/dist/module/runtime/native/metro.js +5 -0
- package/dist/module/runtime/native/metro.js.map +1 -0
- package/dist/module/runtime/native/react/interaction.js +59 -0
- package/dist/module/runtime/native/react/interaction.js.map +1 -0
- package/dist/module/runtime/native/react/rules.js +248 -0
- package/dist/module/runtime/native/react/rules.js.map +1 -0
- package/dist/module/runtime/native/react/useNativeCss.js +153 -0
- package/dist/module/runtime/native/react/useNativeCss.js.map +1 -0
- package/dist/module/runtime/native/react/usePassthrough.js +45 -0
- package/dist/module/runtime/native/react/usePassthrough.js.map +1 -0
- package/dist/module/runtime/native/reactivity.js +166 -0
- package/dist/module/runtime/native/reactivity.js.map +1 -0
- package/dist/module/runtime/native/reanimated.js +13 -0
- package/dist/module/runtime/native/reanimated.js.map +1 -0
- package/dist/module/runtime/native/root.js +24 -0
- package/dist/module/runtime/native/root.js.map +1 -0
- package/dist/module/runtime/native/styles/calculate-props.js +143 -0
- package/dist/module/runtime/native/styles/calculate-props.js.map +1 -0
- package/dist/module/runtime/native/styles/constants.js +5 -0
- package/dist/module/runtime/native/styles/constants.js.map +1 -0
- package/dist/module/runtime/native/styles/defaults.js +65 -0
- package/dist/module/runtime/native/styles/defaults.js.map +1 -0
- package/dist/module/runtime/native/styles/functions/animation-timing.js +30 -0
- package/dist/module/runtime/native/styles/functions/animation-timing.js.map +1 -0
- package/dist/module/runtime/native/styles/functions/calc.js +120 -0
- package/dist/module/runtime/native/styles/functions/calc.js.map +1 -0
- package/dist/module/runtime/native/styles/functions/filters.js +70 -0
- package/dist/module/runtime/native/styles/functions/filters.js.map +1 -0
- package/dist/module/runtime/native/styles/functions/index.js +8 -0
- package/dist/module/runtime/native/styles/functions/index.js.map +1 -0
- package/dist/module/runtime/native/styles/functions/platform-functions.js +36 -0
- package/dist/module/runtime/native/styles/functions/platform-functions.js.map +1 -0
- package/dist/module/runtime/native/styles/functions/transform-functions.js +114 -0
- package/dist/module/runtime/native/styles/functions/transform-functions.js.map +1 -0
- package/dist/module/runtime/native/styles/index.js +110 -0
- package/dist/module/runtime/native/styles/index.js.map +1 -0
- package/dist/module/runtime/native/styles/resolve.js +101 -0
- package/dist/module/runtime/native/styles/resolve.js.map +1 -0
- package/dist/module/runtime/native/styles/shorthands/_handler.js +74 -0
- package/dist/module/runtime/native/styles/shorthands/_handler.js.map +1 -0
- package/dist/module/runtime/native/styles/shorthands/animation.js +51 -0
- package/dist/module/runtime/native/styles/shorthands/animation.js.map +1 -0
- package/dist/module/runtime/native/styles/shorthands/border.js +8 -0
- package/dist/module/runtime/native/styles/shorthands/border.js.map +1 -0
- package/dist/module/runtime/native/styles/shorthands/box-shadow.js +35 -0
- package/dist/module/runtime/native/styles/shorthands/box-shadow.js.map +1 -0
- package/dist/module/runtime/native/styles/shorthands/index.js +8 -0
- package/dist/module/runtime/native/styles/shorthands/index.js.map +1 -0
- package/dist/module/runtime/native/styles/shorthands/text-shadow.js +9 -0
- package/dist/module/runtime/native/styles/shorthands/text-shadow.js.map +1 -0
- package/dist/module/runtime/native/styles/shorthands/transform.js +18 -0
- package/dist/module/runtime/native/styles/shorthands/transform.js.map +1 -0
- package/dist/module/runtime/native/styles/units.js +43 -0
- package/dist/module/runtime/native/styles/units.js.map +1 -0
- package/dist/module/runtime/native/styles/variables.js +75 -0
- package/dist/module/runtime/native/styles/variables.js.map +1 -0
- package/dist/module/runtime/runtime.js +4 -0
- package/dist/module/runtime/runtime.js.map +1 -0
- package/dist/module/runtime/runtime.native.js +4 -0
- package/dist/module/runtime/runtime.native.js.map +1 -0
- package/dist/module/runtime/runtime.types.js +4 -0
- package/dist/module/runtime/runtime.types.js.map +1 -0
- package/dist/module/runtime/utils/components.js +14 -0
- package/dist/module/runtime/utils/components.js.map +1 -0
- package/dist/module/runtime/utils/dot-notation.types.js +2 -0
- package/dist/module/runtime/utils/dot-notation.types.js.map +1 -0
- package/dist/module/runtime/utils/index.js +8 -0
- package/dist/module/runtime/utils/index.js.map +1 -0
- package/dist/module/runtime/utils/objects.js +84 -0
- package/dist/module/runtime/utils/objects.js.map +1 -0
- package/dist/module/runtime/utils/specificity.js +39 -0
- package/dist/module/runtime/utils/specificity.js.map +1 -0
- package/dist/module/runtime/utils/style-value.js +16 -0
- package/dist/module/runtime/utils/style-value.js.map +1 -0
- package/dist/module/runtime/utils/utils.types.js +4 -0
- package/dist/module/runtime/utils/utils.types.js.map +1 -0
- package/dist/module/runtime/web/api.js +59 -0
- package/dist/module/runtime/web/api.js.map +1 -0
- package/dist/module/runtime/web/assign-style.js +23 -0
- package/dist/module/runtime/web/assign-style.js.map +1 -0
- package/dist/module/runtime/web/index.js +6 -0
- package/dist/module/runtime/web/index.js.map +1 -0
- package/dist/module/runtime/web/metro.js +5 -0
- package/dist/module/runtime/web/metro.js.map +1 -0
- package/dist/typescript/commonjs/example/app.config.d.ts +4 -0
- package/dist/typescript/commonjs/example/app.config.d.ts.map +1 -0
- package/dist/typescript/commonjs/example/src/App.d.ts +3 -0
- package/dist/typescript/commonjs/example/src/App.d.ts.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/commonjs/src/babel/allowedModules.d.ts +2 -0
- package/dist/typescript/commonjs/src/babel/allowedModules.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/babel/helpers.d.ts +13 -0
- package/dist/typescript/commonjs/src/babel/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/babel/import-plugin.d.ts +6 -0
- package/dist/typescript/commonjs/src/babel/import-plugin.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/babel/index.d.ts +1 -0
- package/dist/typescript/commonjs/src/babel/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/babel/react-native-web.d.ts +8 -0
- package/dist/typescript/commonjs/src/babel/react-native-web.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/babel/react-native.d.ts +8 -0
- package/dist/typescript/commonjs/src/babel/react-native.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/atRules.d.ts +34 -0
- package/dist/typescript/commonjs/src/compiler/atRules.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts +17 -0
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +197 -0
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/container-query.d.ts +5 -0
- package/dist/typescript/commonjs/src/compiler/container-query.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts +118 -0
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/functions-web.d.ts +11 -0
- package/dist/typescript/commonjs/src/compiler/functions-web.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/functions.d.ts +11 -0
- package/dist/typescript/commonjs/src/compiler/functions.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/index.d.ts +7 -0
- package/dist/typescript/commonjs/src/compiler/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts +2 -0
- package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/keyframes.d.ts +7 -0
- package/dist/typescript/commonjs/src/compiler/keyframes.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/media-query.d.ts +7 -0
- package/dist/typescript/commonjs/src/compiler/media-query.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/pseudo-elements.d.ts +4 -0
- package/dist/typescript/commonjs/src/compiler/pseudo-elements.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts +24 -0
- package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/selectors.d.ts +24 -0
- package/dist/typescript/commonjs/src/compiler/selectors.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/split-by-delimiter.d.ts +2 -0
- package/dist/typescript/commonjs/src/compiler/split-by-delimiter.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +68 -0
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/supports.d.ts +3 -0
- package/dist/typescript/commonjs/src/compiler/supports.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts +13 -0
- package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/Button.d.ts +13 -0
- package/dist/typescript/commonjs/src/components/Button.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/FlatList.d.ts +10 -0
- package/dist/typescript/commonjs/src/components/FlatList.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/Image.d.ts +8 -0
- package/dist/typescript/commonjs/src/components/Image.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/Switch.d.ts +8 -0
- package/dist/typescript/commonjs/src/components/Switch.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/Text.d.ts +8 -0
- package/dist/typescript/commonjs/src/components/Text.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/TextInput.d.ts +8 -0
- package/dist/typescript/commonjs/src/components/TextInput.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/View.d.ts +8 -0
- package/dist/typescript/commonjs/src/components/View.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/index.d.ts +10 -0
- package/dist/typescript/commonjs/src/components/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/doctor/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/doctor/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/index.d.ts +3 -0
- package/dist/typescript/commonjs/src/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/jest/index.d.ts +30 -0
- package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/jest/setup.d.ts +1 -0
- package/dist/typescript/commonjs/src/jest/setup.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/jest/setupAfterEnv.d.ts +1 -0
- package/dist/typescript/commonjs/src/jest/setupAfterEnv.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/index.d.ts +11 -0
- package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/injection-code.d.ts +16 -0
- package/dist/typescript/commonjs/src/metro/injection-code.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/metro-transformer.d.ts +3 -0
- package/dist/typescript/commonjs/src/metro/metro-transformer.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/picocolors.d.ts +27 -0
- package/dist/typescript/commonjs/src/metro/picocolors.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/resolver.d.ts +4 -0
- package/dist/typescript/commonjs/src/metro/resolver.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/stringify.d.ts +7 -0
- package/dist/typescript/commonjs/src/metro/stringify.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/typescript.d.ts +2 -0
- package/dist/typescript/commonjs/src/metro/typescript.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/poison.pill.d.ts +2 -0
- package/dist/typescript/commonjs/src/poison.pill.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/index.d.ts +7 -0
- package/dist/typescript/commonjs/src/runtime/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/api.d.ts +17 -0
- package/dist/typescript/commonjs/src/runtime/native/api.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/attributes.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/attributes.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts +7 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts +6 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts +4 -0
- package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/index.d.ts +4 -0
- package/dist/typescript/commonjs/src/runtime/native/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/injection.d.ts +16 -0
- package/dist/typescript/commonjs/src/runtime/native/injection.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/metro.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/native/metro.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts +6 -0
- package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts +7 -0
- package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts +38 -0
- package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/react/usePassthrough.d.ts +4 -0
- package/dist/typescript/commonjs/src/runtime/native/react/usePassthrough.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +55 -0
- package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/reanimated.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/native/reanimated.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/root.d.ts +11 -0
- package/dist/typescript/commonjs/src/runtime/native/root.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts +10 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/constants.d.ts +3 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/defaults.d.ts +3 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/defaults.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/animation-timing.d.ts +4 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/animation-timing.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/calc.d.ts +3 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/calc.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/filters.d.ts +12 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/filters.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/index.d.ts +6 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/platform-functions.d.ts +8 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/platform-functions.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/transform-functions.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/functions/transform-functions.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts +19 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts +18 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/_handler.d.ts +11 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/_handler.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/animation.d.ts +4 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/animation.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/border.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/border.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/box-shadow.d.ts +3 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/box-shadow.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/index.d.ts +6 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/text-shadow.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/text-shadow.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/transform.d.ts +7 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/transform.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/units.d.ts +6 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/units.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/runtime.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/runtime.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/runtime.native.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/runtime.native.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts +47 -0
- package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/components.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/utils/components.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/dot-notation.types.d.ts +23 -0
- package/dist/typescript/commonjs/src/runtime/utils/dot-notation.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/index.d.ts +6 -0
- package/dist/typescript/commonjs/src/runtime/utils/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/specificity.d.ts +13 -0
- package/dist/typescript/commonjs/src/runtime/utils/specificity.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts +4 -0
- package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/utils/utils.types.d.ts +5 -0
- package/dist/typescript/commonjs/src/runtime/utils/utils.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/web/api.d.ts +10 -0
- package/dist/typescript/commonjs/src/runtime/web/api.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/web/assign-style.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/web/assign-style.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/web/index.d.ts +4 -0
- package/dist/typescript/commonjs/src/runtime/web/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/web/metro.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/web/metro.d.ts.map +1 -0
- package/dist/typescript/module/example/app.config.d.ts +4 -0
- package/dist/typescript/module/example/app.config.d.ts.map +1 -0
- package/dist/typescript/module/example/src/App.d.ts +3 -0
- package/dist/typescript/module/example/src/App.d.ts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/dist/typescript/module/src/babel/allowedModules.d.ts +2 -0
- package/dist/typescript/module/src/babel/allowedModules.d.ts.map +1 -0
- package/dist/typescript/module/src/babel/helpers.d.ts +13 -0
- package/dist/typescript/module/src/babel/helpers.d.ts.map +1 -0
- package/dist/typescript/module/src/babel/import-plugin.d.ts +6 -0
- package/dist/typescript/module/src/babel/import-plugin.d.ts.map +1 -0
- package/dist/typescript/module/src/babel/index.d.ts +1 -0
- package/dist/typescript/module/src/babel/index.d.ts.map +1 -0
- package/dist/typescript/module/src/babel/react-native-web.d.ts +8 -0
- package/dist/typescript/module/src/babel/react-native-web.d.ts.map +1 -0
- package/dist/typescript/module/src/babel/react-native.d.ts +8 -0
- package/dist/typescript/module/src/babel/react-native.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/atRules.d.ts +34 -0
- package/dist/typescript/module/src/compiler/atRules.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/compiler.d.ts +17 -0
- package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/compiler.types.d.ts +197 -0
- package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/container-query.d.ts +5 -0
- package/dist/typescript/module/src/compiler/container-query.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/declarations.d.ts +118 -0
- package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/functions-web.d.ts +11 -0
- package/dist/typescript/module/src/compiler/functions-web.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/functions.d.ts +11 -0
- package/dist/typescript/module/src/compiler/functions.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/index.d.ts +7 -0
- package/dist/typescript/module/src/compiler/index.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/inheritance.test.d.ts +2 -0
- package/dist/typescript/module/src/compiler/inheritance.test.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/keyframes.d.ts +7 -0
- package/dist/typescript/module/src/compiler/keyframes.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/media-query.d.ts +7 -0
- package/dist/typescript/module/src/compiler/media-query.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/pseudo-elements.d.ts +4 -0
- package/dist/typescript/module/src/compiler/pseudo-elements.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/selector-builder.d.ts +24 -0
- package/dist/typescript/module/src/compiler/selector-builder.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/selectors.d.ts +24 -0
- package/dist/typescript/module/src/compiler/selectors.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/split-by-delimiter.d.ts +2 -0
- package/dist/typescript/module/src/compiler/split-by-delimiter.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/stylesheet.d.ts +68 -0
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/supports.d.ts +3 -0
- package/dist/typescript/module/src/compiler/supports.d.ts.map +1 -0
- package/dist/typescript/module/src/components/ActivityIndicator.d.ts +13 -0
- package/dist/typescript/module/src/components/ActivityIndicator.d.ts.map +1 -0
- package/dist/typescript/module/src/components/Button.d.ts +13 -0
- package/dist/typescript/module/src/components/Button.d.ts.map +1 -0
- package/dist/typescript/module/src/components/FlatList.d.ts +10 -0
- package/dist/typescript/module/src/components/FlatList.d.ts.map +1 -0
- package/dist/typescript/module/src/components/Image.d.ts +8 -0
- package/dist/typescript/module/src/components/Image.d.ts.map +1 -0
- package/dist/typescript/module/src/components/Switch.d.ts +8 -0
- package/dist/typescript/module/src/components/Switch.d.ts.map +1 -0
- package/dist/typescript/module/src/components/Text.d.ts +8 -0
- package/dist/typescript/module/src/components/Text.d.ts.map +1 -0
- package/dist/typescript/module/src/components/TextInput.d.ts +8 -0
- package/dist/typescript/module/src/components/TextInput.d.ts.map +1 -0
- package/dist/typescript/module/src/components/View.d.ts +8 -0
- package/dist/typescript/module/src/components/View.d.ts.map +1 -0
- package/dist/typescript/module/src/components/index.d.ts +10 -0
- package/dist/typescript/module/src/components/index.d.ts.map +1 -0
- package/dist/typescript/module/src/doctor/index.d.ts +2 -0
- package/dist/typescript/module/src/doctor/index.d.ts.map +1 -0
- package/dist/typescript/module/src/index.d.ts +3 -0
- package/dist/typescript/module/src/index.d.ts.map +1 -0
- package/dist/typescript/module/src/jest/index.d.ts +30 -0
- package/dist/typescript/module/src/jest/index.d.ts.map +1 -0
- package/dist/typescript/module/src/jest/setup.d.ts +1 -0
- package/dist/typescript/module/src/jest/setup.d.ts.map +1 -0
- package/dist/typescript/module/src/jest/setupAfterEnv.d.ts +1 -0
- package/dist/typescript/module/src/jest/setupAfterEnv.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/index.d.ts +11 -0
- package/dist/typescript/module/src/metro/index.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/injection-code.d.ts +16 -0
- package/dist/typescript/module/src/metro/injection-code.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/metro-transformer.d.ts +3 -0
- package/dist/typescript/module/src/metro/metro-transformer.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/picocolors.d.ts +27 -0
- package/dist/typescript/module/src/metro/picocolors.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/resolver.d.ts +4 -0
- package/dist/typescript/module/src/metro/resolver.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/stringify.d.ts +7 -0
- package/dist/typescript/module/src/metro/stringify.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/typescript.d.ts +2 -0
- package/dist/typescript/module/src/metro/typescript.d.ts.map +1 -0
- package/dist/typescript/module/src/poison.pill.d.ts +2 -0
- package/dist/typescript/module/src/poison.pill.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/index.d.ts +7 -0
- package/dist/typescript/module/src/runtime/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/api.d.ts +17 -0
- package/dist/typescript/module/src/runtime/native/api.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/conditions/attributes.d.ts +5 -0
- package/dist/typescript/module/src/runtime/native/conditions/attributes.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts +7 -0
- package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts +5 -0
- package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/conditions/index.d.ts +6 -0
- package/dist/typescript/module/src/runtime/native/conditions/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts +4 -0
- package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/index.d.ts +4 -0
- package/dist/typescript/module/src/runtime/native/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/injection.d.ts +16 -0
- package/dist/typescript/module/src/runtime/native/injection.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/metro.d.ts +2 -0
- package/dist/typescript/module/src/runtime/native/metro.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/react/interaction.d.ts +6 -0
- package/dist/typescript/module/src/runtime/native/react/interaction.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/react/rules.d.ts +7 -0
- package/dist/typescript/module/src/runtime/native/react/rules.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts +38 -0
- package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/react/usePassthrough.d.ts +4 -0
- package/dist/typescript/module/src/runtime/native/react/usePassthrough.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/reactivity.d.ts +55 -0
- package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/reanimated.d.ts +5 -0
- package/dist/typescript/module/src/runtime/native/reanimated.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/root.d.ts +11 -0
- package/dist/typescript/module/src/runtime/native/root.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts +10 -0
- package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/constants.d.ts +3 -0
- package/dist/typescript/module/src/runtime/native/styles/constants.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/defaults.d.ts +3 -0
- package/dist/typescript/module/src/runtime/native/styles/defaults.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/animation-timing.d.ts +4 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/animation-timing.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/calc.d.ts +3 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/calc.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/filters.d.ts +12 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/filters.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/index.d.ts +6 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/platform-functions.d.ts +8 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/platform-functions.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/transform-functions.d.ts +5 -0
- package/dist/typescript/module/src/runtime/native/styles/functions/transform-functions.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/index.d.ts +19 -0
- package/dist/typescript/module/src/runtime/native/styles/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts +18 -0
- package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/_handler.d.ts +11 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/_handler.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/animation.d.ts +4 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/animation.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/border.d.ts +2 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/border.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/box-shadow.d.ts +3 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/box-shadow.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/index.d.ts +6 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/text-shadow.d.ts +2 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/text-shadow.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/transform.d.ts +7 -0
- package/dist/typescript/module/src/runtime/native/styles/shorthands/transform.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/units.d.ts +6 -0
- package/dist/typescript/module/src/runtime/native/styles/units.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/variables.d.ts +5 -0
- package/dist/typescript/module/src/runtime/native/styles/variables.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/runtime.d.ts +2 -0
- package/dist/typescript/module/src/runtime/runtime.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/runtime.native.d.ts +2 -0
- package/dist/typescript/module/src/runtime/runtime.native.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/runtime.types.d.ts +47 -0
- package/dist/typescript/module/src/runtime/runtime.types.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/utils/components.d.ts +2 -0
- package/dist/typescript/module/src/runtime/utils/components.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/utils/dot-notation.types.d.ts +23 -0
- package/dist/typescript/module/src/runtime/utils/dot-notation.types.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/utils/index.d.ts +6 -0
- package/dist/typescript/module/src/runtime/utils/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/utils/objects.d.ts +5 -0
- package/dist/typescript/module/src/runtime/utils/objects.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/utils/specificity.d.ts +13 -0
- package/dist/typescript/module/src/runtime/utils/specificity.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/utils/style-value.d.ts +4 -0
- package/dist/typescript/module/src/runtime/utils/style-value.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/utils/utils.types.d.ts +5 -0
- package/dist/typescript/module/src/runtime/utils/utils.types.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/web/api.d.ts +10 -0
- package/dist/typescript/module/src/runtime/web/api.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/web/assign-style.d.ts +2 -0
- package/dist/typescript/module/src/runtime/web/assign-style.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/web/index.d.ts +4 -0
- package/dist/typescript/module/src/runtime/web/index.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/web/metro.d.ts +2 -0
- package/dist/typescript/module/src/runtime/web/metro.d.ts.map +1 -0
- package/package.json +248 -47
- package/src/babel/allowedModules.ts +24 -0
- package/src/babel/helpers.ts +40 -0
- package/src/babel/import-plugin.ts +176 -0
- package/src/babel/index.ts +9 -0
- package/src/babel/react-native-web.ts +226 -0
- package/src/babel/react-native.ts +226 -0
- package/src/compiler/atRules.ts +158 -0
- package/src/compiler/compiler.ts +305 -0
- package/src/compiler/compiler.types.ts +267 -0
- package/src/compiler/container-query.ts +97 -0
- package/src/compiler/declarations.ts +3177 -0
- package/src/compiler/functions-web.ts +44 -0
- package/src/compiler/functions.ts +64 -0
- package/src/compiler/index.ts +7 -0
- package/src/compiler/inheritance.test.ts +121 -0
- package/src/compiler/keyframes.ts +86 -0
- package/src/compiler/media-query.ts +251 -0
- package/src/compiler/pseudo-elements.ts +54 -0
- package/src/compiler/selector-builder.ts +586 -0
- package/src/compiler/selectors.ts +505 -0
- package/src/compiler/split-by-delimiter.ts +19 -0
- package/src/compiler/stylesheet.ts +681 -0
- package/src/compiler/supports.ts +26 -0
- package/src/components/ActivityIndicator.tsx +27 -0
- package/src/components/Button.tsx +22 -0
- package/src/components/FlatList.tsx +21 -0
- package/src/components/Image.tsx +17 -0
- package/src/components/Switch.tsx +17 -0
- package/src/components/Text.tsx +17 -0
- package/src/components/TextInput.tsx +17 -0
- package/src/components/View.tsx +17 -0
- package/src/components/index.tsx +10 -0
- package/src/doctor/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/jest/expect.d.ts +1 -0
- package/src/jest/index.ts +74 -0
- package/src/jest/setup.ts +1 -0
- package/src/jest/setupAfterEnv.ts +13 -0
- package/src/metro/index.ts +237 -0
- package/src/metro/injection-code.ts +38 -0
- package/src/metro/metro-transformer.ts +31 -0
- package/src/metro/picocolors.ts +77 -0
- package/src/metro/resolver.ts +89 -0
- package/src/metro/stringify.ts +59 -0
- package/src/metro/typescript.ts +73 -0
- package/src/poison.pill.ts +36 -0
- package/src/runtime/index.ts +7 -0
- package/src/runtime/native/api.ts +106 -0
- package/src/runtime/native/conditions/attributes.ts +52 -0
- package/src/runtime/native/conditions/container-query.ts +162 -0
- package/src/runtime/native/conditions/guards.ts +44 -0
- package/src/runtime/native/conditions/index.ts +54 -0
- package/src/runtime/native/conditions/media-query.ts +98 -0
- package/src/runtime/native/index.ts +4 -0
- package/src/runtime/native/injection.ts +132 -0
- package/src/runtime/native/metro.ts +2 -0
- package/src/runtime/native/react/interaction.ts +90 -0
- package/src/runtime/native/react/rules.ts +330 -0
- package/src/runtime/native/react/useNativeCss.ts +203 -0
- package/src/runtime/native/react/usePassthrough.ts +51 -0
- package/src/runtime/native/reactivity.ts +243 -0
- package/src/runtime/native/reanimated.ts +22 -0
- package/src/runtime/native/root.ts +31 -0
- package/src/runtime/native/styles/calculate-props.ts +197 -0
- package/src/runtime/native/styles/constants.ts +2 -0
- package/src/runtime/native/styles/defaults.ts +79 -0
- package/src/runtime/native/styles/functions/animation-timing.ts +44 -0
- package/src/runtime/native/styles/functions/calc.ts +121 -0
- package/src/runtime/native/styles/functions/filters.ts +98 -0
- package/src/runtime/native/styles/functions/index.ts +5 -0
- package/src/runtime/native/styles/functions/platform-functions.ts +50 -0
- package/src/runtime/native/styles/functions/transform-functions.ts +84 -0
- package/src/runtime/native/styles/index.ts +197 -0
- package/src/runtime/native/styles/resolve.ts +162 -0
- package/src/runtime/native/styles/shorthands/_handler.ts +121 -0
- package/src/runtime/native/styles/shorthands/animation.ts +122 -0
- package/src/runtime/native/styles/shorthands/border.ts +10 -0
- package/src/runtime/native/styles/shorthands/box-shadow.ts +54 -0
- package/src/runtime/native/styles/shorthands/index.ts +5 -0
- package/src/runtime/native/styles/shorthands/text-shadow.ts +17 -0
- package/src/runtime/native/styles/shorthands/transform.ts +23 -0
- package/src/runtime/native/styles/units.ts +57 -0
- package/src/runtime/native/styles/variables.ts +84 -0
- package/src/runtime/runtime.native.ts +1 -0
- package/src/runtime/runtime.ts +1 -0
- package/src/runtime/runtime.types.ts +130 -0
- package/src/runtime/utils/components.ts +15 -0
- package/src/runtime/utils/dot-notation.types.ts +118 -0
- package/src/runtime/utils/index.ts +5 -0
- package/src/runtime/utils/objects.ts +109 -0
- package/src/runtime/utils/specificity.ts +45 -0
- package/src/runtime/utils/style-value.ts +24 -0
- package/src/runtime/utils/utils.types.ts +19 -0
- package/src/runtime/web/api.ts +88 -0
- package/src/runtime/web/assign-style.ts +26 -0
- package/src/runtime/web/index.ts +5 -0
- package/src/runtime/web/metro.ts +2 -0
- package/types.d.ts +70 -0
- package/.babelrc +0 -17
- package/.editorconfig +0 -17
- package/.eslintignore +0 -3
- package/.eslintrc +0 -39
- package/.npmignore +0 -7
- package/build/index.js +0 -299
- package/build/utils.js +0 -61
- package/circle.yml +0 -31
- package/jsconfig.json +0 -9
- package/login.sh +0 -11
- package/src/index.js +0 -184
- package/src/utils.js +0 -32
- package/test/rnc.test.js +0 -258
- package/yarn.lock +0 -3333
|
@@ -0,0 +1,3177 @@
|
|
|
1
|
+
// cSpell:ignore rcap,vmin,svmin,lvmin,dvmin,cqmin,vmax,svmax,lvmax,dvmax,cqmax,currentcolor,oklab,oklch,prophoto
|
|
2
|
+
|
|
3
|
+
import Color from "colorjs.io";
|
|
4
|
+
import type {
|
|
5
|
+
Angle,
|
|
6
|
+
BorderSideWidth,
|
|
7
|
+
BorderStyle,
|
|
8
|
+
ColorOrAuto,
|
|
9
|
+
CssColor,
|
|
10
|
+
Declaration,
|
|
11
|
+
DimensionPercentageFor_LengthValue,
|
|
12
|
+
EnvironmentVariable,
|
|
13
|
+
FontSize,
|
|
14
|
+
FontStyle,
|
|
15
|
+
FontVariantCaps,
|
|
16
|
+
FontWeight,
|
|
17
|
+
GapValue,
|
|
18
|
+
Gradient,
|
|
19
|
+
GradientItemFor_DimensionPercentageFor_LengthValue,
|
|
20
|
+
Length,
|
|
21
|
+
LengthPercentageOrAuto,
|
|
22
|
+
LengthValue,
|
|
23
|
+
LineDirection,
|
|
24
|
+
LineHeight,
|
|
25
|
+
LineStyle,
|
|
26
|
+
MaxSize,
|
|
27
|
+
NumberOrPercentage,
|
|
28
|
+
Scale,
|
|
29
|
+
Size,
|
|
30
|
+
Size2DFor_DimensionPercentageFor_LengthValue,
|
|
31
|
+
Time,
|
|
32
|
+
Token,
|
|
33
|
+
TokenOrValue,
|
|
34
|
+
Translate,
|
|
35
|
+
UnresolvedColor,
|
|
36
|
+
} from "lightningcss";
|
|
37
|
+
|
|
38
|
+
import type {
|
|
39
|
+
StyleDescriptor,
|
|
40
|
+
StyleFunction,
|
|
41
|
+
StyleRule,
|
|
42
|
+
} from "./compiler.types";
|
|
43
|
+
import { parseEasingFunction, parseIterationCount } from "./keyframes";
|
|
44
|
+
import { toRNProperty } from "./selectors";
|
|
45
|
+
import type { StylesheetBuilder } from "./stylesheet";
|
|
46
|
+
|
|
47
|
+
const CommaSeparator = Symbol("CommaSeparator");
|
|
48
|
+
|
|
49
|
+
type DeclarationType<P extends Declaration["property"]> = Extract<
|
|
50
|
+
Declaration,
|
|
51
|
+
{ property: P }
|
|
52
|
+
>;
|
|
53
|
+
|
|
54
|
+
type Parser<T extends Declaration["property"] = Declaration["property"]> = (
|
|
55
|
+
declaration: Extract<Declaration, { property: T }>,
|
|
56
|
+
builder: StylesheetBuilder,
|
|
57
|
+
propertyName: string,
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
59
|
+
) => StyleDescriptor | void;
|
|
60
|
+
|
|
61
|
+
const propertyRename: Record<string, string> = {
|
|
62
|
+
"background-image": "experimental_backgroundImage",
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// TODO: We need a better way to handle this
|
|
66
|
+
const unparsedRuntimeParsing = new Set([
|
|
67
|
+
"animation",
|
|
68
|
+
"border",
|
|
69
|
+
"box-shadow",
|
|
70
|
+
"text-shadow",
|
|
71
|
+
"transform",
|
|
72
|
+
"scale",
|
|
73
|
+
"rotate",
|
|
74
|
+
"translate",
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
const parsers: {
|
|
78
|
+
[K in Declaration["property"]]?: Parser<K>;
|
|
79
|
+
} = {
|
|
80
|
+
"align-content": parseAlignContent,
|
|
81
|
+
"align-items": parseAlignItems,
|
|
82
|
+
"align-self": parseAlignSelf,
|
|
83
|
+
"animation": addAnimationValue,
|
|
84
|
+
"animation-delay": addAnimationValue,
|
|
85
|
+
"animation-direction": addAnimationValue,
|
|
86
|
+
"animation-duration": addAnimationValue,
|
|
87
|
+
"animation-fill-mode": addAnimationValue,
|
|
88
|
+
"animation-iteration-count": addAnimationValue,
|
|
89
|
+
"animation-name": addAnimationValue,
|
|
90
|
+
"animation-play-state": addAnimationValue,
|
|
91
|
+
"animation-timing-function": addAnimationValue,
|
|
92
|
+
"aspect-ratio": parseAspectRatio,
|
|
93
|
+
"background-color": parseColorDeclaration,
|
|
94
|
+
"background-image": parseBackgroundImage,
|
|
95
|
+
"block-size": parseSizeDeclaration,
|
|
96
|
+
"border": parseBorder,
|
|
97
|
+
"border-block": parseBorderBlock,
|
|
98
|
+
"border-block-color": parseBorderColor,
|
|
99
|
+
"border-block-end": parseBorderBlockEnd,
|
|
100
|
+
"border-block-end-color": parseColorDeclaration,
|
|
101
|
+
"border-block-end-width": parseBorderSideWidthDeclaration,
|
|
102
|
+
"border-block-start": parseBorderBlockStart,
|
|
103
|
+
"border-block-start-color": parseColorDeclaration,
|
|
104
|
+
"border-block-start-width": parseBorderSideWidthDeclaration,
|
|
105
|
+
"border-block-style": parseBorderBlockStyle,
|
|
106
|
+
"border-block-width": parseBorderBlockWidth,
|
|
107
|
+
"border-bottom": parseBorderSide,
|
|
108
|
+
"border-bottom-color": parseColorDeclaration,
|
|
109
|
+
"border-bottom-left-radius": parseSize2DDimensionPercentageDeclaration,
|
|
110
|
+
"border-bottom-right-radius": parseSize2DDimensionPercentageDeclaration,
|
|
111
|
+
"border-bottom-style": parseBorderStyleDeclaration,
|
|
112
|
+
"border-bottom-width": parseBorderSideWidthDeclaration,
|
|
113
|
+
"border-color": parseBorderColor,
|
|
114
|
+
"border-end-end-radius": parseSize2DDimensionPercentageDeclaration,
|
|
115
|
+
"border-end-start-radius": parseSize2DDimensionPercentageDeclaration,
|
|
116
|
+
"border-inline": parseBorderInline,
|
|
117
|
+
"border-inline-color": parseBorderColor,
|
|
118
|
+
"border-inline-end": parseBorderInlineEnd,
|
|
119
|
+
"border-inline-end-color": parseColorDeclaration,
|
|
120
|
+
"border-inline-end-style": parseBorderInlineStyle,
|
|
121
|
+
"border-inline-end-width": parseBorderSideWidthDeclaration,
|
|
122
|
+
"border-inline-start": parseBorderInlineStart,
|
|
123
|
+
"border-inline-start-color": parseColorDeclaration,
|
|
124
|
+
"border-inline-start-style": parseBorderInlineStyle,
|
|
125
|
+
"border-inline-start-width": parseBorderSideWidthDeclaration,
|
|
126
|
+
"border-inline-style": parseBorderInlineStyle,
|
|
127
|
+
"border-inline-width": parseBorderInlineWidth,
|
|
128
|
+
"border-left": parseBorderSide,
|
|
129
|
+
"border-left-color": parseColorDeclaration,
|
|
130
|
+
"border-left-style": parseBorderStyleDeclaration,
|
|
131
|
+
"border-left-width": parseBorderSideWidthDeclaration,
|
|
132
|
+
"border-radius": parseBorderRadius,
|
|
133
|
+
"border-right": parseBorderSide,
|
|
134
|
+
"border-right-color": parseColorDeclaration,
|
|
135
|
+
"border-right-style": parseBorderStyleDeclaration,
|
|
136
|
+
"border-right-width": parseBorderSideWidthDeclaration,
|
|
137
|
+
"border-start-end-radius": parseSize2DDimensionPercentageDeclaration,
|
|
138
|
+
"border-start-start-radius": parseSize2DDimensionPercentageDeclaration,
|
|
139
|
+
"border-style": parseBorderStyleDeclaration,
|
|
140
|
+
"border-top": parseBorderSide,
|
|
141
|
+
"border-top-color": parseColorDeclaration,
|
|
142
|
+
"border-top-left-radius": parseSize2DDimensionPercentageDeclaration,
|
|
143
|
+
"border-top-right-radius": parseSize2DDimensionPercentageDeclaration,
|
|
144
|
+
"border-top-style": parseBorderStyleDeclaration,
|
|
145
|
+
"border-top-width": parseBorderSideWidthDeclaration,
|
|
146
|
+
"border-width": parseBorderWidth,
|
|
147
|
+
"bottom": parseSizeDeclaration,
|
|
148
|
+
"box-shadow": parseBoxShadow,
|
|
149
|
+
"caret-color": parseColorOrAutoDeclaration,
|
|
150
|
+
"color": parseFontColorDeclaration,
|
|
151
|
+
"column-gap": parseGap,
|
|
152
|
+
"container": parseContainer,
|
|
153
|
+
"container-name": parseContainerName,
|
|
154
|
+
"container-type": parseContainerType,
|
|
155
|
+
"display": parseDisplay,
|
|
156
|
+
"fill": parseSVGPaint,
|
|
157
|
+
"filter": parseFilter,
|
|
158
|
+
"flex": parseFlex,
|
|
159
|
+
"flex-basis": parseLengthPercentageOrAutoDeclaration,
|
|
160
|
+
"flex-direction": ({ value }) => value,
|
|
161
|
+
"flex-flow": parseFlexFlow,
|
|
162
|
+
"flex-grow": ({ value }) => value,
|
|
163
|
+
"flex-shrink": ({ value }) => value,
|
|
164
|
+
"flex-wrap": ({ value }) => value,
|
|
165
|
+
"font": parseFont,
|
|
166
|
+
"font-family": parseFontFamily,
|
|
167
|
+
"font-size": parseFontSizeDeclaration,
|
|
168
|
+
"font-style": parseFontStyleDeclaration,
|
|
169
|
+
"font-variant-caps": parseFontVariantCapsDeclaration,
|
|
170
|
+
"font-weight": parseFontWeightDeclaration,
|
|
171
|
+
"gap": parseGap,
|
|
172
|
+
"height": parseSizeDeclaration,
|
|
173
|
+
"inline-size": parseSizeDeclaration,
|
|
174
|
+
"inset": parseInset,
|
|
175
|
+
"inset-block": parseInsetBlock,
|
|
176
|
+
"inset-block-end": parseLengthPercentageOrAutoDeclaration,
|
|
177
|
+
"inset-block-start": parseLengthPercentageOrAutoDeclaration,
|
|
178
|
+
"inset-inline": parseInsetInline,
|
|
179
|
+
"inset-inline-end": parseLengthPercentageOrAutoDeclaration,
|
|
180
|
+
"inset-inline-start": parseLengthPercentageOrAutoDeclaration,
|
|
181
|
+
"justify-content": parseJustifyContent,
|
|
182
|
+
"left": parseSizeDeclaration,
|
|
183
|
+
"letter-spacing": parseLetterSpacing,
|
|
184
|
+
"line-height": parseLineHeightDeclaration,
|
|
185
|
+
"margin": parseMargin,
|
|
186
|
+
"margin-block": parseMarginBlock,
|
|
187
|
+
"margin-block-end": parseLengthPercentageOrAutoDeclaration,
|
|
188
|
+
"margin-block-start": parseLengthPercentageOrAutoDeclaration,
|
|
189
|
+
"margin-bottom": parseSizeDeclaration,
|
|
190
|
+
"margin-inline": parseMarginInline,
|
|
191
|
+
"margin-inline-end": parseLengthPercentageOrAutoDeclaration,
|
|
192
|
+
"margin-inline-start": parseLengthPercentageOrAutoDeclaration,
|
|
193
|
+
"margin-left": parseSizeDeclaration,
|
|
194
|
+
"margin-right": parseSizeDeclaration,
|
|
195
|
+
"margin-top": parseSizeDeclaration,
|
|
196
|
+
"max-block-size": parseSizeDeclaration,
|
|
197
|
+
"max-height": parseSizeDeclaration,
|
|
198
|
+
"max-inline-size": parseSizeDeclaration,
|
|
199
|
+
"max-width": parseSizeDeclaration,
|
|
200
|
+
"min-block-size": parseSizeDeclaration,
|
|
201
|
+
"min-height": parseSizeDeclaration,
|
|
202
|
+
"min-inline-size": parseSizeDeclaration,
|
|
203
|
+
"min-width": parseSizeDeclaration,
|
|
204
|
+
"opacity": ({ value }) => value,
|
|
205
|
+
"overflow": parseOverflow,
|
|
206
|
+
"padding": parsePadding,
|
|
207
|
+
"padding-block": parsePaddingBlock,
|
|
208
|
+
"padding-block-end": parseLengthPercentageOrAutoDeclaration,
|
|
209
|
+
"padding-block-start": parseLengthPercentageOrAutoDeclaration,
|
|
210
|
+
"padding-bottom": parseSizeDeclaration,
|
|
211
|
+
"padding-inline": parsePaddingInline,
|
|
212
|
+
"padding-inline-end": parseLengthPercentageOrAutoDeclaration,
|
|
213
|
+
"padding-inline-start": parseLengthPercentageOrAutoDeclaration,
|
|
214
|
+
"padding-left": parseSizeDeclaration,
|
|
215
|
+
"padding-right": parseSizeDeclaration,
|
|
216
|
+
"padding-top": parseSizeDeclaration,
|
|
217
|
+
"position": parsePosition,
|
|
218
|
+
"right": parseSizeDeclaration,
|
|
219
|
+
"rotate": parseRotate,
|
|
220
|
+
"row-gap": parseGap,
|
|
221
|
+
"scale": parseScale,
|
|
222
|
+
"stroke": parseSVGPaint,
|
|
223
|
+
"stroke-width": parseLengthDeclaration,
|
|
224
|
+
"text-align": parseTextAlign,
|
|
225
|
+
"text-decoration": parseTextDecoration,
|
|
226
|
+
"text-decoration-color": parseColorDeclaration,
|
|
227
|
+
"text-decoration-line": parseTextDecorationLineDeclaration,
|
|
228
|
+
"text-decoration-style": parseTextDecorationStyle,
|
|
229
|
+
"text-shadow": parseTextShadow,
|
|
230
|
+
"text-transform": ({ value }) => value.case,
|
|
231
|
+
"top": parseSizeDeclaration,
|
|
232
|
+
"transform": parseTransform,
|
|
233
|
+
"transition": addTransitionValue,
|
|
234
|
+
"transition-delay": addTransitionValue,
|
|
235
|
+
"transition-duration": addTransitionValue,
|
|
236
|
+
"transition-property": addTransitionValue,
|
|
237
|
+
"transition-timing-function": addTransitionValue,
|
|
238
|
+
"translate": parseTranslate,
|
|
239
|
+
"user-select": parseUserSelect,
|
|
240
|
+
"vertical-align": parseVerticalAlign,
|
|
241
|
+
"width": parseSizeDeclaration,
|
|
242
|
+
"z-index": parseZIndex,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// This is missing LightningCSS types
|
|
246
|
+
(parsers as Record<string, Parser>)["pointer-events"] =
|
|
247
|
+
parsePointerEvents as Parser;
|
|
248
|
+
|
|
249
|
+
const validProperties = new Set(Object.keys(parsers));
|
|
250
|
+
|
|
251
|
+
export function parseDeclaration(
|
|
252
|
+
declaration: Declaration,
|
|
253
|
+
builder: StylesheetBuilder,
|
|
254
|
+
) {
|
|
255
|
+
if ("vendorPrefix" in declaration && declaration.vendorPrefix.length) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (
|
|
260
|
+
"value" in declaration &&
|
|
261
|
+
typeof declaration.value === "object" &&
|
|
262
|
+
"vendorPrefix" in declaration.value &&
|
|
263
|
+
Array.isArray(declaration.value.vendorPrefix) &&
|
|
264
|
+
declaration.value.vendorPrefix.length
|
|
265
|
+
) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (declaration.property === "unparsed") {
|
|
270
|
+
parseUnparsedDeclaration(declaration, builder);
|
|
271
|
+
} else if (declaration.property === "custom") {
|
|
272
|
+
parseCustomDeclaration(declaration, builder);
|
|
273
|
+
} else {
|
|
274
|
+
parseWithParser(declaration, builder);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function parseWithParser(declaration: Declaration, builder: StylesheetBuilder) {
|
|
279
|
+
if (declaration.property in parsers) {
|
|
280
|
+
const parser = parsers[declaration.property] as Parser;
|
|
281
|
+
|
|
282
|
+
builder.descriptorProperty = declaration.property;
|
|
283
|
+
|
|
284
|
+
builder.setWarningProperty(declaration.property);
|
|
285
|
+
const value = parser(declaration, builder, declaration.property);
|
|
286
|
+
|
|
287
|
+
if (value !== undefined) {
|
|
288
|
+
builder.addDescriptor(
|
|
289
|
+
propertyRename[declaration.property] ?? declaration.property,
|
|
290
|
+
value,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
builder.addWarning("property", declaration.property);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function parseInsetBlock(
|
|
299
|
+
{ value }: DeclarationType<"inset-block">,
|
|
300
|
+
builder: StylesheetBuilder,
|
|
301
|
+
) {
|
|
302
|
+
builder.addShorthand("inset-block", {
|
|
303
|
+
"inset-block-start": parseLengthPercentageOrAuto(value.blockStart, builder),
|
|
304
|
+
"inset-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder),
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function parseInsetInline(
|
|
309
|
+
{ value }: DeclarationType<"inset-inline">,
|
|
310
|
+
builder: StylesheetBuilder,
|
|
311
|
+
) {
|
|
312
|
+
builder.addShorthand("inset-inline", {
|
|
313
|
+
"inset-block-start": parseLengthPercentageOrAuto(
|
|
314
|
+
value.inlineStart,
|
|
315
|
+
builder,
|
|
316
|
+
),
|
|
317
|
+
"inset-block-end": parseLengthPercentageOrAuto(value.inlineEnd, builder),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function parseInset(
|
|
322
|
+
{ value }: DeclarationType<"inset">,
|
|
323
|
+
builder: StylesheetBuilder,
|
|
324
|
+
) {
|
|
325
|
+
builder.addShorthand("inset", {
|
|
326
|
+
top: parseLengthPercentageOrAuto(value.top, builder),
|
|
327
|
+
bottom: parseLengthPercentageOrAuto(value.bottom, builder),
|
|
328
|
+
left: parseLengthPercentageOrAuto(value.left, builder),
|
|
329
|
+
right: parseLengthPercentageOrAuto(value.right, builder),
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function parseBorderRadius(
|
|
334
|
+
{ value }: DeclarationType<"border-radius">,
|
|
335
|
+
builder: StylesheetBuilder,
|
|
336
|
+
) {
|
|
337
|
+
builder.addShorthand("border-radius", {
|
|
338
|
+
"border-bottom-left-radius": parseSize2DDimensionPercentage(
|
|
339
|
+
value.bottomLeft,
|
|
340
|
+
builder,
|
|
341
|
+
),
|
|
342
|
+
"border-bottom-right-radius": parseSize2DDimensionPercentage(
|
|
343
|
+
value.bottomRight,
|
|
344
|
+
builder,
|
|
345
|
+
),
|
|
346
|
+
"border-top-left-radius": parseSize2DDimensionPercentage(
|
|
347
|
+
value.topLeft,
|
|
348
|
+
builder,
|
|
349
|
+
),
|
|
350
|
+
"border-top-right-radius": parseSize2DDimensionPercentage(
|
|
351
|
+
value.topRight,
|
|
352
|
+
builder,
|
|
353
|
+
),
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function parseBorderColor(
|
|
358
|
+
declaration: DeclarationType<
|
|
359
|
+
"border-color" | "border-block-color" | "border-inline-color"
|
|
360
|
+
>,
|
|
361
|
+
builder: StylesheetBuilder,
|
|
362
|
+
) {
|
|
363
|
+
switch (declaration.property) {
|
|
364
|
+
case "border-color":
|
|
365
|
+
builder.addShorthand("border-color", {
|
|
366
|
+
"border-top-color": parseColor(declaration.value.top, builder),
|
|
367
|
+
"border-bottom-color": parseColor(declaration.value.bottom, builder),
|
|
368
|
+
"border-left-color": parseColor(declaration.value.left, builder),
|
|
369
|
+
"border-right-color": parseColor(declaration.value.right, builder),
|
|
370
|
+
});
|
|
371
|
+
break;
|
|
372
|
+
case "border-block-color":
|
|
373
|
+
builder.addDescriptor(
|
|
374
|
+
"border-top-color",
|
|
375
|
+
parseColor(declaration.value.start, builder),
|
|
376
|
+
);
|
|
377
|
+
builder.addDescriptor(
|
|
378
|
+
"border-bottom-color",
|
|
379
|
+
parseColor(declaration.value.end, builder),
|
|
380
|
+
);
|
|
381
|
+
break;
|
|
382
|
+
case "border-inline-color":
|
|
383
|
+
builder.addDescriptor(
|
|
384
|
+
"border-left-color",
|
|
385
|
+
parseColor(declaration.value.start, builder),
|
|
386
|
+
);
|
|
387
|
+
builder.addDescriptor(
|
|
388
|
+
"border-right-color",
|
|
389
|
+
parseColor(declaration.value.end, builder),
|
|
390
|
+
);
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function parseBorderWidth(
|
|
396
|
+
{ value }: DeclarationType<"border-width">,
|
|
397
|
+
builder: StylesheetBuilder,
|
|
398
|
+
) {
|
|
399
|
+
builder.addShorthand("border-width", {
|
|
400
|
+
"border-top-width": parseBorderSideWidth(value.top, builder),
|
|
401
|
+
"border-bottom-width": parseBorderSideWidth(value.bottom, builder),
|
|
402
|
+
"border-left-width": parseBorderSideWidth(value.left, builder),
|
|
403
|
+
"border-right-width": parseBorderSideWidth(value.right, builder),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function parseBorder(
|
|
408
|
+
{ value }: DeclarationType<"border">,
|
|
409
|
+
builder: StylesheetBuilder,
|
|
410
|
+
) {
|
|
411
|
+
builder.addShorthand("border", {
|
|
412
|
+
"border-width": parseBorderSideWidth(value.width, builder),
|
|
413
|
+
"border-style": parseBorderStyle(value.style, builder),
|
|
414
|
+
"border-color": parseColor(value.color, builder),
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function parseBorderSide(
|
|
419
|
+
{
|
|
420
|
+
value,
|
|
421
|
+
property,
|
|
422
|
+
}: DeclarationType<
|
|
423
|
+
"border-top" | "border-bottom" | "border-left" | "border-right"
|
|
424
|
+
>,
|
|
425
|
+
builder: StylesheetBuilder,
|
|
426
|
+
) {
|
|
427
|
+
builder.addDescriptor(property + "-color", parseColor(value.color, builder));
|
|
428
|
+
builder.addDescriptor(
|
|
429
|
+
property + "-width",
|
|
430
|
+
parseBorderSideWidth(value.width, builder),
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function parseBorderBlock(
|
|
435
|
+
{ value }: DeclarationType<"border-block">,
|
|
436
|
+
builder: StylesheetBuilder,
|
|
437
|
+
) {
|
|
438
|
+
builder.addDescriptor("border-top-color", parseColor(value.color, builder));
|
|
439
|
+
builder.addDescriptor(
|
|
440
|
+
"border-bottom-color",
|
|
441
|
+
parseColor(value.color, builder),
|
|
442
|
+
);
|
|
443
|
+
builder.addDescriptor(
|
|
444
|
+
"border-top-width",
|
|
445
|
+
parseBorderSideWidth(value.width, builder),
|
|
446
|
+
);
|
|
447
|
+
builder.addDescriptor(
|
|
448
|
+
"border-bottom-width",
|
|
449
|
+
parseBorderSideWidth(value.width, builder),
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function parseBorderBlockStart(
|
|
454
|
+
{ value }: DeclarationType<"border-block-start">,
|
|
455
|
+
builder: StylesheetBuilder,
|
|
456
|
+
) {
|
|
457
|
+
builder.addDescriptor("border-top-color", parseColor(value.color, builder));
|
|
458
|
+
builder.addDescriptor(
|
|
459
|
+
"border-top-width",
|
|
460
|
+
parseBorderSideWidth(value.width, builder),
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function parseBorderBlockEnd(
|
|
465
|
+
{ value }: DeclarationType<"border-block-end">,
|
|
466
|
+
builder: StylesheetBuilder,
|
|
467
|
+
) {
|
|
468
|
+
builder.addDescriptor(
|
|
469
|
+
"border-bottom-color",
|
|
470
|
+
parseColor(value.color, builder),
|
|
471
|
+
);
|
|
472
|
+
builder.addDescriptor(
|
|
473
|
+
"border-bottom-width",
|
|
474
|
+
parseBorderSideWidth(value.width, builder),
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function parseBorderInline(
|
|
479
|
+
{ value }: DeclarationType<"border-inline">,
|
|
480
|
+
builder: StylesheetBuilder,
|
|
481
|
+
) {
|
|
482
|
+
builder.addDescriptor("border-left-color", parseColor(value.color, builder));
|
|
483
|
+
builder.addDescriptor("border-right-color", parseColor(value.color, builder));
|
|
484
|
+
builder.addDescriptor(
|
|
485
|
+
"border-left-width",
|
|
486
|
+
parseBorderSideWidth(value.width, builder),
|
|
487
|
+
);
|
|
488
|
+
builder.addDescriptor(
|
|
489
|
+
"border-right-width",
|
|
490
|
+
parseBorderSideWidth(value.width, builder),
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function parseBorderInlineStart(
|
|
495
|
+
{ value }: DeclarationType<"border-inline-start">,
|
|
496
|
+
builder: StylesheetBuilder,
|
|
497
|
+
) {
|
|
498
|
+
builder.addDescriptor("border-left-color", parseColor(value.color, builder));
|
|
499
|
+
builder.addDescriptor(
|
|
500
|
+
"border-left-width",
|
|
501
|
+
parseBorderSideWidth(value.width, builder),
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function parseBorderInlineEnd(
|
|
506
|
+
{ value }: DeclarationType<"border-inline-end">,
|
|
507
|
+
builder: StylesheetBuilder,
|
|
508
|
+
) {
|
|
509
|
+
builder.addDescriptor("border-right-color", parseColor(value.color, builder));
|
|
510
|
+
builder.addDescriptor(
|
|
511
|
+
"border-right-width",
|
|
512
|
+
parseBorderSideWidth(value.width, builder),
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export function parseBorderInlineWidth(
|
|
517
|
+
declaration: DeclarationType<"border-inline-width">,
|
|
518
|
+
builder: StylesheetBuilder,
|
|
519
|
+
) {
|
|
520
|
+
builder.addDescriptor(
|
|
521
|
+
"border-left-width",
|
|
522
|
+
parseBorderSideWidth(declaration.value.start, builder),
|
|
523
|
+
);
|
|
524
|
+
builder.addDescriptor(
|
|
525
|
+
"border-right-width",
|
|
526
|
+
parseBorderSideWidth(declaration.value.end, builder),
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export function parseBorderInlineStyle(
|
|
531
|
+
declaration: DeclarationType<
|
|
532
|
+
| "border-inline-style"
|
|
533
|
+
| "border-inline-start-style"
|
|
534
|
+
| "border-inline-end-style"
|
|
535
|
+
>,
|
|
536
|
+
builder: StylesheetBuilder,
|
|
537
|
+
) {
|
|
538
|
+
if (typeof declaration.value === "string") {
|
|
539
|
+
builder.addDescriptor(
|
|
540
|
+
"border-style",
|
|
541
|
+
parseBorderStyle(declaration.value, builder),
|
|
542
|
+
);
|
|
543
|
+
} else if (declaration.value.start === declaration.value.end) {
|
|
544
|
+
builder.addDescriptor(
|
|
545
|
+
"border-style",
|
|
546
|
+
parseBorderStyle(declaration.value.start, builder),
|
|
547
|
+
);
|
|
548
|
+
} else {
|
|
549
|
+
builder.addWarning("property", "border-inline-style");
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function parseFlexFlow(
|
|
554
|
+
{ value }: DeclarationType<"flex-flow">,
|
|
555
|
+
builder: StylesheetBuilder,
|
|
556
|
+
) {
|
|
557
|
+
builder.addDescriptor("flexWrap", value.wrap);
|
|
558
|
+
builder.addDescriptor("flexDirection", value.direction);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function parseFlex(
|
|
562
|
+
{ value }: DeclarationType<"flex">,
|
|
563
|
+
builder: StylesheetBuilder,
|
|
564
|
+
) {
|
|
565
|
+
builder.addDescriptor("flex-grow", value.grow);
|
|
566
|
+
builder.addDescriptor("flex-shrink", value.shrink);
|
|
567
|
+
builder.addDescriptor(
|
|
568
|
+
"flex-basis",
|
|
569
|
+
parseLengthPercentageOrAuto(value.basis, builder),
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function parseMargin(
|
|
574
|
+
{ value }: DeclarationType<"margin">,
|
|
575
|
+
builder: StylesheetBuilder,
|
|
576
|
+
) {
|
|
577
|
+
builder.addShorthand("margin", {
|
|
578
|
+
"margin-top": parseSize(value.top, builder, { allowAuto: true }),
|
|
579
|
+
"margin-bottom": parseSize(value.bottom, builder, { allowAuto: true }),
|
|
580
|
+
"margin-left": parseSize(value.left, builder, { allowAuto: true }),
|
|
581
|
+
"margin-right": parseSize(value.right, builder, { allowAuto: true }),
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function parseMarginBlock(
|
|
586
|
+
{ value }: DeclarationType<"margin-block">,
|
|
587
|
+
builder: StylesheetBuilder,
|
|
588
|
+
) {
|
|
589
|
+
builder.addShorthand("margin-block", {
|
|
590
|
+
"margin-block-start": parseLengthPercentageOrAuto(
|
|
591
|
+
value.blockStart,
|
|
592
|
+
builder,
|
|
593
|
+
),
|
|
594
|
+
"margin-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder),
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function parseMarginInline(
|
|
599
|
+
{ value }: DeclarationType<"margin-inline">,
|
|
600
|
+
builder: StylesheetBuilder,
|
|
601
|
+
) {
|
|
602
|
+
builder.addShorthand("margin-inline", {
|
|
603
|
+
"margin-inline-start": parseLengthPercentageOrAuto(
|
|
604
|
+
value.inlineStart,
|
|
605
|
+
builder,
|
|
606
|
+
),
|
|
607
|
+
"margin-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder),
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function parsePadding(
|
|
612
|
+
{ value }: DeclarationType<"padding">,
|
|
613
|
+
builder: StylesheetBuilder,
|
|
614
|
+
) {
|
|
615
|
+
builder.addShorthand("padding", {
|
|
616
|
+
"padding-top": parseSize(value.top, builder),
|
|
617
|
+
"padding-bottom": parseSize(value.bottom, builder),
|
|
618
|
+
"padding-left": parseSize(value.left, builder),
|
|
619
|
+
"padding-right": parseSize(value.right, builder),
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function parsePaddingBlock(
|
|
624
|
+
{ value }: DeclarationType<"padding-block">,
|
|
625
|
+
builder: StylesheetBuilder,
|
|
626
|
+
) {
|
|
627
|
+
builder.addShorthand("padding-block", {
|
|
628
|
+
"padding-block-start": parseLengthPercentageOrAuto(
|
|
629
|
+
value.blockStart,
|
|
630
|
+
builder,
|
|
631
|
+
),
|
|
632
|
+
"padding-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder),
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function parsePaddingInline(
|
|
637
|
+
{ value }: DeclarationType<"padding-inline">,
|
|
638
|
+
builder: StylesheetBuilder,
|
|
639
|
+
) {
|
|
640
|
+
builder.addShorthand("padding-inline", {
|
|
641
|
+
"padding-inline-start": parseLengthPercentageOrAuto(
|
|
642
|
+
value.inlineStart,
|
|
643
|
+
builder,
|
|
644
|
+
),
|
|
645
|
+
"padding-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder),
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function parseFont(
|
|
650
|
+
{ value }: DeclarationType<"font">,
|
|
651
|
+
builder: StylesheetBuilder,
|
|
652
|
+
) {
|
|
653
|
+
builder.addDescriptor("font-family", value.family[0]);
|
|
654
|
+
builder.addDescriptor(
|
|
655
|
+
"line-height",
|
|
656
|
+
parseLineHeight(value.lineHeight, builder),
|
|
657
|
+
);
|
|
658
|
+
builder.addDescriptor("font-size", parseFontSize(value.size, builder));
|
|
659
|
+
builder.addDescriptor("font-style", parseFontStyle(value.style, builder));
|
|
660
|
+
builder.addDescriptor(
|
|
661
|
+
"font-variant-caps",
|
|
662
|
+
parseFontVariantCaps(value.variantCaps, builder),
|
|
663
|
+
);
|
|
664
|
+
builder.addDescriptor("font-weight", parseFontWeight(value.weight, builder));
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function parseTransform(
|
|
668
|
+
{ value }: DeclarationType<"transform">,
|
|
669
|
+
builder: StylesheetBuilder,
|
|
670
|
+
) {
|
|
671
|
+
builder.addDescriptor("transform", [
|
|
672
|
+
{},
|
|
673
|
+
"transform",
|
|
674
|
+
value.flatMap((t): StyleDescriptor[] => {
|
|
675
|
+
switch (t.type) {
|
|
676
|
+
case "perspective":
|
|
677
|
+
return [[{}, "perspective", parseLength(t.value, builder)]];
|
|
678
|
+
case "translate":
|
|
679
|
+
return [
|
|
680
|
+
[
|
|
681
|
+
{},
|
|
682
|
+
"translateX",
|
|
683
|
+
parseLengthOrCoercePercentageToRuntime(t.value[0], builder),
|
|
684
|
+
],
|
|
685
|
+
[
|
|
686
|
+
[
|
|
687
|
+
{},
|
|
688
|
+
"translateY",
|
|
689
|
+
parseLengthOrCoercePercentageToRuntime(t.value[1], builder),
|
|
690
|
+
],
|
|
691
|
+
],
|
|
692
|
+
];
|
|
693
|
+
case "translateX":
|
|
694
|
+
return [
|
|
695
|
+
[
|
|
696
|
+
{},
|
|
697
|
+
"translateX",
|
|
698
|
+
parseLengthOrCoercePercentageToRuntime(t.value, builder),
|
|
699
|
+
],
|
|
700
|
+
];
|
|
701
|
+
case "translateY":
|
|
702
|
+
return [
|
|
703
|
+
[
|
|
704
|
+
{},
|
|
705
|
+
"translateY",
|
|
706
|
+
parseLengthOrCoercePercentageToRuntime(t.value, builder),
|
|
707
|
+
],
|
|
708
|
+
];
|
|
709
|
+
case "rotate":
|
|
710
|
+
return [[{}, "rotate", parseAngle(t.value, builder)]];
|
|
711
|
+
case "rotateX":
|
|
712
|
+
return [[{}, "rotateX", parseAngle(t.value, builder)]];
|
|
713
|
+
case "rotateY":
|
|
714
|
+
return [[{}, "rotateY", parseAngle(t.value, builder)]];
|
|
715
|
+
case "rotateZ":
|
|
716
|
+
return [[{}, "rotateZ", parseAngle(t.value, builder)]];
|
|
717
|
+
case "scale":
|
|
718
|
+
return [
|
|
719
|
+
[{}, "scaleX", parseLength(t.value[0], builder)],
|
|
720
|
+
[{}, "scaleY", parseLength(t.value[1], builder)],
|
|
721
|
+
];
|
|
722
|
+
case "scaleX":
|
|
723
|
+
return [[{}, "scaleX", parseLength(t.value, builder)]];
|
|
724
|
+
case "scaleY":
|
|
725
|
+
return [[{}, "scaleY", parseLength(t.value, builder)]];
|
|
726
|
+
case "skew":
|
|
727
|
+
return [
|
|
728
|
+
[{}, "skewX", parseAngle(t.value[0], builder)],
|
|
729
|
+
[{}, "skewY", parseAngle(t.value[1], builder)],
|
|
730
|
+
];
|
|
731
|
+
case "skewX":
|
|
732
|
+
return [[{}, "skewX", parseAngle(t.value, builder)]];
|
|
733
|
+
case "skewY":
|
|
734
|
+
return [[{}, "skewY", parseAngle(t.value, builder)]];
|
|
735
|
+
case "translateZ":
|
|
736
|
+
case "translate3d":
|
|
737
|
+
case "scaleZ":
|
|
738
|
+
case "scale3d":
|
|
739
|
+
case "rotate3d":
|
|
740
|
+
case "matrix":
|
|
741
|
+
case "matrix3d":
|
|
742
|
+
return [[]];
|
|
743
|
+
}
|
|
744
|
+
}),
|
|
745
|
+
]);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
function parseTranslate(
|
|
750
|
+
{ value }: DeclarationType<"translate">,
|
|
751
|
+
builder: StylesheetBuilder,
|
|
752
|
+
) {
|
|
753
|
+
builder.addDescriptor("translateX", [
|
|
754
|
+
{},
|
|
755
|
+
"translateX",
|
|
756
|
+
parseTranslateProp(value, "x", builder),
|
|
757
|
+
]);
|
|
758
|
+
builder.addDescriptor("translateY", [
|
|
759
|
+
{},
|
|
760
|
+
"translateY",
|
|
761
|
+
parseTranslateProp(value, "y", builder),
|
|
762
|
+
]);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function parseRotate(
|
|
766
|
+
{ value }: DeclarationType<"rotate">,
|
|
767
|
+
builder: StylesheetBuilder,
|
|
768
|
+
) {
|
|
769
|
+
if (value.x) {
|
|
770
|
+
builder.addDescriptor("rotateX", [
|
|
771
|
+
{},
|
|
772
|
+
"rotateX",
|
|
773
|
+
parseAngle(value.angle, builder),
|
|
774
|
+
]);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
if (value.y) {
|
|
778
|
+
builder.addDescriptor("rotateY", [
|
|
779
|
+
{},
|
|
780
|
+
"rotateY",
|
|
781
|
+
parseAngle(value.angle, builder),
|
|
782
|
+
]);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (value.z) {
|
|
786
|
+
builder.addDescriptor("rotateZ", [
|
|
787
|
+
{},
|
|
788
|
+
"rotateZ",
|
|
789
|
+
parseAngle(value.angle, builder),
|
|
790
|
+
]);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
function parseScale(
|
|
795
|
+
{ value }: DeclarationType<"scale">,
|
|
796
|
+
builder: StylesheetBuilder,
|
|
797
|
+
) {
|
|
798
|
+
builder.addDescriptor("scaleX", [
|
|
799
|
+
{},
|
|
800
|
+
"scaleX",
|
|
801
|
+
parseScaleValue(value, "x", builder),
|
|
802
|
+
]);
|
|
803
|
+
builder.addDescriptor("scaleY", [
|
|
804
|
+
{},
|
|
805
|
+
"scaleY",
|
|
806
|
+
parseScaleValue(value, "y", builder),
|
|
807
|
+
]);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
export function parseScaleValue(
|
|
811
|
+
translate: Scale,
|
|
812
|
+
prop: keyof Extract<Scale, object>,
|
|
813
|
+
builder: StylesheetBuilder,
|
|
814
|
+
): StyleDescriptor {
|
|
815
|
+
if (translate === "none") {
|
|
816
|
+
return 0;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
return parseLength(translate[prop], builder);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function parseLetterSpacing(
|
|
823
|
+
{ value }: DeclarationType<"letter-spacing">,
|
|
824
|
+
builder: StylesheetBuilder,
|
|
825
|
+
) {
|
|
826
|
+
if (value.type === "normal") {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
const descriptor = parseLength(value.value, builder);
|
|
830
|
+
|
|
831
|
+
if (
|
|
832
|
+
Array.isArray(descriptor) &&
|
|
833
|
+
descriptor[1] === "em" &&
|
|
834
|
+
typeof descriptor[2] === "number"
|
|
835
|
+
) {
|
|
836
|
+
return descriptor[2];
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
return descriptor;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function parseTextDecoration(
|
|
843
|
+
{ value }: DeclarationType<"text-decoration">,
|
|
844
|
+
builder: StylesheetBuilder,
|
|
845
|
+
) {
|
|
846
|
+
builder.addDescriptor(
|
|
847
|
+
"text-decoration-color",
|
|
848
|
+
parseColor(value.color, builder),
|
|
849
|
+
);
|
|
850
|
+
builder.addDescriptor(
|
|
851
|
+
"text-decoration-line",
|
|
852
|
+
parseTextDecorationLine(value.line, builder),
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function parseZIndex(
|
|
857
|
+
{ value }: DeclarationType<"z-index">,
|
|
858
|
+
builder: StylesheetBuilder,
|
|
859
|
+
): StyleDescriptor {
|
|
860
|
+
if (value.type === "integer") {
|
|
861
|
+
return parseLength(value.value, builder);
|
|
862
|
+
} else {
|
|
863
|
+
builder.addWarning("value", value.type);
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
function parseContainerType(
|
|
869
|
+
_declaration: DeclarationType<"container-type">,
|
|
870
|
+
builder: StylesheetBuilder,
|
|
871
|
+
) {
|
|
872
|
+
builder.addContainer(["___default___"]);
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
function parseContainerName(
|
|
877
|
+
{ value }: DeclarationType<"container-name">,
|
|
878
|
+
builder: StylesheetBuilder,
|
|
879
|
+
) {
|
|
880
|
+
builder.addContainer(value.type === "none" ? false : value.value);
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function parseContainer(
|
|
885
|
+
{ value }: DeclarationType<"container">,
|
|
886
|
+
builder: StylesheetBuilder,
|
|
887
|
+
) {
|
|
888
|
+
builder.addContainer(value.name.type === "none" ? false : value.name.value);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
export function parseUnparsedDeclaration(
|
|
893
|
+
declaration: Extract<Declaration, { property: "unparsed" }>,
|
|
894
|
+
builder: StylesheetBuilder,
|
|
895
|
+
) {
|
|
896
|
+
let property = declaration.value.propertyId.property;
|
|
897
|
+
|
|
898
|
+
if (!(property in parsers)) {
|
|
899
|
+
builder.addWarning("property", property);
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
builder.setWarningProperty(property);
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* React Native doesn't support all the logical properties
|
|
907
|
+
*/
|
|
908
|
+
const rename = propertyRename[property];
|
|
909
|
+
if (rename) {
|
|
910
|
+
property = rename;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Unparsed shorthand properties need to be parsed at runtime
|
|
915
|
+
*/
|
|
916
|
+
builder.descriptorProperty = property;
|
|
917
|
+
|
|
918
|
+
if (unparsedRuntimeParsing.has(property)) {
|
|
919
|
+
const args = parseUnparsed(declaration.value.value, builder, property);
|
|
920
|
+
|
|
921
|
+
if (property === "animation") {
|
|
922
|
+
builder.addDescriptor("animation", [{}, property, args]);
|
|
923
|
+
} else {
|
|
924
|
+
builder.addDescriptor(property, [{}, toRNProperty(property), args, 1]);
|
|
925
|
+
}
|
|
926
|
+
} else {
|
|
927
|
+
const value = parseUnparsed(declaration.value.value, builder, property);
|
|
928
|
+
|
|
929
|
+
builder.addDescriptor(property, value);
|
|
930
|
+
|
|
931
|
+
if (property === "font-size") {
|
|
932
|
+
builder.addDescriptor("--__rn-css-em", value);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
if (property === "color") {
|
|
936
|
+
builder.addDescriptor("--__rn-css-current-color", value);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
export function parseCustomDeclaration(
|
|
942
|
+
declaration: Extract<Declaration, { property: "custom" }>,
|
|
943
|
+
builder: StylesheetBuilder,
|
|
944
|
+
) {
|
|
945
|
+
const property = declaration.value.name;
|
|
946
|
+
|
|
947
|
+
if (property === "-webkit-line-clamp") {
|
|
948
|
+
builder.addDescriptor(
|
|
949
|
+
property,
|
|
950
|
+
parseUnparsed(declaration.value.value, builder, property),
|
|
951
|
+
);
|
|
952
|
+
} else if (property === "-rn-ripple-style") {
|
|
953
|
+
builder.addDescriptor(
|
|
954
|
+
property,
|
|
955
|
+
parseUnparsed(declaration.value.value, builder, property) ===
|
|
956
|
+
"borderless",
|
|
957
|
+
);
|
|
958
|
+
} else if (
|
|
959
|
+
validProperties.has(property) ||
|
|
960
|
+
property.startsWith("--") ||
|
|
961
|
+
property.startsWith("-rn-")
|
|
962
|
+
) {
|
|
963
|
+
builder.addDescriptor(
|
|
964
|
+
property,
|
|
965
|
+
parseUnparsed(declaration.value.value, builder, property),
|
|
966
|
+
);
|
|
967
|
+
} else {
|
|
968
|
+
builder.addWarning("property", declaration.value.name);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
export function reduceParseUnparsed(
|
|
973
|
+
tokenOrValues: TokenOrValue[],
|
|
974
|
+
builder: StylesheetBuilder,
|
|
975
|
+
property: string,
|
|
976
|
+
allowAuto: boolean,
|
|
977
|
+
): StyleDescriptor {
|
|
978
|
+
const result = tokenOrValues
|
|
979
|
+
.map((tokenOrValue) =>
|
|
980
|
+
parseUnparsed(tokenOrValue, builder, property, allowAuto),
|
|
981
|
+
)
|
|
982
|
+
.filter((v) => v !== undefined);
|
|
983
|
+
|
|
984
|
+
if (result.length === 0) {
|
|
985
|
+
return undefined;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
let currentGroup: StyleDescriptor = [];
|
|
989
|
+
let groups: StyleDescriptor[] = [currentGroup];
|
|
990
|
+
|
|
991
|
+
for (const value of result) {
|
|
992
|
+
if ((value as unknown) === CommaSeparator) {
|
|
993
|
+
currentGroup = [];
|
|
994
|
+
groups.push(currentGroup);
|
|
995
|
+
} else {
|
|
996
|
+
currentGroup.push(value);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// Groups are the tokens grouped together by comma location
|
|
1001
|
+
// If a group only has 1 item, it shouldn't be an array
|
|
1002
|
+
groups = groups.flatMap((group): StyleDescriptor[] => {
|
|
1003
|
+
if (!Array.isArray(group)) {
|
|
1004
|
+
return [];
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
if (group.length === 0) {
|
|
1008
|
+
return [];
|
|
1009
|
+
} else if (group.length === 1) {
|
|
1010
|
+
const first = group[0];
|
|
1011
|
+
|
|
1012
|
+
if (first === undefined) {
|
|
1013
|
+
return [];
|
|
1014
|
+
} else {
|
|
1015
|
+
return [first];
|
|
1016
|
+
}
|
|
1017
|
+
} else if (
|
|
1018
|
+
// This is a special case for <ratio> values
|
|
1019
|
+
group.includes("/") &&
|
|
1020
|
+
group.every((item) =>
|
|
1021
|
+
typeof item === "string" && item === "/"
|
|
1022
|
+
? item
|
|
1023
|
+
: typeof item === "number",
|
|
1024
|
+
)
|
|
1025
|
+
) {
|
|
1026
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
1027
|
+
return [group.join(" ")];
|
|
1028
|
+
} else {
|
|
1029
|
+
return [group];
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
return groups.length === 1 ? groups[0] : groups;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
export function unparsedFunction(
|
|
1037
|
+
token: Extract<TokenOrValue, { type: "function" }>,
|
|
1038
|
+
builder: StylesheetBuilder,
|
|
1039
|
+
property: string,
|
|
1040
|
+
allowAuto: boolean,
|
|
1041
|
+
): StyleFunction {
|
|
1042
|
+
return [
|
|
1043
|
+
{},
|
|
1044
|
+
toRNProperty(token.value.name),
|
|
1045
|
+
reduceParseUnparsed(token.value.arguments, builder, property, allowAuto),
|
|
1046
|
+
];
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* When the CSS cannot be parsed (often due to a runtime condition like a CSS variable)
|
|
1051
|
+
* This export function best efforts parsing it into a export function that we can evaluate at runtime
|
|
1052
|
+
*/
|
|
1053
|
+
export function parseUnparsed(
|
|
1054
|
+
tokenOrValue:
|
|
1055
|
+
| TokenOrValue
|
|
1056
|
+
| TokenOrValue[]
|
|
1057
|
+
| string
|
|
1058
|
+
| number
|
|
1059
|
+
| undefined
|
|
1060
|
+
| null,
|
|
1061
|
+
builder: StylesheetBuilder,
|
|
1062
|
+
property: string,
|
|
1063
|
+
allowAuto = allowAutoProperties.has(property),
|
|
1064
|
+
): StyleDescriptor {
|
|
1065
|
+
if (tokenOrValue === undefined || tokenOrValue === null) {
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
if (typeof tokenOrValue === "string") {
|
|
1070
|
+
if (tokenOrValue === "true") {
|
|
1071
|
+
return true;
|
|
1072
|
+
} else if (tokenOrValue === "false") {
|
|
1073
|
+
return false;
|
|
1074
|
+
} else if (tokenOrValue === "currentcolor") {
|
|
1075
|
+
return [{}, "var", "__rn-css-current-color"] as const;
|
|
1076
|
+
} else {
|
|
1077
|
+
return tokenOrValue;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
if (typeof tokenOrValue === "number") {
|
|
1082
|
+
return round(tokenOrValue);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
if (Array.isArray(tokenOrValue)) {
|
|
1086
|
+
const args = reduceParseUnparsed(
|
|
1087
|
+
tokenOrValue,
|
|
1088
|
+
builder,
|
|
1089
|
+
property,
|
|
1090
|
+
allowAuto,
|
|
1091
|
+
);
|
|
1092
|
+
if (!args) return;
|
|
1093
|
+
if (Array.isArray(args) && args.length === 1) return args[0];
|
|
1094
|
+
return args;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
switch (tokenOrValue.type) {
|
|
1098
|
+
case "unresolved-color": {
|
|
1099
|
+
return parseUnresolvedColor(
|
|
1100
|
+
tokenOrValue.value,
|
|
1101
|
+
builder,
|
|
1102
|
+
property,
|
|
1103
|
+
allowAuto,
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
case "var": {
|
|
1107
|
+
let args: StyleDescriptor = tokenOrValue.value.name.ident.slice(2);
|
|
1108
|
+
const fallback = parseUnparsed(
|
|
1109
|
+
tokenOrValue.value.fallback,
|
|
1110
|
+
builder,
|
|
1111
|
+
property,
|
|
1112
|
+
allowAuto,
|
|
1113
|
+
);
|
|
1114
|
+
if (fallback !== undefined) {
|
|
1115
|
+
args = [args, fallback];
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
return [{}, "var", args, 1];
|
|
1119
|
+
}
|
|
1120
|
+
case "function": {
|
|
1121
|
+
switch (tokenOrValue.value.name) {
|
|
1122
|
+
case "blur":
|
|
1123
|
+
case "brightness":
|
|
1124
|
+
case "contrast":
|
|
1125
|
+
case "cubic-bezier":
|
|
1126
|
+
case "drop-shadow":
|
|
1127
|
+
case "fontScale":
|
|
1128
|
+
case "getPixelSizeForLayoutSize":
|
|
1129
|
+
case "grayscale":
|
|
1130
|
+
case "hsl":
|
|
1131
|
+
case "hsla":
|
|
1132
|
+
case "hue-rotate":
|
|
1133
|
+
case "invert":
|
|
1134
|
+
case "opacity":
|
|
1135
|
+
case "pixelScale":
|
|
1136
|
+
case "platformColor":
|
|
1137
|
+
case "rgb":
|
|
1138
|
+
case "rgba":
|
|
1139
|
+
case "rotate":
|
|
1140
|
+
case "rotateX":
|
|
1141
|
+
case "rotateY":
|
|
1142
|
+
case "roundToNearestPixel":
|
|
1143
|
+
case "saturate":
|
|
1144
|
+
case "scale":
|
|
1145
|
+
case "scaleX":
|
|
1146
|
+
case "scaleY":
|
|
1147
|
+
case "sepia":
|
|
1148
|
+
case "shadow":
|
|
1149
|
+
case "skewX":
|
|
1150
|
+
case "skewY":
|
|
1151
|
+
case "steps":
|
|
1152
|
+
case "translate":
|
|
1153
|
+
case "translateX":
|
|
1154
|
+
case "translateY":
|
|
1155
|
+
return unparsedFunction(tokenOrValue, builder, property, allowAuto);
|
|
1156
|
+
case "linear-gradient":
|
|
1157
|
+
case "radial-gradient":
|
|
1158
|
+
// These are special as React Native requires the '-' in their name
|
|
1159
|
+
return [
|
|
1160
|
+
{},
|
|
1161
|
+
tokenOrValue.value.name,
|
|
1162
|
+
reduceParseUnparsed(
|
|
1163
|
+
tokenOrValue.value.arguments,
|
|
1164
|
+
builder,
|
|
1165
|
+
property,
|
|
1166
|
+
allowAuto,
|
|
1167
|
+
),
|
|
1168
|
+
];
|
|
1169
|
+
case "hairlineWidth":
|
|
1170
|
+
return [{}, tokenOrValue.value.name, []];
|
|
1171
|
+
case "calc":
|
|
1172
|
+
case "max":
|
|
1173
|
+
case "min":
|
|
1174
|
+
case "clamp":
|
|
1175
|
+
return parseCalcFn(
|
|
1176
|
+
tokenOrValue.value.name,
|
|
1177
|
+
tokenOrValue.value.arguments,
|
|
1178
|
+
builder,
|
|
1179
|
+
property,
|
|
1180
|
+
);
|
|
1181
|
+
default: {
|
|
1182
|
+
builder.addWarning("value", `${tokenOrValue.value.name}()`);
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
case "length":
|
|
1188
|
+
return parseLength(tokenOrValue.value, builder);
|
|
1189
|
+
case "angle":
|
|
1190
|
+
return parseAngle(tokenOrValue.value, builder);
|
|
1191
|
+
case "token":
|
|
1192
|
+
switch (tokenOrValue.value.type) {
|
|
1193
|
+
case "string":
|
|
1194
|
+
case "ident": {
|
|
1195
|
+
const value = tokenOrValue.value.value;
|
|
1196
|
+
if (!allowAuto && value === "auto") {
|
|
1197
|
+
builder.addWarning("value", value);
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
if (value === "inherit" || value === "initial") {
|
|
1202
|
+
builder.addWarning("value", value);
|
|
1203
|
+
return;
|
|
1204
|
+
} else if (value === "currentcolor") {
|
|
1205
|
+
return [{}, "var", "__rn-css-current-color"] as const;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
if (value === "true") {
|
|
1209
|
+
return true;
|
|
1210
|
+
} else if (value === "false") {
|
|
1211
|
+
return false;
|
|
1212
|
+
} else if (value === "infinity") {
|
|
1213
|
+
return Number.MAX_SAFE_INTEGER;
|
|
1214
|
+
} else {
|
|
1215
|
+
return value;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
case "number": {
|
|
1219
|
+
return round(tokenOrValue.value.value);
|
|
1220
|
+
}
|
|
1221
|
+
case "function":
|
|
1222
|
+
builder.addWarning("value", tokenOrValue.value.value);
|
|
1223
|
+
return;
|
|
1224
|
+
case "percentage":
|
|
1225
|
+
return `${round(tokenOrValue.value.value * 100)}%`;
|
|
1226
|
+
case "dimension":
|
|
1227
|
+
return parseDimension(tokenOrValue.value, builder);
|
|
1228
|
+
case "comma":
|
|
1229
|
+
return CommaSeparator as unknown as StyleDescriptor;
|
|
1230
|
+
case "delim": {
|
|
1231
|
+
if (tokenOrValue.value.value === "/") {
|
|
1232
|
+
return tokenOrValue.value.value;
|
|
1233
|
+
}
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
case "at-keyword":
|
|
1237
|
+
case "hash":
|
|
1238
|
+
case "id-hash":
|
|
1239
|
+
case "unquoted-url":
|
|
1240
|
+
case "white-space":
|
|
1241
|
+
case "comment":
|
|
1242
|
+
case "colon":
|
|
1243
|
+
case "semicolon":
|
|
1244
|
+
case "include-match":
|
|
1245
|
+
case "dash-match":
|
|
1246
|
+
case "prefix-match":
|
|
1247
|
+
case "suffix-match":
|
|
1248
|
+
case "substring-match":
|
|
1249
|
+
case "cdo":
|
|
1250
|
+
case "cdc":
|
|
1251
|
+
case "parenthesis-block":
|
|
1252
|
+
case "square-bracket-block":
|
|
1253
|
+
case "curly-bracket-block":
|
|
1254
|
+
case "bad-url":
|
|
1255
|
+
case "bad-string":
|
|
1256
|
+
case "close-parenthesis":
|
|
1257
|
+
case "close-square-bracket":
|
|
1258
|
+
case "close-curly-bracket":
|
|
1259
|
+
return;
|
|
1260
|
+
default: {
|
|
1261
|
+
tokenOrValue.value satisfies never;
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
case "color":
|
|
1266
|
+
return parseColor(tokenOrValue.value, builder);
|
|
1267
|
+
case "env":
|
|
1268
|
+
return parseEnv(tokenOrValue.value, builder);
|
|
1269
|
+
case "time":
|
|
1270
|
+
return parseTime(tokenOrValue.value);
|
|
1271
|
+
case "url":
|
|
1272
|
+
case "resolution":
|
|
1273
|
+
case "dashed-ident":
|
|
1274
|
+
case "animation-name":
|
|
1275
|
+
return;
|
|
1276
|
+
default: {
|
|
1277
|
+
tokenOrValue satisfies never;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
export function parseLengthDeclaration(
|
|
1285
|
+
declaration: {
|
|
1286
|
+
value:
|
|
1287
|
+
| number
|
|
1288
|
+
| Length
|
|
1289
|
+
| DimensionPercentageFor_LengthValue
|
|
1290
|
+
| NumberOrPercentage
|
|
1291
|
+
| LengthValue;
|
|
1292
|
+
},
|
|
1293
|
+
builder: StylesheetBuilder,
|
|
1294
|
+
) {
|
|
1295
|
+
return parseLength(declaration.value, builder);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
export function parseLength(
|
|
1299
|
+
length:
|
|
1300
|
+
| number
|
|
1301
|
+
| Length
|
|
1302
|
+
| DimensionPercentageFor_LengthValue
|
|
1303
|
+
| NumberOrPercentage
|
|
1304
|
+
| LengthValue,
|
|
1305
|
+
builder: StylesheetBuilder,
|
|
1306
|
+
): StyleDescriptor {
|
|
1307
|
+
const { inlineRem = 14 } = builder.getOptions();
|
|
1308
|
+
|
|
1309
|
+
if (typeof length === "number") {
|
|
1310
|
+
return round(length);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
if ("unit" in length) {
|
|
1314
|
+
switch (length.unit) {
|
|
1315
|
+
case "px": {
|
|
1316
|
+
if (length.value === Infinity) {
|
|
1317
|
+
return 9999;
|
|
1318
|
+
} else if (length.value === -Infinity) {
|
|
1319
|
+
return -9999;
|
|
1320
|
+
} else {
|
|
1321
|
+
// Normalize large values to safe integers, e.g. `calc(infinity * 1px)`
|
|
1322
|
+
const value = Math.max(
|
|
1323
|
+
Math.min(length.value, Number.MAX_SAFE_INTEGER),
|
|
1324
|
+
Number.MIN_SAFE_INTEGER,
|
|
1325
|
+
);
|
|
1326
|
+
return round(value);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
case "rem":
|
|
1330
|
+
if (typeof inlineRem === "number") {
|
|
1331
|
+
return length.value * inlineRem;
|
|
1332
|
+
} else {
|
|
1333
|
+
return [{}, "rem", round(length.value)];
|
|
1334
|
+
}
|
|
1335
|
+
case "vw":
|
|
1336
|
+
case "vh":
|
|
1337
|
+
case "em":
|
|
1338
|
+
return [{}, length.unit, round(length.value), 1];
|
|
1339
|
+
case "in":
|
|
1340
|
+
case "cm":
|
|
1341
|
+
case "mm":
|
|
1342
|
+
case "q":
|
|
1343
|
+
case "pt":
|
|
1344
|
+
case "pc":
|
|
1345
|
+
case "ex":
|
|
1346
|
+
case "rex":
|
|
1347
|
+
case "ch":
|
|
1348
|
+
case "rch":
|
|
1349
|
+
case "cap":
|
|
1350
|
+
case "rcap":
|
|
1351
|
+
case "ic":
|
|
1352
|
+
case "ric":
|
|
1353
|
+
case "lh":
|
|
1354
|
+
case "rlh":
|
|
1355
|
+
case "lvw":
|
|
1356
|
+
case "svw":
|
|
1357
|
+
case "dvw":
|
|
1358
|
+
case "cqw":
|
|
1359
|
+
case "lvh":
|
|
1360
|
+
case "svh":
|
|
1361
|
+
case "dvh":
|
|
1362
|
+
case "cqh":
|
|
1363
|
+
case "vi":
|
|
1364
|
+
case "svi":
|
|
1365
|
+
case "lvi":
|
|
1366
|
+
case "dvi":
|
|
1367
|
+
case "cqi":
|
|
1368
|
+
case "vb":
|
|
1369
|
+
case "svb":
|
|
1370
|
+
case "lvb":
|
|
1371
|
+
case "dvb":
|
|
1372
|
+
case "cqb":
|
|
1373
|
+
case "vmin":
|
|
1374
|
+
case "svmin":
|
|
1375
|
+
case "lvmin":
|
|
1376
|
+
case "dvmin":
|
|
1377
|
+
case "cqmin":
|
|
1378
|
+
case "vmax":
|
|
1379
|
+
case "svmax":
|
|
1380
|
+
case "lvmax":
|
|
1381
|
+
case "dvmax":
|
|
1382
|
+
case "cqmax":
|
|
1383
|
+
builder.addWarning("value", `${length.value}${length.unit}`);
|
|
1384
|
+
return undefined;
|
|
1385
|
+
default: {
|
|
1386
|
+
length.unit satisfies never;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
} else {
|
|
1390
|
+
switch (length.type) {
|
|
1391
|
+
case "calc": {
|
|
1392
|
+
// TODO: Add the calc polyfill
|
|
1393
|
+
return undefined;
|
|
1394
|
+
}
|
|
1395
|
+
case "number": {
|
|
1396
|
+
return round(length.value);
|
|
1397
|
+
}
|
|
1398
|
+
case "percentage": {
|
|
1399
|
+
return `${round(length.value * 100)}%`;
|
|
1400
|
+
}
|
|
1401
|
+
case "dimension":
|
|
1402
|
+
case "value": {
|
|
1403
|
+
return parseLength(length.value, builder);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
export function parseAngle(angle: Angle | number, builder: StylesheetBuilder) {
|
|
1412
|
+
if (typeof angle === "number") {
|
|
1413
|
+
return `${angle}deg`;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
switch (angle.type) {
|
|
1417
|
+
case "deg":
|
|
1418
|
+
case "rad":
|
|
1419
|
+
return `${angle.value}${angle.type}`;
|
|
1420
|
+
default:
|
|
1421
|
+
builder.addWarning("value", `${angle.value} ${angle.type}`);
|
|
1422
|
+
return undefined;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
export function parseSizeDeclaration(
|
|
1427
|
+
declaration: { value: Size | MaxSize },
|
|
1428
|
+
builder: StylesheetBuilder,
|
|
1429
|
+
) {
|
|
1430
|
+
return parseSize(declaration.value, builder);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
export function parsePointerEvents(
|
|
1434
|
+
{ value }: { value: string },
|
|
1435
|
+
builder: StylesheetBuilder,
|
|
1436
|
+
) {
|
|
1437
|
+
switch (value) {
|
|
1438
|
+
case "none":
|
|
1439
|
+
case "box-none":
|
|
1440
|
+
case "box-only":
|
|
1441
|
+
case "auto":
|
|
1442
|
+
return value;
|
|
1443
|
+
case "visible":
|
|
1444
|
+
case "visiblePainted":
|
|
1445
|
+
case "visibleFill":
|
|
1446
|
+
case "visibleStroke":
|
|
1447
|
+
case "painted":
|
|
1448
|
+
case "fill":
|
|
1449
|
+
case "stroke":
|
|
1450
|
+
builder.addWarning("value", value);
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
export function parseSize(
|
|
1457
|
+
size: Size | MaxSize,
|
|
1458
|
+
builder: StylesheetBuilder,
|
|
1459
|
+
options?: { allowAuto?: boolean },
|
|
1460
|
+
): StyleDescriptor;
|
|
1461
|
+
export function parseSize(
|
|
1462
|
+
size: Size | MaxSize,
|
|
1463
|
+
builder: StylesheetBuilder,
|
|
1464
|
+
property: string,
|
|
1465
|
+
options?: { allowAuto?: boolean },
|
|
1466
|
+
): StyleDescriptor;
|
|
1467
|
+
export function parseSize(
|
|
1468
|
+
size: Size | MaxSize,
|
|
1469
|
+
builder: StylesheetBuilder,
|
|
1470
|
+
options?: string | { allowAuto?: boolean },
|
|
1471
|
+
{ allowAuto = false } = {},
|
|
1472
|
+
) {
|
|
1473
|
+
allowAuto =
|
|
1474
|
+
(typeof options === "object" ? options.allowAuto : allowAuto) ?? false;
|
|
1475
|
+
|
|
1476
|
+
switch (size.type) {
|
|
1477
|
+
case "length-percentage":
|
|
1478
|
+
return parseLength(size.value, builder);
|
|
1479
|
+
case "none":
|
|
1480
|
+
return size.type;
|
|
1481
|
+
case "auto":
|
|
1482
|
+
if (allowAuto) {
|
|
1483
|
+
return size.type;
|
|
1484
|
+
} else {
|
|
1485
|
+
builder.addWarning("value", size.type);
|
|
1486
|
+
return undefined;
|
|
1487
|
+
}
|
|
1488
|
+
case "min-content":
|
|
1489
|
+
case "max-content":
|
|
1490
|
+
case "fit-content":
|
|
1491
|
+
case "fit-content-function":
|
|
1492
|
+
case "stretch":
|
|
1493
|
+
case "contain":
|
|
1494
|
+
builder.addWarning("value", size.type);
|
|
1495
|
+
return undefined;
|
|
1496
|
+
default: {
|
|
1497
|
+
size satisfies never;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
export function parseColorOrAutoDeclaration(
|
|
1505
|
+
{ value }: { value: ColorOrAuto },
|
|
1506
|
+
builder: StylesheetBuilder,
|
|
1507
|
+
) {
|
|
1508
|
+
if (value.type === "auto") {
|
|
1509
|
+
builder.addWarning("value", `Invalid color value ${value.type}`);
|
|
1510
|
+
return;
|
|
1511
|
+
} else {
|
|
1512
|
+
return parseColor(value.value, builder);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
export function parseFontColorDeclaration(
|
|
1517
|
+
declaration: Extract<Declaration, { value: CssColor }>,
|
|
1518
|
+
builder: StylesheetBuilder,
|
|
1519
|
+
) {
|
|
1520
|
+
parseColorDeclaration(declaration, builder);
|
|
1521
|
+
|
|
1522
|
+
builder.addDescriptor(
|
|
1523
|
+
"--__rn-css-color",
|
|
1524
|
+
parseColor(declaration.value, builder),
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
export function parseColorDeclaration(
|
|
1529
|
+
declaration: Extract<Declaration, { value: CssColor }>,
|
|
1530
|
+
builder: StylesheetBuilder,
|
|
1531
|
+
) {
|
|
1532
|
+
builder.addDescriptor(
|
|
1533
|
+
declaration.property,
|
|
1534
|
+
parseColor(declaration.value, builder),
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
export function parseColor(cssColor: CssColor, builder: StylesheetBuilder) {
|
|
1539
|
+
if (typeof cssColor === "string") {
|
|
1540
|
+
if (namedColors.has(cssColor)) {
|
|
1541
|
+
return cssColor;
|
|
1542
|
+
}
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
let color: Color | undefined;
|
|
1547
|
+
|
|
1548
|
+
const { hexColors = true, colorPrecision } = builder.getOptions();
|
|
1549
|
+
|
|
1550
|
+
switch (cssColor.type) {
|
|
1551
|
+
case "currentcolor":
|
|
1552
|
+
return [{}, "var", "__rn-css-current-color"] as const;
|
|
1553
|
+
case "light-dark": {
|
|
1554
|
+
const extraRule: StyleRule = {
|
|
1555
|
+
s: [],
|
|
1556
|
+
m: [["=", "prefers-color-scheme", "dark"]],
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
builder.addUnnamedDescriptor(
|
|
1560
|
+
parseColor(cssColor.dark, builder),
|
|
1561
|
+
false,
|
|
1562
|
+
extraRule,
|
|
1563
|
+
);
|
|
1564
|
+
builder.addExtraRule(extraRule);
|
|
1565
|
+
return parseColor(cssColor.light, builder);
|
|
1566
|
+
}
|
|
1567
|
+
case "rgb": {
|
|
1568
|
+
color = new Color({
|
|
1569
|
+
space: "sRGB",
|
|
1570
|
+
coords: [cssColor.r / 255, cssColor.g / 255, cssColor.b / 255],
|
|
1571
|
+
alpha: cssColor.alpha,
|
|
1572
|
+
});
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
case "hsl":
|
|
1576
|
+
color = new Color({
|
|
1577
|
+
space: cssColor.type,
|
|
1578
|
+
coords: [cssColor.h, cssColor.s, cssColor.l],
|
|
1579
|
+
alpha: cssColor.alpha,
|
|
1580
|
+
});
|
|
1581
|
+
break;
|
|
1582
|
+
case "hwb":
|
|
1583
|
+
color = new Color({
|
|
1584
|
+
space: cssColor.type,
|
|
1585
|
+
coords: [cssColor.h, cssColor.w, cssColor.b],
|
|
1586
|
+
alpha: cssColor.alpha,
|
|
1587
|
+
});
|
|
1588
|
+
break;
|
|
1589
|
+
case "lab":
|
|
1590
|
+
color = new Color({
|
|
1591
|
+
space: cssColor.type,
|
|
1592
|
+
coords: [cssColor.l, cssColor.a, cssColor.b],
|
|
1593
|
+
alpha: cssColor.alpha,
|
|
1594
|
+
});
|
|
1595
|
+
break;
|
|
1596
|
+
case "lch":
|
|
1597
|
+
color = new Color({
|
|
1598
|
+
space: cssColor.type,
|
|
1599
|
+
coords: [cssColor.l, cssColor.c, cssColor.h],
|
|
1600
|
+
alpha: cssColor.alpha,
|
|
1601
|
+
});
|
|
1602
|
+
break;
|
|
1603
|
+
case "oklab":
|
|
1604
|
+
color = new Color({
|
|
1605
|
+
space: cssColor.type,
|
|
1606
|
+
coords: [cssColor.l, cssColor.a, cssColor.b],
|
|
1607
|
+
alpha: cssColor.alpha,
|
|
1608
|
+
});
|
|
1609
|
+
break;
|
|
1610
|
+
case "oklch":
|
|
1611
|
+
color = new Color({
|
|
1612
|
+
space: cssColor.type,
|
|
1613
|
+
coords: [cssColor.l, cssColor.c, cssColor.h],
|
|
1614
|
+
alpha: cssColor.alpha,
|
|
1615
|
+
});
|
|
1616
|
+
break;
|
|
1617
|
+
case "srgb":
|
|
1618
|
+
color = new Color({
|
|
1619
|
+
space: cssColor.type,
|
|
1620
|
+
coords: [cssColor.r, cssColor.g, cssColor.b],
|
|
1621
|
+
alpha: cssColor.alpha,
|
|
1622
|
+
});
|
|
1623
|
+
break;
|
|
1624
|
+
case "srgb-linear":
|
|
1625
|
+
color = new Color({
|
|
1626
|
+
space: cssColor.type,
|
|
1627
|
+
coords: [cssColor.r, cssColor.g, cssColor.b],
|
|
1628
|
+
alpha: cssColor.alpha,
|
|
1629
|
+
});
|
|
1630
|
+
break;
|
|
1631
|
+
case "display-p3":
|
|
1632
|
+
color = new Color({
|
|
1633
|
+
space: "p3",
|
|
1634
|
+
coords: [cssColor.r, cssColor.g, cssColor.b],
|
|
1635
|
+
alpha: cssColor.alpha,
|
|
1636
|
+
});
|
|
1637
|
+
break;
|
|
1638
|
+
case "a98-rgb":
|
|
1639
|
+
color = new Color({
|
|
1640
|
+
space: "a98rgb",
|
|
1641
|
+
coords: [cssColor.r, cssColor.g, cssColor.b],
|
|
1642
|
+
alpha: cssColor.alpha,
|
|
1643
|
+
});
|
|
1644
|
+
break;
|
|
1645
|
+
case "prophoto-rgb":
|
|
1646
|
+
color = new Color({
|
|
1647
|
+
space: "prophoto",
|
|
1648
|
+
coords: [cssColor.r, cssColor.g, cssColor.b],
|
|
1649
|
+
alpha: cssColor.alpha,
|
|
1650
|
+
});
|
|
1651
|
+
break;
|
|
1652
|
+
case "rec2020":
|
|
1653
|
+
color = new Color({
|
|
1654
|
+
space: cssColor.type,
|
|
1655
|
+
coords: [cssColor.r, cssColor.g, cssColor.b],
|
|
1656
|
+
alpha: cssColor.alpha,
|
|
1657
|
+
});
|
|
1658
|
+
break;
|
|
1659
|
+
case "xyz-d50":
|
|
1660
|
+
color = new Color({
|
|
1661
|
+
space: cssColor.type,
|
|
1662
|
+
coords: [cssColor.x, cssColor.y, cssColor.z],
|
|
1663
|
+
alpha: cssColor.alpha,
|
|
1664
|
+
});
|
|
1665
|
+
break;
|
|
1666
|
+
case "xyz-d65":
|
|
1667
|
+
color = new Color({
|
|
1668
|
+
space: cssColor.type,
|
|
1669
|
+
coords: [cssColor.x, cssColor.y, cssColor.z],
|
|
1670
|
+
alpha: cssColor.alpha,
|
|
1671
|
+
});
|
|
1672
|
+
break;
|
|
1673
|
+
default: {
|
|
1674
|
+
cssColor satisfies never;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
if (!hexColors || colorPrecision) {
|
|
1679
|
+
return color?.toString({ precision: colorPrecision ?? 3 });
|
|
1680
|
+
} else {
|
|
1681
|
+
return color?.toString({ format: "hex" });
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
export function parseLengthPercentageOrAutoDeclaration(
|
|
1686
|
+
value: { value: LengthPercentageOrAuto },
|
|
1687
|
+
builder: StylesheetBuilder,
|
|
1688
|
+
) {
|
|
1689
|
+
return parseLengthPercentageOrAuto(value.value, builder);
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
export function parseLengthPercentageOrAuto(
|
|
1693
|
+
lengthPercentageOrAuto: LengthPercentageOrAuto,
|
|
1694
|
+
builder: StylesheetBuilder,
|
|
1695
|
+
{ allowAuto = false } = {},
|
|
1696
|
+
) {
|
|
1697
|
+
switch (lengthPercentageOrAuto.type) {
|
|
1698
|
+
case "auto":
|
|
1699
|
+
if (allowAuto) {
|
|
1700
|
+
return lengthPercentageOrAuto.type;
|
|
1701
|
+
} else {
|
|
1702
|
+
builder.addWarning("value", lengthPercentageOrAuto.type);
|
|
1703
|
+
return undefined;
|
|
1704
|
+
}
|
|
1705
|
+
case "length-percentage":
|
|
1706
|
+
return parseLength(lengthPercentageOrAuto.value, builder);
|
|
1707
|
+
default: {
|
|
1708
|
+
lengthPercentageOrAuto satisfies never;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
export function parseJustifyContent(
|
|
1716
|
+
declaration: DeclarationType<"justify-content">,
|
|
1717
|
+
builder: StylesheetBuilder,
|
|
1718
|
+
) {
|
|
1719
|
+
const allowed = new Set([
|
|
1720
|
+
"flex-start",
|
|
1721
|
+
"flex-end",
|
|
1722
|
+
"center",
|
|
1723
|
+
"space-between",
|
|
1724
|
+
"space-around",
|
|
1725
|
+
"space-evenly",
|
|
1726
|
+
]);
|
|
1727
|
+
|
|
1728
|
+
let value: string | undefined;
|
|
1729
|
+
|
|
1730
|
+
switch (declaration.value.type) {
|
|
1731
|
+
case "normal":
|
|
1732
|
+
case "left":
|
|
1733
|
+
case "right":
|
|
1734
|
+
value = declaration.value.type;
|
|
1735
|
+
break;
|
|
1736
|
+
case "content-distribution":
|
|
1737
|
+
case "content-position":
|
|
1738
|
+
value = declaration.value.value;
|
|
1739
|
+
break;
|
|
1740
|
+
default: {
|
|
1741
|
+
declaration.value satisfies never;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
if (value && !allowed.has(value)) {
|
|
1746
|
+
builder.addWarning("value", value);
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
return value;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
export function parseAlignContent(
|
|
1754
|
+
declaration: DeclarationType<"align-content">,
|
|
1755
|
+
builder: StylesheetBuilder,
|
|
1756
|
+
) {
|
|
1757
|
+
const allowed = new Set([
|
|
1758
|
+
"flex-start",
|
|
1759
|
+
"flex-end",
|
|
1760
|
+
"center",
|
|
1761
|
+
"stretch",
|
|
1762
|
+
"space-between",
|
|
1763
|
+
"space-around",
|
|
1764
|
+
]);
|
|
1765
|
+
|
|
1766
|
+
let value: string | undefined;
|
|
1767
|
+
|
|
1768
|
+
switch (declaration.value.type) {
|
|
1769
|
+
case "normal":
|
|
1770
|
+
case "baseline-position":
|
|
1771
|
+
value = declaration.value.type;
|
|
1772
|
+
break;
|
|
1773
|
+
case "content-distribution":
|
|
1774
|
+
case "content-position":
|
|
1775
|
+
value = declaration.value.value;
|
|
1776
|
+
break;
|
|
1777
|
+
default: {
|
|
1778
|
+
declaration.value satisfies never;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
if (value && !allowed.has(value)) {
|
|
1783
|
+
builder.addWarning("value", value);
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
return value;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
export function parseAlignItems(
|
|
1791
|
+
alignItems: DeclarationType<"align-items">,
|
|
1792
|
+
builder: StylesheetBuilder,
|
|
1793
|
+
) {
|
|
1794
|
+
const allowed = new Set([
|
|
1795
|
+
"auto",
|
|
1796
|
+
"flex-start",
|
|
1797
|
+
"flex-end",
|
|
1798
|
+
"center",
|
|
1799
|
+
"stretch",
|
|
1800
|
+
"baseline",
|
|
1801
|
+
]);
|
|
1802
|
+
|
|
1803
|
+
let value: string | undefined;
|
|
1804
|
+
|
|
1805
|
+
switch (alignItems.value.type) {
|
|
1806
|
+
case "normal":
|
|
1807
|
+
value = "auto";
|
|
1808
|
+
break;
|
|
1809
|
+
case "stretch":
|
|
1810
|
+
value = alignItems.value.type;
|
|
1811
|
+
break;
|
|
1812
|
+
case "baseline-position":
|
|
1813
|
+
value = "baseline";
|
|
1814
|
+
break;
|
|
1815
|
+
case "self-position":
|
|
1816
|
+
value = alignItems.value.value;
|
|
1817
|
+
break;
|
|
1818
|
+
default: {
|
|
1819
|
+
alignItems.value satisfies never;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
if (value && !allowed.has(value)) {
|
|
1824
|
+
builder.addWarning("value", value);
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
return value;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
export function parseAlignSelf(
|
|
1832
|
+
alignSelf: DeclarationType<"align-self">,
|
|
1833
|
+
builder: StylesheetBuilder,
|
|
1834
|
+
) {
|
|
1835
|
+
const allowed = new Set([
|
|
1836
|
+
"auto",
|
|
1837
|
+
"flex-start",
|
|
1838
|
+
"flex-end",
|
|
1839
|
+
"center",
|
|
1840
|
+
"stretch",
|
|
1841
|
+
"baseline",
|
|
1842
|
+
]);
|
|
1843
|
+
|
|
1844
|
+
let value: string | undefined;
|
|
1845
|
+
|
|
1846
|
+
switch (alignSelf.value.type) {
|
|
1847
|
+
case "normal":
|
|
1848
|
+
case "auto":
|
|
1849
|
+
value = "auto";
|
|
1850
|
+
break;
|
|
1851
|
+
case "stretch":
|
|
1852
|
+
value = alignSelf.value.type;
|
|
1853
|
+
break;
|
|
1854
|
+
case "baseline-position":
|
|
1855
|
+
value = "baseline";
|
|
1856
|
+
break;
|
|
1857
|
+
case "self-position":
|
|
1858
|
+
value = alignSelf.value.value;
|
|
1859
|
+
break;
|
|
1860
|
+
default: {
|
|
1861
|
+
alignSelf.value satisfies never;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
if (value && !allowed.has(value)) {
|
|
1866
|
+
builder.addWarning("value", value);
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
return value;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
export function parseFontWeightDeclaration(
|
|
1874
|
+
declaration: DeclarationType<"font-weight">,
|
|
1875
|
+
builder: StylesheetBuilder,
|
|
1876
|
+
) {
|
|
1877
|
+
return parseFontWeight(declaration.value, builder);
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
export function parseFontWeight(
|
|
1881
|
+
fontWeight: FontWeight,
|
|
1882
|
+
builder: StylesheetBuilder,
|
|
1883
|
+
) {
|
|
1884
|
+
switch (fontWeight.type) {
|
|
1885
|
+
case "absolute":
|
|
1886
|
+
if (fontWeight.value.type === "weight") {
|
|
1887
|
+
return fontWeight.value.value.toString();
|
|
1888
|
+
} else {
|
|
1889
|
+
return fontWeight.value.type;
|
|
1890
|
+
}
|
|
1891
|
+
case "bolder":
|
|
1892
|
+
case "lighter":
|
|
1893
|
+
builder.addWarning("value", fontWeight.type);
|
|
1894
|
+
return;
|
|
1895
|
+
default: {
|
|
1896
|
+
fontWeight satisfies never;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
export function parseTextShadow(
|
|
1904
|
+
declaration: DeclarationType<"text-shadow">,
|
|
1905
|
+
builder: StylesheetBuilder,
|
|
1906
|
+
) {
|
|
1907
|
+
const [textShadow] = declaration.value;
|
|
1908
|
+
|
|
1909
|
+
if (!textShadow) {
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
builder.addDescriptor(
|
|
1913
|
+
"textShadowColor",
|
|
1914
|
+
parseColor(textShadow.color, builder),
|
|
1915
|
+
);
|
|
1916
|
+
builder.addDescriptor(
|
|
1917
|
+
"textShadowOffset.width",
|
|
1918
|
+
parseLength(textShadow.xOffset, builder),
|
|
1919
|
+
);
|
|
1920
|
+
builder.addDescriptor(
|
|
1921
|
+
"textShadowOffset.height",
|
|
1922
|
+
parseLength(textShadow.yOffset, builder),
|
|
1923
|
+
);
|
|
1924
|
+
builder.addDescriptor(
|
|
1925
|
+
"textShadowRadius",
|
|
1926
|
+
parseLength(textShadow.blur, builder),
|
|
1927
|
+
);
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export function parseTextDecorationStyle(
|
|
1931
|
+
declaration: DeclarationType<"text-decoration-style">,
|
|
1932
|
+
builder: StylesheetBuilder,
|
|
1933
|
+
) {
|
|
1934
|
+
const allowed = new Set(["solid", "double", "dotted", "dashed"]);
|
|
1935
|
+
|
|
1936
|
+
if (allowed.has(declaration.value)) {
|
|
1937
|
+
return declaration.value;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
builder.addWarning("value", declaration.value);
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
export function parseTextDecorationLineDeclaration(
|
|
1945
|
+
declaration: DeclarationType<"text-decoration-line">,
|
|
1946
|
+
builder: StylesheetBuilder,
|
|
1947
|
+
) {
|
|
1948
|
+
return parseTextDecorationLine(declaration.value, builder);
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
export function parseTextDecorationLine(
|
|
1952
|
+
value: DeclarationType<"text-decoration-line">["value"],
|
|
1953
|
+
builder: StylesheetBuilder,
|
|
1954
|
+
) {
|
|
1955
|
+
if (!Array.isArray(value)) {
|
|
1956
|
+
if (value === "none") {
|
|
1957
|
+
return value;
|
|
1958
|
+
}
|
|
1959
|
+
builder.addWarning("value", value);
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
const set = new Set(value);
|
|
1964
|
+
|
|
1965
|
+
if (set.has("underline")) {
|
|
1966
|
+
if (set.has("line-through")) {
|
|
1967
|
+
return "underline line-through";
|
|
1968
|
+
} else {
|
|
1969
|
+
return "underline";
|
|
1970
|
+
}
|
|
1971
|
+
} else if (set.has("line-through")) {
|
|
1972
|
+
return "line-through";
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
builder.addWarning("value", value.join(" "));
|
|
1976
|
+
return undefined;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
export function parsePosition(
|
|
1980
|
+
{ value }: DeclarationType<"position">,
|
|
1981
|
+
builder: StylesheetBuilder,
|
|
1982
|
+
) {
|
|
1983
|
+
if (value.type === "absolute" || value.type === "relative") {
|
|
1984
|
+
return value.type;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
builder.addWarning("value", value.type);
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
export function parseOverflow(
|
|
1992
|
+
{ value }: DeclarationType<"overflow">,
|
|
1993
|
+
builder: StylesheetBuilder,
|
|
1994
|
+
) {
|
|
1995
|
+
const allowed = new Set(["visible", "hidden"]);
|
|
1996
|
+
|
|
1997
|
+
if (allowed.has(value.x)) {
|
|
1998
|
+
return value.x;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
builder.addWarning("value", value.x);
|
|
2002
|
+
return undefined;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
export function parseBorderStyleDeclaration(
|
|
2006
|
+
declaration: DeclarationType<
|
|
2007
|
+
| "border-style"
|
|
2008
|
+
| "border-left-style"
|
|
2009
|
+
| "border-right-style"
|
|
2010
|
+
| "border-top-style"
|
|
2011
|
+
| "border-bottom-style"
|
|
2012
|
+
>,
|
|
2013
|
+
builder: StylesheetBuilder,
|
|
2014
|
+
) {
|
|
2015
|
+
return parseBorderStyle(declaration.value, builder);
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
export function parseBorderStyle(
|
|
2019
|
+
value: BorderStyle | LineStyle,
|
|
2020
|
+
builder: StylesheetBuilder,
|
|
2021
|
+
) {
|
|
2022
|
+
const allowed = new Set(["solid", "dotted", "dashed"]);
|
|
2023
|
+
|
|
2024
|
+
if (typeof value === "string") {
|
|
2025
|
+
if (allowed.has(value)) {
|
|
2026
|
+
return value;
|
|
2027
|
+
} else {
|
|
2028
|
+
builder.addWarning("value", value);
|
|
2029
|
+
return undefined;
|
|
2030
|
+
}
|
|
2031
|
+
} else if (
|
|
2032
|
+
value.top === value.bottom &&
|
|
2033
|
+
value.top === value.left &&
|
|
2034
|
+
value.top === value.right &&
|
|
2035
|
+
allowed.has(value.top)
|
|
2036
|
+
) {
|
|
2037
|
+
return value.top;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
builder.addWarning("value", value.top);
|
|
2041
|
+
|
|
2042
|
+
return undefined;
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
export function parseBorderBlockWidth(
|
|
2046
|
+
declaration: DeclarationType<"border-block-width">,
|
|
2047
|
+
builder: StylesheetBuilder,
|
|
2048
|
+
) {
|
|
2049
|
+
builder.addDescriptor(
|
|
2050
|
+
"border-top-width",
|
|
2051
|
+
parseBorderSideWidth(declaration.value.start, builder),
|
|
2052
|
+
);
|
|
2053
|
+
builder.addDescriptor(
|
|
2054
|
+
"border-bottom-width",
|
|
2055
|
+
parseBorderSideWidth(declaration.value.end, builder),
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
function parseBorderBlockStyle(
|
|
2060
|
+
declaration: DeclarationType<"border-block-style">,
|
|
2061
|
+
builder: StylesheetBuilder,
|
|
2062
|
+
) {
|
|
2063
|
+
if (declaration.value.start === declaration.value.end) {
|
|
2064
|
+
builder.addDescriptor(
|
|
2065
|
+
"border-style",
|
|
2066
|
+
parseBorderStyle(declaration.value.start, builder),
|
|
2067
|
+
);
|
|
2068
|
+
} else {
|
|
2069
|
+
builder.addWarning("property", "border-block-style");
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
export function parseBorderSideWidthDeclaration(
|
|
2074
|
+
declaration: DeclarationType<
|
|
2075
|
+
| "border-block-end-width"
|
|
2076
|
+
| "border-block-start-width"
|
|
2077
|
+
| "border-bottom-width"
|
|
2078
|
+
| "border-inline-end-width"
|
|
2079
|
+
| "border-inline-start-width"
|
|
2080
|
+
| "border-left-width"
|
|
2081
|
+
| "border-right-width"
|
|
2082
|
+
| "border-top-width"
|
|
2083
|
+
>,
|
|
2084
|
+
builder: StylesheetBuilder,
|
|
2085
|
+
) {
|
|
2086
|
+
if (declaration.property.includes("block")) {
|
|
2087
|
+
builder.addDescriptor(
|
|
2088
|
+
`border-${declaration.property.includes("start") ? "top" : "bottom"}-width`,
|
|
2089
|
+
parseBorderSideWidth(declaration.value, builder),
|
|
2090
|
+
);
|
|
2091
|
+
return;
|
|
2092
|
+
} else if (declaration.property.includes("inline")) {
|
|
2093
|
+
builder.addDescriptor(
|
|
2094
|
+
`border-${declaration.property.includes("start") ? "left" : "right"}-width`,
|
|
2095
|
+
parseBorderSideWidth(declaration.value, builder),
|
|
2096
|
+
);
|
|
2097
|
+
return;
|
|
2098
|
+
} else {
|
|
2099
|
+
return parseBorderSideWidth(declaration.value, builder);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
export function parseBorderSideWidth(
|
|
2104
|
+
value: BorderSideWidth,
|
|
2105
|
+
builder: StylesheetBuilder,
|
|
2106
|
+
) {
|
|
2107
|
+
if (value.type === "length") {
|
|
2108
|
+
return parseLength(value.value, builder);
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
builder.addWarning("value", value.type);
|
|
2112
|
+
return undefined;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
export function parseVerticalAlign(
|
|
2116
|
+
{ value }: DeclarationType<"vertical-align">,
|
|
2117
|
+
builder: StylesheetBuilder,
|
|
2118
|
+
) {
|
|
2119
|
+
if (value.type === "length") {
|
|
2120
|
+
return undefined;
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
const allowed = new Set(["auto", "top", "bottom", "middle"]);
|
|
2124
|
+
|
|
2125
|
+
if (allowed.has(value.value)) {
|
|
2126
|
+
return value.value;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
builder.addWarning("value", value.value);
|
|
2130
|
+
return undefined;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
function parseFontFamily({ value }: DeclarationType<"font-family">) {
|
|
2134
|
+
// React Native only allows one font family - better hope this is the right one :)
|
|
2135
|
+
return value[0];
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
export function parseLineHeightDeclaration(
|
|
2139
|
+
declaration: DeclarationType<"line-height">,
|
|
2140
|
+
builder: StylesheetBuilder,
|
|
2141
|
+
) {
|
|
2142
|
+
return parseLineHeight(declaration.value, builder);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
export function parseLineHeight(
|
|
2146
|
+
value: LineHeight,
|
|
2147
|
+
builder: StylesheetBuilder,
|
|
2148
|
+
): StyleDescriptor {
|
|
2149
|
+
switch (value.type) {
|
|
2150
|
+
case "normal":
|
|
2151
|
+
return undefined;
|
|
2152
|
+
case "number":
|
|
2153
|
+
return [{}, "em", [value.value], 1];
|
|
2154
|
+
case "length": {
|
|
2155
|
+
const length = value.value;
|
|
2156
|
+
|
|
2157
|
+
switch (length.type) {
|
|
2158
|
+
case "dimension":
|
|
2159
|
+
return parseLength(length, builder);
|
|
2160
|
+
case "percentage":
|
|
2161
|
+
case "calc":
|
|
2162
|
+
builder.addWarning(
|
|
2163
|
+
"style",
|
|
2164
|
+
"line-height",
|
|
2165
|
+
typeof length.value === "number"
|
|
2166
|
+
? length.value
|
|
2167
|
+
: JSON.stringify(length.value),
|
|
2168
|
+
);
|
|
2169
|
+
return;
|
|
2170
|
+
default: {
|
|
2171
|
+
length satisfies never;
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
default: {
|
|
2178
|
+
value satisfies never;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
export function parseFontSizeDeclaration(
|
|
2186
|
+
declaration: DeclarationType<"font-size">,
|
|
2187
|
+
builder: StylesheetBuilder,
|
|
2188
|
+
) {
|
|
2189
|
+
const fontSize = parseFontSize(declaration.value, builder);
|
|
2190
|
+
builder.addDescriptor("fontSize", fontSize);
|
|
2191
|
+
builder.addDescriptor("--__rn-css-em", fontSize);
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
export function parseFontSize(value: FontSize, builder: StylesheetBuilder) {
|
|
2195
|
+
switch (value.type) {
|
|
2196
|
+
case "length":
|
|
2197
|
+
return parseLength(value.value, builder);
|
|
2198
|
+
case "absolute":
|
|
2199
|
+
case "relative":
|
|
2200
|
+
builder.addWarning("value", value.value);
|
|
2201
|
+
return undefined;
|
|
2202
|
+
default: {
|
|
2203
|
+
value satisfies never;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
return;
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
export function parseFontStyleDeclaration(
|
|
2211
|
+
declaration: DeclarationType<"font-style">,
|
|
2212
|
+
builder: StylesheetBuilder,
|
|
2213
|
+
) {
|
|
2214
|
+
return parseFontStyle(declaration.value, builder);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
export function parseFontStyle(value: FontStyle, builder: StylesheetBuilder) {
|
|
2218
|
+
switch (value.type) {
|
|
2219
|
+
case "normal":
|
|
2220
|
+
case "italic":
|
|
2221
|
+
return value.type;
|
|
2222
|
+
case "oblique":
|
|
2223
|
+
builder.addWarning("value", value.type);
|
|
2224
|
+
return undefined;
|
|
2225
|
+
default: {
|
|
2226
|
+
value satisfies never;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
return;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
export function parseFontVariantCapsDeclaration(
|
|
2234
|
+
declaration: DeclarationType<"font-variant-caps">,
|
|
2235
|
+
builder: StylesheetBuilder,
|
|
2236
|
+
) {
|
|
2237
|
+
return parseFontVariantCaps(declaration.value, builder);
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
export function parseFontVariantCaps(
|
|
2241
|
+
value: FontVariantCaps,
|
|
2242
|
+
builder: StylesheetBuilder,
|
|
2243
|
+
) {
|
|
2244
|
+
const allowed = new Set([
|
|
2245
|
+
"small-caps",
|
|
2246
|
+
"oldstyle-nums",
|
|
2247
|
+
"lining-nums",
|
|
2248
|
+
"tabular-nums",
|
|
2249
|
+
"proportional-nums",
|
|
2250
|
+
]);
|
|
2251
|
+
if (allowed.has(value)) {
|
|
2252
|
+
return value;
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
builder.addWarning("value", value);
|
|
2256
|
+
return undefined;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
export function parseLengthOrCoercePercentageToRuntime(
|
|
2260
|
+
value: Length | DimensionPercentageFor_LengthValue | NumberOrPercentage,
|
|
2261
|
+
builder: StylesheetBuilder,
|
|
2262
|
+
): StyleDescriptor {
|
|
2263
|
+
return parseLength(value, builder);
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
export function parseGap(
|
|
2267
|
+
declaration: DeclarationType<"gap" | "column-gap" | "row-gap">,
|
|
2268
|
+
builder: StylesheetBuilder,
|
|
2269
|
+
) {
|
|
2270
|
+
if ("column" in declaration.value) {
|
|
2271
|
+
builder.addDescriptor(
|
|
2272
|
+
"row-gap",
|
|
2273
|
+
parseGapValue(declaration.value.row, builder),
|
|
2274
|
+
);
|
|
2275
|
+
builder.addDescriptor(
|
|
2276
|
+
"column-gap",
|
|
2277
|
+
parseGapValue(declaration.value.column, builder),
|
|
2278
|
+
);
|
|
2279
|
+
|
|
2280
|
+
return;
|
|
2281
|
+
} else {
|
|
2282
|
+
if (declaration.value.type === "normal") {
|
|
2283
|
+
builder.addWarning("value", declaration.value.type);
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
return parseLength(declaration.value.value, builder);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
function parseGapValue(
|
|
2292
|
+
value: GapValue,
|
|
2293
|
+
builder: StylesheetBuilder,
|
|
2294
|
+
): StyleDescriptor {
|
|
2295
|
+
if (value.type === "normal") {
|
|
2296
|
+
return;
|
|
2297
|
+
} else {
|
|
2298
|
+
return parseLength(value.value, builder);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
export function parseTextAlign(
|
|
2303
|
+
{ value }: DeclarationType<"text-align">,
|
|
2304
|
+
builder: StylesheetBuilder,
|
|
2305
|
+
) {
|
|
2306
|
+
const allowed = new Set(["auto", "left", "right", "center", "justify"]);
|
|
2307
|
+
if (allowed.has(value)) {
|
|
2308
|
+
return value;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
builder.addWarning("value", value);
|
|
2312
|
+
return undefined;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
export function parseBoxShadow(
|
|
2316
|
+
{ value }: DeclarationType<"box-shadow">,
|
|
2317
|
+
builder: StylesheetBuilder,
|
|
2318
|
+
) {
|
|
2319
|
+
for (const [index, shadow] of value.entries()) {
|
|
2320
|
+
builder.addDescriptor(
|
|
2321
|
+
`boxShadow.[${index}].color`,
|
|
2322
|
+
parseColor(shadow.color, builder),
|
|
2323
|
+
);
|
|
2324
|
+
builder.addDescriptor(
|
|
2325
|
+
`boxShadow.[${index}].offsetX`,
|
|
2326
|
+
parseLength(shadow.xOffset, builder),
|
|
2327
|
+
);
|
|
2328
|
+
builder.addDescriptor(
|
|
2329
|
+
`boxShadow.[${index}].offsetY`,
|
|
2330
|
+
parseLength(shadow.yOffset, builder),
|
|
2331
|
+
);
|
|
2332
|
+
builder.addDescriptor(
|
|
2333
|
+
`boxShadow.[${index}].blurRadius`,
|
|
2334
|
+
parseLength(shadow.blur, builder),
|
|
2335
|
+
);
|
|
2336
|
+
builder.addDescriptor(
|
|
2337
|
+
`boxShadow.[${index}].spreadDistance`,
|
|
2338
|
+
parseLength(shadow.spread, builder),
|
|
2339
|
+
);
|
|
2340
|
+
builder.addDescriptor(
|
|
2341
|
+
`boxShadow.[${index}].inset`,
|
|
2342
|
+
shadow.inset ? true : undefined,
|
|
2343
|
+
);
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
export function parseDisplay(
|
|
2348
|
+
{ value }: DeclarationType<"display">,
|
|
2349
|
+
builder: StylesheetBuilder,
|
|
2350
|
+
) {
|
|
2351
|
+
if (value.type === "keyword") {
|
|
2352
|
+
if (value.value === "none") {
|
|
2353
|
+
return value.value;
|
|
2354
|
+
} else {
|
|
2355
|
+
builder.addWarning("value", value.value);
|
|
2356
|
+
return;
|
|
2357
|
+
}
|
|
2358
|
+
} else {
|
|
2359
|
+
if (value.outside === "block") {
|
|
2360
|
+
switch (value.inside.type) {
|
|
2361
|
+
case "flow":
|
|
2362
|
+
if (value.isListItem) {
|
|
2363
|
+
builder.addWarning("value", "list-item");
|
|
2364
|
+
} else {
|
|
2365
|
+
builder.addWarning("value", "block");
|
|
2366
|
+
}
|
|
2367
|
+
return;
|
|
2368
|
+
case "flex":
|
|
2369
|
+
return value.inside.type;
|
|
2370
|
+
case "flow-root":
|
|
2371
|
+
case "table":
|
|
2372
|
+
case "box":
|
|
2373
|
+
case "grid":
|
|
2374
|
+
case "ruby":
|
|
2375
|
+
builder.addWarning("value", value.inside.type);
|
|
2376
|
+
return;
|
|
2377
|
+
}
|
|
2378
|
+
} else {
|
|
2379
|
+
switch (value.inside.type) {
|
|
2380
|
+
case "flow":
|
|
2381
|
+
builder.addWarning("value", "inline");
|
|
2382
|
+
return;
|
|
2383
|
+
case "flow-root":
|
|
2384
|
+
builder.addWarning("value", "inline-block");
|
|
2385
|
+
return;
|
|
2386
|
+
case "table":
|
|
2387
|
+
builder.addWarning("value", "inline-table");
|
|
2388
|
+
return;
|
|
2389
|
+
case "flex":
|
|
2390
|
+
builder.addWarning("value", "inline-flex");
|
|
2391
|
+
return;
|
|
2392
|
+
case "box":
|
|
2393
|
+
case "grid":
|
|
2394
|
+
builder.addWarning("value", "inline-grid");
|
|
2395
|
+
return;
|
|
2396
|
+
case "ruby":
|
|
2397
|
+
builder.addWarning("value", value.inside.type);
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
export function parseAspectRatio({
|
|
2405
|
+
value,
|
|
2406
|
+
}: DeclarationType<"aspect-ratio">): StyleDescriptor {
|
|
2407
|
+
if (!value.ratio) {
|
|
2408
|
+
return;
|
|
2409
|
+
} else if (value.auto) {
|
|
2410
|
+
return "auto";
|
|
2411
|
+
} else {
|
|
2412
|
+
const [width, height] = value.ratio;
|
|
2413
|
+
if (width === height) {
|
|
2414
|
+
return 1;
|
|
2415
|
+
} else {
|
|
2416
|
+
return `${width}/${height}`;
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
export function parseDimension(
|
|
2422
|
+
{ unit, value }: Extract<Token, { type: "dimension" }>,
|
|
2423
|
+
builder: StylesheetBuilder,
|
|
2424
|
+
): StyleDescriptor {
|
|
2425
|
+
switch (unit) {
|
|
2426
|
+
case "px":
|
|
2427
|
+
if (value === Infinity) {
|
|
2428
|
+
return 9999;
|
|
2429
|
+
} else {
|
|
2430
|
+
return value;
|
|
2431
|
+
}
|
|
2432
|
+
case "%":
|
|
2433
|
+
return `${value}%`;
|
|
2434
|
+
case "rnh":
|
|
2435
|
+
case "rnw":
|
|
2436
|
+
return [{}, unit, [value / 100], 1];
|
|
2437
|
+
default: {
|
|
2438
|
+
builder.addWarning("value", `${value}${unit}`);
|
|
2439
|
+
return;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
export function parseUserSelect(
|
|
2445
|
+
{ value }: DeclarationType<"user-select">,
|
|
2446
|
+
builder: StylesheetBuilder,
|
|
2447
|
+
) {
|
|
2448
|
+
const allowed = ["auto", "text", "none", "contain", "all"];
|
|
2449
|
+
if (allowed.includes(value)) {
|
|
2450
|
+
return value;
|
|
2451
|
+
} else {
|
|
2452
|
+
builder.addWarning("value", value);
|
|
2453
|
+
return;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
export function parseSVGPaint(
|
|
2458
|
+
{ value, property }: DeclarationType<"fill" | "stroke">,
|
|
2459
|
+
builder: StylesheetBuilder,
|
|
2460
|
+
) {
|
|
2461
|
+
let parsedValue: StyleDescriptor | undefined;
|
|
2462
|
+
|
|
2463
|
+
if (value.type === "none") {
|
|
2464
|
+
parsedValue = "transparent";
|
|
2465
|
+
} else if (value.type === "color") {
|
|
2466
|
+
parsedValue = parseColor(value.value, builder);
|
|
2467
|
+
} else {
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
builder.addDescriptor(property, parsedValue);
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
export function round(number: number) {
|
|
2475
|
+
return Math.round((number + Number.EPSILON) * 10000) / 10000;
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
export function parseDimensionPercentageFor_LengthValue(
|
|
2479
|
+
value: DimensionPercentageFor_LengthValue,
|
|
2480
|
+
builder: StylesheetBuilder,
|
|
2481
|
+
) {
|
|
2482
|
+
if (value.type === "calc") {
|
|
2483
|
+
return undefined;
|
|
2484
|
+
} else if (value.type === "percentage") {
|
|
2485
|
+
return `${value.value}%`;
|
|
2486
|
+
} else {
|
|
2487
|
+
return parseLength(value.value, builder);
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
const allowAutoProperties = new Set(["pointer-events"]);
|
|
2492
|
+
|
|
2493
|
+
export function parseEnv(
|
|
2494
|
+
value: EnvironmentVariable,
|
|
2495
|
+
builder: StylesheetBuilder,
|
|
2496
|
+
): StyleFunction | undefined {
|
|
2497
|
+
switch (value.name.type) {
|
|
2498
|
+
case "ua":
|
|
2499
|
+
switch (value.name.value) {
|
|
2500
|
+
case "safe-area-inset-top":
|
|
2501
|
+
case "safe-area-inset-right":
|
|
2502
|
+
case "safe-area-inset-bottom":
|
|
2503
|
+
case "safe-area-inset-left":
|
|
2504
|
+
return [
|
|
2505
|
+
{},
|
|
2506
|
+
"var",
|
|
2507
|
+
[
|
|
2508
|
+
`--react-native-css-${value.name.value}`,
|
|
2509
|
+
parseUnparsed(value.fallback, builder, value.name.value),
|
|
2510
|
+
],
|
|
2511
|
+
1,
|
|
2512
|
+
];
|
|
2513
|
+
case "viewport-segment-width":
|
|
2514
|
+
case "viewport-segment-height":
|
|
2515
|
+
case "viewport-segment-top":
|
|
2516
|
+
case "viewport-segment-left":
|
|
2517
|
+
case "viewport-segment-bottom":
|
|
2518
|
+
case "viewport-segment-right":
|
|
2519
|
+
}
|
|
2520
|
+
break;
|
|
2521
|
+
case "custom":
|
|
2522
|
+
case "unknown":
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
return;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
export function parseCalcFn(
|
|
2529
|
+
name: string,
|
|
2530
|
+
tokens: TokenOrValue[],
|
|
2531
|
+
builder: StylesheetBuilder,
|
|
2532
|
+
property: string,
|
|
2533
|
+
): StyleDescriptor {
|
|
2534
|
+
const args = parseCalcArguments(tokens, builder, property);
|
|
2535
|
+
if (args) {
|
|
2536
|
+
return [{}, name, args];
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
return;
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
export function parseCalcArguments(
|
|
2543
|
+
[...args]: TokenOrValue[],
|
|
2544
|
+
builder: StylesheetBuilder,
|
|
2545
|
+
property: string,
|
|
2546
|
+
) {
|
|
2547
|
+
const parsed: StyleDescriptor[] = [];
|
|
2548
|
+
|
|
2549
|
+
for (const arg of args) {
|
|
2550
|
+
switch (arg.type) {
|
|
2551
|
+
case "env": {
|
|
2552
|
+
parsed.push(parseEnv(arg.value, builder));
|
|
2553
|
+
break;
|
|
2554
|
+
}
|
|
2555
|
+
case "var":
|
|
2556
|
+
case "function":
|
|
2557
|
+
case "unresolved-color": {
|
|
2558
|
+
const value = parseUnparsed(arg, builder, property);
|
|
2559
|
+
|
|
2560
|
+
if (value === undefined) {
|
|
2561
|
+
return undefined;
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
parsed.push(value);
|
|
2565
|
+
break;
|
|
2566
|
+
}
|
|
2567
|
+
case "length": {
|
|
2568
|
+
const value = parseLength(arg.value, builder);
|
|
2569
|
+
if (value !== undefined) {
|
|
2570
|
+
parsed.push(value);
|
|
2571
|
+
}
|
|
2572
|
+
break;
|
|
2573
|
+
}
|
|
2574
|
+
case "color":
|
|
2575
|
+
case "url":
|
|
2576
|
+
case "angle":
|
|
2577
|
+
case "time":
|
|
2578
|
+
case "resolution":
|
|
2579
|
+
case "dashed-ident":
|
|
2580
|
+
break;
|
|
2581
|
+
case "token":
|
|
2582
|
+
switch (arg.value.type) {
|
|
2583
|
+
case "delim":
|
|
2584
|
+
switch (arg.value.value) {
|
|
2585
|
+
case "+":
|
|
2586
|
+
case "-":
|
|
2587
|
+
case "*":
|
|
2588
|
+
case "/":
|
|
2589
|
+
parsed.push(arg.value.value);
|
|
2590
|
+
break;
|
|
2591
|
+
}
|
|
2592
|
+
break;
|
|
2593
|
+
case "percentage":
|
|
2594
|
+
parsed.push(`${round(arg.value.value * 100)}%`);
|
|
2595
|
+
break;
|
|
2596
|
+
case "number": {
|
|
2597
|
+
parsed.push(round(arg.value.value));
|
|
2598
|
+
break;
|
|
2599
|
+
}
|
|
2600
|
+
case "parenthesis-block": {
|
|
2601
|
+
parsed.push("(");
|
|
2602
|
+
break;
|
|
2603
|
+
}
|
|
2604
|
+
case "close-parenthesis":
|
|
2605
|
+
parsed.push(")");
|
|
2606
|
+
break;
|
|
2607
|
+
case "string":
|
|
2608
|
+
case "function":
|
|
2609
|
+
case "ident":
|
|
2610
|
+
case "at-keyword":
|
|
2611
|
+
case "hash":
|
|
2612
|
+
case "id-hash":
|
|
2613
|
+
case "unquoted-url":
|
|
2614
|
+
case "dimension":
|
|
2615
|
+
case "white-space":
|
|
2616
|
+
case "comment":
|
|
2617
|
+
case "colon":
|
|
2618
|
+
case "semicolon":
|
|
2619
|
+
case "comma":
|
|
2620
|
+
case "include-match":
|
|
2621
|
+
case "dash-match":
|
|
2622
|
+
case "prefix-match":
|
|
2623
|
+
case "suffix-match":
|
|
2624
|
+
case "substring-match":
|
|
2625
|
+
case "cdo":
|
|
2626
|
+
case "cdc":
|
|
2627
|
+
case "square-bracket-block":
|
|
2628
|
+
case "curly-bracket-block":
|
|
2629
|
+
case "bad-url":
|
|
2630
|
+
case "bad-string":
|
|
2631
|
+
case "close-square-bracket":
|
|
2632
|
+
case "close-curly-bracket":
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
return parsed;
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
export function parseTranslateProp(
|
|
2641
|
+
value: Translate,
|
|
2642
|
+
prop: keyof Extract<Translate, object>,
|
|
2643
|
+
builder: StylesheetBuilder,
|
|
2644
|
+
): StyleDescriptor {
|
|
2645
|
+
if (value === "none") {
|
|
2646
|
+
return 0;
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
return parseLength(value[prop], builder);
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
export function parseUnresolvedColor(
|
|
2653
|
+
color: UnresolvedColor,
|
|
2654
|
+
builder: StylesheetBuilder,
|
|
2655
|
+
property: string,
|
|
2656
|
+
allowAuto: boolean,
|
|
2657
|
+
): StyleDescriptor {
|
|
2658
|
+
switch (color.type) {
|
|
2659
|
+
case "rgb":
|
|
2660
|
+
return [
|
|
2661
|
+
{},
|
|
2662
|
+
"rgba",
|
|
2663
|
+
[
|
|
2664
|
+
round(color.r * 255),
|
|
2665
|
+
round(color.g * 255),
|
|
2666
|
+
round(color.b * 255),
|
|
2667
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2668
|
+
],
|
|
2669
|
+
];
|
|
2670
|
+
case "hsl":
|
|
2671
|
+
return [
|
|
2672
|
+
{},
|
|
2673
|
+
color.type,
|
|
2674
|
+
[
|
|
2675
|
+
color.h,
|
|
2676
|
+
color.s,
|
|
2677
|
+
color.l,
|
|
2678
|
+
parseUnparsed(color.alpha, builder, property),
|
|
2679
|
+
],
|
|
2680
|
+
];
|
|
2681
|
+
case "light-dark": {
|
|
2682
|
+
const extraRule = builder.extendRule({
|
|
2683
|
+
m: [["=", "prefers-color-scheme", "dark"]],
|
|
2684
|
+
});
|
|
2685
|
+
builder.addUnnamedDescriptor(
|
|
2686
|
+
reduceParseUnparsed(color.dark, builder, property, allowAuto),
|
|
2687
|
+
false,
|
|
2688
|
+
extraRule,
|
|
2689
|
+
);
|
|
2690
|
+
builder.addExtraRule(extraRule);
|
|
2691
|
+
return reduceParseUnparsed(color.light, builder, property, allowAuto);
|
|
2692
|
+
}
|
|
2693
|
+
default:
|
|
2694
|
+
color satisfies never;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
export function allEqual(...params: unknown[]) {
|
|
2701
|
+
return params.every((param, index, array) => {
|
|
2702
|
+
return index === 0 ? true : equal(array[0], param);
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
export function equal(a: unknown, b: unknown) {
|
|
2706
|
+
if (a === b) return true;
|
|
2707
|
+
if (typeof a !== typeof b) return false;
|
|
2708
|
+
if (a === null || b === null) return false;
|
|
2709
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
2710
|
+
if (a.length !== b.length) return false;
|
|
2711
|
+
for (let i = 0; i < a.length; i++) {
|
|
2712
|
+
if (!equal(a[i], b[i])) return false;
|
|
2713
|
+
}
|
|
2714
|
+
return true;
|
|
2715
|
+
}
|
|
2716
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
2717
|
+
if (Object.keys(a).length !== Object.keys(b).length) return false;
|
|
2718
|
+
for (const key in a) {
|
|
2719
|
+
if (
|
|
2720
|
+
!equal(
|
|
2721
|
+
(a as Record<string, unknown>)[key],
|
|
2722
|
+
(b as Record<string, unknown>)[key],
|
|
2723
|
+
)
|
|
2724
|
+
)
|
|
2725
|
+
return false;
|
|
2726
|
+
}
|
|
2727
|
+
return true;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
return false;
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
export function parseTime(time: Time) {
|
|
2734
|
+
return time.type === "milliseconds" ? time.value : time.value * 1000;
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
export function parseSize2DDimensionPercentageDeclaration(
|
|
2738
|
+
declaration: { value: Size2DFor_DimensionPercentageFor_LengthValue },
|
|
2739
|
+
builder: StylesheetBuilder,
|
|
2740
|
+
) {
|
|
2741
|
+
return parseSize2DDimensionPercentage(declaration.value, builder);
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
export function parseSize2DDimensionPercentage(
|
|
2745
|
+
value: Size2DFor_DimensionPercentageFor_LengthValue,
|
|
2746
|
+
builder: StylesheetBuilder,
|
|
2747
|
+
) {
|
|
2748
|
+
return parseLength(value[0], builder);
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
export function addTransitionValue(
|
|
2752
|
+
declaration: Extract<
|
|
2753
|
+
Declaration,
|
|
2754
|
+
{ property: `transition${string}` | "transition" }
|
|
2755
|
+
>,
|
|
2756
|
+
builder: StylesheetBuilder,
|
|
2757
|
+
) {
|
|
2758
|
+
switch (declaration.property) {
|
|
2759
|
+
case "transition": {
|
|
2760
|
+
const grouped: Record<string, unknown[]> = {};
|
|
2761
|
+
|
|
2762
|
+
for (const animation of declaration.value) {
|
|
2763
|
+
for (const [key, value] of Object.entries(animation)) {
|
|
2764
|
+
grouped[key] ??= [];
|
|
2765
|
+
grouped[key].push(value);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
for (const [property, value] of Object.entries(grouped)) {
|
|
2770
|
+
addTransitionValue(
|
|
2771
|
+
{
|
|
2772
|
+
property: `transition-${kebabCase(property)}`,
|
|
2773
|
+
value,
|
|
2774
|
+
} as Extract<
|
|
2775
|
+
Declaration,
|
|
2776
|
+
{ property: `transition${string}` | "transition" }
|
|
2777
|
+
>,
|
|
2778
|
+
builder,
|
|
2779
|
+
);
|
|
2780
|
+
}
|
|
2781
|
+
break;
|
|
2782
|
+
}
|
|
2783
|
+
case "transition-property": {
|
|
2784
|
+
builder.addDescriptor(
|
|
2785
|
+
declaration.property,
|
|
2786
|
+
declaration.value
|
|
2787
|
+
.map((v) => v.property)
|
|
2788
|
+
.filter((v) => v in parsers || v === "all" || v === "none")
|
|
2789
|
+
.map((v) => toRNProperty(v)),
|
|
2790
|
+
);
|
|
2791
|
+
return;
|
|
2792
|
+
}
|
|
2793
|
+
case "transition-duration":
|
|
2794
|
+
builder.addDescriptor(
|
|
2795
|
+
declaration.property,
|
|
2796
|
+
declaration.value.map((t) => parseTime(t)),
|
|
2797
|
+
);
|
|
2798
|
+
return;
|
|
2799
|
+
case "transition-delay":
|
|
2800
|
+
builder.addDescriptor(
|
|
2801
|
+
declaration.property,
|
|
2802
|
+
declaration.value.map((t) => parseTime(t)),
|
|
2803
|
+
);
|
|
2804
|
+
return;
|
|
2805
|
+
case "transition-timing-function":
|
|
2806
|
+
builder.addDescriptor(
|
|
2807
|
+
declaration.property,
|
|
2808
|
+
parseEasingFunction(declaration.value),
|
|
2809
|
+
);
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
export function addAnimationValue(
|
|
2815
|
+
declaration: Extract<
|
|
2816
|
+
Declaration,
|
|
2817
|
+
{ property: `animation${string}` | "animation" }
|
|
2818
|
+
>,
|
|
2819
|
+
builder: StylesheetBuilder,
|
|
2820
|
+
) {
|
|
2821
|
+
switch (declaration.property) {
|
|
2822
|
+
case "animation": {
|
|
2823
|
+
const grouped: Record<string, unknown[]> = {};
|
|
2824
|
+
|
|
2825
|
+
for (const animation of declaration.value) {
|
|
2826
|
+
for (const [key, value] of Object.entries(animation)) {
|
|
2827
|
+
grouped[key] ??= [];
|
|
2828
|
+
grouped[key].push(value);
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
for (const [property, value] of Object.entries(grouped)) {
|
|
2833
|
+
addAnimationValue(
|
|
2834
|
+
{
|
|
2835
|
+
property: `animation-${kebabCase(property)}`,
|
|
2836
|
+
value,
|
|
2837
|
+
} as Extract<
|
|
2838
|
+
Declaration,
|
|
2839
|
+
{ property: `animation${string}` | "animation" }
|
|
2840
|
+
>,
|
|
2841
|
+
builder,
|
|
2842
|
+
);
|
|
2843
|
+
}
|
|
2844
|
+
break;
|
|
2845
|
+
}
|
|
2846
|
+
case "animation-delay": {
|
|
2847
|
+
builder.addDescriptor(
|
|
2848
|
+
declaration.property,
|
|
2849
|
+
declaration.value.map((t) => parseTime(t)),
|
|
2850
|
+
);
|
|
2851
|
+
break;
|
|
2852
|
+
}
|
|
2853
|
+
case "animation-direction": {
|
|
2854
|
+
builder.addDescriptor(declaration.property, declaration.value);
|
|
2855
|
+
break;
|
|
2856
|
+
}
|
|
2857
|
+
case "animation-duration": {
|
|
2858
|
+
builder.addDescriptor(
|
|
2859
|
+
declaration.property,
|
|
2860
|
+
declaration.value.map((t) => parseTime(t)),
|
|
2861
|
+
);
|
|
2862
|
+
break;
|
|
2863
|
+
}
|
|
2864
|
+
case "animation-fill-mode": {
|
|
2865
|
+
builder.addDescriptor(declaration.property, declaration.value);
|
|
2866
|
+
break;
|
|
2867
|
+
}
|
|
2868
|
+
case "animation-iteration-count": {
|
|
2869
|
+
builder.addDescriptor(
|
|
2870
|
+
declaration.property,
|
|
2871
|
+
parseIterationCount(declaration.value),
|
|
2872
|
+
);
|
|
2873
|
+
break;
|
|
2874
|
+
}
|
|
2875
|
+
case "animation-name": {
|
|
2876
|
+
builder.addDescriptor(
|
|
2877
|
+
declaration.property,
|
|
2878
|
+
declaration.value.map((v) =>
|
|
2879
|
+
v.type === "none"
|
|
2880
|
+
? "none"
|
|
2881
|
+
: ([{}, "animationName", [v.value], 1] as StyleDescriptor),
|
|
2882
|
+
),
|
|
2883
|
+
);
|
|
2884
|
+
break;
|
|
2885
|
+
}
|
|
2886
|
+
case "animation-play-state": {
|
|
2887
|
+
builder.addDescriptor(declaration.property, declaration.value);
|
|
2888
|
+
break;
|
|
2889
|
+
}
|
|
2890
|
+
case "animation-timing-function": {
|
|
2891
|
+
builder.addDescriptor(
|
|
2892
|
+
declaration.property,
|
|
2893
|
+
parseEasingFunction(declaration.value),
|
|
2894
|
+
);
|
|
2895
|
+
break;
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
export function kebabCase(str: string) {
|
|
2901
|
+
return str.replace(
|
|
2902
|
+
/[A-Z]+(?![a-z])|[A-Z]/g,
|
|
2903
|
+
($, ofs) => (ofs ? "-" : "") + $.toLowerCase(),
|
|
2904
|
+
);
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
function parseBackgroundImage(
|
|
2908
|
+
declaration: DeclarationType<"background-image">,
|
|
2909
|
+
builder: StylesheetBuilder,
|
|
2910
|
+
) {
|
|
2911
|
+
builder.addDescriptor(
|
|
2912
|
+
"experimental_backgroundImage",
|
|
2913
|
+
declaration.value.flatMap((image): StyleDescriptor[] => {
|
|
2914
|
+
switch (image.type) {
|
|
2915
|
+
case "gradient": {
|
|
2916
|
+
const gradient = parseGradient(image.value, builder);
|
|
2917
|
+
return gradient ? [gradient] : [];
|
|
2918
|
+
}
|
|
2919
|
+
case "none":
|
|
2920
|
+
return ["none"];
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
return [];
|
|
2924
|
+
}),
|
|
2925
|
+
);
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2929
|
+
function parseGradient(
|
|
2930
|
+
gradient: Gradient,
|
|
2931
|
+
builder: StylesheetBuilder,
|
|
2932
|
+
): StyleDescriptor {
|
|
2933
|
+
switch (gradient.type) {
|
|
2934
|
+
case "linear": {
|
|
2935
|
+
return [
|
|
2936
|
+
{},
|
|
2937
|
+
"linear-gradient",
|
|
2938
|
+
[
|
|
2939
|
+
parseLineDirection(gradient.direction, builder),
|
|
2940
|
+
...gradient.items.map((item) => parseGradientItem(item, builder)),
|
|
2941
|
+
],
|
|
2942
|
+
];
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
return;
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
function parseLineDirection(
|
|
2950
|
+
lineDirection: LineDirection,
|
|
2951
|
+
builder: StylesheetBuilder,
|
|
2952
|
+
): StyleDescriptor {
|
|
2953
|
+
switch (lineDirection.type) {
|
|
2954
|
+
case "corner":
|
|
2955
|
+
return `to ${lineDirection.horizontal} ${lineDirection.vertical}`;
|
|
2956
|
+
case "horizontal":
|
|
2957
|
+
case "vertical":
|
|
2958
|
+
return `to ${lineDirection.value}`;
|
|
2959
|
+
case "angle":
|
|
2960
|
+
return parseAngle(lineDirection.value, builder);
|
|
2961
|
+
default: {
|
|
2962
|
+
lineDirection satisfies never;
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
return;
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
function parseGradientItem(
|
|
2970
|
+
item: GradientItemFor_DimensionPercentageFor_LengthValue,
|
|
2971
|
+
builder: StylesheetBuilder,
|
|
2972
|
+
): StyleDescriptor {
|
|
2973
|
+
switch (item.type) {
|
|
2974
|
+
case "color-stop": {
|
|
2975
|
+
const args: StyleDescriptor[] = [parseColor(item.color, builder)];
|
|
2976
|
+
if (item.position) {
|
|
2977
|
+
args.push(parseLength(item.position, builder));
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
return [{}, "@colorStop", args, 1];
|
|
2981
|
+
}
|
|
2982
|
+
case "hint":
|
|
2983
|
+
return parseLength(item.value, builder);
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
function parseFilter(
|
|
2988
|
+
declaration: DeclarationType<"filter">,
|
|
2989
|
+
builder: StylesheetBuilder,
|
|
2990
|
+
) {
|
|
2991
|
+
if (declaration.value.type === "none") {
|
|
2992
|
+
return "unset";
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
return declaration.value.value
|
|
2996
|
+
.map((value) => {
|
|
2997
|
+
switch (value.type) {
|
|
2998
|
+
case "opacity":
|
|
2999
|
+
case "blur":
|
|
3000
|
+
case "brightness":
|
|
3001
|
+
case "contrast":
|
|
3002
|
+
case "grayscale":
|
|
3003
|
+
case "invert":
|
|
3004
|
+
case "saturate":
|
|
3005
|
+
case "sepia":
|
|
3006
|
+
return {
|
|
3007
|
+
[value.type]: parseLength(value.value, builder),
|
|
3008
|
+
} as unknown as StyleDescriptor;
|
|
3009
|
+
case "hue-rotate":
|
|
3010
|
+
return {
|
|
3011
|
+
[value.type]: parseAngle(value.value, builder),
|
|
3012
|
+
} as unknown as StyleDescriptor;
|
|
3013
|
+
case "drop-shadow":
|
|
3014
|
+
return [
|
|
3015
|
+
{},
|
|
3016
|
+
toRNProperty(value.type),
|
|
3017
|
+
[
|
|
3018
|
+
parseLength(value.value.xOffset, builder),
|
|
3019
|
+
parseLength(value.value.yOffset, builder),
|
|
3020
|
+
parseLength(value.value.blur, builder),
|
|
3021
|
+
parseColor(value.value.color, builder),
|
|
3022
|
+
],
|
|
3023
|
+
] as unknown as StyleDescriptor;
|
|
3024
|
+
case "url":
|
|
3025
|
+
return;
|
|
3026
|
+
}
|
|
3027
|
+
})
|
|
3028
|
+
.filter((value) => value !== undefined);
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
const namedColors = new Set([
|
|
3032
|
+
"aliceblue",
|
|
3033
|
+
"antiquewhite",
|
|
3034
|
+
"aqua",
|
|
3035
|
+
"aquamarine",
|
|
3036
|
+
"azure",
|
|
3037
|
+
"beige",
|
|
3038
|
+
"bisque",
|
|
3039
|
+
"black",
|
|
3040
|
+
"blanchedalmond",
|
|
3041
|
+
"blue",
|
|
3042
|
+
"blueviolet",
|
|
3043
|
+
"brown",
|
|
3044
|
+
"burlywood",
|
|
3045
|
+
"cadetblue",
|
|
3046
|
+
"chartreuse",
|
|
3047
|
+
"chocolate",
|
|
3048
|
+
"coral",
|
|
3049
|
+
"cornflowerblue",
|
|
3050
|
+
"cornsilk",
|
|
3051
|
+
"crimson",
|
|
3052
|
+
"cyan",
|
|
3053
|
+
"darkblue",
|
|
3054
|
+
"darkcyan",
|
|
3055
|
+
"darkgoldenrod",
|
|
3056
|
+
"darkgray",
|
|
3057
|
+
"darkgreen",
|
|
3058
|
+
"darkgrey",
|
|
3059
|
+
"darkkhaki",
|
|
3060
|
+
"darkmagenta",
|
|
3061
|
+
"darkolivegreen",
|
|
3062
|
+
"darkorange",
|
|
3063
|
+
"darkorchid",
|
|
3064
|
+
"darkred",
|
|
3065
|
+
"darksalmon",
|
|
3066
|
+
"darkseagreen",
|
|
3067
|
+
"darkslateblue",
|
|
3068
|
+
"darkslategrey",
|
|
3069
|
+
"darkturquoise",
|
|
3070
|
+
"darkviolet",
|
|
3071
|
+
"deeppink",
|
|
3072
|
+
"deepskyblue",
|
|
3073
|
+
"dimgray",
|
|
3074
|
+
"dimgrey",
|
|
3075
|
+
"dodgerblue",
|
|
3076
|
+
"firebrick",
|
|
3077
|
+
"floralwhite",
|
|
3078
|
+
"forestgreen",
|
|
3079
|
+
"fuchsia",
|
|
3080
|
+
"gainsboro",
|
|
3081
|
+
"ghostwhite",
|
|
3082
|
+
"gold",
|
|
3083
|
+
"goldenrod",
|
|
3084
|
+
"gray",
|
|
3085
|
+
"green",
|
|
3086
|
+
"greenyellow",
|
|
3087
|
+
"grey",
|
|
3088
|
+
"honeydew",
|
|
3089
|
+
"hotpink",
|
|
3090
|
+
"indianred",
|
|
3091
|
+
"indigo",
|
|
3092
|
+
"ivory",
|
|
3093
|
+
"khaki",
|
|
3094
|
+
"lavender",
|
|
3095
|
+
"lavenderblush",
|
|
3096
|
+
"lawngreen",
|
|
3097
|
+
"lemonchiffon",
|
|
3098
|
+
"lightblue",
|
|
3099
|
+
"lightcoral",
|
|
3100
|
+
"lightcyan",
|
|
3101
|
+
"lightgoldenrodyellow",
|
|
3102
|
+
"lightgray",
|
|
3103
|
+
"lightgreen",
|
|
3104
|
+
"lightgrey",
|
|
3105
|
+
"lightpink",
|
|
3106
|
+
"lightsalmon",
|
|
3107
|
+
"lightseagreen",
|
|
3108
|
+
"lightskyblue",
|
|
3109
|
+
"lightslategrey",
|
|
3110
|
+
"lightsteelblue",
|
|
3111
|
+
"lightyellow",
|
|
3112
|
+
"lime",
|
|
3113
|
+
"limegreen",
|
|
3114
|
+
"linen",
|
|
3115
|
+
"magenta",
|
|
3116
|
+
"maroon",
|
|
3117
|
+
"mediumaquamarine",
|
|
3118
|
+
"mediumblue",
|
|
3119
|
+
"mediumorchid",
|
|
3120
|
+
"mediumpurple",
|
|
3121
|
+
"mediumseagreen",
|
|
3122
|
+
"mediumslateblue",
|
|
3123
|
+
"mediumspringgreen",
|
|
3124
|
+
"mediumturquoise",
|
|
3125
|
+
"mediumvioletred",
|
|
3126
|
+
"midnightblue",
|
|
3127
|
+
"mintcream",
|
|
3128
|
+
"mistyrose",
|
|
3129
|
+
"moccasin",
|
|
3130
|
+
"navajowhite",
|
|
3131
|
+
"navy",
|
|
3132
|
+
"oldlace",
|
|
3133
|
+
"olive",
|
|
3134
|
+
"olivedrab",
|
|
3135
|
+
"orange",
|
|
3136
|
+
"orangered",
|
|
3137
|
+
"orchid",
|
|
3138
|
+
"palegoldenrod",
|
|
3139
|
+
"palegreen",
|
|
3140
|
+
"paleturquoise",
|
|
3141
|
+
"palevioletred",
|
|
3142
|
+
"papayawhip",
|
|
3143
|
+
"peachpuff",
|
|
3144
|
+
"peru",
|
|
3145
|
+
"pink",
|
|
3146
|
+
"plum",
|
|
3147
|
+
"powderblue",
|
|
3148
|
+
"purple",
|
|
3149
|
+
"rebeccapurple",
|
|
3150
|
+
"red",
|
|
3151
|
+
"rosybrown",
|
|
3152
|
+
"royalblue",
|
|
3153
|
+
"saddlebrown",
|
|
3154
|
+
"salmon",
|
|
3155
|
+
"sandybrown",
|
|
3156
|
+
"seagreen",
|
|
3157
|
+
"seashell",
|
|
3158
|
+
"sienna",
|
|
3159
|
+
"silver",
|
|
3160
|
+
"skyblue",
|
|
3161
|
+
"slateblue",
|
|
3162
|
+
"slategray",
|
|
3163
|
+
"snow",
|
|
3164
|
+
"springgreen",
|
|
3165
|
+
"steelblue",
|
|
3166
|
+
"tan",
|
|
3167
|
+
"teal",
|
|
3168
|
+
"thistle",
|
|
3169
|
+
"tomato",
|
|
3170
|
+
"turquoise",
|
|
3171
|
+
"violet",
|
|
3172
|
+
"wheat",
|
|
3173
|
+
"white",
|
|
3174
|
+
"whitesmoke",
|
|
3175
|
+
"yellow",
|
|
3176
|
+
"yellowgreen",
|
|
3177
|
+
]);
|