react-native-css 3.0.0-nightly.4723140 → 3.0.0-nightly.61014be
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/README.md +184 -1
- package/dist/commonjs/babel/allowedModules.js +23 -0
- package/dist/commonjs/babel/allowedModules.js.map +1 -0
- package/dist/commonjs/babel/helpers.js +18 -122
- package/dist/commonjs/babel/helpers.js.map +1 -1
- package/dist/commonjs/babel/import-plugin.js +62 -58
- package/dist/commonjs/babel/import-plugin.js.map +1 -1
- 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 +101 -0
- package/dist/commonjs/compiler/atRules.js.map +1 -0
- package/dist/commonjs/compiler/attributes.test.js +20 -0
- package/dist/commonjs/compiler/attributes.test.js.map +1 -0
- package/dist/commonjs/compiler/compiler.js +143 -344
- package/dist/commonjs/compiler/compiler.js.map +1 -1
- package/dist/commonjs/compiler/compiler.types.js.map +1 -1
- package/dist/commonjs/compiler/container-query.js +10 -10
- package/dist/commonjs/compiler/container-query.js.map +1 -1
- package/dist/commonjs/compiler/declarations.js +1233 -988
- package/dist/commonjs/compiler/declarations.js.map +1 -1
- 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 +15 -24
- package/dist/commonjs/compiler/keyframes.js.map +1 -1
- package/dist/commonjs/compiler/media-query.js +22 -22
- package/dist/commonjs/compiler/media-query.js.map +1 -1
- package/dist/commonjs/compiler/selectors.js +264 -184
- package/dist/commonjs/compiler/selectors.js.map +1 -1
- 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 +385 -0
- package/dist/commonjs/compiler/stylesheet.js.map +1 -0
- package/dist/commonjs/components/Text.js +2 -0
- package/dist/commonjs/components/Text.js.map +1 -1
- package/dist/commonjs/components/View.js +2 -0
- package/dist/commonjs/components/View.js.map +1 -1
- package/dist/commonjs/index.js +11 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/jest/index.js +2 -18
- package/dist/commonjs/jest/index.js.map +1 -1
- package/dist/commonjs/metro/index.js +111 -50
- package/dist/commonjs/metro/index.js.map +1 -1
- package/dist/commonjs/metro/injection-code.js +24 -4
- package/dist/commonjs/metro/injection-code.js.map +1 -1
- package/dist/commonjs/metro/resolver.js +62 -0
- package/dist/commonjs/metro/resolver.js.map +1 -0
- package/dist/commonjs/metro/typescript.js +1 -1
- package/dist/commonjs/poison.pill.js +36 -0
- package/dist/commonjs/poison.pill.js.map +1 -0
- package/dist/commonjs/runtime/native/conditions/guards.js +10 -4
- package/dist/commonjs/runtime/native/conditions/guards.js.map +1 -1
- package/dist/commonjs/runtime/native/conditions/media-query.js +2 -0
- package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
- package/dist/commonjs/runtime/native/index.js +11 -1
- package/dist/commonjs/runtime/native/index.js.map +1 -1
- package/dist/commonjs/runtime/native/injection.js +18 -0
- package/dist/commonjs/runtime/native/injection.js.map +1 -1
- package/dist/commonjs/runtime/native/react/rules.js +23 -27
- package/dist/commonjs/runtime/native/react/rules.js.map +1 -1
- package/dist/commonjs/runtime/native/reactivity.js +1 -5
- package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/animation.js +70 -72
- package/dist/commonjs/runtime/native/styles/animation.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/border.js +12 -0
- package/dist/commonjs/runtime/native/styles/border.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/box-shadow.js +40 -0
- package/dist/commonjs/runtime/native/styles/box-shadow.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/calc.js +33 -61
- package/dist/commonjs/runtime/native/styles/calc.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/calculate-props.js +123 -0
- package/dist/commonjs/runtime/native/styles/calculate-props.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/constants.js +2 -1
- package/dist/commonjs/runtime/native/styles/constants.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/filters.js +84 -0
- package/dist/commonjs/runtime/native/styles/filters.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/index.js +2 -110
- package/dist/commonjs/runtime/native/styles/index.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/platform-functions.js +46 -0
- package/dist/commonjs/runtime/native/styles/platform-functions.js.map +1 -0
- package/dist/commonjs/runtime/native/styles/resolve.js +46 -13
- package/dist/commonjs/runtime/native/styles/resolve.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/shorthand.js +34 -17
- package/dist/commonjs/runtime/native/styles/shorthand.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/transform.js +9 -3
- package/dist/commonjs/runtime/native/styles/transform.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/units.js +7 -4
- package/dist/commonjs/runtime/native/styles/units.js.map +1 -1
- package/dist/commonjs/runtime/native/styles/variables.js +57 -36
- package/dist/commonjs/runtime/native/styles/variables.js.map +1 -1
- package/dist/commonjs/runtime/utils/objects.js +18 -5
- package/dist/commonjs/runtime/utils/objects.js.map +1 -1
- package/dist/commonjs/runtime/utils/style-value.js +7 -0
- package/dist/commonjs/runtime/utils/style-value.js.map +1 -1
- package/dist/commonjs/runtime/web/index.js +1 -0
- package/dist/commonjs/runtime/web/index.js.map +1 -1
- 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 +17 -116
- package/dist/module/babel/helpers.js.map +1 -1
- package/dist/module/babel/import-plugin.js +63 -59
- package/dist/module/babel/import-plugin.js.map +1 -1
- 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 +97 -0
- package/dist/module/compiler/atRules.js.map +1 -0
- package/dist/module/compiler/attributes.test.js +20 -0
- package/dist/module/compiler/attributes.test.js.map +1 -0
- package/dist/module/compiler/compiler.js +144 -345
- package/dist/module/compiler/compiler.js.map +1 -1
- package/dist/module/compiler/compiler.types.js +0 -12
- package/dist/module/compiler/compiler.types.js.map +1 -1
- package/dist/module/compiler/container-query.js +10 -10
- package/dist/module/compiler/container-query.js.map +1 -1
- package/dist/module/compiler/declarations.js +1172 -992
- package/dist/module/compiler/declarations.js.map +1 -1
- 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 +15 -24
- package/dist/module/compiler/keyframes.js.map +1 -1
- package/dist/module/compiler/media-query.js +22 -22
- package/dist/module/compiler/media-query.js.map +1 -1
- package/dist/module/compiler/selectors.js +264 -184
- package/dist/module/compiler/selectors.js.map +1 -1
- 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 +380 -0
- package/dist/module/compiler/stylesheet.js.map +1 -0
- package/dist/module/components/Text.js +1 -0
- package/dist/module/components/Text.js.map +1 -1
- package/dist/module/components/View.js +1 -0
- package/dist/module/components/View.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/jest/index.js +3 -3
- package/dist/module/jest/index.js.map +1 -1
- package/dist/module/metro/index.js +111 -50
- package/dist/module/metro/index.js.map +1 -1
- package/dist/module/metro/injection-code.js +22 -3
- package/dist/module/metro/injection-code.js.map +1 -1
- package/dist/module/metro/resolver.js +57 -0
- package/dist/module/metro/resolver.js.map +1 -0
- package/dist/module/metro/typescript.js +1 -1
- package/dist/module/poison.pill.js +34 -0
- package/dist/module/poison.pill.js.map +1 -0
- package/dist/module/runtime/native/conditions/guards.js +10 -4
- package/dist/module/runtime/native/conditions/guards.js.map +1 -1
- package/dist/module/runtime/native/conditions/media-query.js +2 -0
- package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
- package/dist/module/runtime/native/index.js +1 -2
- package/dist/module/runtime/native/index.js.map +1 -1
- package/dist/module/runtime/native/injection.js +18 -0
- package/dist/module/runtime/native/injection.js.map +1 -1
- package/dist/module/runtime/native/react/rules.js +22 -27
- package/dist/module/runtime/native/react/rules.js.map +1 -1
- package/dist/module/runtime/native/reactivity.js +1 -5
- package/dist/module/runtime/native/reactivity.js.map +1 -1
- package/dist/module/runtime/native/styles/animation.js +68 -71
- package/dist/module/runtime/native/styles/animation.js.map +1 -1
- package/dist/module/runtime/native/styles/border.js +8 -0
- package/dist/module/runtime/native/styles/border.js.map +1 -0
- package/dist/module/runtime/native/styles/box-shadow.js +35 -0
- package/dist/module/runtime/native/styles/box-shadow.js.map +1 -0
- package/dist/module/runtime/native/styles/calc.js +33 -62
- package/dist/module/runtime/native/styles/calc.js.map +1 -1
- package/dist/module/runtime/native/styles/calculate-props.js +118 -0
- package/dist/module/runtime/native/styles/calculate-props.js.map +1 -0
- package/dist/module/runtime/native/styles/constants.js +1 -0
- package/dist/module/runtime/native/styles/constants.js.map +1 -1
- package/dist/module/runtime/native/styles/filters.js +70 -0
- package/dist/module/runtime/native/styles/filters.js.map +1 -0
- package/dist/module/runtime/native/styles/index.js +2 -110
- package/dist/module/runtime/native/styles/index.js.map +1 -1
- package/dist/module/runtime/native/styles/platform-functions.js +36 -0
- package/dist/module/runtime/native/styles/platform-functions.js.map +1 -0
- package/dist/module/runtime/native/styles/resolve.js +47 -14
- package/dist/module/runtime/native/styles/resolve.js.map +1 -1
- package/dist/module/runtime/native/styles/shorthand.js +34 -17
- package/dist/module/runtime/native/styles/shorthand.js.map +1 -1
- package/dist/module/runtime/native/styles/transform.js +9 -3
- package/dist/module/runtime/native/styles/transform.js.map +1 -1
- package/dist/module/runtime/native/styles/units.js +7 -4
- package/dist/module/runtime/native/styles/units.js.map +1 -1
- package/dist/module/runtime/native/styles/variables.js +57 -36
- package/dist/module/runtime/native/styles/variables.js.map +1 -1
- package/dist/module/runtime/utils/objects.js +16 -4
- package/dist/module/runtime/utils/objects.js.map +1 -1
- package/dist/module/runtime/utils/style-value.js +6 -0
- package/dist/module/runtime/utils/style-value.js.map +1 -1
- package/dist/module/runtime/web/index.js +2 -0
- package/dist/module/runtime/web/index.js.map +1 -1
- 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.map +1 -1
- 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 +3 -8
- package/dist/typescript/commonjs/src/babel/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/babel/import-plugin.d.ts.map +1 -1
- 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/attributes.test.d.ts +2 -0
- package/dist/typescript/commonjs/src/compiler/attributes.test.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +27 -108
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/container-query.d.ts +2 -2
- package/dist/typescript/commonjs/src/compiler/container-query.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts +118 -25
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
- 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 +5 -4
- package/dist/typescript/commonjs/src/compiler/keyframes.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/media-query.d.ts +4 -4
- package/dist/typescript/commonjs/src/compiler/media-query.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/selectors.d.ts +10 -5
- package/dist/typescript/commonjs/src/compiler/selectors.d.ts.map +1 -1
- 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 +54 -0
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/Text.d.ts +1 -1
- package/dist/typescript/commonjs/src/components/Text.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/View.d.ts +1 -1
- package/dist/typescript/commonjs/src/components/View.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/index.d.ts +1 -0
- package/dist/typescript/commonjs/src/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts +2 -3
- package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/index.d.ts +5 -4
- package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/injection-code.d.ts +15 -1
- package/dist/typescript/commonjs/src/metro/injection-code.d.ts.map +1 -1
- 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/poison.pill.d.ts +2 -0
- package/dist/typescript/commonjs/src/poison.pill.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/api.d.ts +1 -1
- package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/index.d.ts +1 -1
- package/dist/typescript/commonjs/src/runtime/native/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts +2 -1
- package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts +1 -1
- package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +1 -1
- package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts +3 -2
- package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts +2 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts +3 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/calc.d.ts.map +1 -1
- 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 +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/filters.d.ts +12 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/filters.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts +3 -4
- package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/platform-functions.d.ts +8 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/platform-functions.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts +6 -2
- package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthand.d.ts +3 -4
- package/dist/typescript/commonjs/src/runtime/native/styles/shorthand.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/transform.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/units.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts +1 -1
- package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts +0 -15
- package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/utils/components.d.ts +1 -1
- package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts +2 -1
- package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts +3 -2
- package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime/web/index.d.ts +1 -0
- package/dist/typescript/commonjs/src/runtime/web/index.d.ts.map +1 -1
- 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.map +1 -1
- 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 +3 -8
- package/dist/typescript/module/src/babel/helpers.d.ts.map +1 -1
- package/dist/typescript/module/src/babel/import-plugin.d.ts.map +1 -1
- 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/attributes.test.d.ts +2 -0
- package/dist/typescript/module/src/compiler/attributes.test.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/compiler.d.ts +1 -1
- package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/compiler.types.d.ts +27 -108
- package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/container-query.d.ts +2 -2
- package/dist/typescript/module/src/compiler/container-query.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/declarations.d.ts +118 -25
- package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
- 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 +5 -4
- package/dist/typescript/module/src/compiler/keyframes.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/media-query.d.ts +4 -4
- package/dist/typescript/module/src/compiler/media-query.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/selectors.d.ts +10 -5
- package/dist/typescript/module/src/compiler/selectors.d.ts.map +1 -1
- 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 +54 -0
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -0
- package/dist/typescript/module/src/components/Text.d.ts +1 -1
- package/dist/typescript/module/src/components/Text.d.ts.map +1 -1
- package/dist/typescript/module/src/components/View.d.ts +1 -1
- package/dist/typescript/module/src/components/View.d.ts.map +1 -1
- package/dist/typescript/module/src/index.d.ts +1 -0
- package/dist/typescript/module/src/index.d.ts.map +1 -1
- package/dist/typescript/module/src/jest/index.d.ts +2 -3
- package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/index.d.ts +5 -4
- package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/injection-code.d.ts +15 -1
- package/dist/typescript/module/src/metro/injection-code.d.ts.map +1 -1
- 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/poison.pill.d.ts +2 -0
- package/dist/typescript/module/src/poison.pill.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/api.d.ts +1 -1
- package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/index.d.ts +1 -1
- package/dist/typescript/module/src/runtime/native/index.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/react/rules.d.ts +2 -1
- package/dist/typescript/module/src/runtime/native/react/rules.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts +1 -1
- package/dist/typescript/module/src/runtime/native/reactivity.d.ts +1 -1
- package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/animation.d.ts +3 -2
- package/dist/typescript/module/src/runtime/native/styles/animation.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/border.d.ts +2 -0
- package/dist/typescript/module/src/runtime/native/styles/border.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts +3 -0
- package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/calc.d.ts.map +1 -1
- 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 +1 -0
- package/dist/typescript/module/src/runtime/native/styles/constants.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/filters.d.ts +12 -0
- package/dist/typescript/module/src/runtime/native/styles/filters.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/index.d.ts +3 -4
- package/dist/typescript/module/src/runtime/native/styles/index.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/platform-functions.d.ts +8 -0
- package/dist/typescript/module/src/runtime/native/styles/platform-functions.d.ts.map +1 -0
- package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts +6 -2
- package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/shorthand.d.ts +3 -4
- package/dist/typescript/module/src/runtime/native/styles/shorthand.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts +1 -1
- package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/transform.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/units.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/native/styles/variables.d.ts +1 -1
- package/dist/typescript/module/src/runtime/native/styles/variables.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/runtime.types.d.ts +0 -15
- package/dist/typescript/module/src/runtime/runtime.types.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/utils/components.d.ts +1 -1
- package/dist/typescript/module/src/runtime/utils/objects.d.ts +2 -1
- package/dist/typescript/module/src/runtime/utils/objects.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/utils/style-value.d.ts +3 -2
- package/dist/typescript/module/src/runtime/utils/style-value.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime/web/index.d.ts +1 -0
- package/dist/typescript/module/src/runtime/web/index.d.ts.map +1 -1
- 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 +67 -13
- package/src/babel/allowedModules.ts +24 -0
- package/src/babel/helpers.ts +16 -158
- package/src/babel/import-plugin.ts +125 -132
- package/src/babel/react-native-web.ts +226 -0
- package/src/babel/react-native.ts +226 -0
- package/src/compiler/atRules.ts +144 -0
- package/src/compiler/attributes.test.ts +28 -0
- package/src/compiler/compiler.ts +154 -482
- package/src/compiler/compiler.types.ts +30 -135
- package/src/compiler/container-query.ts +12 -12
- package/src/compiler/declarations.ts +1789 -1971
- package/src/compiler/inheritance.test.ts +121 -0
- package/src/compiler/keyframes.ts +28 -42
- package/src/compiler/media-query.ts +27 -26
- package/src/compiler/selectors.ts +289 -271
- package/src/compiler/split-by-delimiter.ts +19 -0
- package/src/compiler/stylesheet.ts +546 -0
- package/src/components/Text.tsx +2 -0
- package/src/components/View.tsx +2 -0
- package/src/index.ts +2 -0
- package/src/jest/index.ts +6 -5
- package/src/metro/index.ts +161 -64
- package/src/metro/injection-code.ts +33 -3
- package/src/metro/resolver.ts +89 -0
- package/src/metro/typescript.ts +1 -1
- package/src/poison.pill.ts +32 -0
- package/src/runtime/native/conditions/guards.ts +12 -4
- package/src/runtime/native/conditions/media-query.ts +2 -0
- package/src/runtime/native/index.ts +1 -2
- package/src/runtime/native/injection.ts +30 -0
- package/src/runtime/native/react/rules.ts +26 -33
- package/src/runtime/native/reactivity.ts +3 -7
- package/src/runtime/native/styles/animation.ts +143 -104
- package/src/runtime/native/styles/border.ts +10 -0
- package/src/runtime/native/styles/box-shadow.ts +54 -0
- package/src/runtime/native/styles/calc.ts +37 -60
- package/src/runtime/native/styles/calculate-props.ts +165 -0
- package/src/runtime/native/styles/constants.ts +1 -0
- package/src/runtime/native/styles/filters.ts +98 -0
- package/src/runtime/native/styles/index.ts +2 -138
- package/src/runtime/native/styles/platform-functions.ts +50 -0
- package/src/runtime/native/styles/resolve.ts +91 -17
- package/src/runtime/native/styles/shorthand.ts +61 -41
- package/src/runtime/native/styles/transform.ts +10 -4
- package/src/runtime/native/styles/units.ts +9 -4
- package/src/runtime/native/styles/variables.ts +51 -35
- package/src/runtime/runtime.types.ts +0 -25
- package/src/runtime/utils/objects.ts +20 -5
- package/src/runtime/utils/style-value.ts +14 -2
- package/src/runtime/web/index.ts +3 -0
- package/src/runtime/web/metro.ts +2 -0
- package/types.d.ts +70 -0
- package/dist/commonjs/compiler/add.js +0 -175
- package/dist/commonjs/compiler/add.js.map +0 -1
- package/dist/commonjs/components/ActivityIndicator.js +0 -20
- package/dist/commonjs/components/ActivityIndicator.js.map +0 -1
- package/dist/commonjs/components/SafeAreaProvider/index.js +0 -41
- package/dist/commonjs/components/SafeAreaProvider/index.js.map +0 -1
- package/dist/commonjs/components/SafeAreaProvider/index.web.js +0 -13
- package/dist/commonjs/components/SafeAreaProvider/index.web.js.map +0 -1
- package/dist/commonjs/components/TextInput.js +0 -20
- package/dist/commonjs/components/TextInput.js.map +0 -1
- package/dist/module/compiler/add.js +0 -168
- package/dist/module/compiler/add.js.map +0 -1
- package/dist/module/components/ActivityIndicator.js +0 -16
- package/dist/module/components/ActivityIndicator.js.map +0 -1
- package/dist/module/components/SafeAreaProvider/index.js +0 -36
- package/dist/module/components/SafeAreaProvider/index.js.map +0 -1
- package/dist/module/components/SafeAreaProvider/index.web.js +0 -4
- package/dist/module/components/SafeAreaProvider/index.web.js.map +0 -1
- package/dist/module/components/TextInput.js +0 -16
- package/dist/module/components/TextInput.js.map +0 -1
- package/dist/typescript/commonjs/src/compiler/add.d.ts +0 -10
- package/dist/typescript/commonjs/src/compiler/add.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts +0 -3
- package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.d.ts +0 -4
- package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.web.d.ts +0 -2
- package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.web.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/components/TextInput.d.ts +0 -13
- package/dist/typescript/commonjs/src/components/TextInput.d.ts.map +0 -1
- package/dist/typescript/module/src/compiler/add.d.ts +0 -10
- package/dist/typescript/module/src/compiler/add.d.ts.map +0 -1
- package/dist/typescript/module/src/components/ActivityIndicator.d.ts +0 -3
- package/dist/typescript/module/src/components/ActivityIndicator.d.ts.map +0 -1
- package/dist/typescript/module/src/components/SafeAreaProvider/index.d.ts +0 -4
- package/dist/typescript/module/src/components/SafeAreaProvider/index.d.ts.map +0 -1
- package/dist/typescript/module/src/components/SafeAreaProvider/index.web.d.ts +0 -2
- package/dist/typescript/module/src/components/SafeAreaProvider/index.web.d.ts.map +0 -1
- package/dist/typescript/module/src/components/TextInput.d.ts +0 -13
- package/dist/typescript/module/src/components/TextInput.d.ts.map +0 -1
- package/src/compiler/add.ts +0 -257
- package/src/components/ActivityIndicator.tsx +0 -19
- package/src/components/SafeAreaProvider/index.tsx +0 -50
- package/src/components/SafeAreaProvider/index.web.tsx +0 -1
- package/src/components/TextInput.tsx +0 -20
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function splitByDelimiter<T>(
|
|
2
|
+
arr: T[],
|
|
3
|
+
callback: (item: T) => boolean,
|
|
4
|
+
): T[][] {
|
|
5
|
+
const result = [];
|
|
6
|
+
let current = [];
|
|
7
|
+
|
|
8
|
+
for (const item of arr) {
|
|
9
|
+
if (callback(item)) {
|
|
10
|
+
if (current.length > 0) result.push(current);
|
|
11
|
+
current = [];
|
|
12
|
+
} else {
|
|
13
|
+
current.push(item);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (current.length > 0) result.push(current);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isStyleDescriptorArray,
|
|
3
|
+
Specificity,
|
|
4
|
+
specificityCompareFn,
|
|
5
|
+
} from "../runtime/utils";
|
|
6
|
+
import type {
|
|
7
|
+
AnimationKeyframes_V2,
|
|
8
|
+
AnimationRecord,
|
|
9
|
+
CompilerOptions,
|
|
10
|
+
ContainerQuery,
|
|
11
|
+
MediaCondition,
|
|
12
|
+
ReactNativeCssStyleSheet,
|
|
13
|
+
StyleDeclaration,
|
|
14
|
+
StyleDescriptor,
|
|
15
|
+
StyleFunction,
|
|
16
|
+
StyleRule,
|
|
17
|
+
StyleRuleMapping,
|
|
18
|
+
StyleRuleSet,
|
|
19
|
+
VariableRecord,
|
|
20
|
+
} from "./compiler.types";
|
|
21
|
+
import { toRNProperty, type NormalizeSelector } from "./selectors";
|
|
22
|
+
|
|
23
|
+
type BuilderMode = "style" | "media" | "container" | "keyframes";
|
|
24
|
+
|
|
25
|
+
const staticDeclarations = new WeakMap<
|
|
26
|
+
WeakKey,
|
|
27
|
+
Record<string, StyleDescriptor>
|
|
28
|
+
>();
|
|
29
|
+
|
|
30
|
+
const extraRules = new WeakMap<StyleRule, Partial<StyleRule>[]>();
|
|
31
|
+
|
|
32
|
+
export class StylesheetBuilder {
|
|
33
|
+
animationFrames?: AnimationKeyframes_V2[];
|
|
34
|
+
animationDeclarations: StyleDeclaration[] = [];
|
|
35
|
+
|
|
36
|
+
stylesheet: ReactNativeCssStyleSheet = {};
|
|
37
|
+
|
|
38
|
+
varUsage = new Set<string>();
|
|
39
|
+
|
|
40
|
+
private rule: StyleRule = {
|
|
41
|
+
s: [],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
constructor(
|
|
45
|
+
private options: CompilerOptions,
|
|
46
|
+
public mode: BuilderMode = "style",
|
|
47
|
+
private ruleTemplate: StyleRule = {
|
|
48
|
+
s: [],
|
|
49
|
+
},
|
|
50
|
+
private mapping: StyleRuleMapping = {},
|
|
51
|
+
public descriptorProperty?: string,
|
|
52
|
+
private shared: {
|
|
53
|
+
ruleSets: Record<string, StyleRuleSet>;
|
|
54
|
+
rootVariables?: VariableRecord;
|
|
55
|
+
universalVariables?: VariableRecord;
|
|
56
|
+
animations?: AnimationRecord;
|
|
57
|
+
rem: number;
|
|
58
|
+
ruleOrder: number;
|
|
59
|
+
} = { ruleSets: {}, rem: 14, ruleOrder: 0 },
|
|
60
|
+
private selectors?: NormalizeSelector[],
|
|
61
|
+
) {}
|
|
62
|
+
|
|
63
|
+
fork(
|
|
64
|
+
mode = this.mode,
|
|
65
|
+
selectors: NormalizeSelector[] | undefined = this.selectors,
|
|
66
|
+
): StylesheetBuilder {
|
|
67
|
+
this.shared.ruleOrder++;
|
|
68
|
+
return new StylesheetBuilder(
|
|
69
|
+
this.options,
|
|
70
|
+
mode,
|
|
71
|
+
this.cloneRule(),
|
|
72
|
+
{ ...this.mapping },
|
|
73
|
+
this.descriptorProperty,
|
|
74
|
+
this.shared,
|
|
75
|
+
selectors,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
cloneRule({ ...rule } = this.rule): StyleRule {
|
|
80
|
+
rule.s = [...rule.s];
|
|
81
|
+
rule.aq &&= [...rule.aq];
|
|
82
|
+
rule.c &&= [...rule.c];
|
|
83
|
+
rule.cq &&= [...rule.cq];
|
|
84
|
+
rule.d &&= [...rule.d];
|
|
85
|
+
rule.m &&= [...rule.m];
|
|
86
|
+
rule.p &&= { ...rule.p };
|
|
87
|
+
rule.v &&= [...rule.v];
|
|
88
|
+
|
|
89
|
+
return rule;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private createRuleFromPartial(rule: StyleRule, partial: Partial<StyleRule>) {
|
|
93
|
+
rule = this.cloneRule(rule);
|
|
94
|
+
|
|
95
|
+
if (partial.m) {
|
|
96
|
+
rule.m ??= [];
|
|
97
|
+
rule.m.push(...partial.m);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (partial.d) {
|
|
101
|
+
rule.d = partial.d;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return rule;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
extendRule(rule: Partial<StyleRule>) {
|
|
108
|
+
return this.cloneRule({ ...this.rule, ...rule });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getOptions(): CompilerOptions {
|
|
112
|
+
return this.options;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
setOptions<T extends keyof CompilerOptions>(
|
|
116
|
+
key: T,
|
|
117
|
+
value: CompilerOptions[T],
|
|
118
|
+
) {
|
|
119
|
+
this.options[key] = value;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getNativeStyleSheet(): ReactNativeCssStyleSheet {
|
|
123
|
+
const stylesheetOptions: ReactNativeCssStyleSheet = {};
|
|
124
|
+
|
|
125
|
+
const ruleSets = this.getRuleSets();
|
|
126
|
+
if (ruleSets) {
|
|
127
|
+
stylesheetOptions.s = ruleSets;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.shared.rootVariables) {
|
|
131
|
+
stylesheetOptions.vr = Object.entries(this.shared.rootVariables);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (this.shared.universalVariables) {
|
|
135
|
+
stylesheetOptions.vu = Object.entries(this.shared.universalVariables);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.shared.animations) {
|
|
139
|
+
stylesheetOptions.k = Object.entries(this.shared.animations);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return stylesheetOptions;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getRuleSets() {
|
|
146
|
+
const entries = Object.entries(this.shared.ruleSets);
|
|
147
|
+
|
|
148
|
+
if (!entries.length) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return Object.entries(this.shared.ruleSets).map(
|
|
153
|
+
([key, value]) =>
|
|
154
|
+
[key, value.sort((a, b) => specificityCompareFn(a, b))] as const,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
addWarning(
|
|
159
|
+
_type: "property" | "value" | "function",
|
|
160
|
+
_property: string | number,
|
|
161
|
+
): void {
|
|
162
|
+
// TODO
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
newRule(mapping = this.mapping, { important = false } = {}) {
|
|
166
|
+
this.mapping = mapping;
|
|
167
|
+
this.rule = this.cloneRule(this.ruleTemplate);
|
|
168
|
+
this.rule.s[Specificity.Order] = this.shared.ruleOrder;
|
|
169
|
+
if (important) {
|
|
170
|
+
this.rule.s[Specificity.Important] = 1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
newRuleFork({ important = false } = {}) {
|
|
175
|
+
this.rule = this.cloneRule(this.rule);
|
|
176
|
+
this.rule.s[Specificity.Order] = this.shared.ruleOrder;
|
|
177
|
+
if (important) {
|
|
178
|
+
this.rule.s[Specificity.Important] = 1;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
addExtraRule(rule: Partial<StyleRule>) {
|
|
183
|
+
let extraRuleArray = extraRules.get(this.rule);
|
|
184
|
+
if (!extraRuleArray) {
|
|
185
|
+
extraRuleArray = [];
|
|
186
|
+
extraRules.set(this.rule, extraRuleArray);
|
|
187
|
+
}
|
|
188
|
+
extraRuleArray.push(rule);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private addRuleToRuleSet(name: string, rule = this.rule) {
|
|
192
|
+
if (this.shared.ruleSets[name]) {
|
|
193
|
+
this.shared.ruleSets[name].push(rule);
|
|
194
|
+
} else {
|
|
195
|
+
this.shared.ruleSets[name] = [rule];
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
addMediaQuery(condition: MediaCondition) {
|
|
200
|
+
this.rule.m ??= [];
|
|
201
|
+
this.rule.m.push(condition);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
addContainer(value: string[] | false) {
|
|
205
|
+
this.rule.c ??= [];
|
|
206
|
+
|
|
207
|
+
if (value === false) {
|
|
208
|
+
this.rule.c = [];
|
|
209
|
+
} else {
|
|
210
|
+
this.rule.c.push(...value.map((name) => `c:${name}`));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
addUnnamedDescriptor(
|
|
215
|
+
value: StyleDescriptor,
|
|
216
|
+
forceTuple?: boolean,
|
|
217
|
+
rule = this.rule,
|
|
218
|
+
) {
|
|
219
|
+
if (this.descriptorProperty === undefined) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.addDescriptor(this.descriptorProperty, value, forceTuple, rule);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
addDescriptor(
|
|
227
|
+
property: string,
|
|
228
|
+
value: StyleDescriptor,
|
|
229
|
+
forceTuple?: boolean,
|
|
230
|
+
rule = this.rule,
|
|
231
|
+
) {
|
|
232
|
+
if (value === undefined) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (this.mode === "keyframes") {
|
|
237
|
+
property = toRNProperty(property);
|
|
238
|
+
this.pushDescriptor(
|
|
239
|
+
property,
|
|
240
|
+
value,
|
|
241
|
+
this.animationDeclarations,
|
|
242
|
+
forceTuple,
|
|
243
|
+
);
|
|
244
|
+
} else if (property.startsWith("--")) {
|
|
245
|
+
// If we have enabled variable usage tracking, skip unused variables
|
|
246
|
+
if (
|
|
247
|
+
this.options.stripUnusedVariables &&
|
|
248
|
+
!property.startsWith("--__rn-css") &&
|
|
249
|
+
!this.varUsage.has(property)
|
|
250
|
+
) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
rule.v ??= [];
|
|
255
|
+
rule.v.push([property.slice(2), value]);
|
|
256
|
+
} else if (isStyleFunction(value)) {
|
|
257
|
+
const [delayed, usesVariables] = postProcessStyleFunction(value);
|
|
258
|
+
|
|
259
|
+
rule.d ??= [];
|
|
260
|
+
if (value[1] === "@animation") {
|
|
261
|
+
rule.a ??= true;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (usesVariables) {
|
|
265
|
+
rule.dv = 1;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
this.pushDescriptor(
|
|
269
|
+
property,
|
|
270
|
+
value,
|
|
271
|
+
rule.d,
|
|
272
|
+
forceTuple,
|
|
273
|
+
delayed || usesVariables,
|
|
274
|
+
);
|
|
275
|
+
} else {
|
|
276
|
+
if (
|
|
277
|
+
property.startsWith("animation-") ||
|
|
278
|
+
property.startsWith("transition-") ||
|
|
279
|
+
property === "transition"
|
|
280
|
+
) {
|
|
281
|
+
rule.a ??= true;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
rule.d ??= [];
|
|
285
|
+
this.pushDescriptor(property, value, rule.d);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
addShorthand(property: string, options: Record<string, StyleDescriptor>) {
|
|
290
|
+
if (allEqual(...Object.values(options))) {
|
|
291
|
+
this.addDescriptor(property, Object.values(options)[0]);
|
|
292
|
+
} else {
|
|
293
|
+
for (const [name, value] of Object.entries(options)) {
|
|
294
|
+
this.addDescriptor(name, value);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private pushDescriptor(
|
|
300
|
+
property: string,
|
|
301
|
+
value: StyleDescriptor,
|
|
302
|
+
declarations: StyleDeclaration[],
|
|
303
|
+
forceTuple = false,
|
|
304
|
+
delayed = false,
|
|
305
|
+
) {
|
|
306
|
+
property = toRNProperty(property);
|
|
307
|
+
|
|
308
|
+
let propPath: string | string[] =
|
|
309
|
+
this.mapping[property] ?? this.mapping["*"] ?? property;
|
|
310
|
+
|
|
311
|
+
if (Array.isArray(propPath)) {
|
|
312
|
+
const first = propPath[0];
|
|
313
|
+
|
|
314
|
+
if (!first) {
|
|
315
|
+
// This should not happen, but if it does, we skip the property
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (propPath.length === 1) {
|
|
320
|
+
propPath = first;
|
|
321
|
+
} else {
|
|
322
|
+
forceTuple = true;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (isStyleFunction(value)) {
|
|
327
|
+
if (delayed) {
|
|
328
|
+
declarations.push([value, propPath, 1]);
|
|
329
|
+
} else {
|
|
330
|
+
declarations.push([value, propPath]);
|
|
331
|
+
}
|
|
332
|
+
} else if (forceTuple || Array.isArray(propPath)) {
|
|
333
|
+
declarations.push([value, propPath]);
|
|
334
|
+
} else if (Array.isArray(value) && value.some(isStyleFunction)) {
|
|
335
|
+
declarations.push([value, propPath]);
|
|
336
|
+
} else {
|
|
337
|
+
let staticDeclarationRecord = staticDeclarations.get(declarations);
|
|
338
|
+
if (!staticDeclarationRecord) {
|
|
339
|
+
staticDeclarationRecord = {};
|
|
340
|
+
staticDeclarations.set(declarations, staticDeclarationRecord);
|
|
341
|
+
declarations.push(staticDeclarationRecord);
|
|
342
|
+
}
|
|
343
|
+
staticDeclarationRecord[propPath] = value;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
applyRuleToSelectors(selectorList = this.selectors): void {
|
|
348
|
+
if (!selectorList?.length) {
|
|
349
|
+
// If there are no selectors, we cannot apply the rule
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (!this.rule.d && !this.rule.v) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
for (const selector of selectorList) {
|
|
358
|
+
const rule = this.cloneRule();
|
|
359
|
+
|
|
360
|
+
if (selector.type === "className") {
|
|
361
|
+
const {
|
|
362
|
+
specificity,
|
|
363
|
+
className,
|
|
364
|
+
mediaQuery,
|
|
365
|
+
containerQuery,
|
|
366
|
+
pseudoClassesQuery,
|
|
367
|
+
attributeQuery,
|
|
368
|
+
} = selector;
|
|
369
|
+
|
|
370
|
+
// Combine the specificity of the selector with the rule's specificity
|
|
371
|
+
for (let i = 0; i < specificity.length; i++) {
|
|
372
|
+
const spec = specificity[i];
|
|
373
|
+
if (!spec) continue;
|
|
374
|
+
rule.s[i] = spec + (rule.s[i] ?? 0);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (mediaQuery) {
|
|
378
|
+
rule.m ??= [];
|
|
379
|
+
rule.m.push(...mediaQuery);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (containerQuery) {
|
|
383
|
+
rule.cq ??= [];
|
|
384
|
+
rule.cq.push(...containerQuery);
|
|
385
|
+
|
|
386
|
+
for (const query of containerQuery) {
|
|
387
|
+
const name = query.n;
|
|
388
|
+
|
|
389
|
+
if (typeof name !== "string") {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const containerRule: StyleRule = {
|
|
394
|
+
// These are not "real" rules, so they use the lowest specificity
|
|
395
|
+
s: [0],
|
|
396
|
+
c: [name],
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
// Create rules for the parent classes
|
|
400
|
+
this.addRuleToRuleSet(name, containerRule);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (pseudoClassesQuery) {
|
|
405
|
+
rule.p = { ...rule.p, ...pseudoClassesQuery };
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (attributeQuery) {
|
|
409
|
+
rule.aq ??= [];
|
|
410
|
+
rule.aq.push(...attributeQuery);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
this.addRuleToRuleSet(className, rule);
|
|
414
|
+
|
|
415
|
+
const extraRulesArray = extraRules.get(this.rule);
|
|
416
|
+
if (extraRulesArray) {
|
|
417
|
+
for (const extraRule of extraRulesArray) {
|
|
418
|
+
this.addRuleToRuleSet(
|
|
419
|
+
className,
|
|
420
|
+
this.createRuleFromPartial(rule, extraRule),
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
// These can only have variable declarations
|
|
426
|
+
if (!this.rule.v) {
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const { type, subtype } = selector;
|
|
431
|
+
|
|
432
|
+
for (const [name, value] of this.rule.v) {
|
|
433
|
+
this.shared[type] ??= {};
|
|
434
|
+
this.shared[type][name] ??= [undefined];
|
|
435
|
+
this.shared[type][name][subtype === "light" ? 0 : 1] = value;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
addContainerQuery(query: ContainerQuery) {
|
|
442
|
+
this.rule.cq ??= [];
|
|
443
|
+
this.rule.cq.push(query);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
newAnimationFrames(name: string) {
|
|
447
|
+
this.shared.animations ??= {};
|
|
448
|
+
|
|
449
|
+
this.animationFrames = this.shared.animations[name];
|
|
450
|
+
if (!this.animationFrames) {
|
|
451
|
+
this.animationFrames = [];
|
|
452
|
+
this.shared.animations[name] = this.animationFrames;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
newAnimationFrame(progress: string) {
|
|
457
|
+
if (!this.animationFrames) {
|
|
458
|
+
throw new Error(
|
|
459
|
+
"No animation frames defined. Call newAnimationFrames first.",
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
this.animationDeclarations = [];
|
|
464
|
+
this.animationFrames.push([progress, this.animationDeclarations]);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function isStyleFunction(
|
|
469
|
+
value: StyleDescriptor | StyleDescriptor[],
|
|
470
|
+
): value is StyleFunction {
|
|
471
|
+
return Boolean(
|
|
472
|
+
Array.isArray(value) &&
|
|
473
|
+
value.length > 0 &&
|
|
474
|
+
value[0] &&
|
|
475
|
+
typeof value[0] === "object" &&
|
|
476
|
+
Object.keys(value[0]).length === 0,
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function postProcessStyleFunction(value: StyleDescriptor): [
|
|
481
|
+
// Should it be delayed
|
|
482
|
+
boolean,
|
|
483
|
+
// Does it use variables
|
|
484
|
+
boolean,
|
|
485
|
+
] {
|
|
486
|
+
if (!Array.isArray(value)) {
|
|
487
|
+
return [false, false];
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (isStyleDescriptorArray(value)) {
|
|
491
|
+
let shouldDelay = false;
|
|
492
|
+
let usesVariables = false;
|
|
493
|
+
for (const v of value) {
|
|
494
|
+
const [delayed, variables] = postProcessStyleFunction(v);
|
|
495
|
+
shouldDelay ||= delayed;
|
|
496
|
+
usesVariables ||= variables;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return [shouldDelay, usesVariables];
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
let [shouldDelay, usesVariables] = postProcessStyleFunction(value[2]);
|
|
503
|
+
|
|
504
|
+
usesVariables ||= value[1] === "var";
|
|
505
|
+
shouldDelay ||= value[3] === 1;
|
|
506
|
+
|
|
507
|
+
if (shouldDelay) {
|
|
508
|
+
return [true, usesVariables];
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return [false, false];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function allEqual(...params: unknown[]) {
|
|
515
|
+
return params.every((param, index, array) => {
|
|
516
|
+
return index === 0 ? true : equal(array[0], param);
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function equal(a: unknown, b: unknown) {
|
|
521
|
+
if (a === b) return true;
|
|
522
|
+
if (typeof a !== typeof b) return false;
|
|
523
|
+
if (a === null || b === null) return false;
|
|
524
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
525
|
+
if (a.length !== b.length) return false;
|
|
526
|
+
for (let i = 0; i < a.length; i++) {
|
|
527
|
+
if (!equal(a[i], b[i])) return false;
|
|
528
|
+
}
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
532
|
+
if (Object.keys(a).length !== Object.keys(b).length) return false;
|
|
533
|
+
for (const key in a) {
|
|
534
|
+
if (
|
|
535
|
+
!equal(
|
|
536
|
+
(a as Record<string, unknown>)[key],
|
|
537
|
+
(b as Record<string, unknown>)[key],
|
|
538
|
+
)
|
|
539
|
+
)
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return false;
|
|
546
|
+
}
|
package/src/components/Text.tsx
CHANGED
package/src/components/View.tsx
CHANGED
package/src/index.ts
CHANGED
package/src/jest/index.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
import { Dimensions } from "react-native";
|
|
1
|
+
import { Appearance, Dimensions } from "react-native";
|
|
3
2
|
|
|
4
3
|
import { compile, type CompilerOptions } from "../compiler";
|
|
5
4
|
import { StyleCollection } from "../runtime/native/injection";
|
|
6
5
|
import { colorScheme, dimensions, rem } from "../runtime/native/reactivity";
|
|
7
6
|
|
|
8
7
|
declare global {
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
9
9
|
namespace jest {
|
|
10
10
|
interface Matchers<R> {
|
|
11
|
-
|
|
12
|
-
toHaveAnimatedStyle(style?: any): R;
|
|
11
|
+
toHaveAnimatedStyle(style?: unknown): R;
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
export * from "@testing-library/react-native";
|
|
18
16
|
export const testID = "react-native-css";
|
|
19
17
|
|
|
20
18
|
beforeEach(() => {
|
|
21
19
|
StyleCollection.styles.clear();
|
|
22
20
|
dimensions.set(Dimensions.get("window"));
|
|
23
21
|
rem.set(14);
|
|
22
|
+
Appearance.setColorScheme(null);
|
|
24
23
|
colorScheme.set(null);
|
|
25
24
|
});
|
|
26
25
|
|
|
@@ -37,4 +36,6 @@ export function registerCSS(
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
StyleCollection.inject(compiled);
|
|
39
|
+
|
|
40
|
+
return compiled;
|
|
40
41
|
}
|