react-native-unistyles 3.0.0-nightly-20250520 → 3.0.0-nightly-20250527
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 +13 -9
- package/android/src/main/cxx/NativeUnistylesModule.cpp +3 -7
- package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -7
- package/cxx/core/UnistylesCommitShadowNode.h +0 -21
- package/cxx/core/UnistylesRegistry.cpp +45 -43
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +6 -1
- package/cxx/hybridObjects/HybridShadowRegistry.h +6 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +7 -16
- package/cxx/hybridObjects/HybridStyleSheet.h +2 -7
- package/cxx/parser/Parser.cpp +150 -107
- package/cxx/shadowTree/ShadowTreeManager.cpp +36 -33
- package/cxx/shadowTree/ShadowTreeManager.h +0 -1
- package/ios/UnistylesModuleOnLoad.h +1 -5
- package/ios/UnistylesModuleOnLoad.mm +5 -13
- package/lib/commonjs/components/ScopedTheme.js +5 -2
- package/lib/commonjs/components/ScopedTheme.js.map +1 -1
- package/lib/commonjs/components/native/Image.js +1 -2
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js +1 -2
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js +1 -2
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +1 -2
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +2 -28
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +6 -21
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +1 -2
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js +1 -2
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +1 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +1 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js +1 -2
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +1 -2
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +1 -2
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/web/create.js +1 -2
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/state.js +10 -7
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -2
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/runtime.js +9 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +2 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +1 -10
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js +1 -2
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +12 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/ScopedTheme.js +4 -0
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +1 -26
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +5 -19
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/web/css/state.js +10 -7
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/runtime.js +10 -2
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +2 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +1 -10
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +10 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/warn.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/serialize.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/css/core.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts +2 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- 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 +1 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/lib/typescript/src/web/variants.d.ts.map +1 -1
- package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -1
- package/package.json +17 -20
- package/plugin/index.d.ts +5 -4
- package/plugin/index.js +9 -1
- package/src/components/ScopedTheme.tsx +5 -0
- package/src/core/createUnistylesElement.native.tsx +1 -29
- package/src/core/createUnistylesImageBackground.tsx +7 -22
- package/src/index.ts +8 -0
- package/src/specs/ShadowRegistry/index.ts +1 -0
- package/src/web/css/state.ts +10 -8
- package/src/web/runtime.ts +15 -2
- package/src/web/shadowRegistry.ts +3 -1
- package/src/web/state.ts +7 -17
- package/src/web/utils/unistyle.ts +13 -1
- package/cxx/core/UnistylesCommitHook.cpp +0 -59
- package/cxx/core/UnistylesCommitHook.h +0 -27
- package/cxx/core/UnistylesMountHook.cpp +0 -26
- package/cxx/core/UnistylesMountHook.h +0 -24
- package/lib/module/package.json +0 -1
package/README.md
CHANGED
@@ -26,10 +26,11 @@ yarn add react-native-edge-to-edge react-native-nitro-modules@0.25.2
|
|
26
26
|
|
27
27
|
> To avoid unexpected behavior, always use a fixed version of `react-native-nitro-modules`
|
28
28
|
|
29
|
-
| react-native-unistyles | react-native-nitro-modules |
|
30
|
-
|
31
|
-
| 3.0.0-nightly-
|
32
|
-
| 3.0.0-
|
29
|
+
| react-native-unistyles | react-native-nitro-modules | other requirements |
|
30
|
+
|------------------------|----------------------------|----- |
|
31
|
+
| 3.0.0-nightly-20250520 | 0.25.2 |
|
32
|
+
| 3.0.0-nightly-20250526 | 0.25.2 | React >= 19 and React Native >= 0.78 |
|
33
|
+
| 3.0.0-rc.4 | 0.25.2 | |
|
33
34
|
|
34
35
|
Then follow [installation guides](https://unistyl.es/v3/start/getting-started) for your platform.
|
35
36
|
|
@@ -60,9 +61,6 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
60
61
|
<a href="https://galaxies.dev">
|
61
62
|
<img src="https://avatars.githubusercontent.com/u/118431096?s=200&v=4" height="70px" width="70px" alt="galaxies-dev" />
|
62
63
|
</a>
|
63
|
-
<a href="https://github.com/FTCHD">
|
64
|
-
<img src="https://avatars.githubusercontent.com/u/144691102?v=4" height="70px" width="70px" alt="FTCHD" />
|
65
|
-
</a>
|
66
64
|
<a href="https://github.com/mobily">
|
67
65
|
<img src="https://avatars.githubusercontent.com/u/1467712?v=4" height="70px" width="70px" alt="mobily" />
|
68
66
|
</a>
|
@@ -81,8 +79,8 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
81
79
|
<a href="https://github.com/ryanlanciaux">
|
82
80
|
<img src="https://avatars.githubusercontent.com/u/85041?v=4" height="70px" width="70px" alt="ryanlanciaux" />
|
83
81
|
</a>
|
84
|
-
<a href="https://github.com/
|
85
|
-
<img src="https://avatars.githubusercontent.com/u/
|
82
|
+
<a href="https://github.com/avega99">
|
83
|
+
<img src="https://avatars.githubusercontent.com/u/177598670?v=4" height="70px" width="70px" alt="avega99" />
|
86
84
|
</a>
|
87
85
|
|
88
86
|
## Past sponsors
|
@@ -126,6 +124,12 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
126
124
|
<a href="https://github.com/guillaumehcht">
|
127
125
|
<img src="https://avatars.githubusercontent.com/u/80776475?v=4" height="60px" width="60px" alt="guillaumehcht" />
|
128
126
|
</a>
|
127
|
+
<a href="https://github.com/loopsware">
|
128
|
+
<img src="https://avatars.githubusercontent.com/u/161434039?s=200&v=4" height="60px" width="60px" alt="loopsware" />
|
129
|
+
</a>
|
130
|
+
<a href="https://github.com/FTCHD">
|
131
|
+
<img src="https://avatars.githubusercontent.com/u/144691102?v=4" height="60px" width="60px" alt="FTCHD" />
|
132
|
+
</a>
|
129
133
|
|
130
134
|
## Sponsor my work
|
131
135
|
|
@@ -10,19 +10,16 @@ using namespace facebook::react;
|
|
10
10
|
UnistylesModule::UnistylesModule(
|
11
11
|
jni::alias_ref<UnistylesModule::jhybridobject> jThis,
|
12
12
|
jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
13
|
-
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
14
13
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
15
14
|
): _runtimeExecutor(runtimeExecutorHolder->cthis()->get()),
|
16
|
-
_uiManager(fabricUIManager->getBinding()->getScheduler()->getUIManager()),
|
17
15
|
_nativePlatform(nativePlatform->cthis()) {}
|
18
16
|
|
19
17
|
jni::local_ref<UnistylesModule::jhybriddata> UnistylesModule::initHybrid(
|
20
18
|
jni::alias_ref<UnistylesModule::jhybridobject> jThis,
|
21
19
|
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
22
|
-
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
23
20
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
24
21
|
) {
|
25
|
-
return makeCxxInstance(jThis, runtimeExecutorHolder,
|
22
|
+
return makeCxxInstance(jThis, runtimeExecutorHolder, nativePlatform);
|
26
23
|
}
|
27
24
|
|
28
25
|
void UnistylesModule::registerNatives() {
|
@@ -34,10 +31,9 @@ void UnistylesModule::registerNatives() {
|
|
34
31
|
|
35
32
|
jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jobj) {
|
36
33
|
auto& runtimeExecutor = jobj->cthis()->_runtimeExecutor;
|
37
|
-
auto& uiManager = jobj->cthis()->_uiManager;
|
38
34
|
auto& nativePlatform = jobj->cthis()->_nativePlatform;
|
39
35
|
|
40
|
-
return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &
|
36
|
+
return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &nativePlatform](jsi::Runtime& rt) {
|
41
37
|
// function is called on: first init and every live reload
|
42
38
|
// check if this is live reload, if so let's replace UnistylesRuntime with new runtime
|
43
39
|
auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
|
@@ -56,7 +52,7 @@ jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindings
|
|
56
52
|
|
57
53
|
// init hybrids
|
58
54
|
auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt, runOnJSThread);
|
59
|
-
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime
|
55
|
+
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime);
|
60
56
|
|
61
57
|
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
|
62
58
|
return unistylesRuntime;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
3
|
#include <ReactCommon/BindingsInstallerHolder.h>
|
4
|
-
#include <react/fabric/JFabricUIManager.h>
|
5
4
|
#include <react/jni/JRuntimeExecutor.h>
|
6
5
|
#include <react/renderer/scheduler/Scheduler.h>
|
7
6
|
#include <fbjni/fbjni.h>
|
@@ -19,7 +18,6 @@ struct UnistylesModule : public jni::HybridClass<UnistylesModule> {
|
|
19
18
|
explicit UnistylesModule(
|
20
19
|
jni::alias_ref<jhybridobject> jThis,
|
21
20
|
jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
22
|
-
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
23
21
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
24
22
|
);
|
25
23
|
|
@@ -27,14 +25,12 @@ struct UnistylesModule : public jni::HybridClass<UnistylesModule> {
|
|
27
25
|
static jni::local_ref<jhybriddata> initHybrid(
|
28
26
|
jni::alias_ref<jhybridobject> jThis,
|
29
27
|
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
30
|
-
jni::alias_ref<JFabricUIManager::javaobject>,
|
31
28
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
32
29
|
);
|
33
30
|
|
34
31
|
static jni::local_ref<BindingsInstallerHolder::javaobject> getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jThis);
|
35
32
|
|
36
33
|
private:
|
37
|
-
std::shared_ptr<UIManager> _uiManager;
|
38
34
|
RuntimeExecutor _runtimeExecutor;
|
39
35
|
std::shared_ptr<HybridNativePlatformSpec> _nativePlatform;
|
40
36
|
};
|
@@ -5,11 +5,8 @@ import com.facebook.jni.HybridData
|
|
5
5
|
import com.facebook.proguard.annotations.DoNotStrip
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
7
7
|
import com.facebook.react.bridge.RuntimeExecutor
|
8
|
-
import com.facebook.react.fabric.FabricUIManager
|
9
8
|
import com.facebook.react.turbomodule.core.interfaces.BindingsInstallerHolder
|
10
9
|
import com.facebook.react.turbomodule.core.interfaces.TurboModuleWithJSIBindings
|
11
|
-
import com.facebook.react.uimanager.UIManagerHelper
|
12
|
-
import com.facebook.react.uimanager.common.UIManagerType
|
13
10
|
import com.margelo.nitro.unistyles.HybridNativePlatformSpec
|
14
11
|
import com.margelo.nitro.unistyles.unistylesOnLoad.Companion.initializeNative
|
15
12
|
|
@@ -34,10 +31,8 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
|
|
34
31
|
private fun initializeHybridData(reactContext: ReactApplicationContext): HybridData {
|
35
32
|
val runtimeExecutor = reactContext.catalystInstance?.runtimeExecutor
|
36
33
|
?: throw IllegalStateException("Unistyles: React Native runtime executor is not available. Please follow installation guides.")
|
37
|
-
val fabricUIManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC) as? FabricUIManager
|
38
|
-
?: throw IllegalStateException("Unistyles: Fabric UI Manager is not available. Please follow installation guides.")
|
39
34
|
|
40
|
-
return initHybrid(runtimeExecutor,
|
35
|
+
return initHybrid(runtimeExecutor, _nativePlatform)
|
41
36
|
}
|
42
37
|
|
43
38
|
@DoNotStrip
|
@@ -46,7 +41,6 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
|
|
46
41
|
@DoNotStrip
|
47
42
|
private external fun initHybrid(
|
48
43
|
runtimeExecutor: RuntimeExecutor,
|
49
|
-
fabricUIManager: FabricUIManager,
|
50
44
|
nativePlatform: HybridNativePlatformSpec
|
51
45
|
): HybridData
|
52
46
|
}
|
@@ -8,32 +8,11 @@ namespace margelo::nitro::unistyles::core {
|
|
8
8
|
// React Native uses 0-10
|
9
9
|
// Reanimated uses 27-28
|
10
10
|
constexpr shadow::ShadowNodeTraits::Trait UnistylesCommitTrait{1 << 30};
|
11
|
-
constexpr shadow::ShadowNodeTraits::Trait UnistylesMountTrait{1 << 31};
|
12
11
|
|
13
12
|
struct UnistylesCommitShadowNode: public shadow::ShadowNode {
|
14
13
|
inline void addUnistylesCommitTrait() {
|
15
14
|
traits_.set(UnistylesCommitTrait);
|
16
15
|
}
|
17
|
-
|
18
|
-
inline void removeUnistylesCommitTrait() {
|
19
|
-
traits_.unset(UnistylesCommitTrait);
|
20
|
-
}
|
21
|
-
|
22
|
-
inline bool hasUnistylesCommitTrait() {
|
23
|
-
return traits_.check(UnistylesCommitTrait);
|
24
|
-
}
|
25
|
-
|
26
|
-
inline void addUnistylesMountTrait() {
|
27
|
-
traits_.set(UnistylesMountTrait);
|
28
|
-
}
|
29
|
-
|
30
|
-
inline void removeUnistylesMountTrait() {
|
31
|
-
traits_.unset(UnistylesMountTrait);
|
32
|
-
}
|
33
|
-
|
34
|
-
inline bool hasUnistylesMountTrait() {
|
35
|
-
return traits_.check(UnistylesMountTrait);
|
36
|
-
}
|
37
16
|
};
|
38
17
|
|
39
18
|
}
|
@@ -82,7 +82,7 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
|
|
82
82
|
});
|
83
83
|
|
84
84
|
updates[shadowNodeFamily] = parser.parseStylesToShadowTreeStyles(rt, unistylesData);
|
85
|
-
|
85
|
+
|
86
86
|
this->trafficController.setUpdates(updates);
|
87
87
|
this->trafficController.resumeUnistylesTraffic();
|
88
88
|
});
|
@@ -127,31 +127,36 @@ std::shared_ptr<core::StyleSheet> core::UnistylesRegistry::addStyleSheet(jsi::Ru
|
|
127
127
|
}
|
128
128
|
|
129
129
|
core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps) {
|
130
|
-
DependencyMap dependencyMap;
|
131
|
-
|
130
|
+
core::DependencyMap dependencyMap;
|
131
|
+
|
132
|
+
std::unordered_set<UnistyleDependency> uniqueDependencies(deps.begin(), deps.end());
|
132
133
|
|
133
134
|
for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
|
135
|
+
bool hasAnyOfDependencies = false;
|
136
|
+
|
137
|
+
// Check if any dependency matches
|
134
138
|
for (const auto& unistyleData : unistyles) {
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
return std::find(uniqueDependencies.begin(), uniqueDependencies.end(), dep) != uniqueDependencies.end();
|
139
|
+
for (const auto& dep : unistyleData->unistyle->dependencies) {
|
140
|
+
if (uniqueDependencies.count(dep)) {
|
141
|
+
hasAnyOfDependencies = true;
|
142
|
+
break;
|
140
143
|
}
|
141
|
-
);
|
142
|
-
|
143
|
-
if (!hasAnyOfDependencies) {
|
144
|
-
continue;
|
145
144
|
}
|
146
145
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
}
|
146
|
+
if (hasAnyOfDependencies) {
|
147
|
+
break;
|
148
|
+
};
|
149
|
+
}
|
152
150
|
|
153
|
-
|
151
|
+
if (!hasAnyOfDependencies) {
|
152
|
+
continue;
|
154
153
|
}
|
154
|
+
|
155
|
+
dependencyMap[family].insert(
|
156
|
+
dependencyMap[family].end(),
|
157
|
+
unistyles.begin(),
|
158
|
+
unistyles.end()
|
159
|
+
);
|
155
160
|
}
|
156
161
|
|
157
162
|
return dependencyMap;
|
@@ -179,48 +184,45 @@ void core::UnistylesRegistry::shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Uni
|
|
179
184
|
});
|
180
185
|
}
|
181
186
|
|
182
|
-
std::vector<std::shared_ptr<core::StyleSheet>>
|
183
|
-
std::vector<std::shared_ptr<core::StyleSheet>> stylesheetsToRefresh
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
187
|
+
std::vector<std::shared_ptr<core::StyleSheet>>core::UnistylesRegistry::getStyleSheetsToRefresh(jsi::Runtime& rt, std::vector<UnistyleDependency>& unistylesDependencies) {
|
188
|
+
std::vector<std::shared_ptr<core::StyleSheet>> stylesheetsToRefresh;
|
189
|
+
std::unordered_set<UnistyleDependency> depSet(
|
190
|
+
unistylesDependencies.begin(),
|
191
|
+
unistylesDependencies.end()
|
192
|
+
);
|
193
|
+
|
194
|
+
bool themeDidChange = depSet.count(UnistyleDependency::THEME) > 0;
|
195
|
+
bool runtimeDidChange = (themeDidChange && depSet.size() > 1) || !depSet.empty();
|
189
196
|
|
190
|
-
// if nothing changed, skip further lookup
|
191
197
|
if (!themeDidChange && !runtimeDidChange) {
|
192
198
|
return stylesheetsToRefresh;
|
193
199
|
}
|
194
200
|
|
195
201
|
auto& styleSheets = this->_styleSheetRegistry[&rt];
|
196
202
|
|
197
|
-
|
198
|
-
auto& [_, styleSheet] = pair;
|
199
|
-
|
203
|
+
for (const auto& [_, styleSheet] : styleSheets) {
|
200
204
|
if (styleSheet->type == StyleSheetType::ThemableWithMiniRuntime) {
|
201
|
-
|
202
|
-
auto& [_, unistyle]
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
[&unistylesDependencies](UnistyleDependency dep) {
|
208
|
-
return std::find(unistylesDependencies.begin(), unistylesDependencies.end(), dep) != unistylesDependencies.end();
|
205
|
+
auto hasMatchingDependency = [&depSet](const auto& unistyles) {
|
206
|
+
for (const auto& [_, unistyle] : unistyles) {
|
207
|
+
for (const auto& dep : unistyle->dependencies) {
|
208
|
+
if (depSet.count(dep)) {
|
209
|
+
return true;
|
210
|
+
}
|
209
211
|
}
|
210
|
-
|
212
|
+
}
|
211
213
|
|
212
|
-
|
213
|
-
|
214
|
+
return false;
|
215
|
+
};
|
214
216
|
|
215
|
-
|
216
|
-
|
217
|
+
if (hasMatchingDependency(styleSheet->unistyles)) {
|
218
|
+
stylesheetsToRefresh.emplace_back(styleSheet);
|
217
219
|
}
|
218
220
|
}
|
219
221
|
|
220
222
|
if (styleSheet->type == StyleSheetType::Themable && themeDidChange) {
|
221
223
|
stylesheetsToRefresh.emplace_back(styleSheet);
|
222
224
|
}
|
223
|
-
}
|
225
|
+
}
|
224
226
|
|
225
227
|
return stylesheetsToRefresh;
|
226
228
|
}
|
@@ -107,13 +107,18 @@ jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &this
|
|
107
107
|
return jsi::Value::undefined();
|
108
108
|
}
|
109
109
|
|
110
|
+
jsi::Value HybridShadowRegistry::flush(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
111
|
+
shadow::ShadowTreeManager::updateShadowTree(UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry());
|
112
|
+
|
113
|
+
return jsi::Value::undefined();
|
114
|
+
}
|
115
|
+
|
110
116
|
jsi::Value HybridShadowRegistry::setScopedTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
111
117
|
helpers::assertThat(rt, count == 1, "Unistyles: setScopedTheme expected 1 argument.");
|
112
118
|
|
113
119
|
auto& registry = core::UnistylesRegistry::get();
|
114
120
|
|
115
121
|
if (args[0].isUndefined()) {
|
116
|
-
|
117
122
|
registry.setScopedTheme(std::nullopt);
|
118
123
|
}
|
119
124
|
|
@@ -5,6 +5,7 @@
|
|
5
5
|
#include "UnistyleWrapper.h"
|
6
6
|
#include "UnistylesState.h"
|
7
7
|
#include "UnistylesRegistry.h"
|
8
|
+
#include "ShadowTreeManager.h"
|
8
9
|
|
9
10
|
namespace margelo::nitro::unistyles {
|
10
11
|
|
@@ -20,6 +21,10 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
|
|
20
21
|
const jsi::Value& thisValue,
|
21
22
|
const jsi::Value* args,
|
22
23
|
size_t count);
|
24
|
+
jsi::Value flush(jsi::Runtime& rt,
|
25
|
+
const jsi::Value& thisValue,
|
26
|
+
const jsi::Value* args,
|
27
|
+
size_t count);
|
23
28
|
jsi::Value setScopedTheme(jsi::Runtime& rt,
|
24
29
|
const jsi::Value& thisValue,
|
25
30
|
const jsi::Value* args,
|
@@ -35,6 +40,7 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
|
|
35
40
|
registerHybrids(this, [](Prototype& prototype) {
|
36
41
|
prototype.registerRawHybridMethod("link", 2, &HybridShadowRegistry::link);
|
37
42
|
prototype.registerRawHybridMethod("unlink", 1, &HybridShadowRegistry::unlink);
|
43
|
+
prototype.registerRawHybridMethod("flush", 0, &HybridShadowRegistry::flush);
|
38
44
|
prototype.registerRawHybridMethod("setScopedTheme", 1, &HybridShadowRegistry::setScopedTheme);
|
39
45
|
prototype.registerRawHybridMethod("getScopedTheme", 0, &HybridShadowRegistry::getScopedTheme);
|
40
46
|
});
|
@@ -3,10 +3,14 @@
|
|
3
3
|
using namespace facebook::react;
|
4
4
|
|
5
5
|
double HybridStyleSheet::getHairlineWidth() {
|
6
|
-
|
7
|
-
|
6
|
+
double pixelRatio = this->_unistylesRuntime->getPixelRatio();
|
7
|
+
double hairlineWidth = std::round(pixelRatio * 0.4) / pixelRatio;
|
8
8
|
|
9
|
-
|
9
|
+
if (hairlineWidth == 0.0) {
|
10
|
+
hairlineWidth = 1.0 / pixelRatio;
|
11
|
+
}
|
12
|
+
|
13
|
+
return hairlineWidth;
|
10
14
|
}
|
11
15
|
|
12
16
|
double HybridStyleSheet::getUnid() {
|
@@ -87,7 +91,6 @@ jsi::Value HybridStyleSheet::init(jsi::Runtime &rt, const jsi::Value &thisVal, c
|
|
87
91
|
registry.createState(rt);
|
88
92
|
|
89
93
|
loadExternalMethods(thisVal, rt);
|
90
|
-
registerHooks(rt);
|
91
94
|
|
92
95
|
this->isInitialized = true;
|
93
96
|
|
@@ -256,18 +259,6 @@ void HybridStyleSheet::loadExternalMethods(const jsi::Value& thisValue, jsi::Run
|
|
256
259
|
state.registerProcessColorFunction(std::move(processColorFn));
|
257
260
|
}
|
258
261
|
|
259
|
-
void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
|
260
|
-
// cleanup Shadow updates
|
261
|
-
auto& registry = core::UnistylesRegistry::get();
|
262
|
-
|
263
|
-
registry.trafficController.withLock([®istry](){
|
264
|
-
registry.trafficController.restore();
|
265
|
-
});
|
266
|
-
|
267
|
-
this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager);
|
268
|
-
this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager);
|
269
|
-
}
|
270
|
-
|
271
262
|
void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies) {
|
272
263
|
// this event listener is triggered from C++ module, and it's only about theme / adaptive theme changes
|
273
264
|
if (dependencies.size() == 0) {
|
@@ -9,15 +9,13 @@
|
|
9
9
|
#include "UnistylesConstants.h"
|
10
10
|
#include "Breakpoints.h"
|
11
11
|
#include "Parser.h"
|
12
|
-
#include "
|
13
|
-
#include "UnistylesMountHook.h"
|
12
|
+
#include "ShadowTreeManager.h"
|
14
13
|
|
15
14
|
using namespace margelo::nitro::unistyles;
|
16
15
|
using namespace facebook::react;
|
17
16
|
|
18
17
|
struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
|
19
|
-
HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime,
|
20
|
-
: HybridObject(TAG), _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager} {
|
18
|
+
HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime): HybridObject(TAG), _unistylesRuntime{unistylesRuntime} {
|
21
19
|
this->_unistylesRuntime->registerPlatformListener(
|
22
20
|
std::bind(&HybridStyleSheet::onPlatformDependenciesChange, this, std::placeholders::_1)
|
23
21
|
);
|
@@ -67,7 +65,6 @@ private:
|
|
67
65
|
void verifyAndSelectTheme(jsi::Runtime &rt);
|
68
66
|
void setThemeFromColorScheme(jsi::Runtime& rt);
|
69
67
|
void loadExternalMethods(const jsi::Value& thisValue, jsi::Runtime& rt);
|
70
|
-
void registerHooks(jsi::Runtime& rt);
|
71
68
|
void onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies);
|
72
69
|
void onPlatformNativeDependenciesChange(std::vector<UnistyleDependency> dependencies, UnistylesNativeMiniRuntime miniRuntime);
|
73
70
|
void onImeChange(UnistylesNativeMiniRuntime miniRuntime);
|
@@ -77,8 +74,6 @@ private:
|
|
77
74
|
double __unid = -1;
|
78
75
|
std::vector<std::unique_ptr<const std::function<void(std::vector<UnistyleDependency>&)>>> _changeListeners{};
|
79
76
|
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
80
|
-
std::shared_ptr<core::UnistylesCommitHook> _unistylesCommitHook;
|
81
|
-
std::shared_ptr<core::UnistylesMountHook> _unistylesMountHook;
|
82
77
|
std::shared_ptr<UIManager> _uiManager;
|
83
78
|
};
|
84
79
|
|