react-native-unistyles 3.0.0-beta.1 → 3.0.0-beta.3
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 +4 -4
- package/Unistyles.podspec +7 -1
- package/android/build.gradle +6 -0
- package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -2
- package/components/native/ActivityIndicator/package.json +4 -0
- package/components/native/FlatList/package.json +4 -0
- package/components/native/Image/package.json +4 -0
- package/components/native/ImageBackground/package.json +4 -0
- package/components/native/KeyboardAvoidingView/package.json +4 -0
- package/components/native/Pressable/package.json +5 -0
- package/components/native/RefreshControl/package.json +4 -0
- package/components/native/ScrollView/package.json +4 -0
- package/components/native/SectionList/package.json +4 -0
- package/components/native/Switch/package.json +4 -0
- package/components/native/Text/package.json +4 -0
- package/components/native/TextInput/package.json +4 -0
- package/components/native/TouchableHighlight/package.json +4 -0
- package/components/native/TouchableOpacity/package.json +4 -0
- package/components/native/View/package.json +4 -0
- package/components/native/VirtualizedList/package.json +4 -0
- package/cxx/common/Constants.h +2 -0
- package/cxx/core/HostStyle.cpp +17 -7
- package/cxx/core/HostStyle.h +5 -0
- package/cxx/core/UnistyleData.h +3 -3
- package/cxx/core/UnistyleWrapper.h +9 -9
- package/cxx/core/UnistylesRegistry.cpp +23 -30
- package/cxx/core/UnistylesRegistry.h +8 -2
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +117 -12
- package/cxx/hybridObjects/HybridShadowRegistry.h +27 -3
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -0
- package/cxx/parser/Parser.cpp +184 -26
- package/cxx/parser/Parser.h +3 -1
- package/ios/UnistylesModuleOnLoad.mm +2 -2
- package/lib/commonjs/components/ScopedTheme.js +36 -0
- package/lib/commonjs/components/ScopedTheme.js.map +1 -0
- package/lib/commonjs/components/Variants.js +36 -0
- package/lib/commonjs/components/Variants.js.map +1 -0
- package/lib/commonjs/components/index.js +10 -3
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/native/ActivityIndicator.js +10 -0
- package/lib/commonjs/components/native/ActivityIndicator.js.map +1 -0
- package/lib/commonjs/components/native/FlatList.js +10 -0
- package/lib/commonjs/components/native/FlatList.js.map +1 -0
- package/lib/commonjs/components/native/Image.js +10 -0
- package/lib/commonjs/components/native/Image.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +10 -0
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -0
- package/lib/commonjs/components/native/KeyboardAvoidingView.js +10 -0
- package/lib/commonjs/components/native/KeyboardAvoidingView.js.map +1 -0
- package/lib/commonjs/components/{Pressable.web.js → native/Pressable.js} +26 -66
- package/lib/commonjs/components/native/Pressable.js.map +1 -0
- package/lib/commonjs/components/native/Pressable.native.js +51 -0
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -0
- package/lib/commonjs/components/native/RefreshControl.js +10 -0
- package/lib/commonjs/components/native/RefreshControl.js.map +1 -0
- package/lib/commonjs/components/native/ScrollView.js +10 -0
- package/lib/commonjs/components/native/ScrollView.js.map +1 -0
- package/lib/commonjs/components/native/SectionList.js +10 -0
- package/lib/commonjs/components/native/SectionList.js.map +1 -0
- package/lib/commonjs/components/native/Switch.js +10 -0
- package/lib/commonjs/components/native/Switch.js.map +1 -0
- package/lib/commonjs/components/native/Text.js +10 -0
- package/lib/commonjs/components/native/Text.js.map +1 -0
- package/lib/commonjs/components/native/TextInput.js +10 -0
- package/lib/commonjs/components/native/TextInput.js.map +1 -0
- package/lib/commonjs/components/native/TouchableHighlight.js +10 -0
- package/lib/commonjs/components/native/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/native/TouchableOpacity.js +10 -0
- package/lib/commonjs/components/native/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/native/View.js +10 -0
- package/lib/commonjs/components/native/View.js.map +1 -0
- package/lib/commonjs/components/native/VirtualizedList.js +10 -0
- package/lib/commonjs/components/native/VirtualizedList.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +5 -68
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +16 -0
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js +27 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -0
- package/lib/commonjs/core/index.js +20 -6
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/passForwardRef.js +27 -0
- package/lib/commonjs/core/passForwardRef.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/index.js +13 -0
- package/lib/commonjs/core/withUnistyles/index.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/types.js +8 -0
- package/lib/commonjs/core/withUnistyles/types.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/useDependencies.js +85 -0
- package/lib/commonjs/core/withUnistyles/useDependencies.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +88 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +97 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -0
- package/lib/commonjs/hooks/useMedia.js +17 -33
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +60 -0
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -0
- package/lib/commonjs/index.js +52 -31
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +3 -3
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/index.js +14 -40
- package/lib/commonjs/specs/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +54 -0
- package/lib/commonjs/specs/index.native.js.map +1 -0
- package/lib/commonjs/web/create.js +9 -33
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/index.js +15 -16
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +10 -3
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +3 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +66 -64
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +4 -4
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/ScopedTheme.js +29 -0
- package/lib/module/components/ScopedTheme.js.map +1 -0
- package/lib/module/components/Variants.js +29 -0
- package/lib/module/components/Variants.js.map +1 -0
- package/lib/module/components/index.js +2 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/native/ActivityIndicator.js +6 -0
- package/lib/module/components/native/ActivityIndicator.js.map +1 -0
- package/lib/module/components/native/FlatList.js +6 -0
- package/lib/module/components/native/FlatList.js.map +1 -0
- package/lib/module/components/native/Image.js +6 -0
- package/lib/module/components/native/Image.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +6 -0
- package/lib/module/components/native/ImageBackground.js.map +1 -0
- package/lib/module/components/native/KeyboardAvoidingView.js +6 -0
- package/lib/module/components/native/KeyboardAvoidingView.js.map +1 -0
- package/lib/module/components/native/Pressable.js +69 -0
- package/lib/module/components/native/Pressable.js.map +1 -0
- package/lib/module/components/native/Pressable.native.js +45 -0
- package/lib/module/components/native/Pressable.native.js.map +1 -0
- package/lib/module/components/native/RefreshControl.js +6 -0
- package/lib/module/components/native/RefreshControl.js.map +1 -0
- package/lib/module/components/native/ScrollView.js +6 -0
- package/lib/module/components/native/ScrollView.js.map +1 -0
- package/lib/module/components/native/SectionList.js +6 -0
- package/lib/module/components/native/SectionList.js.map +1 -0
- package/lib/module/components/native/Switch.js +6 -0
- package/lib/module/components/native/Switch.js.map +1 -0
- package/lib/module/components/native/Text.js +6 -0
- package/lib/module/components/native/Text.js.map +1 -0
- package/lib/module/components/native/TextInput.js +6 -0
- package/lib/module/components/native/TextInput.js.map +1 -0
- package/lib/module/components/native/TouchableHighlight.js +6 -0
- package/lib/module/components/native/TouchableHighlight.js.map +1 -0
- package/lib/module/components/native/TouchableOpacity.js +6 -0
- package/lib/module/components/native/TouchableOpacity.js.map +1 -0
- package/lib/module/components/native/View.js +6 -0
- package/lib/module/components/native/View.js.map +1 -0
- package/lib/module/components/native/VirtualizedList.js +6 -0
- package/lib/module/components/native/VirtualizedList.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +5 -66
- package/lib/module/core/createUnistylesComponent.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +10 -0
- package/lib/module/core/createUnistylesElement.js.map +1 -0
- package/lib/module/core/createUnistylesImageBackground.js +21 -0
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -0
- package/lib/module/core/index.js +4 -2
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/passForwardRef.js +22 -0
- package/lib/module/core/passForwardRef.js.map +1 -0
- package/lib/module/core/withUnistyles/index.js +4 -0
- package/lib/module/core/withUnistyles/index.js.map +1 -0
- package/lib/module/core/withUnistyles/types.js +4 -0
- package/lib/module/core/withUnistyles/types.js.map +1 -0
- package/lib/module/core/withUnistyles/useDependencies.js +79 -0
- package/lib/module/core/withUnistyles/useDependencies.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.js +81 -0
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js +90 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -0
- package/lib/module/hooks/useMedia.js +19 -35
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +55 -0
- package/lib/module/hooks/useMedia.native.js.map +1 -0
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +3 -3
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/index.js +2 -8
- package/lib/module/specs/index.js.map +1 -1
- package/lib/module/specs/index.native.js +11 -0
- package/lib/module/specs/index.native.js.map +1 -0
- package/lib/module/web/create.js +10 -34
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/index.js +4 -3
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/registry.js +11 -4
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +3 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +64 -62
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +2 -2
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/ScopedTheme.d.ts +8 -0
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/Variants.d.ts +7 -0
- package/lib/typescript/src/components/Variants.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +2 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts +2 -0
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/native/FlatList.d.ts +2 -0
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Image.d.ts +2 -0
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts +3 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -0
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +2 -0
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -0
- package/lib/typescript/src/components/{Pressable.web.d.ts → native/Pressable.d.ts} +3 -2
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/{Pressable.d.ts → native/Pressable.native.d.ts} +1 -3
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/RefreshControl.d.ts +2 -0
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ScrollView.d.ts +2 -0
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/SectionList.d.ts +2 -0
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Switch.d.ts +2 -0
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Text.d.ts +2 -0
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TextInput.d.ts +2 -0
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts +2 -0
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts +2 -0
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -0
- package/lib/typescript/src/components/native/View.d.ts +2 -0
- package/lib/typescript/src/components/native/View.d.ts.map +1 -0
- package/lib/typescript/src/components/native/VirtualizedList.d.ts +2 -0
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +9 -3
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts +3 -0
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +4 -0
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +4 -2
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts +3 -0
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/index.d.ts +2 -0
- package/lib/typescript/src/core/withUnistyles/index.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/types.d.ts +6 -0
- package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts +13 -0
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +11 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +8 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMedia.d.ts +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts +6 -0
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +7 -2
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +17 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.d.ts +3 -11
- package/lib/typescript/src/specs/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.native.d.ts +12 -0
- package/lib/typescript/src/specs/index.native.d.ts.map +1 -0
- package/lib/typescript/src/web/create.d.ts +1 -1441
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +5 -1463
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +2 -3
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +11 -3
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -2
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +3 -0
- package/package.json +20 -4
- package/plugin/common.js +4 -6
- package/plugin/import.js +63 -26
- package/plugin/index.js +48 -28
- package/plugin/ref.js +0 -234
- package/plugin/style.js +4 -317
- package/plugin/stylesheet.js +25 -10
- package/plugin/variants.js +60 -1
- package/src/components/ScopedTheme.tsx +32 -0
- package/src/components/Variants.tsx +30 -0
- package/src/components/index.ts +2 -1
- package/src/components/native/ActivityIndicator.tsx +4 -0
- package/src/components/native/FlatList.tsx +4 -0
- package/src/components/native/Image.tsx +4 -0
- package/src/components/native/ImageBackground.tsx +4 -0
- package/src/components/native/KeyboardAvoidingView.tsx +4 -0
- package/src/components/native/Pressable.native.tsx +57 -0
- package/src/components/native/Pressable.tsx +98 -0
- package/src/components/native/RefreshControl.tsx +4 -0
- package/src/components/native/ScrollView.tsx +4 -0
- package/src/components/native/SectionList.tsx +4 -0
- package/src/components/native/Switch.tsx +4 -0
- package/src/components/native/Text.tsx +4 -0
- package/src/components/native/TextInput.tsx +4 -0
- package/src/components/native/TouchableHighlight.tsx +4 -0
- package/src/components/native/TouchableOpacity.tsx +4 -0
- package/src/components/native/View.tsx +4 -0
- package/src/components/native/VirtualizedList.tsx +4 -0
- package/src/core/createUnistylesComponent.tsx +6 -76
- package/src/core/createUnistylesElement.tsx +9 -0
- package/src/core/createUnistylesImageBackground.tsx +24 -0
- package/src/core/index.ts +4 -2
- package/src/core/passForwardRef.ts +29 -0
- package/src/core/withUnistyles/index.ts +1 -0
- package/src/core/withUnistyles/types.ts +7 -0
- package/src/core/withUnistyles/useDependencies.ts +98 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +97 -0
- package/src/core/withUnistyles/withUnistyles.tsx +90 -0
- package/src/hooks/useMedia.native.ts +65 -0
- package/src/hooks/useMedia.ts +19 -36
- package/src/index.ts +3 -3
- package/src/specs/ShadowRegistry/index.ts +14 -5
- package/src/specs/ShadowRegistry/types.ts +18 -1
- package/src/specs/index.native.ts +27 -0
- package/src/specs/index.ts +3 -27
- package/src/web/create.ts +11 -32
- package/src/web/index.ts +8 -4
- package/src/web/registry.ts +15 -6
- package/src/web/runtime.ts +3 -1
- package/src/web/shadowRegistry.ts +59 -51
- package/src/web/utils/unistyle.ts +2 -3
- package/lib/commonjs/components/Pressable.js +0 -74
- package/lib/commonjs/components/Pressable.js.map +0 -1
- package/lib/commonjs/components/Pressable.web.js.map +0 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js +0 -82
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +0 -1
- package/lib/commonjs/core/getBoundArgs.js +0 -18
- package/lib/commonjs/core/getBoundArgs.js.map +0 -1
- package/lib/commonjs/core/getId.js +0 -9
- package/lib/commonjs/core/getId.js.map +0 -1
- package/lib/commonjs/hooks/useMedia.web.js +0 -43
- package/lib/commonjs/hooks/useMedia.web.js.map +0 -1
- package/lib/commonjs/specs/index.web.js +0 -17
- package/lib/commonjs/specs/index.web.js.map +0 -1
- package/lib/module/components/Pressable.js +0 -68
- package/lib/module/components/Pressable.js.map +0 -1
- package/lib/module/components/Pressable.web.js +0 -109
- package/lib/module/components/Pressable.web.js.map +0 -1
- package/lib/module/core/createUnistylesComponent.native.js +0 -75
- package/lib/module/core/createUnistylesComponent.native.js.map +0 -1
- package/lib/module/core/getBoundArgs.js +0 -13
- package/lib/module/core/getBoundArgs.js.map +0 -1
- package/lib/module/core/getId.js +0 -4
- package/lib/module/core/getId.js.map +0 -1
- package/lib/module/hooks/useMedia.web.js +0 -38
- package/lib/module/hooks/useMedia.web.js.map +0 -1
- package/lib/module/specs/index.web.js +0 -4
- package/lib/module/specs/index.web.js.map +0 -1
- package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
- package/lib/typescript/src/components/Pressable.web.d.ts.map +0 -1
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +0 -8
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +0 -1
- package/lib/typescript/src/core/getBoundArgs.d.ts +0 -2
- package/lib/typescript/src/core/getBoundArgs.d.ts.map +0 -1
- package/lib/typescript/src/core/getId.d.ts +0 -2
- package/lib/typescript/src/core/getId.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useMedia.web.d.ts +0 -6
- package/lib/typescript/src/hooks/useMedia.web.d.ts.map +0 -1
- package/lib/typescript/src/specs/index.web.d.ts +0 -2
- package/lib/typescript/src/specs/index.web.d.ts.map +0 -1
- package/src/components/Pressable.tsx +0 -89
- package/src/components/Pressable.web.tsx +0 -129
- package/src/core/createUnistylesComponent.native.tsx +0 -83
- package/src/core/getBoundArgs.ts +0 -15
- package/src/core/getId.ts +0 -1
- package/src/hooks/useMedia.web.ts +0 -47
- package/src/specs/index.web.ts +0 -1
package/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[<img alt="react-native-unistyles" src="assets/
|
1
|
+
[<img alt="react-native-unistyles" src="assets/banner3.png">](https://unistyl.es/)
|
2
2
|
|
3
3
|

|
4
4
|
[](https://www.npmjs.com/package/react-native-unistyles)
|
@@ -59,12 +59,12 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
59
59
|
<a href="https://github.com/happyfloat">
|
60
60
|
<img src="https://avatars.githubusercontent.com/u/186333704?s=200&v=4" height="70px" width="70px" alt="happyfloat" />
|
61
61
|
</a>
|
62
|
-
<a href="https://github.com">
|
63
|
-
<img src="https://avatars.githubusercontent.com/u/138339?v=4" height="70px" width="70px" alt="anonymous" />
|
64
|
-
</a>
|
65
62
|
<a href="https://github.com/hyoban">
|
66
63
|
<img src="https://avatars.githubusercontent.com/u/38493346?v=4" height="70px" width="70px" alt="hyoban" />
|
67
64
|
</a>
|
65
|
+
<a href="https://github.com/oscklm">
|
66
|
+
<img src="https://avatars.githubusercontent.com/u/22825865?v=4" height="70px" width="70px" alt="oscklm" />
|
67
|
+
</a>
|
68
68
|
|
69
69
|
## Past sponsors
|
70
70
|
|
package/Unistyles.podspec
CHANGED
@@ -26,7 +26,13 @@ Pod::Spec.new do |s|
|
|
26
26
|
"ios/Unistyles.h"
|
27
27
|
]
|
28
28
|
|
29
|
-
|
29
|
+
if ENV["USE_FRAMEWORKS"]
|
30
|
+
s.dependency "React-Core"
|
31
|
+
add_dependency(s, "React-jsinspector", :framework_name => "jsinspector_modern")
|
32
|
+
add_dependency(s, "React-rendererconsistency", :framework_name => "React_rendererconsistency")
|
33
|
+
end
|
34
|
+
|
35
|
+
load "nitrogen/generated/ios/Unistyles+autolinking.rb"
|
30
36
|
add_nitrogen_files(s)
|
31
37
|
|
32
38
|
install_modules_dependencies(s)
|
package/android/build.gradle
CHANGED
@@ -12,6 +12,11 @@ buildscript {
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
|
15
|
+
def reactNativeArchitectures() {
|
16
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
17
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
18
|
+
}
|
19
|
+
|
15
20
|
apply plugin: 'com.android.library'
|
16
21
|
apply plugin: 'org.jetbrains.kotlin.android'
|
17
22
|
apply from: '../nitrogen/generated/android/unistyles+autolinking.gradle'
|
@@ -41,6 +46,7 @@ android {
|
|
41
46
|
externalNativeBuild {
|
42
47
|
cmake {
|
43
48
|
arguments "-DANDROID_STL=c++_shared"
|
49
|
+
abiFilters (*reactNativeArchitectures())
|
44
50
|
}
|
45
51
|
}
|
46
52
|
}
|
@@ -64,8 +64,8 @@ jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindings
|
|
64
64
|
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesStyleSheet", [styleSheet]() -> std::shared_ptr<HybridObject>{
|
65
65
|
return styleSheet;
|
66
66
|
});
|
67
|
-
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesShadowRegistry", []() -> std::shared_ptr<HybridObject>{
|
68
|
-
return std::make_shared<HybridShadowRegistry>();
|
67
|
+
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesShadowRegistry", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
|
68
|
+
return std::make_shared<HybridShadowRegistry>(unistylesRuntime);
|
69
69
|
});
|
70
70
|
});
|
71
71
|
}
|
package/cxx/common/Constants.h
CHANGED
@@ -9,5 +9,7 @@ static const std::string STYLE_VARIANTS = "uni__variants";
|
|
9
9
|
static const std::string WEB_STYLE_KEY = "_web";
|
10
10
|
static const std::string EXOTIC_STYLE_KEY = "_exotic";
|
11
11
|
static const std::string NAME_STYLE_KEY = "__unistyles_name";
|
12
|
+
static const std::string SECRETS = "__uni__secrets";
|
13
|
+
static const std::string ARGUMENTS = "__uni__args";
|
12
14
|
|
13
15
|
}
|
package/cxx/core/HostStyle.cpp
CHANGED
@@ -22,15 +22,26 @@ jsi::Value HostStyle::get(jsi::Runtime& rt, const jsi::PropNameID& propNameId) {
|
|
22
22
|
if (propertyName == helpers::UNISTYLES_ID) {
|
23
23
|
return jsi::Value(this->_styleSheet->tag);
|
24
24
|
}
|
25
|
-
|
25
|
+
|
26
26
|
if (propertyName == helpers::ADD_VARIANTS_FN) {
|
27
27
|
return this->createAddVariantsProxyFunction(rt);
|
28
28
|
}
|
29
29
|
|
30
30
|
if (this->_styleSheet->unistyles.contains(propertyName)) {
|
31
|
-
|
31
|
+
if (this->_styleCache.contains(propertyName)) {
|
32
|
+
return jsi::Value(rt, this->_styleCache[propertyName]);
|
33
|
+
}
|
34
|
+
|
35
|
+
this->_styleCache[propertyName] = valueFromUnistyle(
|
36
|
+
rt,
|
37
|
+
this->_unistylesRuntime,
|
38
|
+
this->_styleSheet->unistyles[propertyName],
|
39
|
+
this->_variants
|
40
|
+
);
|
41
|
+
|
42
|
+
return jsi::Value(rt, this->_styleCache[propertyName]);
|
32
43
|
}
|
33
|
-
|
44
|
+
|
34
45
|
if (propertyName == helpers::STYLE_VARIANTS) {
|
35
46
|
return helpers::variantsToValue(rt, this->_variants);
|
36
47
|
}
|
@@ -45,17 +56,16 @@ jsi::Function HostStyle::createAddVariantsProxyFunction(jsi::Runtime& rt) {
|
|
45
56
|
helpers::assertThat(rt, count == 1, "Unistyles: useVariants expected to be called with one argument.");
|
46
57
|
helpers::assertThat(rt, arguments[0].isObject(), "Unistyles: useVariants expected to be called with object.");
|
47
58
|
|
48
|
-
auto parser = parser::Parser(this->_unistylesRuntime);
|
49
59
|
auto pairs = helpers::variantsToPairs(rt, arguments[0].asObject(rt));
|
50
60
|
|
51
|
-
if (pairs == this->_variants) {
|
61
|
+
if (this->hasVariantsSet && pairs == this->_variants) {
|
52
62
|
return jsi::Value::undefined();
|
53
63
|
}
|
54
64
|
|
65
|
+
// new variants or empty variants
|
66
|
+
this->hasVariantsSet = true;
|
55
67
|
this->_variants = pairs;
|
56
68
|
|
57
|
-
parser.rebuildUnistylesWithVariants(rt, this->_styleSheet, this->_variants);
|
58
|
-
|
59
69
|
return jsi::Value::undefined();
|
60
70
|
});
|
61
71
|
}
|
package/cxx/core/HostStyle.h
CHANGED
@@ -21,9 +21,14 @@ struct JSI_EXPORT HostStyle : public jsi::HostObject {
|
|
21
21
|
jsi::Function createAddVariantsProxyFunction(jsi::Runtime& rt);
|
22
22
|
|
23
23
|
private:
|
24
|
+
// to additionally distinguish between empty variants
|
25
|
+
// that are set at the beginning
|
26
|
+
bool hasVariantsSet = false;
|
27
|
+
|
24
28
|
std::shared_ptr<StyleSheet> _styleSheet;
|
25
29
|
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
26
30
|
std::vector<std::pair<std::string, std::string>> _variants{};
|
31
|
+
std::unordered_map<std::string, jsi::Value> _styleCache{};
|
27
32
|
};
|
28
33
|
|
29
34
|
}
|
package/cxx/core/UnistyleData.h
CHANGED
@@ -8,8 +8,8 @@ namespace margelo::nitro::unistyles::core {
|
|
8
8
|
using Variants = std::vector<std::pair<std::string, std::string>>;
|
9
9
|
|
10
10
|
struct UnistyleData {
|
11
|
-
UnistyleData(Unistyle::Shared unistyle, const Variants& variants, std::vector<folly::dynamic>& arguments, std::optional<std::string>
|
12
|
-
: unistyle{unistyle}, variants(std::move(variants)), dynamicFunctionMetadata{std::move(arguments)},
|
11
|
+
UnistyleData(Unistyle::Shared unistyle, const Variants& variants, std::vector<folly::dynamic>& arguments, std::optional<std::string> scopedTheme)
|
12
|
+
: unistyle{unistyle}, variants(std::move(variants)), dynamicFunctionMetadata{std::move(arguments)}, scopedTheme{scopedTheme} {}
|
13
13
|
|
14
14
|
UnistyleData(const UnistyleData&) = delete;
|
15
15
|
UnistyleData(UnistyleData&& other) = delete;
|
@@ -18,7 +18,7 @@ struct UnistyleData {
|
|
18
18
|
core::Variants variants;
|
19
19
|
std::optional<jsi::Object> parsedStyle = std::nullopt;
|
20
20
|
std::optional<std::vector<folly::dynamic>> dynamicFunctionMetadata = std::nullopt;
|
21
|
-
std::optional<std::string>
|
21
|
+
std::optional<std::string> scopedTheme = std::nullopt;
|
22
22
|
};
|
23
23
|
|
24
24
|
}
|
@@ -88,35 +88,35 @@ inline static std::vector<Unistyle::Shared> unistyleFromValue(jsi::Runtime& rt,
|
|
88
88
|
if (value.isNull() || !value.isObject()) {
|
89
89
|
return {};
|
90
90
|
}
|
91
|
-
|
91
|
+
|
92
92
|
auto maybeArray = value.asObject(rt);
|
93
|
-
|
93
|
+
|
94
94
|
helpers::assertThat(rt, maybeArray.isArray(rt), "Unistyles: can't retrieve Unistyle state from node as it's not an array.");
|
95
|
-
|
95
|
+
|
96
96
|
std::vector<Unistyle::Shared> unistyles;
|
97
97
|
jsi::Array unistylesArray = maybeArray.asArray(rt);
|
98
|
-
|
98
|
+
|
99
99
|
helpers::iterateJSIArray(rt, unistylesArray, [&rt, &unistyles](size_t index, jsi::Value& value){
|
100
100
|
auto obj = value.getObject(rt);
|
101
101
|
|
102
102
|
// possible if user used React Native styles or inline styles or did spread styles
|
103
103
|
if (!obj.hasNativeState(rt)) {
|
104
104
|
auto exoticUnistyles = unistylesFromNonExistentNativeState(rt, obj);
|
105
|
-
|
105
|
+
|
106
106
|
for (auto& exoticUnistyle: exoticUnistyles) {
|
107
107
|
unistyles.emplace_back(exoticUnistyle);
|
108
108
|
}
|
109
|
-
|
109
|
+
|
110
110
|
return;
|
111
111
|
}
|
112
112
|
|
113
113
|
unistyles.emplace_back(value.getObject(rt).getNativeState<UnistyleWrapper>(rt)->unistyle);
|
114
114
|
});
|
115
|
-
|
115
|
+
|
116
116
|
return unistyles;
|
117
117
|
}
|
118
118
|
|
119
|
-
inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, Unistyle::Shared unistyle,
|
119
|
+
inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, Unistyle::Shared unistyle, Variants& variants) {
|
120
120
|
auto wrappedUnistyle = std::make_shared<UnistyleWrapper>(unistyle);
|
121
121
|
|
122
122
|
if (unistyle->type == UnistyleType::Object) {
|
@@ -128,7 +128,7 @@ inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, std::shared_ptr<Hyb
|
|
128
128
|
helpers::defineHiddenProperty(rt, obj, helpers::STYLE_DEPENDENCIES.c_str(), helpers::dependenciesToJSIArray(rt, unistyle->dependencies));
|
129
129
|
helpers::mergeJSIObjects(rt, obj, unistyle->parsedStyle.value());
|
130
130
|
|
131
|
-
obj.setProperty(rt, "__proto__", generateUnistylesPrototype(rt, unistylesRuntime, unistyle,
|
131
|
+
obj.setProperty(rt, "__proto__", generateUnistylesPrototype(rt, unistylesRuntime, unistyle, variants, std::nullopt));
|
132
132
|
|
133
133
|
return obj;
|
134
134
|
}
|
@@ -71,32 +71,16 @@ void core::UnistylesRegistry::updateTheme(jsi::Runtime& rt, std::string& themeNa
|
|
71
71
|
void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
|
72
72
|
jsi::Runtime& rt,
|
73
73
|
const ShadowNodeFamily* shadowNodeFamily,
|
74
|
-
std::vector<
|
75
|
-
Variants& variants,
|
76
|
-
std::vector<std::vector<folly::dynamic>>& arguments,
|
77
|
-
std::optional<std::string> uniquePressableId
|
74
|
+
std::vector<std::shared_ptr<UnistyleData>>& unistylesData
|
78
75
|
) {
|
79
|
-
auto parser = parser::Parser(nullptr);
|
80
76
|
shadow::ShadowLeafUpdates updates;
|
77
|
+
auto parser = parser::Parser(nullptr);
|
81
78
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
// add or update node for shadow leaf updates
|
89
|
-
// dynamic functions are parsed later
|
90
|
-
if (unistyle->type == UnistyleType::Object) {
|
91
|
-
for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
|
92
|
-
for (const auto& unistyleData : unistyles) {
|
93
|
-
if (unistyleData->unistyle == unistyle && family == shadowNodeFamily) {
|
94
|
-
updates[family] = parser.parseStylesToShadowTreeStyles(rt, {unistyleData});
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
}
|
99
|
-
}
|
79
|
+
std::for_each(unistylesData.begin(), unistylesData.end(), [this, &rt, shadowNodeFamily](std::shared_ptr<UnistyleData> unistyleData){
|
80
|
+
this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(unistyleData);
|
81
|
+
});
|
82
|
+
|
83
|
+
updates[shadowNodeFamily] = parser.parseStylesToShadowTreeStyles(rt, unistylesData);
|
100
84
|
|
101
85
|
this->trafficController.setUpdates(updates);
|
102
86
|
this->trafficController.resumeUnistylesTraffic();
|
@@ -160,13 +144,6 @@ void core::UnistylesRegistry::shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Uni
|
|
160
144
|
for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
|
161
145
|
for (const auto& unistyleData : unistyles) {
|
162
146
|
if (unistyleData->unistyle == unistyle) {
|
163
|
-
// special case for pressable
|
164
|
-
if (pressableId.has_value() && unistyleData->pressableId.has_value()) {
|
165
|
-
if (pressableId.value() == unistyleData->pressableId.value()) {
|
166
|
-
unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
|
170
147
|
updates[family] = parser.parseStylesToShadowTreeStyles(rt, { unistyleData });
|
171
148
|
}
|
172
149
|
}
|
@@ -220,3 +197,19 @@ std::vector<std::shared_ptr<core::StyleSheet>> core::UnistylesRegistry::getStyle
|
|
220
197
|
|
221
198
|
return stylesheetsToRefresh;
|
222
199
|
}
|
200
|
+
|
201
|
+
const core::Variants& core::UnistylesRegistry::getScopedVariants() {
|
202
|
+
return this->_scopedVariants;
|
203
|
+
}
|
204
|
+
|
205
|
+
const std::optional<std::string> core::UnistylesRegistry::getScopedTheme() {
|
206
|
+
return this->_scopedTheme;
|
207
|
+
}
|
208
|
+
|
209
|
+
void core::UnistylesRegistry::setScopedVariants(core::Variants&& variants) {
|
210
|
+
this->_scopedVariants = std::move(variants);
|
211
|
+
}
|
212
|
+
|
213
|
+
void core::UnistylesRegistry::setScopedTheme(std::optional<std::string> themeName) {
|
214
|
+
this->_scopedTheme = std::move(themeName);
|
215
|
+
}
|
@@ -37,16 +37,22 @@ struct UnistylesRegistry: public StyleSheetRegistry {
|
|
37
37
|
UnistylesState& getState(jsi::Runtime& rt);
|
38
38
|
void createState(jsi::Runtime& rt);
|
39
39
|
std::vector<std::shared_ptr<core::StyleSheet>> getStyleSheetsToRefresh(jsi::Runtime& rt, std::vector<UnistyleDependency>& unistylesDependencies);
|
40
|
-
void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, std::vector<
|
40
|
+
void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>& unistylesData);
|
41
41
|
void unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily*);
|
42
42
|
std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
|
43
43
|
DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
|
44
44
|
void shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Value& maybePressableId);
|
45
45
|
shadow::ShadowTrafficController trafficController{};
|
46
|
+
const core::Variants& getScopedVariants();
|
47
|
+
const std::optional<std::string> getScopedTheme();
|
48
|
+
void setScopedVariants(core::Variants&& variants);
|
49
|
+
void setScopedTheme(std::optional<std::string> themeName);
|
46
50
|
|
47
51
|
private:
|
48
52
|
UnistylesRegistry() = default;
|
49
|
-
|
53
|
+
|
54
|
+
core::Variants _scopedVariants{};
|
55
|
+
std::optional<std::string> _scopedTheme{};
|
50
56
|
std::unordered_map<jsi::Runtime*, UnistylesState> _states{};
|
51
57
|
std::unordered_map<jsi::Runtime*, std::unordered_map<int, std::shared_ptr<core::StyleSheet>>> _styleSheetRegistry{};
|
52
58
|
std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<const std::shared_ptr<UnistyleData>>>> _shadowRegistry{};
|
@@ -4,29 +4,83 @@ using namespace margelo::nitro::unistyles;
|
|
4
4
|
using namespace facebook::react;
|
5
5
|
|
6
6
|
jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
7
|
-
helpers::assertThat(rt, count ==
|
7
|
+
helpers::assertThat(rt, count == 2, "Unistyles: Invalid babel transform 'ShadowRegistry link' expected 2 arguments.");
|
8
8
|
|
9
9
|
ShadowNode::Shared shadowNodeWrapper = shadowNodeFromValue(rt, args[0]);
|
10
10
|
std::vector<core::Unistyle::Shared> unistyleWrappers = core::unistyleFromValue(rt, args[1]);
|
11
|
-
core::Variants variants = helpers::variantsToPairs(rt, args[2].asObject(rt));
|
12
|
-
jsi::Array rawArguments = args[3].asObject(rt).asArray(rt);
|
13
|
-
std::optional<std::string> uniquePressableId = args[4].isUndefined()
|
14
|
-
? std::nullopt
|
15
|
-
: std::make_optional<std::string>(args[4].asString(rt).utf8(rt));
|
16
11
|
std::vector<std::vector<folly::dynamic>> arguments;
|
17
12
|
auto& registry = core::UnistylesRegistry::get();
|
13
|
+
|
14
|
+
for (size_t i = 0; i < unistyleWrappers.size(); i++) {
|
15
|
+
if (unistyleWrappers[i]->type == core::UnistyleType::DynamicFunction) {
|
16
|
+
auto rawStyle = args[1].asObject(rt).asArray(rt).getValueAtIndex(rt, i);
|
17
|
+
|
18
|
+
helpers::assertThat(rt, rawStyle.isObject(), "Unistyles: Dynamic function is not bound!");
|
19
|
+
|
20
|
+
auto maybeSecrets = rawStyle.getObject(rt).getProperty(rt, helpers::SECRETS.c_str());
|
21
|
+
|
22
|
+
helpers::assertThat(rt, maybeSecrets.isObject(), "Unistyles: Dynamic function is not bound!");
|
23
|
+
|
24
|
+
auto secrets = maybeSecrets.asObject(rt).getProperty(rt, helpers::ARGUMENTS.c_str());
|
25
|
+
|
26
|
+
arguments.push_back(helpers::parseDynamicFunctionArguments(rt, secrets.asObject(rt).asArray(rt)));
|
27
|
+
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
|
31
|
+
arguments.push_back({});
|
32
|
+
}
|
18
33
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
34
|
+
auto scopedTheme = registry.getScopedTheme();
|
35
|
+
|
36
|
+
// check if scope theme exists
|
37
|
+
if (scopedTheme.has_value()) {
|
38
|
+
auto themeName = scopedTheme.value();
|
39
|
+
|
40
|
+
helpers::assertThat(rt, registry.getState(rt).hasTheme(themeName), "Unistyles: You're trying to use scoped theme '" + themeName + "' but it wasn't registered.");
|
41
|
+
}
|
42
|
+
|
43
|
+
auto parser = parser::Parser(this->_unistylesRuntime);
|
44
|
+
auto parsedStyleSheet = jsi::Value::undefined();
|
45
|
+
std::vector<std::shared_ptr<core::UnistyleData>> unistylesData{};
|
46
|
+
|
47
|
+
// create unistyleData based on wrappers
|
48
|
+
for (size_t i = 0; i < unistyleWrappers.size(); i++) {
|
49
|
+
core::Unistyle::Shared& unistyle = unistyleWrappers[i];
|
50
|
+
std::shared_ptr<core::UnistyleData> unistyleData = std::make_shared<core::UnistyleData>(
|
51
|
+
unistyle,
|
52
|
+
registry.getScopedVariants(),
|
53
|
+
arguments[i],
|
54
|
+
scopedTheme
|
55
|
+
);
|
56
|
+
|
57
|
+
// before linking we need to check if given unistyle is affected by scoped theme
|
58
|
+
if (scopedTheme.has_value()) {
|
59
|
+
if (parsedStyleSheet.isUndefined()) {
|
60
|
+
parsedStyleSheet = parser.getParsedStyleSheetForScopedTheme(rt, unistyle, scopedTheme.value());
|
61
|
+
}
|
62
|
+
|
63
|
+
// if so we need to force update
|
64
|
+
parser.rebuildUnistyleWithScopedTheme(rt, parsedStyleSheet, unistyleData);
|
65
|
+
} else {
|
66
|
+
// for other styles, not scoped to theme we need to compute variants value
|
67
|
+
parser.rebuildUnistyleWithVariants(rt, unistyleData);
|
68
|
+
}
|
69
|
+
|
70
|
+
unistylesData.emplace_back(unistyleData);
|
71
|
+
}
|
72
|
+
|
73
|
+
registry.linkShadowNodeWithUnistyle(
|
74
|
+
rt,
|
75
|
+
&shadowNodeWrapper->getFamily(),
|
76
|
+
unistylesData
|
77
|
+
);
|
24
78
|
|
25
79
|
return jsi::Value::undefined();
|
26
80
|
}
|
27
81
|
|
28
82
|
jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
29
|
-
helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry unlink' expected 1
|
83
|
+
helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry unlink' expected 1 argument.");
|
30
84
|
|
31
85
|
ShadowNode::Shared shadowNodeWrapper = shadowNodeFromValue(rt, args[0]);
|
32
86
|
|
@@ -36,3 +90,54 @@ jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &this
|
|
36
90
|
|
37
91
|
return jsi::Value::undefined();
|
38
92
|
}
|
93
|
+
|
94
|
+
jsi::Value HybridShadowRegistry::selectVariants(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
95
|
+
helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry selectVariants' expected 1 arguments.");
|
96
|
+
|
97
|
+
auto& registry = core::UnistylesRegistry::get();
|
98
|
+
|
99
|
+
if (args[0].isUndefined()) {
|
100
|
+
registry.setScopedVariants({});
|
101
|
+
}
|
102
|
+
|
103
|
+
if (args[0].isObject()) {
|
104
|
+
registry.setScopedVariants(helpers::variantsToPairs(rt, args[0].asObject(rt)));
|
105
|
+
}
|
106
|
+
|
107
|
+
return jsi::Value::undefined();
|
108
|
+
}
|
109
|
+
|
110
|
+
jsi::Value HybridShadowRegistry::setScopedTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
111
|
+
helpers::assertThat(rt, count == 1, "Unistyles: setScopedTheme expected 1 argument.");
|
112
|
+
|
113
|
+
auto& registry = core::UnistylesRegistry::get();
|
114
|
+
|
115
|
+
if (args[0].isUndefined()) {
|
116
|
+
|
117
|
+
registry.setScopedTheme(std::nullopt);
|
118
|
+
}
|
119
|
+
|
120
|
+
if (args[0].isString()) {
|
121
|
+
registry.setScopedTheme(args[0].asString(rt).utf8(rt));
|
122
|
+
}
|
123
|
+
|
124
|
+
return jsi::Value::undefined();
|
125
|
+
}
|
126
|
+
|
127
|
+
jsi::Value HybridShadowRegistry::getScopedTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
128
|
+
auto& registry = core::UnistylesRegistry::get();
|
129
|
+
auto maybeScopedTheme = registry.getScopedTheme();
|
130
|
+
|
131
|
+
return maybeScopedTheme.has_value()
|
132
|
+
? jsi::String::createFromUtf8(rt, maybeScopedTheme.value())
|
133
|
+
: jsi::Value::undefined();
|
134
|
+
}
|
135
|
+
|
136
|
+
jsi::Value HybridShadowRegistry::getVariants(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
137
|
+
auto& registry = core::UnistylesRegistry::get();
|
138
|
+
auto maybeScopedVariants = registry.getScopedVariants();
|
139
|
+
|
140
|
+
return maybeScopedVariants.size() > 0
|
141
|
+
? helpers::variantsToValue(rt, maybeScopedVariants)
|
142
|
+
: jsi::Value::undefined();
|
143
|
+
}
|
@@ -9,8 +9,9 @@
|
|
9
9
|
namespace margelo::nitro::unistyles {
|
10
10
|
|
11
11
|
struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
|
12
|
-
HybridShadowRegistry(
|
13
|
-
|
12
|
+
HybridShadowRegistry(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime)
|
13
|
+
: HybridObject(TAG), _unistylesRuntime{unistylesRuntime} {}
|
14
|
+
|
14
15
|
jsi::Value link(jsi::Runtime& rt,
|
15
16
|
const jsi::Value& thisValue,
|
16
17
|
const jsi::Value* args,
|
@@ -19,15 +20,38 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
|
|
19
20
|
const jsi::Value& thisValue,
|
20
21
|
const jsi::Value* args,
|
21
22
|
size_t count);
|
23
|
+
jsi::Value selectVariants(jsi::Runtime& rt,
|
24
|
+
const jsi::Value& thisValue,
|
25
|
+
const jsi::Value* args,
|
26
|
+
size_t count);
|
27
|
+
jsi::Value setScopedTheme(jsi::Runtime& rt,
|
28
|
+
const jsi::Value& thisValue,
|
29
|
+
const jsi::Value* args,
|
30
|
+
size_t count);
|
31
|
+
jsi::Value getScopedTheme(jsi::Runtime& rt,
|
32
|
+
const jsi::Value& thisValue,
|
33
|
+
const jsi::Value* args,
|
34
|
+
size_t count);
|
35
|
+
jsi::Value getVariants(jsi::Runtime& rt,
|
36
|
+
const jsi::Value& thisValue,
|
37
|
+
const jsi::Value* args,
|
38
|
+
size_t count);
|
22
39
|
|
23
40
|
void loadHybridMethods() override {
|
24
41
|
HybridUnistylesShadowRegistrySpec::loadHybridMethods();
|
25
42
|
|
26
43
|
registerHybrids(this, [](Prototype& prototype) {
|
27
44
|
prototype.registerRawHybridMethod("link", 2, &HybridShadowRegistry::link);
|
28
|
-
prototype.registerRawHybridMethod("unlink",
|
45
|
+
prototype.registerRawHybridMethod("unlink", 1, &HybridShadowRegistry::unlink);
|
46
|
+
prototype.registerRawHybridMethod("selectVariants", 1, &HybridShadowRegistry::selectVariants);
|
47
|
+
prototype.registerRawHybridMethod("setScopedTheme", 1, &HybridShadowRegistry::setScopedTheme);
|
48
|
+
prototype.registerRawHybridMethod("getScopedTheme", 0, &HybridShadowRegistry::getScopedTheme);
|
49
|
+
prototype.registerRawHybridMethod("getVariants", 0, &HybridShadowRegistry::getVariants);
|
29
50
|
});
|
30
51
|
};
|
52
|
+
|
53
|
+
private:
|
54
|
+
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
31
55
|
};
|
32
56
|
|
33
57
|
}
|
@@ -130,6 +130,10 @@ jsi::Value HybridUnistylesRuntime::getTheme(jsi::Runtime &rt, const jsi::Value &
|
|
130
130
|
auto& state = core::UnistylesRegistry::get().getState(*_rt);
|
131
131
|
|
132
132
|
if (count == 1) {
|
133
|
+
if (args[0].isUndefined()) {
|
134
|
+
return state.getCurrentJSTheme();
|
135
|
+
}
|
136
|
+
|
133
137
|
helpers::assertThat(rt, args[0].isString(), "UnistylesRuntime.getTheme expected to be called with string.");
|
134
138
|
|
135
139
|
auto themeName = args[0].asString(rt).utf8(rt);
|