react-native-css 0.0.0-nightly.2c68396 → 0.0.0-nightly.2e152c9
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 +35 -5
- package/dist/commonjs/babel/helpers.js +7 -0
- package/dist/commonjs/babel/helpers.js.map +1 -1
- package/dist/commonjs/babel/import-plugin.js +20 -8
- package/dist/commonjs/babel/import-plugin.js.map +1 -1
- package/dist/commonjs/babel/react-native-web.js +17 -4
- package/dist/commonjs/babel/react-native-web.js.map +1 -1
- package/dist/commonjs/babel/react-native.js +9 -4
- package/dist/commonjs/babel/react-native.js.map +1 -1
- package/dist/commonjs/compiler/atRules.js +35 -0
- package/dist/commonjs/compiler/atRules.js.map +1 -1
- package/dist/commonjs/compiler/compiler.js +198 -39
- package/dist/commonjs/compiler/compiler.js.map +1 -1
- package/dist/commonjs/compiler/container-query.js +6 -1
- package/dist/commonjs/compiler/container-query.js.map +1 -1
- package/dist/commonjs/compiler/declarations.js +190 -101
- package/dist/commonjs/compiler/declarations.js.map +1 -1
- package/dist/commonjs/compiler/individual-transforms.js +129 -0
- package/dist/commonjs/compiler/individual-transforms.js.map +1 -0
- package/dist/commonjs/compiler/inline-variables.js +47 -1
- package/dist/commonjs/compiler/inline-variables.js.map +1 -1
- package/dist/commonjs/compiler/lightningcss-loader.js +11 -8
- package/dist/commonjs/compiler/lightningcss-loader.js.map +1 -1
- package/dist/commonjs/compiler/media-query.js +16 -6
- package/dist/commonjs/compiler/media-query.js.map +1 -1
- package/dist/commonjs/compiler/selector-builder.js +16 -4
- package/dist/commonjs/compiler/selector-builder.js.map +1 -1
- package/dist/commonjs/compiler/stylesheet.js +33 -9
- package/dist/commonjs/compiler/stylesheet.js.map +1 -1
- package/dist/commonjs/compiler/supports.js +1 -3
- package/dist/commonjs/compiler/supports.js.map +1 -1
- package/dist/commonjs/components/FlatList.js +1 -0
- package/dist/commonjs/components/FlatList.js.map +1 -1
- package/dist/commonjs/components/ImageBackground.js +2 -6
- package/dist/commonjs/components/ImageBackground.js.map +1 -1
- package/dist/commonjs/components/KeyboardAvoidingView.js +2 -3
- package/dist/commonjs/components/KeyboardAvoidingView.js.map +1 -1
- package/dist/commonjs/components/SafeAreaProvider.js +13 -0
- package/dist/commonjs/components/SafeAreaProvider.js.map +1 -0
- package/dist/commonjs/components/index.cjs +49 -1
- package/dist/commonjs/components/index.cjs.map +1 -1
- package/dist/commonjs/components/react-native-safe-area-context.native.js +10 -0
- package/dist/commonjs/components/react-native-safe-area-context.native.js.map +1 -1
- package/dist/commonjs/jest/index.js +3 -1
- package/dist/commonjs/jest/index.js.map +1 -1
- package/dist/commonjs/metro/cache-version.js +43 -0
- package/dist/commonjs/metro/cache-version.js.map +1 -0
- package/dist/commonjs/metro/index.js +2 -0
- package/dist/commonjs/metro/index.js.map +1 -1
- package/dist/commonjs/metro/metro-transformer.js +16 -3
- package/dist/commonjs/metro/metro-transformer.js.map +1 -1
- package/dist/commonjs/metro/typescript.js +26 -6
- package/dist/commonjs/metro/typescript.js.map +1 -1
- package/dist/commonjs/metro/warnings.js +135 -0
- package/dist/commonjs/metro/warnings.js.map +1 -0
- package/dist/commonjs/native/api.js +16 -11
- package/dist/commonjs/native/api.js.map +1 -1
- package/dist/commonjs/native/conditions/attributes.js +16 -9
- package/dist/commonjs/native/conditions/attributes.js.map +1 -1
- package/dist/commonjs/native/conditions/container-query.js +11 -11
- package/dist/commonjs/native/conditions/container-query.js.map +1 -1
- package/dist/commonjs/native/conditions/guards.js +7 -0
- package/dist/commonjs/native/conditions/guards.js.map +1 -1
- package/dist/commonjs/native/conditions/media-query.js +1 -1
- package/dist/commonjs/native/conditions/media-query.js.map +1 -1
- package/dist/commonjs/native/objects.js +11 -18
- package/dist/commonjs/native/objects.js.map +1 -1
- package/dist/commonjs/native/react/interaction.js +10 -5
- package/dist/commonjs/native/react/interaction.js.map +1 -1
- package/dist/commonjs/native/react/rules.js +45 -38
- package/dist/commonjs/native/react/rules.js.map +1 -1
- package/dist/commonjs/native/react/useNativeCss.js +70 -15
- package/dist/commonjs/native/react/useNativeCss.js.map +1 -1
- package/dist/commonjs/native/react/usePassthrough.js +5 -2
- package/dist/commonjs/native/react/usePassthrough.js.map +1 -1
- package/dist/commonjs/native/reactivity.js +64 -24
- package/dist/commonjs/native/reactivity.js.map +1 -1
- package/dist/commonjs/native/reanimated.js +15 -3
- package/dist/commonjs/native/reanimated.js.map +1 -1
- package/dist/commonjs/native/styles/calculate-props.js +139 -26
- package/dist/commonjs/native/styles/calculate-props.js.map +1 -1
- package/dist/commonjs/native/styles/functions/animation-timing.js +2 -1
- package/dist/commonjs/native/styles/functions/animation-timing.js.map +1 -1
- package/dist/commonjs/native/styles/functions/color-mix.js +43 -29
- package/dist/commonjs/native/styles/functions/color-mix.js.map +1 -1
- package/dist/commonjs/native/styles/functions/filters.js +19 -5
- package/dist/commonjs/native/styles/functions/filters.js.map +1 -1
- package/dist/commonjs/native/styles/functions/numeric-functions.js +4 -3
- package/dist/commonjs/native/styles/functions/numeric-functions.js.map +1 -1
- package/dist/commonjs/native/styles/functions/platform-functions.js +2 -1
- package/dist/commonjs/native/styles/functions/platform-functions.js.map +1 -1
- package/dist/commonjs/native/styles/functions/string-functions.js +22 -6
- package/dist/commonjs/native/styles/functions/string-functions.js.map +1 -1
- package/dist/commonjs/native/styles/functions/transform-functions.js +95 -105
- package/dist/commonjs/native/styles/functions/transform-functions.js.map +1 -1
- package/dist/commonjs/native/styles/index.js +303 -49
- package/dist/commonjs/native/styles/index.js.map +1 -1
- package/dist/commonjs/native/styles/resolve.js +136 -19
- package/dist/commonjs/native/styles/resolve.js.map +1 -1
- package/dist/commonjs/native/styles/scale-factor.js +12 -0
- package/dist/commonjs/native/styles/scale-factor.js.map +1 -0
- package/dist/commonjs/native/styles/shorthands/_handler.js +10 -0
- package/dist/commonjs/native/styles/shorthands/_handler.js.map +1 -1
- package/dist/commonjs/native/styles/shorthands/animation.js +6 -3
- package/dist/commonjs/native/styles/shorthands/animation.js.map +1 -1
- package/dist/commonjs/native/styles/shorthands/box-shadow.js +41 -20
- package/dist/commonjs/native/styles/shorthands/box-shadow.js.map +1 -1
- package/dist/commonjs/native/styles/shorthands/index.js +11 -0
- package/dist/commonjs/native/styles/shorthands/index.js.map +1 -1
- package/dist/commonjs/native/styles/shorthands/logical-border-width.js +22 -0
- package/dist/commonjs/native/styles/shorthands/logical-border-width.js.map +1 -0
- package/dist/commonjs/native/styles/shorthands/transform.js +31 -8
- package/dist/commonjs/native/styles/shorthands/transform.js.map +1 -1
- package/dist/commonjs/native/styles/variables.js +165 -48
- package/dist/commonjs/native/styles/variables.js.map +1 -1
- package/dist/commonjs/native-internal/root.js +46 -7
- package/dist/commonjs/native-internal/root.js.map +1 -1
- package/dist/commonjs/native-internal/style-collection.js +22 -37
- package/dist/commonjs/native-internal/style-collection.js.map +1 -1
- package/dist/commonjs/native-internal/variables.js +1 -1
- package/dist/commonjs/native-internal/variables.js.map +1 -1
- package/dist/commonjs/utilities/dot-notation.types.js +4 -0
- package/dist/commonjs/utilities/equality.js +41 -0
- package/dist/commonjs/utilities/equality.js.map +1 -0
- package/dist/commonjs/utilities/index.js +11 -0
- package/dist/commonjs/utilities/index.js.map +1 -1
- package/dist/commonjs/utilities/style-descriptor.js +32 -8
- package/dist/commonjs/utilities/style-descriptor.js.map +1 -1
- package/dist/commonjs/web/api.js +2 -2
- package/dist/commonjs/web/api.js.map +1 -1
- package/dist/commonjs/web/assign-style.js +4 -1
- package/dist/commonjs/web/assign-style.js.map +1 -1
- package/dist/module/babel/helpers.js +6 -0
- package/dist/module/babel/helpers.js.map +1 -1
- package/dist/module/babel/import-plugin.js +22 -10
- package/dist/module/babel/import-plugin.js.map +1 -1
- package/dist/module/babel/react-native-web.js +16 -4
- package/dist/module/babel/react-native-web.js.map +1 -1
- package/dist/module/babel/react-native.js +9 -4
- package/dist/module/babel/react-native.js.map +1 -1
- package/dist/module/compiler/atRules.js +33 -0
- package/dist/module/compiler/atRules.js.map +1 -1
- package/dist/module/compiler/compiler.js +200 -41
- package/dist/module/compiler/compiler.js.map +1 -1
- package/dist/module/compiler/compiler.types.js +2 -0
- package/dist/module/compiler/compiler.types.js.map +1 -1
- package/dist/module/compiler/container-query.js +6 -1
- package/dist/module/compiler/container-query.js.map +1 -1
- package/dist/module/compiler/declarations.js +190 -100
- package/dist/module/compiler/declarations.js.map +1 -1
- package/dist/module/compiler/individual-transforms.js +125 -0
- package/dist/module/compiler/individual-transforms.js.map +1 -0
- package/dist/module/compiler/inline-variables.js +47 -1
- package/dist/module/compiler/inline-variables.js.map +1 -1
- package/dist/module/compiler/lightningcss-loader.js +10 -8
- package/dist/module/compiler/lightningcss-loader.js.map +1 -1
- package/dist/module/compiler/media-query.js +16 -6
- package/dist/module/compiler/media-query.js.map +1 -1
- package/dist/module/compiler/selector-builder.js +16 -5
- package/dist/module/compiler/selector-builder.js.map +1 -1
- package/dist/module/compiler/stylesheet.js +33 -9
- package/dist/module/compiler/stylesheet.js.map +1 -1
- package/dist/module/compiler/supports.js +1 -3
- package/dist/module/compiler/supports.js.map +1 -1
- package/dist/module/components/FlatList.js +1 -0
- package/dist/module/components/FlatList.js.map +1 -1
- package/dist/module/components/ImageBackground.js +2 -6
- package/dist/module/components/ImageBackground.js.map +1 -1
- package/dist/module/components/KeyboardAvoidingView.js +2 -3
- package/dist/module/components/KeyboardAvoidingView.js.map +1 -1
- package/dist/module/components/SafeAreaProvider.js +4 -0
- package/dist/module/components/SafeAreaProvider.js.map +1 -0
- package/dist/module/components/index.cjs +49 -1
- package/dist/module/components/index.cjs.map +1 -1
- package/dist/module/components/react-native-safe-area-context.native.js +9 -1
- package/dist/module/components/react-native-safe-area-context.native.js.map +1 -1
- package/dist/module/jest/index.js +3 -1
- package/dist/module/jest/index.js.map +1 -1
- package/dist/module/metro/cache-version.js +39 -0
- package/dist/module/metro/cache-version.js.map +1 -0
- package/dist/module/metro/index.js +2 -0
- package/dist/module/metro/index.js.map +1 -1
- package/dist/module/metro/metro-transformer.js +16 -3
- package/dist/module/metro/metro-transformer.js.map +1 -1
- package/dist/module/metro/typescript.js +26 -6
- package/dist/module/metro/typescript.js.map +1 -1
- package/dist/module/metro/warnings.js +131 -0
- package/dist/module/metro/warnings.js.map +1 -0
- package/dist/module/native/api.js +18 -13
- package/dist/module/native/api.js.map +1 -1
- package/dist/module/native/conditions/attributes.js +16 -9
- package/dist/module/native/conditions/attributes.js.map +1 -1
- package/dist/module/native/conditions/container-query.js +11 -11
- package/dist/module/native/conditions/container-query.js.map +1 -1
- package/dist/module/native/conditions/guards.js +7 -0
- package/dist/module/native/conditions/guards.js.map +1 -1
- package/dist/module/native/conditions/media-query.js +1 -1
- package/dist/module/native/conditions/media-query.js.map +1 -1
- package/dist/module/native/objects.js +11 -18
- package/dist/module/native/objects.js.map +1 -1
- package/dist/module/native/react/interaction.js +10 -5
- package/dist/module/native/react/interaction.js.map +1 -1
- package/dist/module/native/react/rules.js +46 -39
- package/dist/module/native/react/rules.js.map +1 -1
- package/dist/module/native/react/useNativeCss.js +73 -18
- package/dist/module/native/react/useNativeCss.js.map +1 -1
- package/dist/module/native/react/usePassthrough.js +5 -2
- package/dist/module/native/react/usePassthrough.js.map +1 -1
- package/dist/module/native/reactivity.js +58 -22
- package/dist/module/native/reactivity.js.map +1 -1
- package/dist/module/native/reanimated.js +15 -3
- package/dist/module/native/reanimated.js.map +1 -1
- package/dist/module/native/styles/calculate-props.js +139 -26
- package/dist/module/native/styles/calculate-props.js.map +1 -1
- package/dist/module/native/styles/functions/animation-timing.js +2 -1
- package/dist/module/native/styles/functions/animation-timing.js.map +1 -1
- package/dist/module/native/styles/functions/color-mix.js +43 -29
- package/dist/module/native/styles/functions/color-mix.js.map +1 -1
- package/dist/module/native/styles/functions/filters.js +17 -4
- package/dist/module/native/styles/functions/filters.js.map +1 -1
- package/dist/module/native/styles/functions/numeric-functions.js +4 -3
- package/dist/module/native/styles/functions/numeric-functions.js.map +1 -1
- package/dist/module/native/styles/functions/platform-functions.js +2 -1
- package/dist/module/native/styles/functions/platform-functions.js.map +1 -1
- package/dist/module/native/styles/functions/string-functions.js +19 -5
- package/dist/module/native/styles/functions/string-functions.js.map +1 -1
- package/dist/module/native/styles/functions/transform-functions.js +93 -104
- package/dist/module/native/styles/functions/transform-functions.js.map +1 -1
- package/dist/module/native/styles/index.js +304 -49
- package/dist/module/native/styles/index.js.map +1 -1
- package/dist/module/native/styles/resolve.js +136 -19
- package/dist/module/native/styles/resolve.js.map +1 -1
- package/dist/module/native/styles/scale-factor.js +8 -0
- package/dist/module/native/styles/scale-factor.js.map +1 -0
- package/dist/module/native/styles/shorthands/_handler.js +11 -1
- package/dist/module/native/styles/shorthands/_handler.js.map +1 -1
- package/dist/module/native/styles/shorthands/animation.js +6 -3
- package/dist/module/native/styles/shorthands/animation.js.map +1 -1
- package/dist/module/native/styles/shorthands/box-shadow.js +43 -21
- package/dist/module/native/styles/shorthands/box-shadow.js.map +1 -1
- package/dist/module/native/styles/shorthands/index.js +1 -0
- package/dist/module/native/styles/shorthands/index.js.map +1 -1
- package/dist/module/native/styles/shorthands/logical-border-width.js +18 -0
- package/dist/module/native/styles/shorthands/logical-border-width.js.map +1 -0
- package/dist/module/native/styles/shorthands/transform.js +31 -8
- package/dist/module/native/styles/shorthands/transform.js.map +1 -1
- package/dist/module/native/styles/variables.js +166 -50
- package/dist/module/native/styles/variables.js.map +1 -1
- package/dist/module/native-internal/root.js +44 -7
- package/dist/module/native-internal/root.js.map +1 -1
- package/dist/module/native-internal/style-collection.js +10 -37
- package/dist/module/native-internal/style-collection.js.map +1 -1
- package/dist/module/native-internal/variables.js +2 -2
- package/dist/module/native-internal/variables.js.map +1 -1
- package/dist/module/utilities/dot-notation.types.js +2 -0
- package/dist/module/utilities/equality.js +37 -0
- package/dist/module/utilities/equality.js.map +1 -0
- package/dist/module/utilities/index.js +1 -0
- package/dist/module/utilities/index.js.map +1 -1
- package/dist/module/utilities/style-descriptor.js +30 -8
- package/dist/module/utilities/style-descriptor.js.map +1 -1
- package/dist/module/web/api.js +2 -2
- package/dist/module/web/api.js.map +1 -1
- package/dist/module/web/assign-style.js +4 -1
- package/dist/module/web/assign-style.js.map +1 -1
- package/dist/typescript/commonjs/src/babel/helpers.d.ts +2 -1
- 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 +2 -1
- package/dist/typescript/commonjs/src/babel/react-native-web.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/babel/react-native.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/atRules.d.ts +4 -1
- package/dist/typescript/commonjs/src/compiler/atRules.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts +1 -5
- package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +13 -0
- package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts +2 -3
- package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/individual-transforms.d.ts +10 -0
- package/dist/typescript/commonjs/src/compiler/individual-transforms.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/compiler/inline-variables.d.ts +1 -1
- package/dist/typescript/commonjs/src/compiler/inline-variables.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/lightningcss-loader.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/media-query.d.ts +1 -1
- package/dist/typescript/commonjs/src/compiler/media-query.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts +2 -1
- package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +10 -10
- package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/FlatList.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/ImageBackground.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/KeyboardAvoidingView.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/components/SafeAreaProvider.d.ts +2 -0
- package/dist/typescript/commonjs/src/components/SafeAreaProvider.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/react-native-safe-area-context.native.d.ts +2 -1
- package/dist/typescript/commonjs/src/components/react-native-safe-area-context.native.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/jest/index.d.ts +2 -10
- package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/cache-version.d.ts +8 -0
- package/dist/typescript/commonjs/src/metro/cache-version.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/metro/index.d.ts +4 -0
- package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/metro-transformer.d.ts +9 -4
- package/dist/typescript/commonjs/src/metro/metro-transformer.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/typescript.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/metro/warnings.d.ts +13 -0
- package/dist/typescript/commonjs/src/metro/warnings.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/native/api.d.ts +5 -9
- package/dist/typescript/commonjs/src/native/api.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/conditions/container-query.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/conditions/guards.d.ts +2 -1
- package/dist/typescript/commonjs/src/native/conditions/guards.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/objects.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/react/interaction.d.ts +1 -1
- package/dist/typescript/commonjs/src/native/react/interaction.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/react/rules.d.ts +7 -2
- package/dist/typescript/commonjs/src/native/react/rules.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/react/useNativeCss.d.ts +0 -3
- package/dist/typescript/commonjs/src/native/react/useNativeCss.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/react/usePassthrough.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/reactivity.d.ts +15 -3
- package/dist/typescript/commonjs/src/native/reactivity.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/reanimated.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/calculate-props.d.ts +11 -2
- package/dist/typescript/commonjs/src/native/styles/calculate-props.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/functions/animation-timing.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/functions/color-mix.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/functions/filters.d.ts +2 -0
- package/dist/typescript/commonjs/src/native/styles/functions/filters.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/functions/numeric-functions.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/functions/platform-functions.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/functions/string-functions.d.ts +2 -0
- package/dist/typescript/commonjs/src/native/styles/functions/string-functions.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/functions/transform-functions.d.ts +2 -0
- package/dist/typescript/commonjs/src/native/styles/functions/transform-functions.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/index.d.ts +5 -4
- package/dist/typescript/commonjs/src/native/styles/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/resolve.d.ts +4 -1
- package/dist/typescript/commonjs/src/native/styles/resolve.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/scale-factor.d.ts +2 -0
- package/dist/typescript/commonjs/src/native/styles/scale-factor.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/native/styles/shorthands/_handler.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/shorthands/animation.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/shorthands/box-shadow.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/shorthands/index.d.ts +1 -0
- package/dist/typescript/commonjs/src/native/styles/shorthands/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/shorthands/logical-border-width.d.ts +4 -0
- package/dist/typescript/commonjs/src/native/styles/shorthands/logical-border-width.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/native/styles/shorthands/transform.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native/styles/variables.d.ts +3 -2
- package/dist/typescript/commonjs/src/native/styles/variables.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native-internal/root.d.ts +38 -0
- package/dist/typescript/commonjs/src/native-internal/root.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native-internal/style-collection.d.ts +2 -2
- package/dist/typescript/commonjs/src/native-internal/style-collection.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/native-internal/variables.d.ts +1 -1
- package/dist/typescript/commonjs/src/native-internal/variables.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/runtime.types.d.ts +11 -6
- package/dist/typescript/commonjs/src/runtime.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/utilities/dot-notation.types.d.ts +2 -1
- package/dist/typescript/commonjs/src/utilities/dot-notation.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/utilities/equality.d.ts +2 -0
- package/dist/typescript/commonjs/src/utilities/equality.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/utilities/index.d.ts +1 -0
- package/dist/typescript/commonjs/src/utilities/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/utilities/style-descriptor.d.ts +14 -1
- package/dist/typescript/commonjs/src/utilities/style-descriptor.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/web/api.d.ts +5 -5
- package/dist/typescript/commonjs/src/web/api.d.ts.map +1 -1
- package/dist/typescript/commonjs/src/web/assign-style.d.ts.map +1 -1
- package/dist/typescript/module/src/babel/helpers.d.ts +2 -1
- package/dist/typescript/module/src/babel/helpers.d.ts.map +1 -1
- package/dist/typescript/module/src/babel/import-plugin.d.ts +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 +2 -1
- package/dist/typescript/module/src/babel/react-native-web.d.ts.map +1 -1
- package/dist/typescript/module/src/babel/react-native.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/atRules.d.ts +6 -3
- package/dist/typescript/module/src/compiler/atRules.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/compiler.d.ts +3 -7
- package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/compiler.types.d.ts +14 -1
- 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 +4 -5
- package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/index.d.ts +2 -2
- package/dist/typescript/module/src/compiler/index.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/individual-transforms.d.ts +10 -0
- package/dist/typescript/module/src/compiler/individual-transforms.d.ts.map +1 -0
- package/dist/typescript/module/src/compiler/inline-variables.d.ts +2 -2
- package/dist/typescript/module/src/compiler/inline-variables.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/keyframes.d.ts +2 -2
- package/dist/typescript/module/src/compiler/keyframes.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/lightningcss-loader.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/media-query.d.ts +3 -3
- package/dist/typescript/module/src/compiler/media-query.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/pseudo-elements.d.ts +1 -1
- package/dist/typescript/module/src/compiler/pseudo-elements.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/selector-builder.d.ts +3 -2
- package/dist/typescript/module/src/compiler/selector-builder.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/selectors.d.ts +2 -2
- package/dist/typescript/module/src/compiler/selectors.d.ts.map +1 -1
- package/dist/typescript/module/src/compiler/stylesheet.d.ts +10 -10
- package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
- package/dist/typescript/module/src/components/FlatList.d.ts.map +1 -1
- package/dist/typescript/module/src/components/ImageBackground.d.ts.map +1 -1
- package/dist/typescript/module/src/components/KeyboardAvoidingView.d.ts.map +1 -1
- package/dist/typescript/module/src/components/SafeAreaProvider.d.ts +2 -0
- package/dist/typescript/module/src/components/SafeAreaProvider.d.ts.map +1 -0
- package/dist/typescript/module/src/components/index.d.ts +16 -16
- package/dist/typescript/module/src/components/index.d.ts.map +1 -1
- package/dist/typescript/module/src/components/react-native-safe-area-context.native.d.ts +2 -1
- package/dist/typescript/module/src/components/react-native-safe-area-context.native.d.ts.map +1 -1
- package/dist/typescript/module/src/jest/index.d.ts +2 -10
- package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/cache-version.d.ts +8 -0
- package/dist/typescript/module/src/metro/cache-version.d.ts.map +1 -0
- package/dist/typescript/module/src/metro/index.d.ts +5 -1
- package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/metro-transformer.d.ts +10 -5
- package/dist/typescript/module/src/metro/metro-transformer.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/typescript.d.ts.map +1 -1
- package/dist/typescript/module/src/metro/warnings.d.ts +13 -0
- package/dist/typescript/module/src/metro/warnings.d.ts.map +1 -0
- package/dist/typescript/module/src/native/api.d.ts +6 -10
- package/dist/typescript/module/src/native/api.d.ts.map +1 -1
- package/dist/typescript/module/src/native/conditions/attributes.d.ts +1 -1
- package/dist/typescript/module/src/native/conditions/attributes.d.ts.map +1 -1
- package/dist/typescript/module/src/native/conditions/container-query.d.ts +2 -2
- package/dist/typescript/module/src/native/conditions/container-query.d.ts.map +1 -1
- package/dist/typescript/module/src/native/conditions/guards.d.ts +4 -3
- package/dist/typescript/module/src/native/conditions/guards.d.ts.map +1 -1
- package/dist/typescript/module/src/native/conditions/index.d.ts +3 -3
- package/dist/typescript/module/src/native/conditions/index.d.ts.map +1 -1
- package/dist/typescript/module/src/native/conditions/media-query.d.ts +1 -1
- package/dist/typescript/module/src/native/conditions/media-query.d.ts.map +1 -1
- package/dist/typescript/module/src/native/index.d.ts +3 -3
- package/dist/typescript/module/src/native/index.d.ts.map +1 -1
- package/dist/typescript/module/src/native/objects.d.ts.map +1 -1
- package/dist/typescript/module/src/native/react/interaction.d.ts +2 -2
- package/dist/typescript/module/src/native/react/interaction.d.ts.map +1 -1
- package/dist/typescript/module/src/native/react/rules.d.ts +9 -4
- package/dist/typescript/module/src/native/react/rules.d.ts.map +1 -1
- package/dist/typescript/module/src/native/react/useNativeCss.d.ts +4 -7
- package/dist/typescript/module/src/native/react/useNativeCss.d.ts.map +1 -1
- package/dist/typescript/module/src/native/react/usePassthrough.d.ts +1 -1
- package/dist/typescript/module/src/native/react/usePassthrough.d.ts.map +1 -1
- package/dist/typescript/module/src/native/reactivity.d.ts +15 -3
- package/dist/typescript/module/src/native/reactivity.d.ts.map +1 -1
- package/dist/typescript/module/src/native/reanimated.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/calculate-props.d.ts +13 -4
- package/dist/typescript/module/src/native/styles/calculate-props.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/animation-timing.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/functions/animation-timing.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/calc.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/functions/calc.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/color-mix.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/functions/color-mix.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/filters.d.ts +3 -1
- package/dist/typescript/module/src/native/styles/functions/filters.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/index.d.ts +8 -8
- package/dist/typescript/module/src/native/styles/functions/index.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/numeric-functions.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/functions/numeric-functions.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/platform-functions.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/functions/platform-functions.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/string-functions.d.ts +3 -1
- package/dist/typescript/module/src/native/styles/functions/string-functions.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/functions/transform-functions.d.ts +3 -1
- package/dist/typescript/module/src/native/styles/functions/transform-functions.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/index.d.ts +9 -8
- package/dist/typescript/module/src/native/styles/index.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/line-height.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/line-height.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/resolve.d.ts +7 -4
- package/dist/typescript/module/src/native/styles/resolve.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/scale-factor.d.ts +2 -0
- package/dist/typescript/module/src/native/styles/scale-factor.d.ts.map +1 -0
- package/dist/typescript/module/src/native/styles/shorthands/_handler.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/_handler.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/animation.d.ts +2 -2
- package/dist/typescript/module/src/native/styles/shorthands/animation.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/border.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/border.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/box-shadow.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/box-shadow.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/index.d.ts +6 -5
- package/dist/typescript/module/src/native/styles/shorthands/index.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/logical-border-width.d.ts +4 -0
- package/dist/typescript/module/src/native/styles/shorthands/logical-border-width.d.ts.map +1 -0
- package/dist/typescript/module/src/native/styles/shorthands/text-shadow.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/text-shadow.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/transform.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/shorthands/transform.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/units.d.ts +1 -1
- package/dist/typescript/module/src/native/styles/units.d.ts.map +1 -1
- package/dist/typescript/module/src/native/styles/variables.d.ts +4 -3
- package/dist/typescript/module/src/native/styles/variables.d.ts.map +1 -1
- package/dist/typescript/module/src/native-internal/index.d.ts +3 -3
- package/dist/typescript/module/src/native-internal/index.d.ts.map +1 -1
- package/dist/typescript/module/src/native-internal/root.d.ts +39 -1
- package/dist/typescript/module/src/native-internal/root.d.ts.map +1 -1
- package/dist/typescript/module/src/native-internal/style-collection.d.ts +3 -3
- package/dist/typescript/module/src/native-internal/style-collection.d.ts.map +1 -1
- package/dist/typescript/module/src/native-internal/variables.d.ts +2 -2
- package/dist/typescript/module/src/native-internal/variables.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime.d.ts +1 -1
- package/dist/typescript/module/src/runtime.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime.native.d.ts +1 -1
- package/dist/typescript/module/src/runtime.native.d.ts.map +1 -1
- package/dist/typescript/module/src/runtime.types.d.ts +11 -6
- package/dist/typescript/module/src/runtime.types.d.ts.map +1 -1
- package/dist/typescript/module/src/utilities/dot-notation.types.d.ts +2 -1
- package/dist/typescript/module/src/utilities/dot-notation.types.d.ts.map +1 -1
- package/dist/typescript/module/src/utilities/equality.d.ts +2 -0
- package/dist/typescript/module/src/utilities/equality.d.ts.map +1 -0
- package/dist/typescript/module/src/utilities/index.d.ts +4 -3
- package/dist/typescript/module/src/utilities/index.d.ts.map +1 -1
- package/dist/typescript/module/src/utilities/specificity.d.ts +2 -2
- package/dist/typescript/module/src/utilities/specificity.d.ts.map +1 -1
- package/dist/typescript/module/src/utilities/style-descriptor.d.ts +14 -1
- package/dist/typescript/module/src/utilities/style-descriptor.d.ts.map +1 -1
- package/dist/typescript/module/src/web/api.d.ts +5 -5
- package/dist/typescript/module/src/web/api.d.ts.map +1 -1
- package/dist/typescript/module/src/web/assign-style.d.ts.map +1 -1
- package/dist/typescript/module/src/web/index.d.ts +3 -3
- package/dist/typescript/module/src/web/index.d.ts.map +1 -1
- package/node/babel.mjs +4 -0
- package/node/compiler.mjs +2 -0
- package/node/metro.mjs +2 -0
- package/package.json +78 -31
- package/src/babel/helpers.ts +8 -1
- package/src/babel/import-plugin.ts +31 -16
- package/src/babel/react-native-web.ts +32 -4
- package/src/babel/react-native.ts +9 -4
- package/src/compiler/atRules.ts +44 -0
- package/src/compiler/compiler.ts +282 -50
- package/src/compiler/compiler.types.ts +17 -0
- package/src/compiler/container-query.ts +8 -3
- package/src/compiler/declarations.ts +385 -247
- package/src/compiler/individual-transforms.ts +129 -0
- package/src/compiler/inline-variables.ts +67 -0
- package/src/compiler/lightningcss-loader.ts +16 -15
- package/src/compiler/media-query.ts +20 -9
- package/src/compiler/selector-builder.ts +32 -5
- package/src/compiler/stylesheet.ts +51 -15
- package/src/compiler/supports.ts +1 -3
- package/src/components/FlatList.tsx +1 -0
- package/src/components/ImageBackground.tsx +2 -6
- package/src/components/KeyboardAvoidingView.tsx +2 -3
- package/src/components/SafeAreaProvider.tsx +1 -0
- package/src/components/index.cts +49 -1
- package/src/components/react-native-safe-area-context.native.tsx +20 -0
- package/src/jest/index.ts +3 -1
- package/src/metro/cache-version.ts +48 -0
- package/src/metro/index.ts +7 -0
- package/src/metro/metro-transformer.ts +26 -8
- package/src/metro/typescript.ts +53 -6
- package/src/metro/warnings.ts +187 -0
- package/src/native/api.tsx +26 -18
- package/src/native/conditions/attributes.ts +26 -9
- package/src/native/conditions/container-query.ts +11 -9
- package/src/native/conditions/guards.ts +13 -1
- package/src/native/conditions/media-query.ts +1 -1
- package/src/native/objects.ts +12 -22
- package/src/native/react/interaction.ts +11 -6
- package/src/native/react/rules.ts +58 -45
- package/src/native/react/useNativeCss.ts +85 -18
- package/src/native/react/usePassthrough.ts +3 -2
- package/src/native/reactivity.ts +79 -24
- package/src/native/reanimated.ts +24 -5
- package/src/native/styles/calculate-props.ts +179 -28
- package/src/native/styles/functions/animation-timing.ts +3 -1
- package/src/native/styles/functions/color-mix.ts +45 -39
- package/src/native/styles/functions/filters.ts +21 -6
- package/src/native/styles/functions/numeric-functions.ts +7 -6
- package/src/native/styles/functions/platform-functions.ts +3 -1
- package/src/native/styles/functions/string-functions.ts +25 -5
- package/src/native/styles/functions/transform-functions.ts +111 -64
- package/src/native/styles/index.ts +340 -53
- package/src/native/styles/resolve.ts +188 -29
- package/src/native/styles/scale-factor.ts +9 -0
- package/src/native/styles/shorthands/_handler.ts +14 -1
- package/src/native/styles/shorthands/animation.ts +8 -2
- package/src/native/styles/shorthands/box-shadow.ts +46 -25
- package/src/native/styles/shorthands/index.ts +1 -0
- package/src/native/styles/shorthands/logical-border-width.ts +32 -0
- package/src/native/styles/shorthands/transform.ts +36 -11
- package/src/native/styles/variables.ts +242 -45
- package/src/native-internal/root.ts +83 -13
- package/src/native-internal/style-collection.ts +21 -46
- package/src/native-internal/variables.tsx +6 -4
- package/src/runtime.types.ts +17 -15
- package/src/utilities/dot-notation.types.ts +4 -3
- package/src/utilities/equality.ts +41 -0
- package/src/utilities/index.ts +1 -0
- package/src/utilities/style-descriptor.ts +36 -14
- package/src/web/api.tsx +7 -12
- package/src/web/assign-style.ts +2 -1
- package/types.d.ts +0 -20
- package/dist/commonjs/compiler/inheritance.test.js +0 -78
- package/dist/commonjs/compiler/inheritance.test.js.map +0 -1
- package/dist/module/compiler/inheritance.test.js +0 -78
- package/dist/module/compiler/inheritance.test.js.map +0 -1
- package/dist/typescript/commonjs/.config/eslint.config.d.mts +0 -3
- package/dist/typescript/commonjs/.config/eslint.config.d.mts.map +0 -1
- package/dist/typescript/commonjs/eslint.config.d.mts +0 -2
- package/dist/typescript/commonjs/eslint.config.d.mts.map +0 -1
- package/dist/typescript/commonjs/example/app.config.d.ts +0 -4
- package/dist/typescript/commonjs/example/app.config.d.ts.map +0 -1
- package/dist/typescript/commonjs/example/index.d.ts +0 -2
- package/dist/typescript/commonjs/example/index.d.ts.map +0 -1
- package/dist/typescript/commonjs/example/metro.config.d.ts +0 -3
- package/dist/typescript/commonjs/example/metro.config.d.ts.map +0 -1
- package/dist/typescript/commonjs/example/postcss.config.d.mts +0 -7
- package/dist/typescript/commonjs/example/postcss.config.d.mts.map +0 -1
- package/dist/typescript/commonjs/example/src/App.d.ts +0 -3
- package/dist/typescript/commonjs/example/src/App.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts +0 -2
- package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts.map +0 -1
- package/dist/typescript/module/.config/eslint.config.d.mts +0 -3
- package/dist/typescript/module/.config/eslint.config.d.mts.map +0 -1
- package/dist/typescript/module/eslint.config.d.mts +0 -2
- package/dist/typescript/module/eslint.config.d.mts.map +0 -1
- package/dist/typescript/module/example/app.config.d.ts +0 -4
- package/dist/typescript/module/example/app.config.d.ts.map +0 -1
- package/dist/typescript/module/example/index.d.ts +0 -2
- package/dist/typescript/module/example/index.d.ts.map +0 -1
- package/dist/typescript/module/example/metro.config.d.ts +0 -3
- package/dist/typescript/module/example/metro.config.d.ts.map +0 -1
- package/dist/typescript/module/example/postcss.config.d.mts +0 -7
- package/dist/typescript/module/example/postcss.config.d.mts.map +0 -1
- package/dist/typescript/module/example/src/App.d.ts +0 -3
- package/dist/typescript/module/example/src/App.d.ts.map +0 -1
- package/dist/typescript/module/src/compiler/inheritance.test.d.ts +0 -2
- package/dist/typescript/module/src/compiler/inheritance.test.d.ts.map +0 -1
- package/src/compiler/inheritance.test.ts +0 -121
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { resolve } from "path";
|
|
2
|
-
|
|
3
1
|
import { type NodePath } from "@babel/traverse";
|
|
4
2
|
import tBabelTypes, {
|
|
3
|
+
type CallExpression,
|
|
5
4
|
type ImportDeclaration,
|
|
6
5
|
type ObjectPattern,
|
|
7
6
|
type Statement,
|
|
@@ -9,12 +8,13 @@ import tBabelTypes, {
|
|
|
9
8
|
} from "@babel/types";
|
|
10
9
|
|
|
11
10
|
import { allowedModules } from "./allowedModules";
|
|
11
|
+
import { resolveImportSource } from "./helpers";
|
|
12
12
|
|
|
13
13
|
type BabelTypes = typeof tBabelTypes;
|
|
14
14
|
|
|
15
15
|
function parseReactNativeWebSource(source: string, filename: string) {
|
|
16
16
|
if (source.startsWith(".")) {
|
|
17
|
-
source =
|
|
17
|
+
source = resolveImportSource(filename, source);
|
|
18
18
|
|
|
19
19
|
const internalPath = source.split("react-native-web/dist")[1];
|
|
20
20
|
if (!internalPath) {
|
|
@@ -48,6 +48,7 @@ export function handleReactNativeWebImport(
|
|
|
48
48
|
filename: string,
|
|
49
49
|
): Statement[] | undefined {
|
|
50
50
|
const { specifiers, source } = declaration;
|
|
51
|
+
if (declaration.importKind && declaration.importKind !== "value") return;
|
|
51
52
|
|
|
52
53
|
const rnwSource = parseReactNativeWebSource(source.value, filename);
|
|
53
54
|
if (!rnwSource) {
|
|
@@ -76,7 +77,7 @@ export function handleReactNativeWebImport(
|
|
|
76
77
|
} else {
|
|
77
78
|
statements.push(
|
|
78
79
|
t.importDeclaration(
|
|
79
|
-
[t.importSpecifier(specifier.local,
|
|
80
|
+
[t.importSpecifier(specifier.local, t.identifier(name))],
|
|
80
81
|
t.stringLiteral(`react-native-css/components/${name}`),
|
|
81
82
|
),
|
|
82
83
|
);
|
|
@@ -89,6 +90,10 @@ export function handleReactNativeWebImport(
|
|
|
89
90
|
),
|
|
90
91
|
);
|
|
91
92
|
} else {
|
|
93
|
+
if (specifier.importKind && specifier.importKind !== "value") {
|
|
94
|
+
statements.push(t.importDeclaration([specifier], source));
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
92
97
|
const localName = t.isStringLiteral(specifier.imported)
|
|
93
98
|
? specifier.imported.value
|
|
94
99
|
: specifier.imported.name;
|
|
@@ -158,6 +163,28 @@ export function handleReactNativeWebIdentifierRequire(
|
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
|
|
166
|
+
export function handleReactNativeWebInteropRequireDefault(
|
|
167
|
+
path: NodePath<VariableDeclaration>,
|
|
168
|
+
t: BabelTypes,
|
|
169
|
+
id: string,
|
|
170
|
+
init: CallExpression,
|
|
171
|
+
source: string,
|
|
172
|
+
filename: string,
|
|
173
|
+
) {
|
|
174
|
+
const parsed = parseReactNativeWebSource(source, filename);
|
|
175
|
+
if (!parsed) return;
|
|
176
|
+
|
|
177
|
+
const wrapped = t.cloneNode(init);
|
|
178
|
+
wrapped.arguments = [
|
|
179
|
+
t.callExpression(t.identifier("require"), [t.stringLiteral(parsed.source)]),
|
|
180
|
+
];
|
|
181
|
+
return [
|
|
182
|
+
t.variableDeclaration(path.node.kind, [
|
|
183
|
+
t.variableDeclarator(t.identifier(id), wrapped),
|
|
184
|
+
]),
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
|
|
161
188
|
export function handleReactNativeWebObjectPatternRequire(
|
|
162
189
|
path: NodePath<VariableDeclaration>,
|
|
163
190
|
t: BabelTypes,
|
|
@@ -180,6 +207,7 @@ export function handleReactNativeWebObjectPatternRequire(
|
|
|
180
207
|
// We need to exit as we do not handle `const { Text, ...rest } = require('react-native-web');`
|
|
181
208
|
return;
|
|
182
209
|
} else if (
|
|
210
|
+
identifier.computed ||
|
|
183
211
|
!(t.isIdentifier(identifier.value) && t.isIdentifier(identifier.key))
|
|
184
212
|
) {
|
|
185
213
|
// Bail out on anything that isn't `const { <key>: <identifier> } = require('react-native-web');`
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { dirname, resolve } from "path";
|
|
2
|
-
|
|
3
1
|
import { type NodePath } from "@babel/traverse";
|
|
4
2
|
import tBabelTypes, {
|
|
5
3
|
type ImportDeclaration,
|
|
@@ -9,12 +7,13 @@ import tBabelTypes, {
|
|
|
9
7
|
} from "@babel/types";
|
|
10
8
|
|
|
11
9
|
import { allowedModules } from "./allowedModules";
|
|
10
|
+
import { resolveImportSource } from "./helpers";
|
|
12
11
|
|
|
13
12
|
type BabelTypes = typeof tBabelTypes;
|
|
14
13
|
|
|
15
14
|
function parseReactNativeSource(source: string, filename: string) {
|
|
16
15
|
if (source.startsWith(".")) {
|
|
17
|
-
source =
|
|
16
|
+
source = resolveImportSource(filename, source);
|
|
18
17
|
|
|
19
18
|
const internalPath = source.split("react-native/Libraries/Components/")[1];
|
|
20
19
|
if (!internalPath) {
|
|
@@ -48,6 +47,7 @@ export function handleReactNativeImport(
|
|
|
48
47
|
filename: string,
|
|
49
48
|
): Statement[] | undefined {
|
|
50
49
|
const { specifiers, source } = declaration;
|
|
50
|
+
if (declaration.importKind && declaration.importKind !== "value") return;
|
|
51
51
|
|
|
52
52
|
const rnwSource = parseReactNativeSource(source.value, filename);
|
|
53
53
|
if (!rnwSource) {
|
|
@@ -76,7 +76,7 @@ export function handleReactNativeImport(
|
|
|
76
76
|
} else {
|
|
77
77
|
statements.push(
|
|
78
78
|
t.importDeclaration(
|
|
79
|
-
[t.importSpecifier(specifier.local,
|
|
79
|
+
[t.importSpecifier(specifier.local, t.identifier(name))],
|
|
80
80
|
t.stringLiteral(`react-native-css/components/${name}`),
|
|
81
81
|
),
|
|
82
82
|
);
|
|
@@ -89,6 +89,10 @@ export function handleReactNativeImport(
|
|
|
89
89
|
),
|
|
90
90
|
);
|
|
91
91
|
} else {
|
|
92
|
+
if (specifier.importKind && specifier.importKind !== "value") {
|
|
93
|
+
statements.push(t.importDeclaration([specifier], source));
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
92
96
|
const localName = t.isStringLiteral(specifier.imported)
|
|
93
97
|
? specifier.imported.value
|
|
94
98
|
: specifier.imported.name;
|
|
@@ -180,6 +184,7 @@ export function handleReactNativeObjectPatternRequire(
|
|
|
180
184
|
// We need to exit as we do not handle `const { Text, ...rest } = require('react-native');`
|
|
181
185
|
return;
|
|
182
186
|
} else if (
|
|
187
|
+
identifier.computed ||
|
|
183
188
|
!(t.isIdentifier(identifier.value) && t.isIdentifier(identifier.key))
|
|
184
189
|
) {
|
|
185
190
|
// Bail out on anything that isn't `const { <key>: <identifier> } = require('react-native');`
|
package/src/compiler/atRules.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Declaration,
|
|
2
3
|
DeclarationBlock,
|
|
3
4
|
ParsedComponent,
|
|
4
5
|
Rule,
|
|
@@ -99,6 +100,49 @@ export function parsePropAtRule(rules?: (Rule | PropAtRule)[]) {
|
|
|
99
100
|
return mapping;
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
const mappingProperty = "-rn-native-mapping";
|
|
104
|
+
|
|
105
|
+
export function isMappingProperty(name: string) {
|
|
106
|
+
return name === mappingProperty || name.startsWith(`${mappingProperty}-`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Declaration metadata survives the optimizer flattening nested at rules. */
|
|
110
|
+
export function parsePropDeclarations(declarations: Declaration[] = []) {
|
|
111
|
+
const mapping: StyleRuleMapping = {};
|
|
112
|
+
for (const declaration of declarations) {
|
|
113
|
+
if (
|
|
114
|
+
declaration.property !== "custom" ||
|
|
115
|
+
!isMappingProperty(declaration.value.name)
|
|
116
|
+
) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const { name, value } = declaration.value;
|
|
120
|
+
const target = value.filter(
|
|
121
|
+
(item): item is Extract<TokenOrValue, { type: "token" }> =>
|
|
122
|
+
item.type === "token" && item.value.type !== "white-space",
|
|
123
|
+
);
|
|
124
|
+
if (target.length === 0) continue;
|
|
125
|
+
nativeMappingAtRuleBlock(
|
|
126
|
+
[
|
|
127
|
+
{
|
|
128
|
+
type: "token",
|
|
129
|
+
value: {
|
|
130
|
+
type: "ident",
|
|
131
|
+
value:
|
|
132
|
+
name === mappingProperty
|
|
133
|
+
? "*"
|
|
134
|
+
: name.slice(mappingProperty.length + 1),
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{ type: "token", value: { type: "colon" } },
|
|
138
|
+
...target,
|
|
139
|
+
],
|
|
140
|
+
mapping,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
return mapping;
|
|
144
|
+
}
|
|
145
|
+
|
|
102
146
|
function nativeMappingAtRuleBlock(
|
|
103
147
|
token: Extract<TokenOrValue, { type: "token" }>[],
|
|
104
148
|
mapping: StyleRuleMapping = {},
|
package/src/compiler/compiler.ts
CHANGED
|
@@ -4,31 +4,63 @@ import { inspect } from "node:util";
|
|
|
4
4
|
import { debug } from "debug";
|
|
5
5
|
import {
|
|
6
6
|
type ContainerRule,
|
|
7
|
-
type MediaQuery as CSSMediaQuery,
|
|
8
7
|
type CustomAtRules,
|
|
8
|
+
type Declaration,
|
|
9
9
|
type MediaRule,
|
|
10
|
+
type ParsedComponent,
|
|
11
|
+
type PropertyRule,
|
|
10
12
|
type Rule,
|
|
11
13
|
type Visitor,
|
|
14
|
+
type Warning,
|
|
12
15
|
} from "lightningcss";
|
|
13
16
|
|
|
14
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
maybeMutateReactNativeOptions,
|
|
19
|
+
parsePropAtRule,
|
|
20
|
+
parsePropDeclarations,
|
|
21
|
+
} from "./atRules";
|
|
15
22
|
import type {
|
|
16
23
|
CompilerOptions,
|
|
17
24
|
ContainerQuery,
|
|
25
|
+
StyleDescriptor,
|
|
18
26
|
StyleRuleMapping,
|
|
19
27
|
UniqueVarInfo,
|
|
20
28
|
} from "./compiler.types";
|
|
21
29
|
import { parseContainerCondition } from "./container-query";
|
|
22
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
parseAngle,
|
|
32
|
+
parseColor,
|
|
33
|
+
parseDeclaration,
|
|
34
|
+
parseLength,
|
|
35
|
+
reduceParseUnparsed,
|
|
36
|
+
round,
|
|
37
|
+
} from "./declarations";
|
|
38
|
+
import { unparseIndividualTransform } from "./individual-transforms";
|
|
23
39
|
import { inlineVariables } from "./inline-variables";
|
|
24
40
|
import { extractKeyFrames } from "./keyframes";
|
|
25
41
|
import { lightningcssLoader } from "./lightningcss-loader";
|
|
26
42
|
import { parseMediaQuery } from "./media-query";
|
|
43
|
+
import { isUniversalSelector } from "./selector-builder";
|
|
27
44
|
import { StylesheetBuilder } from "./stylesheet";
|
|
28
45
|
import { supportsConditionValid } from "./supports";
|
|
29
46
|
|
|
30
47
|
const defaultLogger = debug("react-native-css:compiler");
|
|
31
48
|
|
|
49
|
+
// lightningcss reports this package's own at-rule as unknown
|
|
50
|
+
const OWN_AT_RULE_WARNING = "Unknown at rule: @nativeMapping";
|
|
51
|
+
|
|
52
|
+
// The warning is the only record of what lightningcss could not parse; only the first pass reads the author's CSS
|
|
53
|
+
function reportSyntaxWarnings(
|
|
54
|
+
builder: StylesheetBuilder,
|
|
55
|
+
warnings: Warning[],
|
|
56
|
+
): void {
|
|
57
|
+
for (const warning of warnings) {
|
|
58
|
+
if (warning.message !== OWN_AT_RULE_WARNING) {
|
|
59
|
+
builder.addSyntaxWarning(warning.message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
32
64
|
/**
|
|
33
65
|
* Converts a CSS file to a collection of style declarations that can be used with the StyleSheet API
|
|
34
66
|
*
|
|
@@ -74,25 +106,98 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) {
|
|
|
74
106
|
|
|
75
107
|
const vars = new Map<string, UniqueVarInfo>();
|
|
76
108
|
|
|
77
|
-
|
|
109
|
+
// Determine the effective rem multiplier for compile-time inlining.
|
|
110
|
+
// If inlineRem is explicitly set, use that. Otherwise, scan for
|
|
111
|
+
// :root { font-size: Npx } in the CSS to allow CSS-based configuration.
|
|
112
|
+
let effectiveRem: number | false = options.inlineRem ?? undefined!;
|
|
113
|
+
if (effectiveRem === undefined) {
|
|
114
|
+
const css = typeof code === "string" ? code : code.toString();
|
|
115
|
+
const match = css.match(/:root\s*\{[^}]*font-size:\s*([\d.]+)px/);
|
|
116
|
+
effectiveRem = match?.[1] ? parseFloat(match[1]) : 14;
|
|
117
|
+
options.inlineRem = effectiveRem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const inlining = options.inlineVariables !== false;
|
|
78
121
|
|
|
79
|
-
|
|
122
|
+
const firstPassVisitor: Visitor<CustomAtRules> = {
|
|
123
|
+
// Registered from the first pass, since lightningcss prints only the last @property of a name, valid or not
|
|
124
|
+
StyleSheetExit(sheet) {
|
|
125
|
+
const nonInheriting = registerProperties(
|
|
126
|
+
collectRegistrations(sheet.rules),
|
|
127
|
+
builder,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
if (!inlining) {
|
|
131
|
+
return sheet;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const universalDeclarations = countUniversalDeclarations(sheet.rules);
|
|
135
|
+
|
|
136
|
+
// A non-inheriting property has one value on every element only when universal rules are all that declare it
|
|
137
|
+
const runtimeVariables = new Set(
|
|
138
|
+
Array.from(nonInheriting).filter((name) => {
|
|
139
|
+
const declarations = vars.get(name)?.count;
|
|
140
|
+
return (
|
|
141
|
+
declarations === undefined ||
|
|
142
|
+
universalDeclarations.get(name) !== declarations
|
|
143
|
+
);
|
|
144
|
+
}),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
return inlineVariables(sheet, vars, runtimeVariables);
|
|
148
|
+
},
|
|
149
|
+
Rule(rule) {
|
|
150
|
+
if (
|
|
151
|
+
rule.type === "unknown" &&
|
|
152
|
+
["cssInterop", "react-native"].includes(rule.value.name)
|
|
153
|
+
) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
`Unsupported @${rule.value.name} configuration. Use the compiler inlineVariables.exclude option to preserve variables, @media (prefers-color-scheme: dark) for dark mode, and React Native Appearance.setColorScheme() for manual selection.`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
// Reject before variable inlining can erase an unsupported condition and
|
|
159
|
+
// accidentally turn its values into unconditional declarations.
|
|
160
|
+
if (
|
|
161
|
+
rule.type === "style" &&
|
|
162
|
+
rule.value.selectors.some(
|
|
163
|
+
(selector) =>
|
|
164
|
+
selector.some(
|
|
165
|
+
(part) => part.type === "pseudo-class" && part.kind === "root",
|
|
166
|
+
) &&
|
|
167
|
+
selector.some(
|
|
168
|
+
(part) =>
|
|
169
|
+
part.type === "class" ||
|
|
170
|
+
(part.type === "attribute" && part.name === "class"),
|
|
171
|
+
),
|
|
172
|
+
)
|
|
173
|
+
) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
"Class-qualified :root selectors are unsupported on native. Use @media (prefers-color-scheme: dark) for dark mode, and React Native Appearance.setColorScheme() for manual selection.",
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
if (effectiveRem !== false) {
|
|
182
|
+
const remMultiplier = effectiveRem;
|
|
80
183
|
firstPassVisitor.Length = (length) => {
|
|
81
|
-
if (length.unit !== "rem"
|
|
82
|
-
return
|
|
184
|
+
if (length.unit !== "rem") {
|
|
185
|
+
return undefined;
|
|
83
186
|
}
|
|
84
187
|
|
|
85
188
|
return {
|
|
86
189
|
unit: "px",
|
|
87
|
-
value: round(length.value *
|
|
190
|
+
value: round(length.value * remMultiplier),
|
|
88
191
|
};
|
|
89
192
|
};
|
|
90
193
|
}
|
|
91
194
|
|
|
195
|
+
let countVariable: ((decl: Declaration) => void) | undefined;
|
|
196
|
+
|
|
92
197
|
if (options.inlineVariables !== false) {
|
|
93
198
|
const exclusionList: string[] = options.inlineVariables?.exclude ?? [];
|
|
94
199
|
|
|
95
|
-
|
|
200
|
+
countVariable = (decl) => {
|
|
96
201
|
if (
|
|
97
202
|
decl.property === "custom" &&
|
|
98
203
|
decl.value.name.startsWith("--") &&
|
|
@@ -109,12 +214,14 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) {
|
|
|
109
214
|
vars.set(decl.value.name, entry);
|
|
110
215
|
}
|
|
111
216
|
};
|
|
112
|
-
firstPassVisitor.StyleSheetExit = (sheet) => {
|
|
113
|
-
return inlineVariables(sheet, vars);
|
|
114
|
-
};
|
|
115
217
|
}
|
|
116
218
|
|
|
117
|
-
|
|
219
|
+
firstPassVisitor.Declaration = (decl) => {
|
|
220
|
+
countVariable?.(decl);
|
|
221
|
+
return unparseIndividualTransform(decl);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const { code: firstPass, warnings: firstPassWarnings } = lightningcss({
|
|
118
225
|
code: typeof code === "string" ? new TextEncoder().encode(code) : code,
|
|
119
226
|
include: Features.DoublePositionGradients | Features.ColorFunction,
|
|
120
227
|
exclude: Features.VendorPrefixes,
|
|
@@ -147,7 +254,6 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) {
|
|
|
147
254
|
const visitor: Visitor<typeof customAtRules> = {
|
|
148
255
|
Rule(rule) {
|
|
149
256
|
maybeMutateReactNativeOptions(rule, builder);
|
|
150
|
-
return rule;
|
|
151
257
|
},
|
|
152
258
|
StyleSheetExit(sheet) {
|
|
153
259
|
if (isLoggerEnabled) {
|
|
@@ -164,7 +270,6 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) {
|
|
|
164
270
|
}
|
|
165
271
|
|
|
166
272
|
logger(`Exiting lightningcss`);
|
|
167
|
-
return sheet;
|
|
168
273
|
},
|
|
169
274
|
};
|
|
170
275
|
|
|
@@ -175,6 +280,8 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) {
|
|
|
175
280
|
projectRoot: options.projectRoot ?? process.cwd(),
|
|
176
281
|
});
|
|
177
282
|
|
|
283
|
+
reportSyntaxWarnings(builder, firstPassWarnings);
|
|
284
|
+
|
|
178
285
|
return {
|
|
179
286
|
stylesheet: () => builder.getNativeStyleSheet(),
|
|
180
287
|
warnings: () => builder.getWarnings(),
|
|
@@ -233,7 +340,12 @@ function extractRule(
|
|
|
233
340
|
const value = rule.value;
|
|
234
341
|
|
|
235
342
|
const declarationBlock = value.declarations;
|
|
236
|
-
mapping = {
|
|
343
|
+
mapping = {
|
|
344
|
+
...mapping,
|
|
345
|
+
...parsePropAtRule(value.rules),
|
|
346
|
+
...parsePropDeclarations(declarationBlock?.declarations),
|
|
347
|
+
...parsePropDeclarations(declarationBlock?.importantDeclarations),
|
|
348
|
+
};
|
|
237
349
|
|
|
238
350
|
// If the rule is a style declaration, extract it with the `getExtractedStyle` function and store it in the `declarations` map
|
|
239
351
|
builder = builder.fork("style", value.selectors);
|
|
@@ -276,13 +388,13 @@ function extractRule(
|
|
|
276
388
|
}
|
|
277
389
|
}
|
|
278
390
|
break;
|
|
391
|
+
case "property":
|
|
279
392
|
case "custom":
|
|
280
393
|
case "font-face":
|
|
281
394
|
case "font-palette-values":
|
|
282
395
|
case "font-feature-values":
|
|
283
396
|
case "namespace":
|
|
284
397
|
case "layer-statement":
|
|
285
|
-
case "property":
|
|
286
398
|
case "view-transition":
|
|
287
399
|
case "ignored":
|
|
288
400
|
case "unknown":
|
|
@@ -314,39 +426,16 @@ function extractMedia(
|
|
|
314
426
|
builder: StylesheetBuilder,
|
|
315
427
|
mapping: StyleRuleMapping,
|
|
316
428
|
) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
// Initialize an empty array to store screen media queries
|
|
320
|
-
const media: CSSMediaQuery[] = [];
|
|
321
|
-
|
|
322
|
-
// Iterate over all media queries in the mediaRule
|
|
429
|
+
// Comma separated queries are alternatives. Each branch inherits the outer
|
|
430
|
+
// conditions without adding its siblings as required conjunctions.
|
|
323
431
|
for (const mediaQuery of mediaRule.query.mediaQueries) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
(mediaQuery.mediaType === "print" && mediaQuery.qualifier !== "not") ||
|
|
327
|
-
// If this is a @media not print {}
|
|
328
|
-
// We can only do this if there are no conditions, as @media not print and (min-width: 100px) could be valid
|
|
329
|
-
(mediaQuery.mediaType !== "print" &&
|
|
330
|
-
mediaQuery.qualifier === "not" &&
|
|
331
|
-
mediaQuery.condition === null)
|
|
332
|
-
) {
|
|
432
|
+
const queryBuilder = builder.fork("media");
|
|
433
|
+
if (!parseMediaQuery(mediaQuery, queryBuilder)) {
|
|
333
434
|
continue;
|
|
334
435
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (media.length === 0) {
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
for (const m of media) {
|
|
344
|
-
parseMediaQuery(m, builder);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Iterate over all rules in the mediaRule and extract their styles using the updated CompilerCollection
|
|
348
|
-
for (const rule of mediaRule.rules) {
|
|
349
|
-
extractRule(rule, builder, mapping);
|
|
436
|
+
for (const rule of mediaRule.rules) {
|
|
437
|
+
extractRule(rule, queryBuilder, mapping);
|
|
438
|
+
}
|
|
350
439
|
}
|
|
351
440
|
}
|
|
352
441
|
|
|
@@ -363,9 +452,12 @@ function extractContainer(
|
|
|
363
452
|
builder = builder.fork("container");
|
|
364
453
|
|
|
365
454
|
// Iterate over all rules inside the containerRule and extract their styles using the updated CompilerCollection
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
455
|
+
const condition = parseContainerCondition(containerRule.condition, builder);
|
|
456
|
+
if (!condition) {
|
|
457
|
+
// An unsupported condition must not turn into an unconditional container.
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const query: ContainerQuery = { m: condition };
|
|
369
461
|
|
|
370
462
|
if (containerRule.name) {
|
|
371
463
|
query.n = `c:${containerRule.name}`;
|
|
@@ -377,3 +469,143 @@ function extractContainer(
|
|
|
377
469
|
extractRule(rule, builder, mapping);
|
|
378
470
|
}
|
|
379
471
|
}
|
|
472
|
+
|
|
473
|
+
// Browsers register the last @property of a name, in a layer, in @container and under an @supports that holds, and one in @media only while it matches
|
|
474
|
+
function collectRegistrations(
|
|
475
|
+
rules: readonly Rule[],
|
|
476
|
+
conditional = false,
|
|
477
|
+
registrations = new Map<string, PropertyRule>(),
|
|
478
|
+
) {
|
|
479
|
+
for (const rule of rules) {
|
|
480
|
+
switch (rule.type) {
|
|
481
|
+
case "property":
|
|
482
|
+
if (!conditional) {
|
|
483
|
+
registrations.set(rule.value.name, rule.value);
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
case "media":
|
|
487
|
+
collectRegistrations(rule.value.rules, true, registrations);
|
|
488
|
+
break;
|
|
489
|
+
case "supports":
|
|
490
|
+
collectRegistrations(
|
|
491
|
+
rule.value.rules,
|
|
492
|
+
conditional || !supportsConditionValid(rule.value.condition),
|
|
493
|
+
registrations,
|
|
494
|
+
);
|
|
495
|
+
break;
|
|
496
|
+
case "container":
|
|
497
|
+
case "layer-block":
|
|
498
|
+
collectRegistrations(rule.value.rules, conditional, registrations);
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return registrations;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// Registers the properties whose initial value has a descriptor, and returns the names that do not inherit
|
|
507
|
+
function registerProperties(
|
|
508
|
+
registrations: ReadonlyMap<string, PropertyRule>,
|
|
509
|
+
builder: StylesheetBuilder,
|
|
510
|
+
): ReadonlySet<string> {
|
|
511
|
+
const nonInheriting = new Set<string>();
|
|
512
|
+
|
|
513
|
+
for (const [name, { inherits, initialValue }] of registrations) {
|
|
514
|
+
const value =
|
|
515
|
+
initialValue == null
|
|
516
|
+
? undefined
|
|
517
|
+
: parsePropertyInitialValue(initialValue, builder);
|
|
518
|
+
|
|
519
|
+
// Left unregistered, since without its initial value the property would fall back where CSS gives that value
|
|
520
|
+
if (initialValue != null && value === undefined) {
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
builder.registerProperty(name.slice(2), inherits, value);
|
|
525
|
+
if (!inherits) {
|
|
526
|
+
nonInheriting.add(name);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return nonInheriting;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Counts each custom property's declarations in universal rules every element shares: at the top level, in a layer or under an @supports, whose declarations the inliner reads too, and not under @media or @container
|
|
534
|
+
function countUniversalDeclarations(
|
|
535
|
+
rules: readonly Rule[],
|
|
536
|
+
counts = new Map<string, number>(),
|
|
537
|
+
) {
|
|
538
|
+
for (const rule of rules) {
|
|
539
|
+
switch (rule.type) {
|
|
540
|
+
case "style":
|
|
541
|
+
if (rule.value.selectors.some(isUniversalSelector)) {
|
|
542
|
+
const { declarations = [], importantDeclarations = [] } =
|
|
543
|
+
rule.value.declarations ?? {};
|
|
544
|
+
for (const declaration of [
|
|
545
|
+
...declarations,
|
|
546
|
+
...importantDeclarations,
|
|
547
|
+
]) {
|
|
548
|
+
if (declaration.property === "custom") {
|
|
549
|
+
const { name } = declaration.value;
|
|
550
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
break;
|
|
555
|
+
case "layer-block":
|
|
556
|
+
countUniversalDeclarations(rule.value.rules, counts);
|
|
557
|
+
break;
|
|
558
|
+
case "supports":
|
|
559
|
+
countUniversalDeclarations(rule.value.rules, counts);
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
return counts;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function parsePropertyInitialValue(
|
|
568
|
+
component: ParsedComponent,
|
|
569
|
+
builder: StylesheetBuilder,
|
|
570
|
+
): StyleDescriptor {
|
|
571
|
+
switch (component.type) {
|
|
572
|
+
case "length":
|
|
573
|
+
return parseLength(component.value, builder);
|
|
574
|
+
case "number":
|
|
575
|
+
case "integer":
|
|
576
|
+
return round(component.value);
|
|
577
|
+
case "percentage":
|
|
578
|
+
return `${round(component.value * 100)}%`;
|
|
579
|
+
case "color":
|
|
580
|
+
return parseColor(component.value, builder);
|
|
581
|
+
case "angle":
|
|
582
|
+
return parseAngle(component.value, builder);
|
|
583
|
+
case "length-percentage":
|
|
584
|
+
return parseLength(component.value, builder);
|
|
585
|
+
case "token-list":
|
|
586
|
+
return reduceParseUnparsed(component.value, builder, "@property", false);
|
|
587
|
+
case "custom-ident":
|
|
588
|
+
case "literal":
|
|
589
|
+
return component.value;
|
|
590
|
+
case "repeated": {
|
|
591
|
+
const results = component.value.components.map((item) =>
|
|
592
|
+
parsePropertyInitialValue(item, builder),
|
|
593
|
+
);
|
|
594
|
+
if (results.includes(undefined)) {
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
// Unwrap single-child repeated values so downstream consumers get a
|
|
598
|
+
// scalar instead of a 1-element array. For example, `<length>+` with
|
|
599
|
+
// initial-value `10px` should produce the same shape as `<length>`.
|
|
600
|
+
if (results.length === 1) {
|
|
601
|
+
return results[0];
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return component.value.multiplier.type === "comma"
|
|
605
|
+
? results.map((result) => [result])
|
|
606
|
+
: results;
|
|
607
|
+
}
|
|
608
|
+
default:
|
|
609
|
+
return undefined;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
@@ -24,6 +24,15 @@ export interface InlineVariableOptions {
|
|
|
24
24
|
exclude?: `--${string}`[];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// A channel is absent when the compile recorded nothing on it
|
|
28
|
+
export interface CompilerWarnings {
|
|
29
|
+
properties?: string[];
|
|
30
|
+
values?: Record<string, string[]>;
|
|
31
|
+
functions?: string[];
|
|
32
|
+
// CSS lightningcss could not parse, which the author fixes in their stylesheet
|
|
33
|
+
syntax?: string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
* A `react-native-css` StyleSheet
|
|
29
38
|
*/
|
|
@@ -40,6 +49,8 @@ export interface ReactNativeCssStyleSheet {
|
|
|
40
49
|
vr?: RootVariables;
|
|
41
50
|
/** Universal Variables */
|
|
42
51
|
vu?: RootVariables;
|
|
52
|
+
/** Registered Properties */
|
|
53
|
+
vp?: PropertyRegistration[];
|
|
43
54
|
}
|
|
44
55
|
|
|
45
56
|
/******************************** Styles ********************************/
|
|
@@ -154,6 +165,12 @@ export type VariableValue =
|
|
|
154
165
|
|
|
155
166
|
export type RootVariables = [string, VariableValue[]][];
|
|
156
167
|
|
|
168
|
+
export type PropertyRegistration = readonly [
|
|
169
|
+
string, // name
|
|
170
|
+
boolean, // inherits
|
|
171
|
+
StyleDescriptor?, // initial value
|
|
172
|
+
];
|
|
173
|
+
|
|
157
174
|
export type InlineVariable = {
|
|
158
175
|
[VAR_SYMBOL]: "inline";
|
|
159
176
|
[key: string]: unknown | undefined;
|