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
package/src/compiler/compiler.ts
CHANGED
|
@@ -4,53 +4,27 @@ import {
|
|
|
4
4
|
transform as lightningcss,
|
|
5
5
|
type ContainerRule,
|
|
6
6
|
type MediaQuery as CSSMediaQuery,
|
|
7
|
-
type
|
|
8
|
-
type DeclarationBlock,
|
|
7
|
+
type CustomAtRules,
|
|
9
8
|
type MediaRule,
|
|
10
|
-
type ParsedComponent,
|
|
11
9
|
type Rule,
|
|
12
|
-
type SelectorList,
|
|
13
10
|
type TokenOrValue,
|
|
11
|
+
type Visitor,
|
|
14
12
|
} from "lightningcss";
|
|
15
13
|
|
|
16
|
-
import {
|
|
17
|
-
import { buildAddFn } from "./add";
|
|
14
|
+
import { maybeMutateReactNativeOptions, parsePropAtRule } from "./atRules";
|
|
18
15
|
import type {
|
|
19
|
-
AnimationKeyframes_V2,
|
|
20
|
-
CompilerCollection,
|
|
21
16
|
CompilerOptions,
|
|
22
17
|
ContainerQuery,
|
|
23
|
-
MediaCondition,
|
|
24
18
|
ReactNativeCssStyleSheet,
|
|
25
|
-
SpecificityArray,
|
|
26
|
-
StyleRule,
|
|
27
|
-
StyleRuleMapping,
|
|
28
|
-
StyleRuleSet,
|
|
29
19
|
} from "./compiler.types";
|
|
30
20
|
import { parseContainerCondition } from "./container-query";
|
|
31
|
-
import {
|
|
32
|
-
parseDeclaration,
|
|
33
|
-
type AddWarningFn,
|
|
34
|
-
type ParseDeclarationOptions,
|
|
35
|
-
type ParserOptions,
|
|
36
|
-
} from "./declarations";
|
|
21
|
+
import { parseDeclaration } from "./declarations";
|
|
37
22
|
import { extractKeyFrames } from "./keyframes";
|
|
38
23
|
import { parseMediaQuery } from "./media-query";
|
|
39
|
-
import { getSelectors
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
value: {
|
|
44
|
-
name: "react-native";
|
|
45
|
-
prelude: null | Extract<ParsedComponent, { type: "repeated" }>;
|
|
46
|
-
body: {
|
|
47
|
-
type: "declaration-list";
|
|
48
|
-
value: DeclarationBlock & {
|
|
49
|
-
importantDeclarations: never;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
24
|
+
import { getSelectors } from "./selectors";
|
|
25
|
+
import { StylesheetBuilder } from "./stylesheet";
|
|
26
|
+
|
|
27
|
+
const defaultLogger = debug("react-native-css:compiler");
|
|
54
28
|
|
|
55
29
|
/**
|
|
56
30
|
* Converts a CSS file to a collection of style declarations that can be used with the StyleSheet API
|
|
@@ -61,274 +35,193 @@ type ReactNativeAtRule = {
|
|
|
61
35
|
*/
|
|
62
36
|
export function compile(
|
|
63
37
|
code: Buffer | string,
|
|
64
|
-
|
|
38
|
+
options: CompilerOptions = {},
|
|
65
39
|
): ReactNativeCssStyleSheet {
|
|
40
|
+
const { logger = defaultLogger } = options;
|
|
66
41
|
const features = Object.assign({}, options.features);
|
|
67
42
|
|
|
43
|
+
if (options.selectorPrefix && options.selectorPrefix.startsWith(".")) {
|
|
44
|
+
options.selectorPrefix = options.selectorPrefix.slice(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
68
47
|
logger(`Features ${JSON.stringify(features)}`);
|
|
69
48
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
rootVariables: {},
|
|
76
|
-
universalVariables: {},
|
|
77
|
-
appearanceOrder: 1,
|
|
78
|
-
...options,
|
|
79
|
-
features,
|
|
80
|
-
varUsageCount: new Map(),
|
|
81
|
-
};
|
|
49
|
+
if (process.env.NODE_ENV !== "production") {
|
|
50
|
+
if (defaultLogger.enabled) {
|
|
51
|
+
defaultLogger(code.toString());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
82
54
|
|
|
83
|
-
|
|
55
|
+
const builder = new StylesheetBuilder(options);
|
|
84
56
|
|
|
85
|
-
|
|
86
|
-
if (token.type === "function") {
|
|
87
|
-
token.value.arguments.forEach((token) => onVarUsage(token));
|
|
88
|
-
} else if (token.type === "var") {
|
|
89
|
-
const variable = token.value;
|
|
90
|
-
const varName = variable.name.ident;
|
|
91
|
-
collection.varUsageCount.set(
|
|
92
|
-
varName,
|
|
93
|
-
(collection.varUsageCount.get(varName) || 0) + 1,
|
|
94
|
-
);
|
|
57
|
+
logger(`Start lightningcss`);
|
|
95
58
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
59
|
+
const customAtRules: CustomAtRules = {
|
|
60
|
+
"react-native": {
|
|
61
|
+
body: "declaration-list",
|
|
62
|
+
},
|
|
101
63
|
};
|
|
102
64
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
code: typeof code === "string" ? new TextEncoder().encode(code) : code,
|
|
107
|
-
visitor: {
|
|
108
|
-
Declaration(decl) {
|
|
109
|
-
// Track variable usage, we remove any unused variables
|
|
110
|
-
if (decl.property !== "unparsed" && decl.property !== "custom") return;
|
|
111
|
-
decl.value.value.forEach((varObj) => onVarUsage(varObj));
|
|
112
|
-
return decl;
|
|
113
|
-
},
|
|
114
|
-
StyleSheetExit(sheet) {
|
|
115
|
-
logger(`Found ${sheet.rules.length} rules to process`);
|
|
116
|
-
|
|
117
|
-
for (const rule of sheet.rules) {
|
|
118
|
-
// Extract the style declarations and animations from the current rule
|
|
119
|
-
extractRule(rule, collection);
|
|
120
|
-
// We have processed this rule, so now delete it from the AST
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
logger(`Exiting lightningcss`);
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
customAtRules: {
|
|
127
|
-
"react-native": {
|
|
128
|
-
prelude: "<custom-ident>+",
|
|
129
|
-
body: "declaration-list",
|
|
130
|
-
},
|
|
65
|
+
const visitor: Visitor<typeof customAtRules> = {
|
|
66
|
+
Rule(rule) {
|
|
67
|
+
maybeMutateReactNativeOptions(rule, builder);
|
|
131
68
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
69
|
+
StyleSheetExit(sheet) {
|
|
70
|
+
logger(`Found ${sheet.rules.length} rules to process`);
|
|
71
|
+
logger(JSON.stringify(sheet.rules, null, 2));
|
|
72
|
+
|
|
73
|
+
for (const rule of sheet.rules) {
|
|
74
|
+
// Extract the style declarations and animations from the current rule
|
|
75
|
+
extractRule(rule, builder);
|
|
76
|
+
// We have processed this rule, so now delete it from the AST
|
|
77
|
+
}
|
|
139
78
|
|
|
140
|
-
|
|
141
|
-
|
|
79
|
+
logger(`Exiting lightningcss`);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
142
82
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
83
|
+
if (options.stripUnusedVariables) {
|
|
84
|
+
const onVarUsage = (token: TokenOrValue) => {
|
|
85
|
+
if (token.type === "function") {
|
|
86
|
+
token.value.arguments.forEach((token) => onVarUsage(token));
|
|
87
|
+
} else if (token.type === "var") {
|
|
88
|
+
builder.varUsage.add(token.value.name.ident);
|
|
89
|
+
if (token.value.fallback) {
|
|
90
|
+
const fallbackValues = token.value.fallback;
|
|
91
|
+
fallbackValues.forEach((varObj) => onVarUsage(varObj));
|
|
92
|
+
}
|
|
148
93
|
}
|
|
149
|
-
}
|
|
94
|
+
};
|
|
150
95
|
|
|
151
|
-
|
|
96
|
+
visitor.Declaration = (decl) => {
|
|
97
|
+
if (decl.property === "unparsed" || decl.property === "custom") {
|
|
98
|
+
decl.value.value.forEach((token) => onVarUsage(token));
|
|
99
|
+
}
|
|
100
|
+
return decl;
|
|
101
|
+
};
|
|
152
102
|
}
|
|
153
103
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
stylesheetOptions.k = Array.from(
|
|
161
|
-
collection.keyframes as Map<string, AnimationKeyframes_V2[]>,
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
if (Object.keys(collection.rootVariables).length) {
|
|
165
|
-
stylesheetOptions.vr = Object.entries(collection.rootVariables);
|
|
166
|
-
}
|
|
167
|
-
if (Object.keys(collection.universalVariables).length) {
|
|
168
|
-
stylesheetOptions.vu = Object.entries(collection.universalVariables);
|
|
169
|
-
}
|
|
104
|
+
// Use the lightningcss library to traverse the CSS AST and extract style declarations and animations
|
|
105
|
+
lightningcss({
|
|
106
|
+
filename: "style.css", // This is ignored, but required
|
|
107
|
+
code: typeof code === "string" ? new TextEncoder().encode(code) : code,
|
|
108
|
+
visitor,
|
|
109
|
+
});
|
|
170
110
|
|
|
171
|
-
return
|
|
111
|
+
return builder.getNativeStyleSheet();
|
|
172
112
|
}
|
|
173
113
|
|
|
174
|
-
type ExtractableRules = Rule | ReactNativeAtRule;
|
|
175
|
-
|
|
176
114
|
/**
|
|
177
115
|
* Extracts style declarations and animations from a given CSS rule, based on its type.
|
|
178
|
-
*
|
|
179
|
-
* @param {Rule} rule - The CSS rule to extract style declarations and animations from.
|
|
180
|
-
* @param {CompilerCollection} collection - Options for the extraction process, including maps for storing extracted data.
|
|
181
|
-
* @param {CssToReactNativeRuntimeOptions} parseOptions - Options for parsing the CSS code, such as grouping related rules together.
|
|
182
116
|
*/
|
|
183
|
-
function extractRule(
|
|
184
|
-
rule: ExtractableRules,
|
|
185
|
-
collection: CompilerCollection,
|
|
186
|
-
partialStyle: Partial<StyleRule> = {},
|
|
187
|
-
) {
|
|
117
|
+
function extractRule(rule: Rule, builder: StylesheetBuilder) {
|
|
188
118
|
// Check the rule's type to determine which extraction function to call
|
|
189
119
|
switch (rule.type) {
|
|
190
120
|
case "keyframes": {
|
|
191
121
|
// If the rule is a keyframe animation, extract it with the `extractKeyFrames` function
|
|
192
|
-
extractKeyFrames(rule.value,
|
|
122
|
+
extractKeyFrames(rule.value, builder);
|
|
193
123
|
break;
|
|
194
124
|
}
|
|
195
125
|
case "container": {
|
|
196
126
|
// If the rule is a container, extract it with the `extractedContainer` function
|
|
197
|
-
|
|
127
|
+
extractContainer(rule.value, builder);
|
|
198
128
|
break;
|
|
199
129
|
}
|
|
200
130
|
case "media": {
|
|
201
131
|
// If the rule is a media query, extract it with the `extractMedia` function
|
|
202
|
-
extractMedia(rule.value,
|
|
132
|
+
extractMedia(rule.value, builder);
|
|
203
133
|
break;
|
|
204
134
|
}
|
|
205
|
-
case "
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
collection,
|
|
217
|
-
);
|
|
135
|
+
case "nested-declarations": {
|
|
136
|
+
const value = rule.value;
|
|
137
|
+
|
|
138
|
+
const declarationBlock = value.declarations;
|
|
139
|
+
if (declarationBlock) {
|
|
140
|
+
if (declarationBlock.declarations) {
|
|
141
|
+
builder.newRuleFork();
|
|
142
|
+
for (const declaration of declarationBlock.declarations) {
|
|
143
|
+
parseDeclaration(declaration, builder);
|
|
144
|
+
}
|
|
145
|
+
builder.applyRuleToSelectors();
|
|
218
146
|
}
|
|
219
|
-
collection.appearanceOrder++;
|
|
220
|
-
}
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
case "custom": {
|
|
224
|
-
if (isReactNativeAtRule(rule)) {
|
|
225
|
-
extractReactNativeOptions(rule, collection);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function isReactNativeAtRule(
|
|
232
|
-
rule: ExtractableRules,
|
|
233
|
-
): rule is ReactNativeAtRule {
|
|
234
|
-
return rule.type === "custom" && rule.value?.name === "react-native";
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function extractReactNativeOptions(
|
|
238
|
-
rule: ReactNativeAtRule,
|
|
239
|
-
collection: CompilerCollection,
|
|
240
|
-
) {
|
|
241
|
-
const { declarations } = rule.value.body.value;
|
|
242
|
-
if (!declarations) return;
|
|
243
147
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
case "preserve-variables": {
|
|
249
|
-
declaration.value.value.forEach((token) => {
|
|
250
|
-
if (token.type !== "dashed-ident") {
|
|
251
|
-
return;
|
|
148
|
+
if (declarationBlock.importantDeclarations) {
|
|
149
|
+
builder.newRuleFork({ important: true });
|
|
150
|
+
for (const declaration of declarationBlock.importantDeclarations) {
|
|
151
|
+
parseDeclaration(declaration, builder);
|
|
252
152
|
}
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
break;
|
|
153
|
+
builder.applyRuleToSelectors();
|
|
154
|
+
}
|
|
256
155
|
}
|
|
257
|
-
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* @rn-move is a custom at-rule that allows you to move a style property to a different prop/location
|
|
265
|
-
* Its a placeholder concept until we improve the LightningCSS parsing
|
|
266
|
-
*/
|
|
267
|
-
function parseReactNativeStyleAtRule(rules?: (Rule | ReactNativeAtRule)[]) {
|
|
268
|
-
const mapping: StyleRuleMapping = {};
|
|
269
|
-
|
|
270
|
-
if (!rules) return mapping;
|
|
271
|
-
|
|
272
|
-
for (const rule of rules) {
|
|
273
|
-
if (!isReactNativeAtRule(rule)) continue;
|
|
274
|
-
if (!rule.value.prelude) continue;
|
|
275
|
-
|
|
276
|
-
if (rule.value.prelude.value.components[0]?.value !== "rename") {
|
|
277
|
-
continue;
|
|
156
|
+
break;
|
|
278
157
|
}
|
|
158
|
+
case "style": {
|
|
159
|
+
const value = rule.value;
|
|
160
|
+
|
|
161
|
+
const declarationBlock = value.declarations;
|
|
162
|
+
const mapping = parsePropAtRule(value.rules);
|
|
163
|
+
const selectors = getSelectors(
|
|
164
|
+
value.selectors,
|
|
165
|
+
false,
|
|
166
|
+
builder.getOptions(),
|
|
167
|
+
);
|
|
279
168
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (!declarations) continue;
|
|
283
|
-
|
|
284
|
-
for (const declaration of declarations) {
|
|
285
|
-
if (declaration.property !== "custom") continue;
|
|
286
|
-
|
|
287
|
-
let values: string[] = [];
|
|
288
|
-
|
|
289
|
-
for (const [index, value] of declaration.value.value.entries()) {
|
|
290
|
-
if (value.type !== "token") {
|
|
291
|
-
values = [];
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const token = value.value;
|
|
296
|
-
|
|
297
|
-
if (token.type === "delim") {
|
|
298
|
-
// Ignore the dot
|
|
299
|
-
if (token.value === ".") {
|
|
300
|
-
continue;
|
|
301
|
-
}
|
|
169
|
+
// If the rule is a style declaration, extract it with the `getExtractedStyle` function and store it in the `declarations` map
|
|
170
|
+
builder = builder.fork("style", selectors);
|
|
302
171
|
|
|
303
|
-
|
|
304
|
-
|
|
172
|
+
if (declarationBlock) {
|
|
173
|
+
if (declarationBlock.declarations) {
|
|
174
|
+
builder.newRule(mapping);
|
|
175
|
+
for (const declaration of declarationBlock.declarations) {
|
|
176
|
+
parseDeclaration(declaration, builder);
|
|
305
177
|
}
|
|
306
|
-
|
|
307
|
-
// Any other delim is invalid
|
|
308
|
-
values = [];
|
|
309
|
-
break;
|
|
178
|
+
builder.applyRuleToSelectors();
|
|
310
179
|
}
|
|
311
180
|
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
181
|
+
if (declarationBlock.importantDeclarations) {
|
|
182
|
+
builder.newRule(mapping, { important: true });
|
|
183
|
+
for (const declaration of declarationBlock.importantDeclarations) {
|
|
184
|
+
parseDeclaration(declaration, builder);
|
|
185
|
+
}
|
|
186
|
+
builder.applyRuleToSelectors();
|
|
316
187
|
}
|
|
188
|
+
}
|
|
317
189
|
|
|
318
|
-
|
|
319
|
-
|
|
190
|
+
if (value.rules) {
|
|
191
|
+
for (const nestedRule of value.rules) {
|
|
192
|
+
extractRule(nestedRule, builder);
|
|
320
193
|
}
|
|
321
|
-
|
|
322
|
-
values.push(toRNProperty(token.value));
|
|
323
194
|
}
|
|
324
195
|
|
|
325
|
-
|
|
326
|
-
mapping[toRNProperty(declaration.value.name)] = values;
|
|
327
|
-
}
|
|
196
|
+
break;
|
|
328
197
|
}
|
|
198
|
+
case "layer-block":
|
|
199
|
+
for (const layerRule of rule.value.rules) {
|
|
200
|
+
extractRule(layerRule, builder);
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
case "custom":
|
|
204
|
+
case "font-face":
|
|
205
|
+
case "font-palette-values":
|
|
206
|
+
case "font-feature-values":
|
|
207
|
+
case "namespace":
|
|
208
|
+
case "layer-statement":
|
|
209
|
+
case "property":
|
|
210
|
+
case "view-transition":
|
|
211
|
+
case "ignored":
|
|
212
|
+
case "unknown":
|
|
213
|
+
case "import":
|
|
214
|
+
case "page":
|
|
215
|
+
case "supports":
|
|
216
|
+
case "counter-style":
|
|
217
|
+
case "moz-document":
|
|
218
|
+
case "nesting":
|
|
219
|
+
case "viewport":
|
|
220
|
+
case "custom-media":
|
|
221
|
+
case "scope":
|
|
222
|
+
case "starting-style":
|
|
223
|
+
break;
|
|
329
224
|
}
|
|
330
|
-
|
|
331
|
-
return mapping;
|
|
332
225
|
}
|
|
333
226
|
|
|
334
227
|
/**
|
|
@@ -341,7 +234,9 @@ function parseReactNativeStyleAtRule(rules?: (Rule | ReactNativeAtRule)[]) {
|
|
|
341
234
|
*
|
|
342
235
|
* @returns undefined if no screen media queries are found in the mediaRule, else it returns the extracted styles.
|
|
343
236
|
*/
|
|
344
|
-
function extractMedia(mediaRule: MediaRule,
|
|
237
|
+
function extractMedia(mediaRule: MediaRule, builder: StylesheetBuilder) {
|
|
238
|
+
builder = builder.fork("media");
|
|
239
|
+
|
|
345
240
|
// Initialize an empty array to store screen media queries
|
|
346
241
|
const media: CSSMediaQuery[] = [];
|
|
347
242
|
|
|
@@ -366,18 +261,13 @@ function extractMedia(mediaRule: MediaRule, collection: CompilerCollection) {
|
|
|
366
261
|
return;
|
|
367
262
|
}
|
|
368
263
|
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
const m = media
|
|
375
|
-
.map((m) => parseMediaQuery(m, options))
|
|
376
|
-
.filter((m): m is MediaCondition => m !== undefined);
|
|
264
|
+
for (const m of media) {
|
|
265
|
+
parseMediaQuery(m, builder);
|
|
266
|
+
}
|
|
377
267
|
|
|
378
268
|
// Iterate over all rules in the mediaRule and extract their styles using the updated CompilerCollection
|
|
379
269
|
for (const rule of mediaRule.rules) {
|
|
380
|
-
extractRule(rule,
|
|
270
|
+
extractRule(rule, builder);
|
|
381
271
|
}
|
|
382
272
|
}
|
|
383
273
|
|
|
@@ -386,242 +276,24 @@ function extractMedia(mediaRule: MediaRule, collection: CompilerCollection) {
|
|
|
386
276
|
* @param collection - The CompilerCollection object to use when extracting styles.
|
|
387
277
|
* @param parseOptions - The CssToReactNativeRuntimeOptions object to use when parsing styles.
|
|
388
278
|
*/
|
|
389
|
-
function
|
|
279
|
+
function extractContainer(
|
|
390
280
|
containerRule: ContainerRule,
|
|
391
|
-
|
|
281
|
+
builder: StylesheetBuilder,
|
|
392
282
|
) {
|
|
393
|
-
|
|
394
|
-
add: () => {},
|
|
395
|
-
addWarning: () => {},
|
|
396
|
-
};
|
|
283
|
+
builder = builder.fork("container");
|
|
397
284
|
|
|
398
285
|
// Iterate over all rules inside the containerRule and extract their styles using the updated CompilerCollection
|
|
399
286
|
for (const rule of containerRule.rules) {
|
|
400
287
|
const query: ContainerQuery = {
|
|
401
|
-
m: parseContainerCondition(containerRule.condition,
|
|
288
|
+
m: parseContainerCondition(containerRule.condition, builder),
|
|
402
289
|
};
|
|
403
290
|
|
|
404
291
|
if (containerRule.name) {
|
|
405
292
|
query.n = containerRule.name;
|
|
406
293
|
}
|
|
407
294
|
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* @param style - The ExtractedStyle object to use when setting styles.
|
|
414
|
-
* @param selectorList - The SelectorList object containing the selectors to use when setting styles.
|
|
415
|
-
* @param declarations - The declarations object to use when adding declarations.
|
|
416
|
-
*/
|
|
417
|
-
function setStyleForSelectorList(
|
|
418
|
-
extractedStyle: StyleRule,
|
|
419
|
-
selectorList: SelectorList,
|
|
420
|
-
collection: CompilerCollection,
|
|
421
|
-
) {
|
|
422
|
-
const { rules: declarations } = collection;
|
|
423
|
-
|
|
424
|
-
const selectors = getSelectors(extractedStyle, selectorList, collection);
|
|
425
|
-
|
|
426
|
-
if (!(extractedStyle.d || extractedStyle.v)) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
for (const selector of selectors) {
|
|
431
|
-
const style: StyleRule = { ...extractedStyle };
|
|
432
|
-
|
|
433
|
-
if (
|
|
434
|
-
selector.type === "rootVariables" || // :root
|
|
435
|
-
selector.type === "universalVariables" // *
|
|
436
|
-
) {
|
|
437
|
-
const fontSizeValue = style.d?.reverse().find((value) => {
|
|
438
|
-
return typeof value === "object" && "fontSize" in value;
|
|
439
|
-
})?.[0];
|
|
440
|
-
|
|
441
|
-
if (
|
|
442
|
-
typeof collection.inlineRem !== "number" &&
|
|
443
|
-
fontSizeValue &&
|
|
444
|
-
typeof fontSizeValue === "object" &&
|
|
445
|
-
"fontSize" in fontSizeValue &&
|
|
446
|
-
typeof fontSizeValue["fontSize"] === "number"
|
|
447
|
-
) {
|
|
448
|
-
collection.rem = fontSizeValue["fontSize"];
|
|
449
|
-
if (collection.inlineRem === undefined) {
|
|
450
|
-
collection.inlineRem = collection.rem;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
if (!style.v) {
|
|
455
|
-
continue;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
const { type, subtype } = selector;
|
|
459
|
-
collection[type] ??= {};
|
|
460
|
-
for (const [name, value] of style.v) {
|
|
461
|
-
collection[type] ??= {};
|
|
462
|
-
collection[type][name] ??= [undefined];
|
|
463
|
-
if (subtype === "light") {
|
|
464
|
-
collection[type][name][0] = value;
|
|
465
|
-
} else {
|
|
466
|
-
collection[type][name][1] = value;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
continue;
|
|
470
|
-
} else if (selector.type === "className") {
|
|
471
|
-
const specificity: SpecificityArray = [];
|
|
472
|
-
|
|
473
|
-
if (selector.classNames.length === 0) {
|
|
474
|
-
continue;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
for (let index = 0; index < 5; index++) {
|
|
478
|
-
const value =
|
|
479
|
-
(extractedStyle.s[index] ?? 0) + (selector.specificity[index] ?? 0);
|
|
480
|
-
if (value) {
|
|
481
|
-
specificity[index] = value;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const primarySelector = selector.classNames.pop()!;
|
|
486
|
-
|
|
487
|
-
for (const [group, conditions] of selector.classNames) {
|
|
488
|
-
// Add the conditions to the declarations object
|
|
489
|
-
addDeclaration(declarations, group, {
|
|
490
|
-
s: specificity,
|
|
491
|
-
c: [`g:${group}`],
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
primarySelector[1] ??= {};
|
|
495
|
-
primarySelector[1].cq ??= [];
|
|
496
|
-
|
|
497
|
-
const containerQuery: ContainerQuery = {
|
|
498
|
-
n: `g:${group}`,
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
if (conditions) {
|
|
502
|
-
if (conditions.m?.length) {
|
|
503
|
-
containerQuery.m = conditions.m[0];
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
if (conditions.aq) {
|
|
507
|
-
containerQuery.a = conditions.aq;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
if (conditions.p) {
|
|
511
|
-
containerQuery.p = conditions.p;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
primarySelector[1].cq.push(containerQuery);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
const rule: StyleRule = {
|
|
519
|
-
...style,
|
|
520
|
-
s: specificity,
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
const conditions = primarySelector[1];
|
|
524
|
-
|
|
525
|
-
if (conditions) {
|
|
526
|
-
if (conditions.cq) {
|
|
527
|
-
rule.cq ??= [];
|
|
528
|
-
rule.cq.push(...conditions.cq);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
if (conditions.m) {
|
|
532
|
-
rule.m = conditions.m;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
if (conditions.p) {
|
|
536
|
-
rule.p = Object.assign({}, rule.p, conditions.p);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
if (conditions.aq) {
|
|
540
|
-
rule.aq ??= [];
|
|
541
|
-
rule.aq.push(...conditions.aq);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
addDeclaration(declarations, primarySelector[0], rule);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
function addDeclaration(
|
|
551
|
-
declarations: CompilerCollection["rules"],
|
|
552
|
-
className: string,
|
|
553
|
-
style: StyleRule,
|
|
554
|
-
) {
|
|
555
|
-
const existing = declarations.get(className);
|
|
556
|
-
if (existing) {
|
|
557
|
-
existing.push(style);
|
|
558
|
-
} else {
|
|
559
|
-
declarations.set(className, [style]);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function getExtractedStyles(
|
|
564
|
-
declarationBlock: DeclarationBlock<Declaration>,
|
|
565
|
-
collection: CompilerCollection,
|
|
566
|
-
mapping: StyleRuleMapping = {},
|
|
567
|
-
): StyleRule[] {
|
|
568
|
-
const extractedStyles = [];
|
|
569
|
-
|
|
570
|
-
const specificity: SpecificityArray = [];
|
|
571
|
-
specificity[Specificity.Order] = collection.appearanceOrder;
|
|
572
|
-
|
|
573
|
-
if (declarationBlock.declarations && declarationBlock.declarations.length) {
|
|
574
|
-
extractedStyles.push(
|
|
575
|
-
declarationsToStyle(
|
|
576
|
-
declarationBlock.declarations,
|
|
577
|
-
collection,
|
|
578
|
-
specificity,
|
|
579
|
-
mapping,
|
|
580
|
-
),
|
|
581
|
-
);
|
|
582
|
-
}
|
|
295
|
+
builder.addContainerQuery(query);
|
|
583
296
|
|
|
584
|
-
|
|
585
|
-
declarationBlock.importantDeclarations &&
|
|
586
|
-
declarationBlock.importantDeclarations.length
|
|
587
|
-
) {
|
|
588
|
-
specificity[Specificity.Important] = 1;
|
|
589
|
-
extractedStyles.push(
|
|
590
|
-
declarationsToStyle(
|
|
591
|
-
declarationBlock.importantDeclarations,
|
|
592
|
-
collection,
|
|
593
|
-
specificity,
|
|
594
|
-
mapping,
|
|
595
|
-
),
|
|
596
|
-
);
|
|
297
|
+
extractRule(rule, builder);
|
|
597
298
|
}
|
|
598
|
-
|
|
599
|
-
return extractedStyles;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
function declarationsToStyle(
|
|
603
|
-
declarations: Declaration[],
|
|
604
|
-
collection: CompilerCollection,
|
|
605
|
-
specificity: SpecificityArray,
|
|
606
|
-
mapping: StyleRuleMapping,
|
|
607
|
-
): StyleRule {
|
|
608
|
-
const extractedStyle: StyleRule = {
|
|
609
|
-
s: [...specificity],
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
const parseDeclarationOptions: ParseDeclarationOptions = {
|
|
613
|
-
...collection,
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
const addWarning: AddWarningFn = () => {
|
|
617
|
-
// TODO
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
const addFn = buildAddFn(extractedStyle, collection, mapping);
|
|
621
|
-
|
|
622
|
-
for (const declaration of declarations) {
|
|
623
|
-
parseDeclaration(declaration, parseDeclarationOptions, addFn, addWarning);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
return extractedStyle;
|
|
627
299
|
}
|