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
package/src/native/reactivity.ts
CHANGED
|
@@ -10,8 +10,12 @@ import {
|
|
|
10
10
|
import type { StyleDescriptor } from "react-native-css/compiler";
|
|
11
11
|
|
|
12
12
|
export type Effect = {
|
|
13
|
-
observers: Set<
|
|
13
|
+
observers: Set<Observable<any, any>>;
|
|
14
14
|
run(): void;
|
|
15
|
+
/** Dependencies recorded by the last cleanupEffect() */
|
|
16
|
+
dependencies?: Observable<any, any>[];
|
|
17
|
+
/** Dependency values recorded by the last cleanupEffect() */
|
|
18
|
+
snapshots?: [Observable<any, any>, unknown][];
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
export type Observable<Value, Arg = Value> = {
|
|
@@ -19,6 +23,7 @@ export type Observable<Value, Arg = Value> = {
|
|
|
19
23
|
get: (effect?: Effect) => Value;
|
|
20
24
|
set: (arg: Arg) => void;
|
|
21
25
|
run: () => void;
|
|
26
|
+
unsubscribe: (effect: Effect) => void;
|
|
22
27
|
};
|
|
23
28
|
type Read<Value, Arg> = (get: Getter, arg?: Arg) => Value;
|
|
24
29
|
export type Getter = <Value>(observable: Observable<Value, any>) => Value;
|
|
@@ -43,9 +48,10 @@ export function observable<Value, Arg = Value>(
|
|
|
43
48
|
|
|
44
49
|
const observers = new Set<Effect>();
|
|
45
50
|
const effect: Effect = {
|
|
46
|
-
observers,
|
|
51
|
+
observers: new Set(),
|
|
47
52
|
run: () => {
|
|
48
53
|
if (!isStatic) {
|
|
54
|
+
cleanupEffect(effect);
|
|
49
55
|
const nextValue = (init as Read<Value, Arg>)(getter, lastArg);
|
|
50
56
|
if (equality(value, nextValue)) {
|
|
51
57
|
return;
|
|
@@ -57,14 +63,19 @@ export function observable<Value, Arg = Value>(
|
|
|
57
63
|
},
|
|
58
64
|
};
|
|
59
65
|
|
|
60
|
-
const getter: Getter = (observable) =>
|
|
66
|
+
const getter: Getter = (observable) =>
|
|
67
|
+
observable.get(observers.size > 0 ? effect : undefined);
|
|
61
68
|
|
|
62
|
-
function get(
|
|
63
|
-
if (
|
|
64
|
-
observers.
|
|
69
|
+
function get(subscriber?: Effect) {
|
|
70
|
+
if (subscriber) {
|
|
71
|
+
if (observers.size === 0 && !isStatic) didInit = false;
|
|
72
|
+
observers.add(subscriber);
|
|
73
|
+
subscriber.observers.add(obs);
|
|
65
74
|
}
|
|
66
75
|
if (!didInit) {
|
|
67
|
-
|
|
76
|
+
cleanupEffect(effect);
|
|
77
|
+
value = (init as Read<Value, Arg>)(getter, lastArg);
|
|
78
|
+
didInit = observers.size > 0;
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
return value;
|
|
@@ -77,9 +88,10 @@ export function observable<Value, Arg = Value>(
|
|
|
77
88
|
}
|
|
78
89
|
value = arg as unknown as Value;
|
|
79
90
|
} else {
|
|
91
|
+
cleanupEffect(effect);
|
|
80
92
|
const nextValue = (init as Read<Value, Arg>)(getter, arg);
|
|
81
93
|
|
|
82
|
-
didInit =
|
|
94
|
+
didInit = observers.size > 0;
|
|
83
95
|
lastArg = arg;
|
|
84
96
|
|
|
85
97
|
if (equality(value, nextValue)) {
|
|
@@ -108,6 +120,13 @@ export function observable<Value, Arg = Value>(
|
|
|
108
120
|
get,
|
|
109
121
|
set,
|
|
110
122
|
run: effect.run,
|
|
123
|
+
unsubscribe(subscriber) {
|
|
124
|
+
if (observers.delete(subscriber) && observers.size === 0 && !isStatic) {
|
|
125
|
+
cleanupEffect(effect);
|
|
126
|
+
didInit = false;
|
|
127
|
+
}
|
|
128
|
+
subscriber.observers.delete(obs);
|
|
129
|
+
},
|
|
111
130
|
};
|
|
112
131
|
|
|
113
132
|
return obs;
|
|
@@ -115,10 +134,26 @@ export function observable<Value, Arg = Value>(
|
|
|
115
134
|
|
|
116
135
|
export function cleanupEffect(effect: Effect) {
|
|
117
136
|
if (!effect) return;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
137
|
+
const dependencies = (effect.dependencies = Array.from(effect.observers));
|
|
138
|
+
// Snapshot before detaching so computed observables return cached values
|
|
139
|
+
effect.snapshots = dependencies.map(
|
|
140
|
+
(observable) =>
|
|
141
|
+
[observable, observable.get()] as [Observable<any, any>, unknown],
|
|
142
|
+
);
|
|
121
143
|
effect.observers.clear();
|
|
144
|
+
for (const dep of dependencies) {
|
|
145
|
+
dep.unsubscribe(effect);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Whether any of the effect's dependencies changed since cleanupEffect() */
|
|
150
|
+
export function hasChangedDependencies(effect: Effect): boolean {
|
|
151
|
+
const snapshots = effect.snapshots;
|
|
152
|
+
if (!snapshots) return false;
|
|
153
|
+
for (const [observable, value] of snapshots) {
|
|
154
|
+
if (!Object.is(observable.get(), value)) return true;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
122
157
|
}
|
|
123
158
|
|
|
124
159
|
/** Family Helpers ************************************************************/
|
|
@@ -129,17 +164,18 @@ export function family<Key, Result = Key, Args extends any = void>(
|
|
|
129
164
|
const map = new Map<Key, Result>();
|
|
130
165
|
return Object.assign(
|
|
131
166
|
(key: Key, args: Args) => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
map.set(key, value);
|
|
136
|
-
}
|
|
167
|
+
if (map.has(key)) return map.get(key)!;
|
|
168
|
+
const value = fn(key, args);
|
|
169
|
+
map.set(key, value);
|
|
137
170
|
return value;
|
|
138
171
|
},
|
|
139
172
|
{
|
|
140
173
|
delete(key: Key) {
|
|
141
174
|
return map.delete(key);
|
|
142
175
|
},
|
|
176
|
+
size() {
|
|
177
|
+
return map.size;
|
|
178
|
+
},
|
|
143
179
|
clear() {
|
|
144
180
|
return map.clear();
|
|
145
181
|
},
|
|
@@ -166,11 +202,9 @@ export function weakFamily<Key extends WeakKey, Args = undefined, Result = Key>(
|
|
|
166
202
|
const map = new WeakMap<Key, Result>();
|
|
167
203
|
return Object.assign(
|
|
168
204
|
(key: Key, args: Args) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
map.set(key, value);
|
|
173
|
-
}
|
|
205
|
+
if (map.has(key)) return map.get(key)!;
|
|
206
|
+
const value = fn(key, args);
|
|
207
|
+
map.set(key, value);
|
|
174
208
|
return value;
|
|
175
209
|
},
|
|
176
210
|
{
|
|
@@ -186,6 +220,21 @@ export type VariableContextValue = Record<string, StyleDescriptor> & {
|
|
|
186
220
|
[VAR_SYMBOL]: true;
|
|
187
221
|
};
|
|
188
222
|
|
|
223
|
+
// Variable lookup is presence-keyed, so an entry with no value produces no key rather than one that stops the cascade
|
|
224
|
+
export function toVariableRecord(
|
|
225
|
+
variables: Record<string, StyleDescriptor>,
|
|
226
|
+
): Record<string, StyleDescriptor> {
|
|
227
|
+
const record: Record<string, StyleDescriptor> = {};
|
|
228
|
+
|
|
229
|
+
for (const [name, value] of Object.entries(variables)) {
|
|
230
|
+
if (value !== undefined) {
|
|
231
|
+
record[name.replace(/^--/, "")] = value;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return record;
|
|
236
|
+
}
|
|
237
|
+
|
|
189
238
|
/** Pseudo Classes ************************************************************/
|
|
190
239
|
|
|
191
240
|
export const hoverFamily = weakFamily(() => observable(false));
|
|
@@ -216,14 +265,20 @@ Dimensions.addEventListener("change", ({ window }) => {
|
|
|
216
265
|
|
|
217
266
|
/** Color Scheme **************************************************************/
|
|
218
267
|
|
|
219
|
-
export const colorScheme = observable<ColorSchemeName>(
|
|
268
|
+
export const colorScheme = observable<ColorSchemeName | null | undefined>(
|
|
220
269
|
Appearance.getColorScheme(),
|
|
221
270
|
);
|
|
222
271
|
Appearance.addChangeListener((event) => colorScheme.set(event.colorScheme));
|
|
223
272
|
|
|
224
273
|
/** Containers ****************************************************************/
|
|
225
274
|
|
|
226
|
-
export type ContainerContextValue = Record<
|
|
275
|
+
export type ContainerContextValue = Record<
|
|
276
|
+
string,
|
|
277
|
+
{
|
|
278
|
+
key: WeakKey;
|
|
279
|
+
props: Record<string, unknown> | null | undefined;
|
|
280
|
+
}
|
|
281
|
+
>;
|
|
227
282
|
export const ContainerContext = createContext<ContainerContextValue>({});
|
|
228
283
|
|
|
229
284
|
export const containerLayoutFamily = weakFamily(() => {
|
|
@@ -243,6 +298,6 @@ export const containerWidthFamily = weakFamily((key) => {
|
|
|
243
298
|
|
|
244
299
|
export const containerHeightFamily = weakFamily((key) => {
|
|
245
300
|
return observable((read) => {
|
|
246
|
-
return read(containerLayoutFamily(key))?.
|
|
301
|
+
return read(containerLayoutFamily(key))?.height || 0;
|
|
247
302
|
});
|
|
248
303
|
});
|
package/src/native/reanimated.ts
CHANGED
|
@@ -11,11 +11,30 @@ export const animatedComponentFamily = weakFamily(
|
|
|
11
11
|
return component;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
14
|
+
// Reanimated 4.5 keeps the original component display name. Compare its
|
|
15
|
+
// public built-in components by identity instead of interpreting that name.
|
|
16
|
+
const reanimated =
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
18
|
+
require("react-native-reanimated") as typeof import("react-native-reanimated");
|
|
19
|
+
const animated = reanimated.default;
|
|
20
|
+
if (
|
|
21
|
+
[
|
|
22
|
+
animated.View,
|
|
23
|
+
animated.Text,
|
|
24
|
+
animated.Image,
|
|
25
|
+
animated.ScrollView,
|
|
26
|
+
animated.FlatList,
|
|
27
|
+
].some((value) => value === component)
|
|
28
|
+
) {
|
|
29
|
+
return component;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// This public constructor remains supported for arbitrary components; only
|
|
33
|
+
// its FlatList-specific overload is deprecated by Reanimated.
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
35
|
+
const createAnimatedComponent = reanimated.createAnimatedComponent as (
|
|
36
|
+
component: ComponentType,
|
|
37
|
+
) => ComponentType;
|
|
19
38
|
|
|
20
39
|
return createAnimatedComponent(component);
|
|
21
40
|
},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type {
|
|
3
3
|
InlineVariable,
|
|
4
4
|
StyleDeclaration,
|
|
5
|
+
StyleDescriptor,
|
|
5
6
|
StyleRule,
|
|
6
7
|
} from "react-native-css/compiler";
|
|
7
8
|
import { Specificity as S } from "react-native-css/utilities";
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
type Getter,
|
|
14
15
|
type VariableContextValue,
|
|
15
16
|
} from "../reactivity";
|
|
16
|
-
import { transformKeys } from "./defaults";
|
|
17
17
|
import { resolveValue } from "./resolve";
|
|
18
18
|
|
|
19
19
|
export function calculateProps(
|
|
@@ -31,7 +31,7 @@ export function calculateProps(
|
|
|
31
31
|
let important: Record<string, any> | undefined;
|
|
32
32
|
|
|
33
33
|
const delayedStyles: (() => void)[] = [];
|
|
34
|
-
const
|
|
34
|
+
const transforms: TransformRecord[] = [];
|
|
35
35
|
|
|
36
36
|
for (const rule of rules) {
|
|
37
37
|
if (VAR_SYMBOL in rule) {
|
|
@@ -50,9 +50,8 @@ export function calculateProps(
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
if (rule.d) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
: (normal ??= {});
|
|
53
|
+
const isImportant = Boolean(rule.s?.[S.Important]);
|
|
54
|
+
let topLevelTarget = isImportant ? (important ??= {}) : (normal ??= {});
|
|
56
55
|
let target = topLevelTarget;
|
|
57
56
|
|
|
58
57
|
const ruleTarget = rule.target || "style";
|
|
@@ -71,10 +70,12 @@ export function calculateProps(
|
|
|
71
70
|
inlineVariables,
|
|
72
71
|
inheritedVariables,
|
|
73
72
|
delayedStyles,
|
|
74
|
-
|
|
73
|
+
transforms,
|
|
75
74
|
guards,
|
|
76
75
|
target,
|
|
77
76
|
topLevelTarget,
|
|
77
|
+
ruleTarget,
|
|
78
|
+
isImportant,
|
|
78
79
|
);
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -83,8 +84,15 @@ export function calculateProps(
|
|
|
83
84
|
delayedStyle();
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
if (transforms.length > 0) {
|
|
88
|
+
composeTransforms(transforms, (value) =>
|
|
89
|
+
resolveValue(value, get, {
|
|
90
|
+
inlineVariables,
|
|
91
|
+
inheritedVariables,
|
|
92
|
+
renderGuards: guards,
|
|
93
|
+
calculateProps,
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
return {
|
|
@@ -94,16 +102,165 @@ export function calculateProps(
|
|
|
94
102
|
};
|
|
95
103
|
}
|
|
96
104
|
|
|
105
|
+
// css-transforms-2 §6: an element's transform is its `translate`, then its `rotate`, then its `scale`, then its `transform` list
|
|
106
|
+
const TRANSFORM_SLOTS = 4;
|
|
107
|
+
|
|
108
|
+
// A transform property's cascade slot in composition order, or -1. This runs for every dynamic declaration
|
|
109
|
+
function transformSlot(prop: string | number): number {
|
|
110
|
+
switch (prop) {
|
|
111
|
+
case "translate":
|
|
112
|
+
return 0;
|
|
113
|
+
case "rotate":
|
|
114
|
+
return 1;
|
|
115
|
+
case "scale":
|
|
116
|
+
return 2;
|
|
117
|
+
case "transform":
|
|
118
|
+
return 3;
|
|
119
|
+
default:
|
|
120
|
+
return -1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A transform property's declaration, kept until every rule has been walked */
|
|
125
|
+
interface TransformRecord {
|
|
126
|
+
readonly target: Record<string, any>;
|
|
127
|
+
readonly path: string | readonly string[];
|
|
128
|
+
readonly important: boolean;
|
|
129
|
+
readonly slot: number;
|
|
130
|
+
readonly value: StyleDescriptor;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** One style target's slots: the normal ones, then the !important ones */
|
|
134
|
+
interface TransformGroup {
|
|
135
|
+
readonly path: string | readonly string[];
|
|
136
|
+
target: Record<string, any>;
|
|
137
|
+
readonly slots: (StyleDescriptor | undefined)[];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function samePath(
|
|
141
|
+
a: string | readonly string[],
|
|
142
|
+
b: string | readonly string[],
|
|
143
|
+
): boolean {
|
|
144
|
+
if (a === b) return true;
|
|
145
|
+
if (typeof a === "string" || typeof b === "string") return false;
|
|
146
|
+
if (a.length !== b.length) return false;
|
|
147
|
+
for (let i = 0; i < a.length; i++) {
|
|
148
|
+
if (a[i] !== b[i]) return false;
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Each transform property of each style target is a cascade slot of its own,
|
|
155
|
+
* and the slots compose into one `transform`. Records arrive in cascade
|
|
156
|
+
* order, so a later one replaces an earlier one, and an !important slot
|
|
157
|
+
* replaces a normal one for the same path.
|
|
158
|
+
*/
|
|
159
|
+
function composeTransforms(
|
|
160
|
+
records: readonly TransformRecord[],
|
|
161
|
+
resolve: (value: StyleDescriptor) => unknown,
|
|
162
|
+
) {
|
|
163
|
+
// One declaration, the usual case, has nothing to compose with
|
|
164
|
+
if (records.length === 1) {
|
|
165
|
+
const record = records[0]!;
|
|
166
|
+
const resolved = resolve(record.value);
|
|
167
|
+
|
|
168
|
+
if (resolved !== undefined && resolved !== null) {
|
|
169
|
+
const composed: unknown[] = [];
|
|
170
|
+
pushEntries(composed, resolved);
|
|
171
|
+
record.target.transform = composed;
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Almost always one group, so a scan beats keying a Map by path
|
|
177
|
+
const groups: TransformGroup[] = [];
|
|
178
|
+
|
|
179
|
+
for (let r = 0; r < records.length; r++) {
|
|
180
|
+
const record = records[r]!;
|
|
181
|
+
let group: TransformGroup | undefined;
|
|
182
|
+
|
|
183
|
+
for (let g = 0; g < groups.length; g++) {
|
|
184
|
+
if (samePath(groups[g]!.path, record.path)) {
|
|
185
|
+
group = groups[g];
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (group === undefined) {
|
|
191
|
+
group = {
|
|
192
|
+
path: record.path,
|
|
193
|
+
target: record.target,
|
|
194
|
+
slots: [
|
|
195
|
+
undefined,
|
|
196
|
+
undefined,
|
|
197
|
+
undefined,
|
|
198
|
+
undefined,
|
|
199
|
+
undefined,
|
|
200
|
+
undefined,
|
|
201
|
+
undefined,
|
|
202
|
+
undefined,
|
|
203
|
+
],
|
|
204
|
+
};
|
|
205
|
+
groups.push(group);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (record.important) {
|
|
209
|
+
// The important target is merged over the normal one, so it takes the composed list
|
|
210
|
+
group.target = record.target;
|
|
211
|
+
group.slots[record.slot + TRANSFORM_SLOTS] = record.value;
|
|
212
|
+
} else {
|
|
213
|
+
group.slots[record.slot] = record.value;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
for (let g = 0; g < groups.length; g++) {
|
|
218
|
+
const group = groups[g]!;
|
|
219
|
+
let composed: unknown[] | undefined;
|
|
220
|
+
|
|
221
|
+
for (let slot = 0; slot < TRANSFORM_SLOTS; slot++) {
|
|
222
|
+
const important = group.slots[slot + TRANSFORM_SLOTS];
|
|
223
|
+
const value = important !== undefined ? important : group.slots[slot];
|
|
224
|
+
|
|
225
|
+
if (value === undefined) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const resolved = resolve(value);
|
|
230
|
+
|
|
231
|
+
// A property that resolves to no value is `none` (css-variables-1 §3.1)
|
|
232
|
+
if (resolved !== undefined && resolved !== null) {
|
|
233
|
+
pushEntries((composed ??= []), resolved);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (composed !== undefined) {
|
|
238
|
+
group.target.transform = composed;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// A resolver returns a group for a two-axis function, so entries are spread into the list
|
|
244
|
+
function pushEntries(entries: unknown[], value: unknown) {
|
|
245
|
+
if (Array.isArray(value)) {
|
|
246
|
+
for (let i = 0; i < value.length; i++) pushEntries(entries, value[i]);
|
|
247
|
+
} else {
|
|
248
|
+
entries.push(value);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
97
252
|
export function applyDeclarations(
|
|
98
253
|
get: Getter,
|
|
99
254
|
declarations: StyleDeclaration[],
|
|
100
255
|
inlineVariables: InlineVariable,
|
|
101
256
|
inheritedVariables: VariableContextValue,
|
|
102
257
|
delayedStyles: (() => void)[] = [],
|
|
103
|
-
|
|
258
|
+
transforms: TransformRecord[] = [],
|
|
104
259
|
guards: RenderGuard[] = [],
|
|
105
260
|
target: Record<string, any> = {},
|
|
106
261
|
topLevelTarget = target,
|
|
262
|
+
path: string | readonly string[] = "style",
|
|
263
|
+
important = false,
|
|
107
264
|
) {
|
|
108
265
|
const originalTarget = target;
|
|
109
266
|
|
|
@@ -162,9 +319,16 @@ export function applyDeclarations(
|
|
|
162
319
|
prop = propPath;
|
|
163
320
|
}
|
|
164
321
|
|
|
322
|
+
const slot = target === originalTarget ? transformSlot(prop) : -1;
|
|
323
|
+
|
|
324
|
+
if (slot !== -1) {
|
|
325
|
+
transforms.push({ target, path, important, slot, value });
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
|
|
165
329
|
const shouldDelay = declaration[2];
|
|
166
330
|
|
|
167
|
-
if (shouldDelay
|
|
331
|
+
if (shouldDelay) {
|
|
168
332
|
/**
|
|
169
333
|
* We need to delay the resolution of this value until after all
|
|
170
334
|
* styles have been calculated. But another style might override
|
|
@@ -175,11 +339,11 @@ export function applyDeclarations(
|
|
|
175
339
|
* mutate the props object and not create a new one
|
|
176
340
|
*/
|
|
177
341
|
const originalValue = value;
|
|
178
|
-
// This needs to be a object with the [prop] so we can discover in transform arrays
|
|
179
342
|
value = { [prop]: true };
|
|
180
343
|
|
|
181
|
-
|
|
182
|
-
|
|
344
|
+
delayedStyles.push(() => {
|
|
345
|
+
if (getDeepPath(target, prop) === value) {
|
|
346
|
+
delete target[prop];
|
|
183
347
|
value = resolveValue(originalValue, get, {
|
|
184
348
|
inlineVariables,
|
|
185
349
|
inheritedVariables,
|
|
@@ -187,21 +351,8 @@ export function applyDeclarations(
|
|
|
187
351
|
calculateProps,
|
|
188
352
|
});
|
|
189
353
|
applyValue(target, prop, value);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
delayedStyles.push(() => {
|
|
193
|
-
if (getDeepPath(target, prop) === value) {
|
|
194
|
-
delete target[prop];
|
|
195
|
-
value = resolveValue(originalValue, get, {
|
|
196
|
-
inlineVariables,
|
|
197
|
-
inheritedVariables,
|
|
198
|
-
renderGuards: guards,
|
|
199
|
-
calculateProps,
|
|
200
|
-
});
|
|
201
|
-
applyValue(target, prop, value);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
354
|
+
}
|
|
355
|
+
});
|
|
205
356
|
} else {
|
|
206
357
|
value = resolveValue(value, get, {
|
|
207
358
|
inlineVariables,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { commaListItems } from "react-native-css/utilities";
|
|
2
|
+
|
|
1
3
|
import type { StyleFunctionResolver } from "../resolve";
|
|
2
4
|
|
|
3
5
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
@@ -26,7 +28,7 @@ const timingFunctionResolver: StyleFunctionResolver = (resolveValue, value) => {
|
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
const args = resolveValue(value[2]);
|
|
31
|
+
const args = commaListItems(resolveValue(value[2]));
|
|
30
32
|
|
|
31
33
|
if (!Array.isArray(args)) {
|
|
32
34
|
return;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
-
import type { PlainColorObject } from "colorjs.io";
|
|
3
1
|
import {
|
|
4
2
|
ColorSpace,
|
|
5
3
|
to as convert,
|
|
@@ -8,7 +6,6 @@ import {
|
|
|
8
6
|
P3,
|
|
9
7
|
parse,
|
|
10
8
|
sRGB,
|
|
11
|
-
type ColorConstructor,
|
|
12
9
|
} from "colorjs.io/fn";
|
|
13
10
|
|
|
14
11
|
import type { StyleFunctionResolver } from "../resolve";
|
|
@@ -18,49 +15,58 @@ ColorSpace.register(P3);
|
|
|
18
15
|
ColorSpace.register(OKLab);
|
|
19
16
|
|
|
20
17
|
export const colorMix: StyleFunctionResolver = (resolveValue, value) => {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
if (!Array.isArray(args) || args.length < 3) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
18
|
+
const resolved = resolveValue(value[2]);
|
|
19
|
+
if (!Array.isArray(resolved)) return;
|
|
26
20
|
|
|
21
|
+
// Resolved descriptors may be cached and shared by another styled component.
|
|
22
|
+
const args: unknown[] = [...(resolved as unknown[])];
|
|
27
23
|
try {
|
|
28
24
|
const space = args.shift();
|
|
25
|
+
const leftValue = args.shift();
|
|
26
|
+
if (typeof space !== "string" || typeof leftValue !== "string") return;
|
|
27
|
+
ColorSpace.get(space);
|
|
28
|
+
const left = parse(leftValue);
|
|
29
|
+
const percentage = () => {
|
|
30
|
+
const next = args[0];
|
|
31
|
+
if (typeof next !== "string" || !next.endsWith("%")) return undefined;
|
|
32
|
+
args.shift();
|
|
33
|
+
return Number(next.slice(0, -1)) / 100;
|
|
34
|
+
};
|
|
35
|
+
let leftWeight = percentage();
|
|
36
|
+
const rightValue = args.shift();
|
|
37
|
+
if (typeof rightValue !== "string") return;
|
|
38
|
+
const right = parse(rightValue);
|
|
39
|
+
let rightWeight = percentage();
|
|
40
|
+
if (args.length) return;
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
next = args.shift();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (next === undefined) {
|
|
42
|
-
if (left.spaceId !== "srgb") {
|
|
43
|
-
left = convert(left, "srgb");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return `rgba(${(left.coords[0] ?? 0) * 255}, ${(left.coords[1] ?? 0) * 255}, ${(left.coords[2] ?? 0) * 255}, ${left.alpha})`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof next !== "string") {
|
|
42
|
+
// CSS Color 5: omitted weights are complementary, then both are normalized.
|
|
43
|
+
leftWeight ??= rightWeight === undefined ? 0.5 : 1 - rightWeight;
|
|
44
|
+
rightWeight ??= 1 - leftWeight;
|
|
45
|
+
if (
|
|
46
|
+
![leftWeight, rightWeight].every(
|
|
47
|
+
(weight) => Number.isFinite(weight) && weight >= 0 && weight <= 1,
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
50
|
return;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const sum = leftWeight + rightWeight;
|
|
52
|
+
if (sum === 0) return;
|
|
53
|
+
const alphaMultiplier = Math.min(sum, 1);
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
55
|
+
let result;
|
|
56
|
+
if (right.alpha === 0 || left.alpha === 0) {
|
|
57
|
+
// A transparent endpoint contributes no premultiplied channels.
|
|
58
|
+
const source = right.alpha === 0 ? left : right;
|
|
59
|
+
const weight = right.alpha === 0 ? leftWeight : rightWeight;
|
|
60
|
+
result = convert(source, "srgb");
|
|
61
|
+
result.alpha = ((source.alpha ?? 1) * weight) / sum;
|
|
62
|
+
} else {
|
|
63
|
+
result = mix(left, right, rightWeight / sum, {
|
|
64
|
+
space,
|
|
65
|
+
outputSpace: "srgb",
|
|
66
|
+
premultiplied: true,
|
|
67
|
+
});
|
|
57
68
|
}
|
|
58
|
-
|
|
59
|
-
const result = mix(left, right, {
|
|
60
|
-
space,
|
|
61
|
-
outputSpace: "srgb",
|
|
62
|
-
});
|
|
63
|
-
|
|
69
|
+
result.alpha = (result.alpha ?? 1) * alphaMultiplier;
|
|
64
70
|
return `rgba(${(result.coords[0] ?? 0) * 255}, ${(result.coords[1] ?? 0) * 255}, ${(result.coords[2] ?? 0) * 255}, ${result.alpha})`;
|
|
65
71
|
} catch {
|
|
66
72
|
return;
|