react-native-unistyles 3.0.0-alpha.8 → 3.0.0-beta.1
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/LICENSE +1 -1
- package/README.md +30 -41
- package/Unistyles.podspec +1 -1
- package/android/CMakeLists.txt +22 -45
- package/android/build.gradle +16 -5
- package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
- package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
- package/android/src/main/cxx/cpp-adapter.cpp +8 -86
- package/android/src/main/java/com/unistyles/Equatable.kt +61 -0
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +294 -0
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +152 -0
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +59 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +51 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
- package/cxx/NativePlatform.h +11 -0
- package/cxx/common/Constants.h +3 -0
- package/cxx/common/Helpers.h +116 -5
- package/cxx/core/HostStyle.cpp +7 -2
- package/cxx/core/HostStyle.h +1 -1
- package/cxx/core/StyleSheet.h +0 -1
- package/cxx/core/Unistyle.h +8 -11
- package/cxx/core/UnistyleData.h +5 -3
- package/cxx/core/UnistyleWrapper.h +108 -13
- package/cxx/core/UnistylesCommitHook.cpp +14 -18
- package/cxx/core/UnistylesCommitHook.h +6 -11
- package/cxx/core/UnistylesCommitShadowNode.h +13 -0
- package/cxx/core/UnistylesMountHook.cpp +28 -0
- package/cxx/core/UnistylesMountHook.h +27 -0
- package/cxx/core/UnistylesRegistry.cpp +109 -48
- package/cxx/core/UnistylesRegistry.h +11 -10
- package/cxx/core/UnistylesState.cpp +29 -8
- package/cxx/core/UnistylesState.h +5 -2
- package/cxx/hybridObjects/HybridNavigationBar.cpp +0 -4
- package/cxx/hybridObjects/HybridNavigationBar.h +3 -4
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +18 -11
- package/cxx/hybridObjects/HybridStatusBar.cpp +0 -4
- package/cxx/hybridObjects/HybridStatusBar.h +3 -4
- package/cxx/hybridObjects/HybridStyleSheet.cpp +145 -19
- package/cxx/hybridObjects/HybridStyleSheet.h +27 -5
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +78 -11
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +17 -3
- package/cxx/parser/Parser.cpp +211 -128
- package/cxx/parser/Parser.h +7 -6
- package/cxx/shadowTree/ShadowLeafUpdate.h +3 -1
- package/cxx/shadowTree/ShadowTrafficController.h +71 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +28 -19
- package/cxx/shadowTree/ShadowTreeManager.h +3 -2
- package/ios/Equatable.swift +2 -1
- package/ios/Extensions.swift +3 -1
- package/ios/NativePlatform+ios.swift +34 -9
- package/ios/NativePlatform+keyboard.swift +83 -0
- package/ios/NativePlatformListener+ios.swift +36 -24
- package/ios/Unistyles.h +1 -0
- package/ios/UnistylesModuleOnLoad.h +8 -2
- package/ios/UnistylesModuleOnLoad.mm +9 -1
- package/lib/commonjs/components/Display.js +18 -0
- package/lib/commonjs/components/Display.js.map +1 -0
- package/lib/commonjs/components/Hide.js +18 -0
- package/lib/commonjs/components/Hide.js.map +1 -0
- package/lib/commonjs/components/Pressable.js +74 -0
- package/lib/commonjs/components/Pressable.js.map +1 -0
- package/lib/commonjs/components/Pressable.web.js +115 -0
- package/lib/commonjs/components/Pressable.web.js.map +1 -0
- package/lib/commonjs/components/index.js +27 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +79 -0
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.native.js +82 -0
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -0
- package/lib/commonjs/core/getBoundArgs.js +18 -0
- package/lib/commonjs/core/getBoundArgs.js.map +1 -0
- package/lib/commonjs/core/getId.js +9 -0
- package/lib/commonjs/core/getId.js.map +1 -0
- package/lib/commonjs/core/index.js +27 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/hooks/index.js +13 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useMedia.js +59 -0
- package/lib/commonjs/hooks/useMedia.js.map +1 -0
- package/lib/commonjs/hooks/useMedia.web.js +43 -0
- package/lib/commonjs/hooks/useMedia.web.js.map +1 -0
- package/lib/commonjs/index.js +28 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mq.js +31 -18
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/NavigtionBar/index.js +0 -15
- package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +11 -8
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js +0 -5
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +1 -0
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js +0 -2
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.js +7 -0
- package/lib/commonjs/specs/index.js.map +1 -1
- package/lib/commonjs/specs/index.web.js +0 -7
- package/lib/commonjs/specs/index.web.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/utils.js +26 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/convert/index.js +27 -24
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js +59 -0
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/object/filter.js +42 -0
- package/lib/commonjs/web/convert/object/filter.js.map +1 -0
- package/lib/commonjs/web/convert/object/index.js +39 -0
- package/lib/commonjs/web/convert/object/index.js.map +1 -0
- package/lib/commonjs/web/convert/object/objectStyle.js +56 -0
- package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
- package/lib/commonjs/web/convert/object/transform.js +27 -0
- package/lib/commonjs/web/convert/object/transform.js.map +1 -0
- package/lib/commonjs/web/convert/pseudo.js +10 -0
- package/lib/commonjs/web/convert/pseudo.js.map +1 -0
- package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +22 -37
- package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/index.js +28 -0
- package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
- package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +21 -35
- package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/style.js +11 -7
- package/lib/commonjs/web/convert/style.js.map +1 -1
- package/lib/commonjs/web/convert/types.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js +8 -4
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/create.js +35 -67
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/index.js +18 -7
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js +61 -0
- package/lib/commonjs/web/listener.js.map +1 -0
- package/lib/commonjs/web/mock.js +2 -12
- package/lib/commonjs/web/mock.js.map +1 -1
- package/lib/commonjs/web/registry.js +154 -19
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +22 -13
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +143 -0
- package/lib/commonjs/web/shadowRegistry.js.map +1 -0
- package/lib/commonjs/web/state.js +31 -72
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +39 -0
- package/lib/commonjs/web/utils/common.js.map +1 -0
- package/lib/commonjs/web/utils/index.js +28 -0
- package/lib/commonjs/web/utils/index.js.map +1 -0
- package/lib/commonjs/web/utils/unistyle.js +77 -0
- package/lib/commonjs/web/utils/unistyle.js.map +1 -0
- package/lib/commonjs/web/{variants/getVariants.js → variants.js} +2 -2
- package/lib/commonjs/web/variants.js.map +1 -0
- package/lib/module/components/Display.js +13 -0
- package/lib/module/components/Display.js.map +1 -0
- package/lib/module/components/Hide.js +13 -0
- package/lib/module/components/Hide.js.map +1 -0
- package/lib/module/components/Pressable.js +68 -0
- package/lib/module/components/Pressable.js.map +1 -0
- package/lib/module/components/Pressable.web.js +109 -0
- package/lib/module/components/Pressable.web.js.map +1 -0
- package/lib/module/components/index.js +6 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +72 -0
- package/lib/module/core/createUnistylesComponent.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.native.js +75 -0
- package/lib/module/core/createUnistylesComponent.native.js.map +1 -0
- package/lib/module/core/getBoundArgs.js +13 -0
- package/lib/module/core/getBoundArgs.js.map +1 -0
- package/lib/module/core/getId.js +4 -0
- package/lib/module/core/getId.js.map +1 -0
- package/lib/module/core/index.js +6 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/hooks/index.js +4 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useMedia.js +54 -0
- package/lib/module/hooks/useMedia.js.map +1 -0
- package/lib/module/hooks/useMedia.web.js +38 -0
- package/lib/module/hooks/useMedia.web.js.map +1 -0
- package/lib/module/index.js +2 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/mq.js +27 -17
- package/lib/module/mq.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/NavigtionBar/index.js +0 -10
- package/lib/module/specs/NavigtionBar/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +11 -8
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js +1 -6
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +1 -0
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js +0 -2
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.js +2 -1
- package/lib/module/specs/index.js.map +1 -1
- package/lib/module/specs/index.web.js +0 -1
- package/lib/module/specs/index.web.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/utils.js +21 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/convert/index.js +23 -20
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js +54 -0
- package/lib/module/web/convert/object/boxShadow.js.map +1 -0
- package/lib/module/web/convert/object/filter.js +37 -0
- package/lib/module/web/convert/object/filter.js.map +1 -0
- package/lib/module/web/convert/object/index.js +6 -0
- package/lib/module/web/convert/object/index.js.map +1 -0
- package/lib/module/web/convert/object/objectStyle.js +51 -0
- package/lib/module/web/convert/object/objectStyle.js.map +1 -0
- package/lib/module/web/convert/object/transform.js +22 -0
- package/lib/module/web/convert/object/transform.js.map +1 -0
- package/lib/module/web/convert/pseudo.js +5 -0
- package/lib/module/web/convert/pseudo.js.map +1 -0
- package/lib/module/web/convert/shadow/boxShadow.js +57 -0
- package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/module/web/convert/shadow/index.js +5 -0
- package/lib/module/web/convert/shadow/index.js.map +1 -0
- package/lib/module/web/convert/shadow/textShadow.js +54 -0
- package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/module/web/convert/style.js +11 -7
- package/lib/module/web/convert/style.js.map +1 -1
- package/lib/module/web/convert/types.js.map +1 -1
- package/lib/module/web/convert/utils.js +5 -3
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/create.js +37 -69
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/index.js +9 -3
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/listener.js +57 -0
- package/lib/module/web/listener.js.map +1 -0
- package/lib/module/web/mock.js +1 -11
- package/lib/module/web/mock.js.map +1 -1
- package/lib/module/web/registry.js +155 -20
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +23 -14
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +139 -0
- package/lib/module/web/shadowRegistry.js.map +1 -0
- package/lib/module/web/state.js +32 -73
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js +28 -0
- package/lib/module/web/utils/common.js.map +1 -0
- package/lib/module/web/utils/index.js +5 -0
- package/lib/module/web/utils/index.js.map +1 -0
- package/lib/module/web/utils/unistyle.js +65 -0
- package/lib/module/web/utils/unistyle.js.map +1 -0
- package/lib/module/web/{variants/getVariants.js → variants.js} +2 -2
- package/lib/module/web/variants.js.map +1 -0
- package/lib/typescript/src/components/Display.d.ts +7 -0
- package/lib/typescript/src/components/Display.d.ts.map +1 -0
- package/lib/typescript/src/components/Hide.d.ts +7 -0
- package/lib/typescript/src/components/Hide.d.ts.map +1 -0
- package/lib/typescript/src/components/Pressable.d.ts +8 -0
- package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/Pressable.web.d.ts +14 -0
- package/lib/typescript/src/components/Pressable.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +4 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +8 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +8 -0
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -0
- package/lib/typescript/src/core/getBoundArgs.d.ts +2 -0
- package/lib/typescript/src/core/getBoundArgs.d.ts.map +1 -0
- package/lib/typescript/src/core/getId.d.ts +2 -0
- package/lib/typescript/src/core/getId.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +4 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +2 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMedia.d.ts +6 -0
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMedia.web.d.ts +6 -0
- package/lib/typescript/src/hooks/useMedia.web.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts +8 -0
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +8 -6
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/index.d.ts +1 -10
- package/lib/typescript/src/specs/NavigtionBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +4 -4
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts +2 -4
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +3 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +5 -3
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +4 -2
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.d.ts +4 -2
- package/lib/typescript/src/specs/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.web.d.ts +0 -2
- package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +11 -11
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +2 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +6 -4
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +4 -1
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +2 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/index.d.ts +1 -2
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
- package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/pseudo.d.ts +6 -0
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts +8 -0
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts +8 -0
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/style.d.ts +1 -2
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/types.d.ts +7 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts +8 -4
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +215 -1221
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +223 -1222
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/{listener/listener.d.ts → listener.d.ts} +5 -2
- package/lib/typescript/src/web/listener.d.ts.map +1 -0
- package/lib/typescript/src/web/mock.d.ts +0 -9
- package/lib/typescript/src/web/mock.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +18 -6
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +6 -5
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
- package/lib/typescript/src/web/state.d.ts +3 -9
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts +8 -0
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/index.d.ts +3 -0
- package/lib/typescript/src/web/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts +19 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -0
- package/lib/typescript/src/web/{variants/getVariants.d.ts → variants.d.ts} +2 -2
- package/lib/typescript/src/web/variants.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JColorScheme.hpp +2 -2
- package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +57 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +69 -0
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +35 -34
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +15 -6
- package/nitrogen/generated/android/c++/JOrientation.hpp +2 -2
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +5 -2
- package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +9 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/ColorScheme.kt +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/{Func_void_std__vector_UnistyleDependency_.kt → Func_void_UnistylesNativeMiniRuntime.kt} +6 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +25 -13
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Orientation.kt +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +6 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +3 -1
- package/nitrogen/generated/android/unistyles+autolinking.cmake +13 -1
- package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
- package/nitrogen/generated/android/{UnistylesOnLoad.cpp → unistylesOnLoad.cpp} +6 -4
- package/nitrogen/generated/android/{UnistylesOnLoad.hpp → unistylesOnLoad.hpp} +1 -1
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +6 -4
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +25 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +73 -38
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +1 -30
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +8 -8
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +4 -16
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +156 -115
- package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
- package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +16 -5
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.cpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +6 -3
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +5 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +2 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +10 -4
- package/nitrogen/generated/shared/c++/Orientation.hpp +2 -2
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +10 -9
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +9 -8
- package/package.json +24 -37
- package/plugin/common.js +27 -2
- package/plugin/import.js +29 -3
- package/plugin/index.js +104 -15
- package/plugin/ref.js +58 -44
- package/plugin/style.js +443 -9
- package/plugin/stylesheet.js +10 -3
- package/src/components/Display.tsx +12 -0
- package/src/components/Hide.tsx +12 -0
- package/src/components/Pressable.tsx +89 -0
- package/src/components/Pressable.web.tsx +129 -0
- package/src/components/index.ts +3 -0
- package/src/core/createUnistylesComponent.native.tsx +83 -0
- package/src/core/createUnistylesComponent.tsx +84 -0
- package/src/core/getBoundArgs.ts +15 -0
- package/src/core/getId.ts +1 -0
- package/src/core/index.ts +3 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useMedia.ts +64 -0
- package/src/hooks/useMedia.web.ts +47 -0
- package/src/index.ts +3 -12
- package/src/mq.ts +33 -15
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +8 -6
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.ts +0 -1
- package/src/specs/NavigtionBar/index.ts +1 -25
- package/src/specs/ShadowRegistry/index.ts +17 -12
- package/src/specs/ShadowRegistry/types.ts +6 -2
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.ts +0 -1
- package/src/specs/StatusBar/index.ts +2 -12
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +4 -1
- package/src/specs/StyleSheet/index.ts +7 -3
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -2
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +2 -2
- package/src/specs/UnistylesRuntime/index.ts +4 -3
- package/src/specs/index.ts +6 -2
- package/src/specs/index.web.ts +0 -4
- package/src/types/breakpoints.ts +25 -13
- package/src/types/common.ts +2 -0
- package/src/types/index.ts +2 -2
- package/src/types/stylesheet.ts +7 -5
- package/src/types/variants.ts +7 -1
- package/src/utils.ts +22 -0
- package/src/web/convert/index.ts +24 -24
- package/src/web/convert/object/boxShadow.ts +55 -0
- package/src/web/convert/object/filter.ts +39 -0
- package/src/web/convert/object/index.ts +3 -0
- package/src/web/convert/object/objectStyle.ts +69 -0
- package/src/web/convert/object/transform.ts +24 -0
- package/src/web/convert/pseudo.ts +137 -0
- package/src/web/convert/shadow/boxShadow.ts +50 -0
- package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
- package/src/web/convert/shadow/index.ts +2 -0
- package/src/web/convert/shadow/textShadow.ts +48 -0
- package/src/web/convert/style.ts +61 -10
- package/src/web/convert/types.ts +8 -1
- package/src/web/convert/utils.ts +13 -7
- package/src/web/create.ts +35 -83
- package/src/web/index.ts +9 -4
- package/src/web/listener.ts +65 -0
- package/src/web/mock.ts +1 -12
- package/src/web/registry.ts +202 -28
- package/src/web/runtime.ts +29 -18
- package/src/web/shadowRegistry.ts +149 -0
- package/src/web/state.ts +52 -87
- package/src/web/utils/common.ts +45 -0
- package/src/web/utils/index.ts +2 -0
- package/src/web/utils/unistyle.ts +94 -0
- package/src/web/{variants/getVariants.ts → variants.ts} +2 -2
- package/android/src/main/cxx/helpers.cpp +0 -105
- package/android/src/main/cxx/helpers.h +0 -16
- package/android/src/main/cxx/platform.cpp +0 -170
- package/android/src/main/cxx/platform.h +0 -20
- package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
- package/lib/commonjs/web/convert/breakpoint.js +0 -25
- package/lib/commonjs/web/convert/breakpoint.js.map +0 -1
- package/lib/commonjs/web/convert/shadow.js +0 -68
- package/lib/commonjs/web/convert/shadow.js.map +0 -1
- package/lib/commonjs/web/convert/textShadow.js.map +0 -1
- package/lib/commonjs/web/convert/transform.js +0 -72
- package/lib/commonjs/web/convert/transform.js.map +0 -1
- package/lib/commonjs/web/listener/index.js +0 -13
- package/lib/commonjs/web/listener/index.js.map +0 -1
- package/lib/commonjs/web/listener/listener.js +0 -36
- package/lib/commonjs/web/listener/listener.js.map +0 -1
- package/lib/commonjs/web/mq.js +0 -23
- package/lib/commonjs/web/mq.js.map +0 -1
- package/lib/commonjs/web/pseudo.js +0 -11
- package/lib/commonjs/web/pseudo.js.map +0 -1
- package/lib/commonjs/web/utils.js +0 -78
- package/lib/commonjs/web/utils.js.map +0 -1
- package/lib/commonjs/web/variants/getVariants.js.map +0 -1
- package/lib/commonjs/web/variants/index.js +0 -28
- package/lib/commonjs/web/variants/index.js.map +0 -1
- package/lib/commonjs/web/variants/useVariants.js +0 -75
- package/lib/commonjs/web/variants/useVariants.js.map +0 -1
- package/lib/module/web/convert/boxShadow.js +0 -72
- package/lib/module/web/convert/boxShadow.js.map +0 -1
- package/lib/module/web/convert/breakpoint.js +0 -20
- package/lib/module/web/convert/breakpoint.js.map +0 -1
- package/lib/module/web/convert/shadow.js +0 -63
- package/lib/module/web/convert/shadow.js.map +0 -1
- package/lib/module/web/convert/textShadow.js +0 -68
- package/lib/module/web/convert/textShadow.js.map +0 -1
- package/lib/module/web/convert/transform.js +0 -67
- package/lib/module/web/convert/transform.js.map +0 -1
- package/lib/module/web/listener/index.js +0 -4
- package/lib/module/web/listener/index.js.map +0 -1
- package/lib/module/web/listener/listener.js +0 -31
- package/lib/module/web/listener/listener.js.map +0 -1
- package/lib/module/web/mq.js +0 -17
- package/lib/module/web/mq.js.map +0 -1
- package/lib/module/web/pseudo.js +0 -6
- package/lib/module/web/pseudo.js.map +0 -1
- package/lib/module/web/utils.js +0 -65
- package/lib/module/web/utils.js.map +0 -1
- package/lib/module/web/variants/getVariants.js.map +0 -1
- package/lib/module/web/variants/index.js +0 -5
- package/lib/module/web/variants/index.js.map +0 -1
- package/lib/module/web/variants/useVariants.js +0 -70
- package/lib/module/web/variants/useVariants.js.map +0 -1
- package/lib/typescript/example/App.d.ts +0 -4
- package/lib/typescript/example/App.d.ts.map +0 -1
- package/lib/typescript/example/Typography.d.ts +0 -11
- package/lib/typescript/example/Typography.d.ts.map +0 -1
- package/lib/typescript/example/unistyles.d.ts +0 -63
- package/lib/typescript/example/unistyles.d.ts.map +0 -1
- package/lib/typescript/expo-example/App.d.ts +0 -4
- package/lib/typescript/expo-example/App.d.ts.map +0 -1
- package/lib/typescript/expo-example/unistyles.d.ts +0 -63
- package/lib/typescript/expo-example/unistyles.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts +0 -3
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/breakpoint.d.ts +0 -3
- package/lib/typescript/src/web/convert/breakpoint.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
- package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/textShadow.d.ts +0 -3
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/transform.d.ts +0 -5
- package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
- package/lib/typescript/src/web/listener/index.d.ts +0 -2
- package/lib/typescript/src/web/listener/index.d.ts.map +0 -1
- package/lib/typescript/src/web/listener/listener.d.ts.map +0 -1
- package/lib/typescript/src/web/mq.d.ts +0 -4
- package/lib/typescript/src/web/mq.d.ts.map +0 -1
- package/lib/typescript/src/web/pseudo.d.ts +0 -4
- package/lib/typescript/src/web/pseudo.d.ts.map +0 -1
- package/lib/typescript/src/web/utils.d.ts +0 -20
- package/lib/typescript/src/web/utils.d.ts.map +0 -1
- package/lib/typescript/src/web/variants/getVariants.d.ts.map +0 -1
- package/lib/typescript/src/web/variants/index.d.ts +0 -3
- package/lib/typescript/src/web/variants/index.d.ts.map +0 -1
- package/lib/typescript/src/web/variants/useVariants.d.ts +0 -3
- package/lib/typescript/src/web/variants/useVariants.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency_.hpp +0 -60
- package/plugin/__tests__/dependencies.spec.js +0 -438
- package/plugin/__tests__/ref.spec.js +0 -1181
- package/plugin/__tests__/stylesheet.spec.js +0 -489
- package/src/web/convert/boxShadow.ts +0 -72
- package/src/web/convert/breakpoint.ts +0 -21
- package/src/web/convert/shadow.ts +0 -68
- package/src/web/convert/textShadow.ts +0 -69
- package/src/web/convert/transform.ts +0 -89
- package/src/web/listener/index.ts +0 -1
- package/src/web/listener/listener.ts +0 -33
- package/src/web/mq.ts +0 -19
- package/src/web/pseudo.ts +0 -11
- package/src/web/utils.ts +0 -95
- package/src/web/variants/index.ts +0 -2
- package/src/web/variants/useVariants.ts +0 -79
- /package/nitrogen/generated/android/{UnistylesOnLoad.kt → unistylesOnLoad.kt} +0 -0
@@ -9,11 +9,15 @@ double HybridStyleSheet::getHairlineWidth() {
|
|
9
9
|
return nearestPixel / pixelRatio;
|
10
10
|
}
|
11
11
|
|
12
|
-
double HybridStyleSheet::
|
12
|
+
double HybridStyleSheet::getUnid() {
|
13
13
|
return this->__unid;
|
14
14
|
}
|
15
15
|
|
16
16
|
jsi::Value HybridStyleSheet::create(jsi::Runtime& rt, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) {
|
17
|
+
if (count == 1) {
|
18
|
+
helpers::assertThat(rt, false, "Unistyles is not initialized correctly. Please add babel plugin to your babel config.");
|
19
|
+
}
|
20
|
+
|
17
21
|
// second argument is hidden, so validation is perfectly fine
|
18
22
|
helpers::assertThat(rt, count == 2, "StyleSheet.create expected to be called with one argument.");
|
19
23
|
helpers::assertThat(rt, arguments[0].isObject(), "StyleSheet.create expected to be called with object or function.");
|
@@ -42,11 +46,7 @@ jsi::Value HybridStyleSheet::configure(jsi::Runtime &rt, const jsi::Value &thisV
|
|
42
46
|
helpers::assertThat(rt, count == 1, "StyleSheet.configure expected to be called with one argument.");
|
43
47
|
helpers::assertThat(rt, arguments[0].isObject(), "StyleSheet.configure expected to be called with object.");
|
44
48
|
|
45
|
-
// create new state
|
46
49
|
auto config = arguments[0].asObject(rt);
|
47
|
-
auto& registry = core::UnistylesRegistry::get();
|
48
|
-
|
49
|
-
registry.createState(rt);
|
50
50
|
|
51
51
|
helpers::enumerateJSIObject(rt, config, [&](const std::string& propertyName, jsi::Value& propertyValue){
|
52
52
|
if (propertyName == "settings") {
|
@@ -71,7 +71,22 @@ jsi::Value HybridStyleSheet::configure(jsi::Runtime &rt, const jsi::Value &thisV
|
|
71
71
|
});
|
72
72
|
|
73
73
|
verifyAndSelectTheme(rt);
|
74
|
+
|
75
|
+
auto& state = core::UnistylesRegistry::get().getState(rt);
|
76
|
+
|
77
|
+
state.hasUserConfig = true;
|
78
|
+
|
79
|
+
return jsi::Value::undefined();
|
80
|
+
}
|
81
|
+
|
82
|
+
jsi::Value HybridStyleSheet::init(jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) {
|
83
|
+
// create new state
|
84
|
+
auto& registry = core::UnistylesRegistry::get();
|
85
|
+
|
86
|
+
registry.createState(rt);
|
87
|
+
|
74
88
|
loadExternalMethods(thisVal, rt);
|
89
|
+
registerHooks(rt);
|
75
90
|
|
76
91
|
return jsi::Value::undefined();
|
77
92
|
}
|
@@ -113,7 +128,7 @@ void HybridStyleSheet::parseSettings(jsi::Runtime &rt, jsi::Object settings) {
|
|
113
128
|
void HybridStyleSheet::parseBreakpoints(jsi::Runtime &rt, jsi::Object breakpoints){
|
114
129
|
helpers::Breakpoints sortedBreakpoints = helpers::jsiBreakpointsToVecPairs(rt, std::move(breakpoints));
|
115
130
|
|
116
|
-
helpers::assertThat(rt, sortedBreakpoints.
|
131
|
+
helpers::assertThat(rt, !sortedBreakpoints.empty(), "StyleSheet.configure's breakpoints can't be empty.");
|
117
132
|
helpers::assertThat(rt, sortedBreakpoints.front().second == 0, "StyleSheet.configure's first breakpoint must start from 0.");
|
118
133
|
|
119
134
|
auto& registry = core::UnistylesRegistry::get();
|
@@ -129,11 +144,10 @@ void HybridStyleSheet::parseThemes(jsi::Runtime &rt, jsi::Object themes) {
|
|
129
144
|
helpers::enumerateJSIObject(rt, themes, [&](const std::string& propertyName, jsi::Value& propertyValue){
|
130
145
|
helpers::assertThat(rt, propertyValue.isObject(), "StyleSheet.configure's registered theme '" + propertyName + "' must be an object.");
|
131
146
|
|
132
|
-
registry.registerTheme(rt, propertyName, propertyValue
|
147
|
+
registry.registerTheme(rt, propertyName, propertyValue);
|
133
148
|
});
|
134
149
|
}
|
135
150
|
|
136
|
-
|
137
151
|
void HybridStyleSheet::verifyAndSelectTheme(jsi::Runtime &rt) {
|
138
152
|
auto& state = core::UnistylesRegistry::get().getState(rt);
|
139
153
|
|
@@ -183,7 +197,7 @@ void HybridStyleSheet::verifyAndSelectTheme(jsi::Runtime &rt) {
|
|
183
197
|
|
184
198
|
void HybridStyleSheet::setThemeFromColorScheme(jsi::Runtime& rt) {
|
185
199
|
auto& state = core::UnistylesRegistry::get().getState(rt);
|
186
|
-
|
200
|
+
auto colorScheme = static_cast<ColorScheme>(this->_unistylesRuntime->getColorScheme());
|
187
201
|
|
188
202
|
switch (colorScheme) {
|
189
203
|
case ColorScheme::LIGHT:
|
@@ -215,27 +229,139 @@ void HybridStyleSheet::loadExternalMethods(const jsi::Value& thisValue, jsi::Run
|
|
215
229
|
state.registerProcessColorFunction(std::move(processColorFn));
|
216
230
|
}
|
217
231
|
|
232
|
+
void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
|
233
|
+
// cleanup Shadow updates
|
234
|
+
core::UnistylesRegistry::get().trafficController.restore();
|
235
|
+
|
236
|
+
this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager);
|
237
|
+
this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager, this->_unistylesRuntime);
|
238
|
+
}
|
239
|
+
|
218
240
|
void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies) {
|
241
|
+
// this event listener is triggered from C++ module, and it's only about theme / adaptive theme changes
|
242
|
+
if (dependencies.size() == 0) {
|
243
|
+
return;
|
244
|
+
}
|
245
|
+
|
219
246
|
auto& registry = core::UnistylesRegistry::get();
|
220
|
-
auto parser = parser::Parser(this->_unistylesRuntime);
|
221
247
|
auto& rt = this->_unistylesRuntime->getRuntime();
|
248
|
+
auto parser = parser::Parser(this->_unistylesRuntime);
|
249
|
+
auto dependencyMap = registry.buildDependencyMap(rt, dependencies);
|
222
250
|
|
223
|
-
|
224
|
-
|
251
|
+
if (dependencyMap.empty()) {
|
252
|
+
this->notifyJSListeners(dependencies);
|
225
253
|
|
226
|
-
|
227
|
-
this->_unistylesRuntime->includeDependenciesForColorSchemeChange(dependencies);
|
254
|
+
return;
|
228
255
|
}
|
229
256
|
|
230
|
-
|
257
|
+
// in a later step, we will rebuild only Unistyles with mounted StyleSheets
|
258
|
+
// however, user may have StyleSheets with components that haven't mounted yet
|
259
|
+
// we need to rebuild all dependent StyleSheets as well
|
260
|
+
auto dependentStyleSheets = registry.getStyleSheetsToRefresh(rt, dependencies);
|
261
|
+
|
262
|
+
parser.rebuildUnistylesInDependencyMap(rt, dependencyMap, dependentStyleSheets, std::nullopt);
|
263
|
+
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
264
|
+
|
265
|
+
this->notifyJSListeners(dependencies);
|
266
|
+
shadow::ShadowTreeManager::updateShadowTree(UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry());
|
267
|
+
}
|
268
|
+
|
269
|
+
void HybridStyleSheet::onPlatformNativeDependenciesChange(std::vector<UnistyleDependency> dependencies, UnistylesNativeMiniRuntime miniRuntime) {
|
270
|
+
// this event listener is triggered from Native platform
|
271
|
+
if (dependencies.size() == 0 || this->_unistylesRuntime == nullptr) {
|
272
|
+
return;
|
273
|
+
}
|
274
|
+
|
275
|
+
this->_unistylesRuntime->runOnJSThread([this, dependencies, miniRuntime](jsi::Runtime& rt){
|
276
|
+
auto& registry = core::UnistylesRegistry::get();
|
277
|
+
auto parser = parser::Parser(this->_unistylesRuntime);
|
278
|
+
auto unistyleDependencies = std::move(dependencies);
|
279
|
+
|
280
|
+
// re-compute new breakpoint
|
281
|
+
auto dimensionsIt = std::find(dependencies.begin(), dependencies.end(), UnistyleDependency::DIMENSIONS);
|
282
|
+
|
283
|
+
if (dimensionsIt != dependencies.end()) {
|
284
|
+
registry.getState(rt).computeCurrentBreakpoint(this->_unistylesRuntime->getScreen().width);
|
285
|
+
}
|
286
|
+
|
287
|
+
// check if color scheme changed and then if Unistyles state depend on it (adaptive themes)
|
288
|
+
auto colorSchemeIt = std::find(dependencies.begin(), dependencies.end(), UnistyleDependency::COLORSCHEME);
|
289
|
+
auto hasNewColorScheme = colorSchemeIt != dependencies.end();
|
290
|
+
|
291
|
+
if (hasNewColorScheme) {
|
292
|
+
this->_unistylesRuntime->includeDependenciesForColorSchemeChange(unistyleDependencies);
|
293
|
+
}
|
294
|
+
|
295
|
+
auto dependencyMap = registry.buildDependencyMap(rt, unistyleDependencies);
|
296
|
+
|
297
|
+
if (dependencyMap.empty()) {
|
298
|
+
this->notifyJSListeners(unistyleDependencies);
|
299
|
+
|
300
|
+
return;
|
301
|
+
}
|
302
|
+
|
303
|
+
// in a later step, we will rebuild only Unistyles with mounted StyleSheets
|
304
|
+
// however, user may have StyleSheets with components that haven't mounted yet
|
305
|
+
// we need to rebuild all dependent StyleSheets as well
|
306
|
+
auto dependentStyleSheets = registry.getStyleSheetsToRefresh(rt, unistyleDependencies);
|
307
|
+
|
308
|
+
parser.rebuildUnistylesInDependencyMap(rt, dependencyMap, dependentStyleSheets, miniRuntime);
|
309
|
+
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
310
|
+
|
311
|
+
this->notifyJSListeners(unistyleDependencies);
|
312
|
+
shadow::ShadowTreeManager::updateShadowTree(UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry());
|
313
|
+
});
|
314
|
+
}
|
231
315
|
|
232
|
-
|
316
|
+
void HybridStyleSheet::onImeChange(UnistylesNativeMiniRuntime miniRuntime) {
|
317
|
+
if (this->_unistylesRuntime == nullptr) {
|
233
318
|
return;
|
234
319
|
}
|
235
320
|
|
236
|
-
|
321
|
+
this->_unistylesRuntime->runOnJSThread([this, miniRuntime](jsi::Runtime& rt){
|
322
|
+
std::vector<UnistyleDependency> dependencies{UnistyleDependency::IME};
|
323
|
+
auto& registry = core::UnistylesRegistry::get();
|
324
|
+
auto parser = parser::Parser(this->_unistylesRuntime);
|
325
|
+
auto dependencyMap = registry.buildDependencyMap(rt, dependencies);
|
326
|
+
|
327
|
+
if (dependencyMap.empty()) {
|
328
|
+
this->notifyJSListeners(dependencies);
|
237
329
|
|
238
|
-
|
330
|
+
return;
|
331
|
+
}
|
239
332
|
|
240
|
-
|
333
|
+
// we don't care about other unmounted stylesheets as their not visible
|
334
|
+
// so user won't see any changes
|
335
|
+
std::vector<std::shared_ptr<core::StyleSheet>> dependentStyleSheets;
|
336
|
+
|
337
|
+
parser.rebuildUnistylesInDependencyMap(rt, dependencyMap, dependentStyleSheets, miniRuntime);
|
338
|
+
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
339
|
+
|
340
|
+
this->notifyJSListeners(dependencies);
|
341
|
+
shadow::ShadowTreeManager::updateShadowTree(UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry());
|
342
|
+
});
|
343
|
+
}
|
344
|
+
|
345
|
+
void HybridStyleSheet::notifyJSListeners(std::vector<UnistyleDependency>& dependencies) {
|
346
|
+
if (!dependencies.empty()) {
|
347
|
+
std::for_each(this->_changeListeners.begin(), this->_changeListeners.end(), [&](auto& listener){
|
348
|
+
(*listener)(dependencies);
|
349
|
+
});
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
353
|
+
std::function<void ()> HybridStyleSheet::addChangeListener(const std::function<void (const std::vector<UnistyleDependency>&)>& onChanged) {
|
354
|
+
auto listener = std::make_unique<std::function<void(std::vector<UnistyleDependency>&)>>(onChanged);
|
355
|
+
|
356
|
+
this->_changeListeners.push_back(std::move(listener));
|
357
|
+
|
358
|
+
return [this, listenerPtr = this->_changeListeners.back().get()](){
|
359
|
+
auto it = std::find_if(this->_changeListeners.begin(), this->_changeListeners.end(), [listenerPtr](auto& ptr) {
|
360
|
+
return ptr.get() == listenerPtr;
|
361
|
+
});
|
362
|
+
|
363
|
+
if (it != this->_changeListeners.end()) {
|
364
|
+
this->_changeListeners.erase(it);
|
365
|
+
}
|
366
|
+
};
|
241
367
|
}
|
@@ -9,21 +9,30 @@
|
|
9
9
|
#include "Constants.h"
|
10
10
|
#include "Breakpoints.h"
|
11
11
|
#include "Parser.h"
|
12
|
-
#include "ShadowTreeManager.h"
|
13
12
|
#include "UnistylesCommitHook.h"
|
13
|
+
#include "UnistylesMountHook.h"
|
14
14
|
|
15
15
|
using namespace margelo::nitro::unistyles;
|
16
16
|
using namespace facebook::react;
|
17
17
|
|
18
18
|
struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
|
19
19
|
HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, std::shared_ptr<UIManager> uiManager)
|
20
|
-
: HybridObject(TAG), _unistylesRuntime{unistylesRuntime} {
|
21
|
-
this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(uiManager, unistylesRuntime);
|
20
|
+
: HybridObject(TAG), _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager} {
|
22
21
|
this->_unistylesRuntime->registerPlatformListener(
|
23
22
|
std::bind(&HybridStyleSheet::onPlatformDependenciesChange, this, std::placeholders::_1)
|
24
23
|
);
|
24
|
+
this->_unistylesRuntime->registerNativePlatformListener(
|
25
|
+
std::bind(&HybridStyleSheet::onPlatformNativeDependenciesChange, this, std::placeholders::_1, std::placeholders::_2)
|
26
|
+
);
|
27
|
+
this->_unistylesRuntime->registerImeListener(
|
28
|
+
std::bind(&HybridStyleSheet::onImeChange, this, std::placeholders::_1)
|
29
|
+
);
|
25
30
|
}
|
26
31
|
|
32
|
+
~HybridStyleSheet() {
|
33
|
+
this->_unistylesRuntime->unregisterNativePlatformListeners();
|
34
|
+
}
|
35
|
+
|
27
36
|
jsi::Value create(jsi::Runtime& rt,
|
28
37
|
const jsi::Value& thisValue,
|
29
38
|
const jsi::Value* args,
|
@@ -32,19 +41,25 @@ struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
|
|
32
41
|
const jsi::Value& thisValue,
|
33
42
|
const jsi::Value* args,
|
34
43
|
size_t count);
|
44
|
+
jsi::Value init(jsi::Runtime& rt,
|
45
|
+
const jsi::Value& thisValue,
|
46
|
+
const jsi::Value* args,
|
47
|
+
size_t count);
|
35
48
|
|
36
49
|
void loadHybridMethods() override {
|
37
50
|
HybridUnistylesStyleSheetSpec::loadHybridMethods();
|
38
51
|
|
39
52
|
registerHybrids(this, [](Prototype& prototype) {
|
53
|
+
prototype.registerRawHybridMethod("init", 1, &HybridStyleSheet::init);
|
40
54
|
prototype.registerRawHybridMethod("create", 1, &HybridStyleSheet::create);
|
41
55
|
prototype.registerRawHybridMethod("configure", 1, &HybridStyleSheet::configure);
|
42
56
|
});
|
43
57
|
};
|
44
58
|
|
45
59
|
double getHairlineWidth() override;
|
46
|
-
double
|
47
|
-
|
60
|
+
double getUnid() override;
|
61
|
+
std::function<void ()> addChangeListener(const std::function<void (const std::vector<UnistyleDependency> &)>& onChanged) override;
|
62
|
+
|
48
63
|
private:
|
49
64
|
void parseSettings(jsi::Runtime& rt, jsi::Object settings);
|
50
65
|
void parseBreakpoints(jsi::Runtime& rt, jsi::Object breakpoints);
|
@@ -52,10 +67,17 @@ private:
|
|
52
67
|
void verifyAndSelectTheme(jsi::Runtime &rt);
|
53
68
|
void setThemeFromColorScheme(jsi::Runtime& rt);
|
54
69
|
void loadExternalMethods(const jsi::Value& thisValue, jsi::Runtime& rt);
|
70
|
+
void registerHooks(jsi::Runtime& rt);
|
55
71
|
void onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies);
|
72
|
+
void onPlatformNativeDependenciesChange(std::vector<UnistyleDependency> dependencies, UnistylesNativeMiniRuntime miniRuntime);
|
73
|
+
void onImeChange(UnistylesNativeMiniRuntime miniRuntime);
|
74
|
+
void notifyJSListeners(std::vector<UnistyleDependency>& dependencies);
|
56
75
|
|
57
76
|
double __unid = -1;
|
77
|
+
std::vector<std::unique_ptr<const std::function<void(std::vector<UnistyleDependency>&)>>> _changeListeners{};
|
58
78
|
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
59
79
|
std::shared_ptr<core::UnistylesCommitHook> _unistylesCommitHook;
|
80
|
+
std::shared_ptr<core::UnistylesMountHook> _unistylesMountHook;
|
81
|
+
std::shared_ptr<UIManager> _uiManager;
|
60
82
|
};
|
61
83
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
using namespace margelo::nitro::unistyles;
|
5
5
|
|
6
6
|
ColorScheme HybridUnistylesRuntime::getColorScheme() {
|
7
|
-
|
7
|
+
auto colorScheme = this->_nativePlatform.getColorScheme();
|
8
8
|
|
9
9
|
return static_cast<ColorScheme>(colorScheme);
|
10
10
|
}
|
@@ -44,7 +44,7 @@ Insets HybridUnistylesRuntime::getInsets() {
|
|
44
44
|
};
|
45
45
|
|
46
46
|
Orientation HybridUnistylesRuntime::getOrientation() {
|
47
|
-
|
47
|
+
auto orientation = this->_nativePlatform.getOrientation();
|
48
48
|
|
49
49
|
return static_cast<Orientation>(orientation);
|
50
50
|
};
|
@@ -57,6 +57,18 @@ double HybridUnistylesRuntime::getFontScale() {
|
|
57
57
|
return this->_nativePlatform.getFontScale();
|
58
58
|
};
|
59
59
|
|
60
|
+
std::unordered_map<std::string, double> HybridUnistylesRuntime::getBreakpoints() {
|
61
|
+
auto& state = core::UnistylesRegistry::get().getState(*_rt);
|
62
|
+
auto sortedBreakpointPairs = state.getSortedBreakpointPairs();
|
63
|
+
std::unordered_map<std::string, double> breakpoints{};
|
64
|
+
|
65
|
+
std::for_each(sortedBreakpointPairs.begin(), sortedBreakpointPairs.end(), [&breakpoints](std::pair<std::string, double>& pair){
|
66
|
+
breakpoints[pair.first] = pair.second;
|
67
|
+
});
|
68
|
+
|
69
|
+
return breakpoints;
|
70
|
+
}
|
71
|
+
|
60
72
|
void HybridUnistylesRuntime::setTheme(const std::string &themeName) {
|
61
73
|
helpers::assertThat(*_rt, !this->getHasAdaptiveThemes(), "Unistyles: You're trying to set theme to: '" + themeName + "', but adaptiveThemes are enabled.");
|
62
74
|
|
@@ -112,6 +124,24 @@ void HybridUnistylesRuntime::calculateNewThemeAndDependencies(std::vector<Unisty
|
|
112
124
|
}
|
113
125
|
}
|
114
126
|
|
127
|
+
jsi::Value HybridUnistylesRuntime::getTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
128
|
+
helpers::assertThat(rt, count <= 1, "UnistylesRuntime.getTheme expected to be called with 0 or 1 argument.");
|
129
|
+
|
130
|
+
auto& state = core::UnistylesRegistry::get().getState(*_rt);
|
131
|
+
|
132
|
+
if (count == 1) {
|
133
|
+
helpers::assertThat(rt, args[0].isString(), "UnistylesRuntime.getTheme expected to be called with string.");
|
134
|
+
|
135
|
+
auto themeName = args[0].asString(rt).utf8(rt);
|
136
|
+
|
137
|
+
helpers::assertThat(rt, state.hasTheme(themeName), "Unistyles: You're trying to get theme '" + themeName + "' but it wasn't registered.");
|
138
|
+
|
139
|
+
return state.getJSThemeByName(themeName);
|
140
|
+
}
|
141
|
+
|
142
|
+
return state.getCurrentJSTheme();
|
143
|
+
}
|
144
|
+
|
115
145
|
jsi::Value HybridUnistylesRuntime::updateTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
116
146
|
helpers::assertThat(rt, count == 2, "UnistylesRuntime.updateTheme expected to be called with 2 arguments.");
|
117
147
|
helpers::assertThat(rt, args[0].isString(), "UnistylesRuntime.updateTheme expected first argument to be a string.");
|
@@ -158,7 +188,6 @@ UnistylesCxxMiniRuntime HybridUnistylesRuntime::getMiniRuntime() {
|
|
158
188
|
UnistylesCxxMiniRuntime cxxMiniRuntime{
|
159
189
|
this->getThemeName(),
|
160
190
|
this->getBreakpoint(),
|
161
|
-
nativeMiniRuntime.orientation,
|
162
191
|
this->getHasAdaptiveThemes(),
|
163
192
|
nativeMiniRuntime.colorScheme,
|
164
193
|
nativeMiniRuntime.screen,
|
@@ -168,20 +197,44 @@ UnistylesCxxMiniRuntime HybridUnistylesRuntime::getMiniRuntime() {
|
|
168
197
|
nativeMiniRuntime.fontScale,
|
169
198
|
nativeMiniRuntime.rtl,
|
170
199
|
nativeMiniRuntime.statusBar,
|
171
|
-
nativeMiniRuntime.navigationBar
|
200
|
+
nativeMiniRuntime.navigationBar,
|
201
|
+
nativeMiniRuntime.isPortrait,
|
202
|
+
nativeMiniRuntime.isLandscape
|
203
|
+
};
|
204
|
+
|
205
|
+
return cxxMiniRuntime;
|
206
|
+
}
|
207
|
+
|
208
|
+
UnistylesCxxMiniRuntime HybridUnistylesRuntime::buildMiniRuntimeFromNativeRuntime(UnistylesNativeMiniRuntime& nativeMiniRuntime) {
|
209
|
+
UnistylesCxxMiniRuntime cxxMiniRuntime{
|
210
|
+
this->getThemeName(),
|
211
|
+
this->getBreakpoint(),
|
212
|
+
this->getHasAdaptiveThemes(),
|
213
|
+
nativeMiniRuntime.colorScheme,
|
214
|
+
nativeMiniRuntime.screen,
|
215
|
+
nativeMiniRuntime.contentSizeCategory,
|
216
|
+
nativeMiniRuntime.insets,
|
217
|
+
nativeMiniRuntime.pixelRatio,
|
218
|
+
nativeMiniRuntime.fontScale,
|
219
|
+
nativeMiniRuntime.rtl,
|
220
|
+
nativeMiniRuntime.statusBar,
|
221
|
+
nativeMiniRuntime.navigationBar,
|
222
|
+
nativeMiniRuntime.isPortrait,
|
223
|
+
nativeMiniRuntime.isLandscape
|
172
224
|
};
|
173
225
|
|
174
226
|
return cxxMiniRuntime;
|
175
227
|
}
|
176
228
|
|
177
|
-
jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
|
178
|
-
auto miniRuntime = this->getMiniRuntime();
|
229
|
+
jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt, std::optional<UnistylesNativeMiniRuntime> maybeMiniRuntime) {
|
179
230
|
jsi::Object obj(rt);
|
231
|
+
auto miniRuntime = maybeMiniRuntime.has_value()
|
232
|
+
? this->buildMiniRuntimeFromNativeRuntime(maybeMiniRuntime.value())
|
233
|
+
: this->getMiniRuntime();
|
180
234
|
|
181
235
|
// auto generated by nitro, but can't be accessed due to static inline function
|
182
236
|
obj.setProperty(rt, "themeName", JSIConverter<std::optional<std::string>>::toJSI(rt, miniRuntime.themeName));
|
183
237
|
obj.setProperty(rt, "breakpoint", JSIConverter<std::optional<std::string>>::toJSI(rt, miniRuntime.breakpoint));
|
184
|
-
obj.setProperty(rt, "orientation", JSIConverter<Orientation>::toJSI(rt, miniRuntime.orientation));
|
185
238
|
obj.setProperty(rt, "hasAdaptiveThemes", JSIConverter<bool>::toJSI(rt, miniRuntime.hasAdaptiveThemes));
|
186
239
|
obj.setProperty(rt, "colorScheme", JSIConverter<ColorScheme>::toJSI(rt, miniRuntime.colorScheme));
|
187
240
|
obj.setProperty(rt, "screen", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.screen));
|
@@ -192,17 +245,27 @@ jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
|
|
192
245
|
obj.setProperty(rt, "rtl", JSIConverter<bool>::toJSI(rt, miniRuntime.rtl));
|
193
246
|
obj.setProperty(rt, "statusBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.statusBar));
|
194
247
|
obj.setProperty(rt, "navigationBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.navigationBar));
|
248
|
+
obj.setProperty(rt, "isPortrait", JSIConverter<bool>::toJSI(rt, miniRuntime.isPortrait));
|
249
|
+
obj.setProperty(rt, "isLandscape", JSIConverter<bool>::toJSI(rt, miniRuntime.isLandscape));
|
195
250
|
|
196
251
|
return obj;
|
197
252
|
}
|
198
253
|
|
199
|
-
|
200
|
-
|
254
|
+
void HybridUnistylesRuntime::registerPlatformListener(const std::function<void (std::vector<UnistyleDependency>)>& listener) {
|
255
|
+
this->_onDependenciesChange = listener;
|
201
256
|
}
|
202
257
|
|
203
|
-
void HybridUnistylesRuntime::
|
258
|
+
void HybridUnistylesRuntime::registerNativePlatformListener(const std::function<void(std::vector<UnistyleDependency>, UnistylesNativeMiniRuntime)>& listener) {
|
204
259
|
this->_nativePlatform.registerPlatformListener(listener);
|
205
|
-
this->
|
260
|
+
this->_onNativeDependenciesChange = listener;
|
261
|
+
}
|
262
|
+
|
263
|
+
void HybridUnistylesRuntime::registerImeListener(const std::function<void(UnistylesNativeMiniRuntime)>& listener) {
|
264
|
+
this->_nativePlatform.registerImeListener(listener);
|
265
|
+
}
|
266
|
+
|
267
|
+
void HybridUnistylesRuntime::unregisterNativePlatformListeners() {
|
268
|
+
this->_nativePlatform.unregisterPlatformListeners();
|
206
269
|
}
|
207
270
|
|
208
271
|
void HybridUnistylesRuntime::includeDependenciesForColorSchemeChange(std::vector<UnistyleDependency>& deps) {
|
@@ -216,3 +279,7 @@ void HybridUnistylesRuntime::includeDependenciesForColorSchemeChange(std::vector
|
|
216
279
|
|
217
280
|
this->calculateNewThemeAndDependencies(deps);
|
218
281
|
}
|
282
|
+
|
283
|
+
jsi::Runtime& HybridUnistylesRuntime::getRuntime() {
|
284
|
+
return *this->_rt;
|
285
|
+
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#include "HybridUnistylesRuntimeSpec.hpp"
|
4
4
|
#include "HybridNativePlatformSpec.hpp"
|
5
|
-
#include "
|
5
|
+
#include "NativePlatform.h"
|
6
6
|
#include "UnistylesState.h"
|
7
7
|
#include "HybridUnistylesStatusBarSpec.hpp"
|
8
8
|
#include "HybridNavigationBar.h"
|
@@ -13,8 +13,13 @@
|
|
13
13
|
namespace margelo::nitro::unistyles {
|
14
14
|
|
15
15
|
struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
|
16
|
-
HybridUnistylesRuntime(Unistyles::HybridNativePlatformSpecCxx nativePlatform, jsi::Runtime& rt
|
16
|
+
HybridUnistylesRuntime(Unistyles::HybridNativePlatformSpecCxx nativePlatform, jsi::Runtime& rt, std::function<void(std::function<void(jsi::Runtime&)>&&)> runOnJSThread)
|
17
|
+
: HybridObject(TAG), _nativePlatform{nativePlatform}, _rt{&rt}, runOnJSThread(std::move(runOnJSThread)) {}
|
17
18
|
|
19
|
+
jsi::Value getTheme(jsi::Runtime& rt,
|
20
|
+
const jsi::Value& thisValue,
|
21
|
+
const jsi::Value* args,
|
22
|
+
size_t count);
|
18
23
|
jsi::Value updateTheme(jsi::Runtime& rt,
|
19
24
|
const jsi::Value& thisValue,
|
20
25
|
const jsi::Value* args,
|
@@ -32,6 +37,7 @@ struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
|
|
32
37
|
HybridUnistylesRuntimeSpec::loadHybridMethods();
|
33
38
|
|
34
39
|
registerHybrids(this, [](Prototype& prototype) {
|
40
|
+
prototype.registerRawHybridMethod("getTheme", 1, &HybridUnistylesRuntime::getTheme);
|
35
41
|
prototype.registerRawHybridMethod("updateTheme", 1, &HybridUnistylesRuntime::updateTheme);
|
36
42
|
prototype.registerRawHybridMethod("createHybridStatusBar", 0, &HybridUnistylesRuntime::createHybridStatusBar);
|
37
43
|
prototype.registerRawHybridMethod("createHybridNavigationBar", 0, &HybridUnistylesRuntime::createHybridNavigationBar);
|
@@ -50,16 +56,23 @@ struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
|
|
50
56
|
double getPixelRatio() override;
|
51
57
|
double getFontScale() override;
|
52
58
|
void registerPlatformListener(const std::function<void(std::vector<UnistyleDependency>)>& listener);
|
59
|
+
void registerNativePlatformListener(const std::function<void(std::vector<UnistyleDependency>, UnistylesNativeMiniRuntime)>& listener);
|
60
|
+
void registerImeListener(const std::function<void(UnistylesNativeMiniRuntime)>& listener);
|
61
|
+
void unregisterNativePlatformListeners();
|
53
62
|
|
54
63
|
void setTheme(const std::string &themeName) override;
|
55
64
|
void setAdaptiveThemes(bool isEnabled) override;
|
56
65
|
void setImmersiveMode(bool isEnabled) override;
|
57
66
|
void setRootViewBackgroundColor(double color) override;
|
58
67
|
UnistylesCxxMiniRuntime getMiniRuntime() override;
|
59
|
-
|
68
|
+
std::unordered_map<std::string, double> getBreakpoints() override;
|
69
|
+
|
60
70
|
jsi::Runtime& getRuntime();
|
71
|
+
UnistylesCxxMiniRuntime buildMiniRuntimeFromNativeRuntime(UnistylesNativeMiniRuntime& nativeMiniRuntime);
|
72
|
+
jsi::Value getMiniRuntimeAsValue(jsi::Runtime& rt, std::optional<UnistylesNativeMiniRuntime> maybeMiniRuntime);
|
61
73
|
void includeDependenciesForColorSchemeChange(std::vector<UnistyleDependency>& deps);
|
62
74
|
void calculateNewThemeAndDependencies(std::vector<UnistyleDependency>& deps);
|
75
|
+
std::function<void(std::function<void(jsi::Runtime&)>&&)> runOnJSThread;
|
63
76
|
|
64
77
|
private:
|
65
78
|
jsi::Runtime* _rt;
|
@@ -67,6 +80,7 @@ private:
|
|
67
80
|
std::shared_ptr<HybridStatusBar> _statusBar;
|
68
81
|
Unistyles::HybridNativePlatformSpecCxx _nativePlatform;
|
69
82
|
std::function<void(std::vector<UnistyleDependency>)> _onDependenciesChange;
|
83
|
+
std::function<void(std::vector<UnistyleDependency>, UnistylesNativeMiniRuntime)> _onNativeDependenciesChange;
|
70
84
|
};
|
71
85
|
|
72
86
|
}
|