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/metro/index.ts
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
+
import { dirname, relative, sep } from "node:path";
|
|
2
3
|
import { versions } from "node:process";
|
|
3
|
-
import { sep } from "node:path";
|
|
4
4
|
|
|
5
5
|
import connect from "connect";
|
|
6
|
+
import debug from "debug";
|
|
6
7
|
import type { MetroConfig } from "metro-config";
|
|
7
8
|
|
|
9
|
+
import type { CompilerOptions } from "../compiler";
|
|
8
10
|
import { compile } from "../compiler/compiler";
|
|
11
|
+
import { getNativeInjectionCode, getWebInjectionCode } from "./injection-code";
|
|
12
|
+
import { nativeResolver, webResolver } from "./resolver";
|
|
9
13
|
import { setupTypeScript } from "./typescript";
|
|
10
|
-
import { getInjectionCode } from "./injection-code";
|
|
11
14
|
|
|
12
|
-
export interface WithReactNativeCSSOptions {
|
|
13
|
-
|
|
14
|
-
browserslistEnv?: string | null;
|
|
15
|
-
libName?: string;
|
|
15
|
+
export interface WithReactNativeCSSOptions extends CompilerOptions {
|
|
16
|
+
/* Specify the path to the TypeScript environment file. Defaults types-env.d.ts */
|
|
16
17
|
typescriptEnvPath?: string;
|
|
18
|
+
/* Disable generation of the types-env.d.ts file. Defaults false */
|
|
17
19
|
disableTypeScriptGeneration?: boolean;
|
|
20
|
+
/** Add className to all React Native primitives. Defaults false */
|
|
21
|
+
globalClassNamePolyfill?: boolean;
|
|
22
|
+
hexColors?: boolean;
|
|
18
23
|
}
|
|
19
24
|
|
|
25
|
+
const defaultLogger = debug("react-native-css:metro");
|
|
26
|
+
|
|
20
27
|
export function withReactNativeCSS<
|
|
21
28
|
T extends MetroConfig | (() => Promise<MetroConfig>),
|
|
22
29
|
>(config: T, options?: WithReactNativeCSSOptions): T {
|
|
@@ -26,23 +33,56 @@ export function withReactNativeCSS<
|
|
|
26
33
|
}) as T;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
if (Number(versions.node.split(".")[0]) <
|
|
30
|
-
throw new Error("react-native-css only supports NodeJS >
|
|
36
|
+
if (Number(versions.node.split(".")[0]) < 20) {
|
|
37
|
+
throw new Error("react-native-css only supports NodeJS >20");
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
const {
|
|
41
|
+
disableTypeScriptGeneration,
|
|
42
|
+
typescriptEnvPath,
|
|
43
|
+
globalClassNamePolyfill = false,
|
|
44
|
+
logger = defaultLogger,
|
|
45
|
+
} = options || {};
|
|
46
|
+
|
|
47
|
+
const loggerEnabled = "enabled" in logger ? logger.enabled : true;
|
|
48
|
+
|
|
49
|
+
if (disableTypeScriptGeneration !== true) {
|
|
50
|
+
setupTypeScript(typescriptEnvPath);
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
const originalMiddleware = config.server?.enhanceMiddleware;
|
|
54
|
+
const originalResolver = config.resolver?.resolveRequest;
|
|
55
|
+
|
|
56
|
+
const poisonPillPath = "./poison.pill";
|
|
38
57
|
|
|
39
58
|
return {
|
|
40
59
|
...config,
|
|
41
60
|
transformerPath: require.resolve("./metro-transformer"),
|
|
42
|
-
|
|
43
|
-
...config.
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
resolver: {
|
|
62
|
+
...config.resolver,
|
|
63
|
+
sourceExts: [...(config?.resolver?.sourceExts || []), "css"],
|
|
64
|
+
resolveRequest: (context, moduleName, platform) => {
|
|
65
|
+
if (moduleName === poisonPillPath) {
|
|
66
|
+
return { type: "empty" };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Don't hijack the resolution of react-native imports
|
|
70
|
+
if (!globalClassNamePolyfill) {
|
|
71
|
+
const parentResolver = originalResolver ?? context.resolveRequest;
|
|
72
|
+
return parentResolver(context, moduleName, platform);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const parentResolver = originalResolver ?? context.resolveRequest;
|
|
76
|
+
const resolver = platform === "web" ? webResolver : nativeResolver;
|
|
77
|
+
const resolved = resolver(
|
|
78
|
+
parentResolver,
|
|
79
|
+
context,
|
|
80
|
+
moduleName,
|
|
81
|
+
platform,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return resolved;
|
|
85
|
+
},
|
|
46
86
|
},
|
|
47
87
|
server: {
|
|
48
88
|
...config.server,
|
|
@@ -53,16 +93,34 @@ export function withReactNativeCSS<
|
|
|
53
93
|
if (!bundler.__react_native_css__patched) {
|
|
54
94
|
bundler.__react_native_css__patched = true;
|
|
55
95
|
|
|
56
|
-
const
|
|
96
|
+
const nativeCSSFiles = new Map();
|
|
97
|
+
const webCSSFiles = new Set<string>();
|
|
98
|
+
|
|
99
|
+
const nativeInjectionPath = require.resolve(
|
|
100
|
+
"../runtime/native/metro",
|
|
101
|
+
);
|
|
102
|
+
const nativeInjectionFilepaths = [
|
|
103
|
+
// CommonJS
|
|
104
|
+
nativeInjectionPath,
|
|
105
|
+
// ES Module
|
|
106
|
+
nativeInjectionPath.replace(
|
|
107
|
+
`dist${sep}commonjs`,
|
|
108
|
+
`dist${sep}module`,
|
|
109
|
+
),
|
|
110
|
+
// TypeScript
|
|
111
|
+
nativeInjectionPath
|
|
112
|
+
.replace(`dist${sep}commonjs`, `src`)
|
|
113
|
+
.replace(".js", ".ts"),
|
|
114
|
+
];
|
|
57
115
|
|
|
58
|
-
const
|
|
59
|
-
const
|
|
116
|
+
const webInjectionPath = require.resolve("../runtime/web/metro");
|
|
117
|
+
const webInjectionFilepaths = [
|
|
60
118
|
// CommonJS
|
|
61
|
-
|
|
119
|
+
webInjectionPath,
|
|
62
120
|
// ES Module
|
|
63
|
-
|
|
121
|
+
webInjectionPath.replace(`dist${sep}commonjs`, `dist${sep}module`),
|
|
64
122
|
// TypeScript
|
|
65
|
-
|
|
123
|
+
webInjectionPath
|
|
66
124
|
.replace(`dist${sep}commonjs`, `src`)
|
|
67
125
|
.replace(".js", ".ts"),
|
|
68
126
|
];
|
|
@@ -70,6 +128,8 @@ export function withReactNativeCSS<
|
|
|
70
128
|
// Keep the original
|
|
71
129
|
const transformFile = bundler.transformFile.bind(bundler);
|
|
72
130
|
|
|
131
|
+
const watcher = bundler.getWatcher();
|
|
132
|
+
|
|
73
133
|
// Patch with our functionality
|
|
74
134
|
bundler.transformFile = async function (
|
|
75
135
|
filePath: string,
|
|
@@ -78,53 +138,90 @@ export function withReactNativeCSS<
|
|
|
78
138
|
) {
|
|
79
139
|
const isCss = /\.(s?css|sass)$/.test(filePath);
|
|
80
140
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// The CSS file has changed, we need to recompile the injection file
|
|
103
|
-
if (next !== last) {
|
|
104
|
-
cssFiles.set(filePath, [next, compile(next, {})]);
|
|
105
|
-
|
|
106
|
-
bundler.getWatcher().emit("change", {
|
|
107
|
-
eventsQueue: injectionFilePaths.map((filePath) => ({
|
|
108
|
-
filePath,
|
|
109
|
-
metadata: {
|
|
110
|
-
modifiedTime: Date.now(),
|
|
111
|
-
size: 1, // Can be anything
|
|
112
|
-
type: "virtual", // Can be anything
|
|
141
|
+
if (transformOptions.platform === "web") {
|
|
142
|
+
if (isCss) {
|
|
143
|
+
webCSSFiles.add(filePath);
|
|
144
|
+
} else if (webInjectionFilepaths.includes(filePath)) {
|
|
145
|
+
fileBuffer = getWebInjectionCode(Array.from(webCSSFiles));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return transformFile(filePath, transformOptions, fileBuffer);
|
|
149
|
+
} else {
|
|
150
|
+
// Handle CSS files on native platforms
|
|
151
|
+
if (isCss) {
|
|
152
|
+
const webTransform = await transformFile(
|
|
153
|
+
filePath,
|
|
154
|
+
{
|
|
155
|
+
...transformOptions,
|
|
156
|
+
// Force the platform to web for CSS files
|
|
157
|
+
platform: "web",
|
|
158
|
+
// Let the transformer know that we will handle compilation
|
|
159
|
+
customTransformOptions: {
|
|
160
|
+
...transformOptions.customTransformOptions,
|
|
161
|
+
reactNativeCSSCompile: false,
|
|
113
162
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
163
|
+
},
|
|
164
|
+
fileBuffer,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const lastTransform = nativeCSSFiles.get(filePath);
|
|
168
|
+
const last = lastTransform?.[0];
|
|
169
|
+
const next = webTransform.output[0].data.css.code.toString();
|
|
170
|
+
|
|
171
|
+
// The CSS file has changed, we need to recompile the injection file
|
|
172
|
+
if (next !== last) {
|
|
173
|
+
nativeCSSFiles.set(filePath, [
|
|
174
|
+
next,
|
|
175
|
+
compile(next, {
|
|
176
|
+
hexColors: options?.hexColors,
|
|
177
|
+
}),
|
|
178
|
+
]);
|
|
179
|
+
|
|
180
|
+
watcher.emit("change", {
|
|
181
|
+
eventsQueue: nativeInjectionFilepaths.map((filePath) => ({
|
|
182
|
+
filePath,
|
|
183
|
+
metadata: {
|
|
184
|
+
modifiedTime: Date.now(),
|
|
185
|
+
size: 1, // Can be anything
|
|
186
|
+
type: "virtual", // Can be anything
|
|
187
|
+
},
|
|
188
|
+
type: "change",
|
|
189
|
+
})),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const nativeTransform = await transformFile(
|
|
194
|
+
filePath,
|
|
195
|
+
transformOptions,
|
|
196
|
+
fileBuffer,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// Tell Expo to skip caching this file
|
|
200
|
+
nativeTransform.output[0].data.css = {
|
|
201
|
+
skipCache: true,
|
|
202
|
+
// Expo requires a `code` property
|
|
203
|
+
code: "",
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
return nativeTransform;
|
|
207
|
+
} else if (nativeInjectionFilepaths.includes(filePath)) {
|
|
208
|
+
// If this is the injection file, we to swap its content with the
|
|
209
|
+
// compiled CSS files
|
|
210
|
+
fileBuffer = getNativeInjectionCode(
|
|
211
|
+
Array.from(nativeCSSFiles.keys()).map((key) =>
|
|
212
|
+
relative(dirname(filePath), key),
|
|
213
|
+
),
|
|
214
|
+
Array.from(nativeCSSFiles.values()).map(([, value]) => value),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
if (loggerEnabled && fileBuffer) {
|
|
218
|
+
logger(`Transformed ${filePath}`);
|
|
219
|
+
logger(fileBuffer?.toString());
|
|
220
|
+
}
|
|
117
221
|
}
|
|
118
|
-
} else if (injectionFilePaths.includes(filePath)) {
|
|
119
|
-
// If this is the injection file, we to swap its content with the
|
|
120
|
-
// compiled CSS files
|
|
121
|
-
fileBuffer = getInjectionCode(
|
|
122
|
-
"./api",
|
|
123
|
-
Array.from(cssFiles.values()).map(([, value]) => value),
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
222
|
|
|
127
|
-
|
|
223
|
+
return transformFile(filePath, transformOptions, fileBuffer);
|
|
224
|
+
}
|
|
128
225
|
};
|
|
129
226
|
}
|
|
130
227
|
|
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This is a hack around Expo's handling of CSS files.
|
|
3
|
+
* When a component is inside a lazy() barrier, it is inside a different JS bundle.
|
|
4
|
+
* So when it updates, it only updates its local bundle, not the global one which contains the CSS files.
|
|
5
|
+
*
|
|
6
|
+
* To fix this, we force our code to always import the CSS files.
|
|
7
|
+
* Now the CSS files are in every bundle.
|
|
8
|
+
*
|
|
9
|
+
* We achieve this by collecting all CSS files and injecting them into a special file
|
|
10
|
+
* which is included inside react-native-css's runtime.
|
|
11
|
+
*
|
|
12
|
+
* This is why both of these function add imports for the CSS files.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export function getWebInjectionCode(filePaths: string[]) {
|
|
16
|
+
const importStatements = filePaths
|
|
17
|
+
.map((filePath) => `import "${filePath}";`)
|
|
18
|
+
.join("\n");
|
|
19
|
+
|
|
20
|
+
return Buffer.from(importStatements);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getNativeInjectionCode(
|
|
24
|
+
cssFilePaths: string[],
|
|
25
|
+
values: unknown[],
|
|
26
|
+
) {
|
|
27
|
+
const importStatements = cssFilePaths
|
|
28
|
+
.map((filePath) => `import "${filePath}";`)
|
|
29
|
+
.join("\n");
|
|
30
|
+
const importPath = `import { StyleCollection } from "./api";`;
|
|
3
31
|
const contents = values
|
|
4
32
|
.map((value) => `StyleCollection.inject(${JSON.stringify(value)});`)
|
|
5
33
|
.join("\n");
|
|
6
34
|
|
|
7
|
-
return Buffer.from(
|
|
35
|
+
return Buffer.from(
|
|
36
|
+
`${importStatements}\n${importPath}\n${contents};export {};`,
|
|
37
|
+
);
|
|
8
38
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { basename, resolve, sep } from "node:path";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CustomResolutionContext,
|
|
5
|
+
CustomResolver,
|
|
6
|
+
Resolution,
|
|
7
|
+
} from "metro-resolver";
|
|
8
|
+
|
|
9
|
+
import { allowedModules } from "../babel/allowedModules";
|
|
10
|
+
|
|
11
|
+
const thisModuleDist = resolve(__dirname, "../../../dist");
|
|
12
|
+
const thisModuleSrc = resolve(__dirname, "../../../src");
|
|
13
|
+
|
|
14
|
+
function isFromThisModule(filename: string): boolean {
|
|
15
|
+
return (
|
|
16
|
+
filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function nativeResolver(
|
|
21
|
+
resolver: CustomResolver,
|
|
22
|
+
context: CustomResolutionContext,
|
|
23
|
+
moduleName: string,
|
|
24
|
+
platform: string | null,
|
|
25
|
+
): Resolution {
|
|
26
|
+
const resolution = resolver(context, moduleName, platform);
|
|
27
|
+
|
|
28
|
+
if (
|
|
29
|
+
// Don't include our internal files
|
|
30
|
+
isFromThisModule(context.originModulePath) ||
|
|
31
|
+
// Only operate on source files
|
|
32
|
+
resolution.type !== "sourceFile" ||
|
|
33
|
+
// Skip the React Native barrel file to prevent infinite recursion
|
|
34
|
+
context.originModulePath.endsWith("react-native/index.js") ||
|
|
35
|
+
// Skip anything that isn't importing a React Native component
|
|
36
|
+
!(
|
|
37
|
+
moduleName.startsWith("react-native") ||
|
|
38
|
+
moduleName.startsWith("react-native/")
|
|
39
|
+
)
|
|
40
|
+
) {
|
|
41
|
+
return resolution;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (moduleName === "react-native") {
|
|
45
|
+
return resolver(context, `react-native-css/components`, platform);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// We only care about `react-native/Library/Components/<module>.js` components
|
|
49
|
+
const segments = resolution.filePath.split(sep);
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
51
|
+
const module = basename(segments.at(-1)!).split(".")[0];
|
|
52
|
+
|
|
53
|
+
if (!module || !allowedModules.has(module)) {
|
|
54
|
+
return resolution;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return resolver(context, `react-native-css/components/${module}`, platform);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function webResolver(
|
|
61
|
+
resolver: CustomResolver,
|
|
62
|
+
context: CustomResolutionContext,
|
|
63
|
+
moduleName: string,
|
|
64
|
+
platform: string | null,
|
|
65
|
+
): Resolution {
|
|
66
|
+
const resolution = resolver(context, moduleName, platform);
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
// Don't include our internal files
|
|
70
|
+
isFromThisModule(context.originModulePath) ||
|
|
71
|
+
// Only operate on source files
|
|
72
|
+
resolution.type !== "sourceFile" ||
|
|
73
|
+
// Skip anything that isn't importing from `react-native-web`
|
|
74
|
+
!resolution.filePath.includes(`${sep}react-native-web${sep}`)
|
|
75
|
+
) {
|
|
76
|
+
return resolution;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// We only care about `react-native-web/<segment>/<segment>/<module>/index.js` components
|
|
80
|
+
const segments = resolution.filePath.split(sep);
|
|
81
|
+
const isIndex = segments.at(-1)?.startsWith("index.");
|
|
82
|
+
const module = segments.at(-2);
|
|
83
|
+
|
|
84
|
+
if (!isIndex || !module || !allowedModules.has(module)) {
|
|
85
|
+
return resolution;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return resolver(context, `react-native-css/components/${module}`, platform);
|
|
89
|
+
}
|
package/src/metro/typescript.ts
CHANGED
|
@@ -41,7 +41,7 @@ export function setupTypeScript(
|
|
|
41
41
|
if (!existsSync(envPath)) {
|
|
42
42
|
writeFileSync(
|
|
43
43
|
envPath,
|
|
44
|
-
`/// <reference types="react-native-css/
|
|
44
|
+
`/// <reference types="react-native-css/types" />
|
|
45
45
|
|
|
46
46
|
// NOTE: This file should not be edited and should be committed with your source code. It is generated by ${name}. If you need to move or disable this file, please see the documentation.`,
|
|
47
47
|
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
throw new Error(`react-native-css has encountered a setup error.
|
|
2
|
+
|
|
3
|
+
┌─────-─┐
|
|
4
|
+
| Metro |
|
|
5
|
+
└─────-─┘
|
|
6
|
+
|
|
7
|
+
Either your metro.config.js is missing the 'withReactNativeCSS' wrapper OR
|
|
8
|
+
the resolver.resolveRequest function of your config is being overridden, and not calling the parent resolver.
|
|
9
|
+
|
|
10
|
+
When using 3rd party libraries, please use withReactNativeCSS as the innermost function when composing Metro configs.
|
|
11
|
+
|
|
12
|
+
\`\`\`ts
|
|
13
|
+
const config = getDefaultConfig(__dirname);
|
|
14
|
+
module.exports = with3rdPartyPlugin(
|
|
15
|
+
withReactNativeCSS(config)
|
|
16
|
+
)
|
|
17
|
+
\`\`\`
|
|
18
|
+
|
|
19
|
+
┌─────------─┐
|
|
20
|
+
| NativeWind |
|
|
21
|
+
└─────------─┘
|
|
22
|
+
|
|
23
|
+
If you are using NativeWind with the 'withNativeWind' function, follow the Metro instructions above, but use 'withNativeWind' instead of 'withReactNativeCSS'.
|
|
24
|
+
|
|
25
|
+
┌─────----------─┐
|
|
26
|
+
| Other bundlers |
|
|
27
|
+
└─────----------─┘
|
|
28
|
+
|
|
29
|
+
If you are using another bundler (Vite, Webpack, etc), or non-Metro framework (Next.js, Remix, etc), please ensure you have included 'react-native-css/babel' as a babel preset.
|
|
30
|
+
`);
|
|
31
|
+
|
|
32
|
+
export {};
|
|
@@ -19,19 +19,27 @@ export function testGuards(
|
|
|
19
19
|
inheritedContainers: ContainerContextValue,
|
|
20
20
|
) {
|
|
21
21
|
return state.guards?.some((guard) => {
|
|
22
|
+
let result = false;
|
|
23
|
+
|
|
22
24
|
switch (guard[0]) {
|
|
23
25
|
case "a":
|
|
24
26
|
// Attribute
|
|
25
|
-
|
|
27
|
+
result = currentProps?.[guard[1]] !== guard[2];
|
|
28
|
+
break;
|
|
26
29
|
case "d":
|
|
27
30
|
// DataSet
|
|
28
|
-
|
|
31
|
+
result = currentProps?.dataSet?.[guard[1]] !== guard[2];
|
|
32
|
+
break;
|
|
29
33
|
case "v":
|
|
30
34
|
// Variables
|
|
31
|
-
|
|
35
|
+
result = inheritedVariables[guard[1]] !== guard[2];
|
|
36
|
+
break;
|
|
32
37
|
case "c":
|
|
33
38
|
// Containers
|
|
34
|
-
|
|
39
|
+
result = inheritedContainers[guard[1]] !== guard[2];
|
|
40
|
+
break;
|
|
35
41
|
}
|
|
42
|
+
|
|
43
|
+
return result;
|
|
36
44
|
});
|
|
37
45
|
}
|
|
@@ -38,6 +38,8 @@ function testComparison(mediaQuery: MediaCondition, effect: Effect): Boolean {
|
|
|
38
38
|
const right = mediaQuery[2];
|
|
39
39
|
|
|
40
40
|
switch (mediaQuery[1]) {
|
|
41
|
+
case "platform":
|
|
42
|
+
return right === Platform.OS;
|
|
41
43
|
case "prefers-color-scheme": {
|
|
42
44
|
return right === colorScheme.get(effect);
|
|
43
45
|
}
|
|
@@ -99,3 +99,33 @@ function isDeepEqual(a: unknown, b: unknown): boolean {
|
|
|
99
99
|
|
|
100
100
|
return true;
|
|
101
101
|
}
|
|
102
|
+
|
|
103
|
+
StyleCollection.styles("will-change-variable").set([
|
|
104
|
+
{
|
|
105
|
+
s: [0],
|
|
106
|
+
v: [],
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
StyleCollection.styles("will-change-container").set([
|
|
111
|
+
{
|
|
112
|
+
s: [0],
|
|
113
|
+
c: [],
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
StyleCollection.styles("will-change-animation").set([
|
|
118
|
+
{
|
|
119
|
+
s: [0],
|
|
120
|
+
a: true,
|
|
121
|
+
},
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
StyleCollection.styles("will-change-pressable").set([
|
|
125
|
+
{
|
|
126
|
+
s: [0],
|
|
127
|
+
p: {
|
|
128
|
+
h: 1,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
]);
|
|
@@ -166,31 +166,20 @@ export function updateRules(
|
|
|
166
166
|
let pressable = activeFamily.has(state.ruleEffect);
|
|
167
167
|
|
|
168
168
|
if (Boolean(variables) !== Boolean(state.variables)) {
|
|
169
|
-
|
|
170
|
-
`ReactNativeCss:
|
|
171
|
-
Use modifier ('hover:my-var', 'active:my-var', 'not(true):my-var', etc) to ensure it present in the initial render`,
|
|
169
|
+
console.log(
|
|
170
|
+
`ReactNativeCss: className '${source}' added or removed a variable after the initial render. This causes the components state to be reset and all children be re-mounted. Use the className 'will-change-variable' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
|
|
172
171
|
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
throw new Error(
|
|
177
|
-
`ReactNativeCss: Cannot dynamic add a container context. '${source}' was added after the initial render.
|
|
178
|
-
Use modifier ('hover:container', 'active:container', 'not(true):container', etc) to ensure it present in the initial render`,
|
|
172
|
+
} else if (Boolean(containers) !== Boolean(state.containers)) {
|
|
173
|
+
console.log(
|
|
174
|
+
`ReactNativeCss: className '${source}' added or removed a container after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-container' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
|
|
179
175
|
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
throw new Error(
|
|
184
|
-
`ReactNativeCss: Cannot dynamically change to an animated component. '${source}' was added after the initial render.
|
|
185
|
-
Use 'animation-none' or a modifier ('hover:animation', 'active:animation', 'not(true):animation', etc) to ensure it present in the initial render`,
|
|
176
|
+
} else if (animated !== state.animated) {
|
|
177
|
+
console.log(
|
|
178
|
+
`ReactNativeCss: className '${source}' added or removed an animation after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-animation' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
|
|
186
179
|
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
throw new Error(
|
|
191
|
-
`ReactNativeCss: Cannot dynamically change to a Pressable. '${source}' was added after the initial render.
|
|
192
|
-
The 'hover', 'active', and 'focus' modifiers on a View will convert it to a Pressable.
|
|
193
|
-
Use a modifier ('not(true):hover:my-class') to ensure it present in the initial render`,
|
|
180
|
+
} else if (pressable !== state.pressable) {
|
|
181
|
+
console.log(
|
|
182
|
+
`ReactNativeCss: className '${source}' added or removed a pressable state after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-pressable' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
|
|
194
183
|
);
|
|
195
184
|
}
|
|
196
185
|
}
|
|
@@ -232,7 +221,7 @@ Use a modifier ('not(true):hover:my-class') to ensure it present in the initial
|
|
|
232
221
|
}
|
|
233
222
|
|
|
234
223
|
// Generate a StyleObservable for this unique set of rules / variables
|
|
235
|
-
const stylesObs = stylesFamily(
|
|
224
|
+
const stylesObs = stylesFamily(generateStateHash(state, rules), rules);
|
|
236
225
|
|
|
237
226
|
// Get the guards without subscribing to the observable
|
|
238
227
|
// We will subscribe within the render using the StyleEffect
|
|
@@ -288,21 +277,12 @@ function pushInlineRule(
|
|
|
288
277
|
let hashKeyCount = 0;
|
|
289
278
|
const hashKeyFamily = weakFamily(() => hashKeyCount++);
|
|
290
279
|
|
|
291
|
-
|
|
292
|
-
* Quickly generate a unique hash for a set of numbers.
|
|
293
|
-
* This is not a cryptographic hash, but it is fast and has a low chance of collision.
|
|
294
|
-
*/
|
|
295
|
-
const MOD = 9007199254740871; // Largest prime within safe integer range 2^53
|
|
296
|
-
const PRIME = 31; // A smaller prime for mixing
|
|
297
|
-
export function generateHash(
|
|
280
|
+
export function generateStateHash(
|
|
298
281
|
state: ComponentState,
|
|
299
282
|
iterableKeys?: Iterable<WeakKey>,
|
|
300
283
|
variables?: WeakKey,
|
|
301
284
|
inlineVars?: Set<WeakKey>,
|
|
302
285
|
): string {
|
|
303
|
-
let hash = 0;
|
|
304
|
-
let product = 1; // Used for mixing to enhance uniqueness
|
|
305
|
-
|
|
306
286
|
if (!iterableKeys) {
|
|
307
287
|
return "";
|
|
308
288
|
}
|
|
@@ -317,6 +297,19 @@ export function generateHash(
|
|
|
317
297
|
keys.push(...inlineVars);
|
|
318
298
|
}
|
|
319
299
|
|
|
300
|
+
return generateHash(keys);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Quickly generate a unique hash for a set of numbers.
|
|
305
|
+
* This is not a cryptographic hash, but it is fast and has a low chance of collision.
|
|
306
|
+
*/
|
|
307
|
+
const MOD = 9007199254740871; // Largest prime within safe integer range 2^53
|
|
308
|
+
const PRIME = 31; // A smaller prime for mixing
|
|
309
|
+
export function generateHash(keys: WeakKey[]): string {
|
|
310
|
+
let hash = 0;
|
|
311
|
+
let product = 1; // Used for mixing to enhance uniqueness
|
|
312
|
+
|
|
320
313
|
for (const key of keys) {
|
|
321
314
|
if (!key) continue; // Skip if key is undefined
|
|
322
315
|
|
|
@@ -29,7 +29,7 @@ export const observableBatch: {
|
|
|
29
29
|
|
|
30
30
|
export function observable<Value, Arg = Value>(
|
|
31
31
|
init: Value | Read<Value, Arg>,
|
|
32
|
-
equality = Object.is,
|
|
32
|
+
equality: (value1: Value, value2: Value) => boolean = Object.is,
|
|
33
33
|
) {
|
|
34
34
|
let value: Value;
|
|
35
35
|
let isStatic = typeof init !== "function";
|
|
@@ -72,7 +72,7 @@ export function observable<Value, Arg = Value>(
|
|
|
72
72
|
|
|
73
73
|
function set(arg: Arg) {
|
|
74
74
|
if (isStatic) {
|
|
75
|
-
if (equality(value, arg)) {
|
|
75
|
+
if (equality(value, arg as unknown as Value)) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
value = arg as unknown as Value;
|
|
@@ -233,11 +233,7 @@ export const vh = observable<number>(
|
|
|
233
233
|
export const colorScheme = observable<ColorSchemeName>(
|
|
234
234
|
Appearance.getColorScheme(),
|
|
235
235
|
);
|
|
236
|
-
colorScheme.set(
|
|
237
|
-
colorScheme.get({
|
|
238
|
-
observers: new Set(),
|
|
239
|
-
run: () => Appearance.setColorScheme(colorScheme.get()),
|
|
240
|
-
});
|
|
236
|
+
Appearance.addChangeListener((event) => colorScheme.set(event.colorScheme));
|
|
241
237
|
|
|
242
238
|
/** Containers ****************************************************************/
|
|
243
239
|
|