react-native-unistyles 3.0.0-alpha.27 → 3.0.0-alpha.29
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/android/CMakeLists.txt +12 -21
- package/cxx/core/UnistylesMountHook.cpp +0 -10
- package/cxx/core/UnistylesMountHook.h +3 -8
- package/cxx/core/UnistylesRegistry.cpp +4 -8
- package/cxx/core/UnistylesRegistry.h +1 -1
- package/cxx/core/UnistylesState.cpp +2 -10
- package/cxx/core/UnistylesState.h +1 -1
- package/cxx/hybridObjects/HybridStyleSheet.cpp +67 -34
- package/cxx/hybridObjects/HybridStyleSheet.h +9 -1
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +15 -7
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +5 -1
- package/cxx/parser/Parser.cpp +73 -5
- package/cxx/parser/Parser.h +2 -0
- package/ios/NativePlatform+ios.swift +16 -5
- package/ios/NativePlatform+keyboard.swift +83 -0
- package/ios/NativePlatformListener+ios.swift +19 -6
- package/ios/UnistylesModuleOnLoad.h +3 -1
- package/ios/UnistylesModuleOnLoad.mm +11 -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/ShadowRegistry/ShadowRegistry.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/types.js +3 -0
- package/lib/commonjs/specs/ShadowRegistry/types.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/UnistylesStatusBar.nitro.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js +2 -4
- package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -3
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +2 -1
- package/lib/commonjs/specs/TurboUnistyles/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +2 -1
- package/lib/commonjs/specs/index.web.js.map +2 -1
- package/lib/commonjs/specs/types.js +10 -10
- package/lib/commonjs/specs/types.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/web/create.js +1 -4
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/registry.js +1 -4
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +1 -4
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +2 -1
- package/lib/module/specs/NavigtionBar/UnistylesNavigationBar.nitro.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +1 -0
- package/lib/module/specs/ShadowRegistry/types.js +2 -0
- package/lib/module/specs/ShadowRegistry/types.js.map +1 -1
- package/lib/module/specs/StatusBar/UnistylesStatusBar.nitro.js.map +1 -0
- package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -1
- package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -0
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js +2 -3
- package/lib/module/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +1 -1
- package/lib/module/specs/index.js.map +2 -1
- package/lib/module/specs/index.web.js.map +2 -1
- package/lib/module/specs/types.js +10 -10
- package/lib/module/specs/types.js.map +1 -0
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/web/create.js +2 -5
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/registry.js +2 -5
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +2 -5
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/global.d.ts +0 -2
- package/lib/typescript/src/global.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +4 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.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/stylesheet.d.ts +4 -2
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +204 -0
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +204 -0
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +3 -3
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +2 -2
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void.hpp +48 -0
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +3 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void.kt +45 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +2 -1
- package/nitrogen/generated/android/unistylesOnLoad.cpp +2 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +29 -1
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +6 -0
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +27 -0
- package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
- package/package.json +13 -13
- package/plugin/common.js +9 -0
- package/plugin/stylesheet.js +7 -1
- package/src/global.ts +1 -4
- package/src/specs/NativePlatform/NativePlatform.nitro.js +18 -0
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +5 -2
- package/src/specs/NativePlatform/index.js +1 -0
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.js +1 -0
- package/src/specs/NavigtionBar/index.js +9 -0
- package/src/specs/ShadowRegistry/ShadowRegistry.nitro.js +1 -0
- package/src/specs/ShadowRegistry/index.js +26 -0
- package/src/specs/ShadowRegistry/types.js +1 -0
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.js +1 -0
- package/src/specs/StatusBar/index.js +25 -0
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -0
- package/src/specs/StyleSheet/index.js +13 -0
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.js +2 -0
- package/src/specs/TurboUnistyles/index.js +1 -0
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.js +1 -0
- package/src/specs/UnistylesRuntime/index.js +20 -0
- package/src/specs/index.js +8 -0
- package/src/specs/index.web.js +2 -0
- package/src/specs/types.js +17 -0
- package/src/types/breakpoints.ts +25 -13
- package/src/types/stylesheet.ts +5 -3
- package/src/web/create.ts +2 -5
- package/src/web/registry.ts +2 -5
- package/src/web/runtime.ts +1 -1
- package/src/web/shadowRegistry.ts +2 -5
- package/src/web/state.ts +3 -3
- package/src/web/utils/unistyle.ts +2 -2
@@ -0,0 +1,48 @@
|
|
1
|
+
///
|
2
|
+
/// JFunc_void.hpp
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
4
|
+
/// https://github.com/mrousavy/nitro
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
6
|
+
///
|
7
|
+
|
8
|
+
#pragma once
|
9
|
+
|
10
|
+
#include <fbjni/fbjni.h>
|
11
|
+
#include <functional>
|
12
|
+
|
13
|
+
#include <functional>
|
14
|
+
|
15
|
+
namespace margelo::nitro::unistyles {
|
16
|
+
|
17
|
+
using namespace facebook;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* C++ representation of the callback Func_void.
|
21
|
+
* This is a Kotlin `() -> Unit`, backed by a `std::function<...>`.
|
22
|
+
*/
|
23
|
+
struct JFunc_void final: public jni::HybridClass<JFunc_void> {
|
24
|
+
public:
|
25
|
+
static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
|
26
|
+
return JFunc_void::newObjectCxxArgs(func);
|
27
|
+
}
|
28
|
+
|
29
|
+
public:
|
30
|
+
void call() {
|
31
|
+
return _func();
|
32
|
+
}
|
33
|
+
|
34
|
+
public:
|
35
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Func_void;";
|
36
|
+
static void registerNatives() {
|
37
|
+
registerHybrid({makeNativeMethod("call", JFunc_void::call)});
|
38
|
+
}
|
39
|
+
|
40
|
+
private:
|
41
|
+
explicit JFunc_void(const std::function<void()>& func): _func(func) { }
|
42
|
+
|
43
|
+
private:
|
44
|
+
friend HybridBase;
|
45
|
+
std::function<void()> _func;
|
46
|
+
};
|
47
|
+
|
48
|
+
} // namespace margelo::nitro::unistyles
|
@@ -36,6 +36,7 @@ namespace margelo::nitro::unistyles { enum class UnistyleDependency; }
|
|
36
36
|
#include "UnistyleDependency.hpp"
|
37
37
|
#include "JFunc_void_std__vector_UnistyleDependency_.hpp"
|
38
38
|
#include "JUnistyleDependency.hpp"
|
39
|
+
#include "JFunc_void.hpp"
|
39
40
|
|
40
41
|
namespace margelo::nitro::unistyles {
|
41
42
|
|
@@ -141,5 +142,13 @@ namespace margelo::nitro::unistyles {
|
|
141
142
|
static const auto method = _javaPart->getClass()->getMethod<void(jni::alias_ref<JFunc_void_std__vector_UnistyleDependency_::javaobject> /* callback */)>("registerPlatformListener");
|
142
143
|
method(_javaPart, JFunc_void_std__vector_UnistyleDependency_::fromCpp(callback));
|
143
144
|
}
|
145
|
+
void JHybridNativePlatformSpec::registerImeListener(const std::function<void()>& callback) {
|
146
|
+
static const auto method = _javaPart->getClass()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* callback */)>("registerImeListener");
|
147
|
+
method(_javaPart, JFunc_void::fromCpp(callback));
|
148
|
+
}
|
149
|
+
void JHybridNativePlatformSpec::unregisterPlatformListeners() {
|
150
|
+
static const auto method = _javaPart->getClass()->getMethod<void()>("unregisterPlatformListeners");
|
151
|
+
method(_javaPart);
|
152
|
+
}
|
144
153
|
|
145
154
|
} // namespace margelo::nitro::unistyles
|
@@ -63,6 +63,8 @@ namespace margelo::nitro::unistyles {
|
|
63
63
|
void setImmersiveMode(bool isEnabled) override;
|
64
64
|
UnistylesNativeMiniRuntime getMiniRuntime() override;
|
65
65
|
void registerPlatformListener(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>& callback) override;
|
66
|
+
void registerImeListener(const std::function<void()>& callback) override;
|
67
|
+
void unregisterPlatformListeners() override;
|
66
68
|
|
67
69
|
private:
|
68
70
|
friend HybridBase;
|
@@ -54,6 +54,7 @@ namespace margelo::nitro::unistyles {
|
|
54
54
|
static const auto fieldFONTSCALE = clazz->getStaticField<JUnistyleDependency>("FONTSCALE");
|
55
55
|
static const auto fieldSTATUSBAR = clazz->getStaticField<JUnistyleDependency>("STATUSBAR");
|
56
56
|
static const auto fieldNAVIGATIONBAR = clazz->getStaticField<JUnistyleDependency>("NAVIGATIONBAR");
|
57
|
+
static const auto fieldIME = clazz->getStaticField<JUnistyleDependency>("IME");
|
57
58
|
|
58
59
|
switch (value) {
|
59
60
|
case UnistyleDependency::THEME:
|
@@ -84,6 +85,8 @@ namespace margelo::nitro::unistyles {
|
|
84
85
|
return clazz->getStaticFieldValue(fieldSTATUSBAR);
|
85
86
|
case UnistyleDependency::NAVIGATIONBAR:
|
86
87
|
return clazz->getStaticFieldValue(fieldNAVIGATIONBAR);
|
88
|
+
case UnistyleDependency::IME:
|
89
|
+
return clazz->getStaticFieldValue(fieldIME);
|
87
90
|
default:
|
88
91
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
89
92
|
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
@@ -0,0 +1,45 @@
|
|
1
|
+
///
|
2
|
+
/// Func_void.kt
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
4
|
+
/// https://github.com/mrousavy/nitro
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
6
|
+
///
|
7
|
+
|
8
|
+
package com.margelo.nitro.unistyles
|
9
|
+
|
10
|
+
import androidx.annotation.Keep
|
11
|
+
import com.facebook.jni.HybridData
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Represents the JavaScript callback `() => void`.
|
17
|
+
* This is implemented in C++, via a `std::function<...>`.
|
18
|
+
*/
|
19
|
+
@DoNotStrip
|
20
|
+
@Keep
|
21
|
+
@Suppress("RedundantSuppression", "ConvertSecondaryConstructorToPrimary", "RedundantUnitReturnType", "KotlinJniMissingFunction", "ClassName", "unused")
|
22
|
+
class Func_void {
|
23
|
+
@DoNotStrip
|
24
|
+
@Keep
|
25
|
+
private val mHybridData: HybridData
|
26
|
+
|
27
|
+
@DoNotStrip
|
28
|
+
@Keep
|
29
|
+
private constructor(hybridData: HybridData) {
|
30
|
+
mHybridData = hybridData
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Converts this function to a Kotlin Lambda.
|
35
|
+
* This exists purely as syntactic sugar, and has minimal runtime overhead.
|
36
|
+
*/
|
37
|
+
fun toLambda(): () -> Unit = this::call
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Call the given JS callback.
|
41
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
42
|
+
*/
|
43
|
+
@FastNative
|
44
|
+
external fun call(): Unit
|
45
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt
CHANGED
@@ -119,6 +119,21 @@ abstract class HybridNativePlatformSpec: HybridObject() {
|
|
119
119
|
val __result = registerPlatformListener(callback.toLambda())
|
120
120
|
return __result
|
121
121
|
}
|
122
|
+
|
123
|
+
@DoNotStrip
|
124
|
+
@Keep
|
125
|
+
abstract fun registerImeListener(callback: () -> Unit): Unit
|
126
|
+
|
127
|
+
@DoNotStrip
|
128
|
+
@Keep
|
129
|
+
private fun registerImeListener(callback: Func_void): Unit {
|
130
|
+
val __result = registerImeListener(callback.toLambda())
|
131
|
+
return __result
|
132
|
+
}
|
133
|
+
|
134
|
+
@DoNotStrip
|
135
|
+
@Keep
|
136
|
+
abstract fun unregisterPlatformListeners(): Unit
|
122
137
|
|
123
138
|
private external fun initHybrid(): HybridData
|
124
139
|
|
@@ -13,6 +13,7 @@
|
|
13
13
|
|
14
14
|
#include "JHybridNativePlatformSpec.hpp"
|
15
15
|
#include "JFunc_void_std__vector_UnistyleDependency_.hpp"
|
16
|
+
#include "JFunc_void.hpp"
|
16
17
|
|
17
18
|
namespace margelo::nitro::unistyles {
|
18
19
|
|
@@ -25,6 +26,7 @@ int initialize(JavaVM* vm) {
|
|
25
26
|
// Register native JNI methods
|
26
27
|
margelo::nitro::unistyles::JHybridNativePlatformSpec::registerNatives();
|
27
28
|
margelo::nitro::unistyles::JFunc_void_std__vector_UnistyleDependency_::registerNatives();
|
29
|
+
margelo::nitro::unistyles::JFunc_void::registerNatives();
|
28
30
|
|
29
31
|
// Register Nitro Hybrid Objects
|
30
32
|
|
@@ -65,7 +65,7 @@ namespace margelo::nitro::unistyles::bridge::swift {
|
|
65
65
|
private:
|
66
66
|
std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)> _function;
|
67
67
|
};
|
68
|
-
inline Func_void_std__vector_UnistyleDependency_ create_Func_void_std__vector_UnistyleDependency_(void*
|
68
|
+
inline Func_void_std__vector_UnistyleDependency_ create_Func_void_std__vector_UnistyleDependency_(void* NONNULL closureHolder, void(* NONNULL call)(void* NONNULL /* closureHolder */, std::vector<UnistyleDependency>), void(* NONNULL destroy)(void* NONNULL)) {
|
69
69
|
std::shared_ptr<void> sharedClosureHolder(closureHolder, destroy);
|
70
70
|
return Func_void_std__vector_UnistyleDependency_([sharedClosureHolder, call](const std::vector<UnistyleDependency>& dependencies) -> void {
|
71
71
|
call(sharedClosureHolder.get(), dependencies);
|
@@ -75,6 +75,34 @@ namespace margelo::nitro::unistyles::bridge::swift {
|
|
75
75
|
return std::make_shared<Func_void_std__vector_UnistyleDependency__Wrapper>(value);
|
76
76
|
}
|
77
77
|
|
78
|
+
// pragma MARK: std::function<void()>
|
79
|
+
/**
|
80
|
+
* Specialized version of `std::function<void()>`.
|
81
|
+
*/
|
82
|
+
using Func_void = std::function<void()>;
|
83
|
+
/**
|
84
|
+
* Wrapper class for a `std::function<void()>`, this can be used from Swift.
|
85
|
+
*/
|
86
|
+
class Func_void_Wrapper final {
|
87
|
+
public:
|
88
|
+
explicit Func_void_Wrapper(const std::function<void()>& func): _function(func) {}
|
89
|
+
explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::move(func)) {}
|
90
|
+
inline void call() const {
|
91
|
+
_function();
|
92
|
+
}
|
93
|
+
private:
|
94
|
+
std::function<void()> _function;
|
95
|
+
};
|
96
|
+
inline Func_void create_Func_void(void* _Nonnull closureHolder, void(* _Nonnull call)(void* _Nonnull /* closureHolder */), void(* _Nonnull destroy)(void* _Nonnull)) {
|
97
|
+
std::shared_ptr<void> sharedClosureHolder(closureHolder, destroy);
|
98
|
+
return Func_void([sharedClosureHolder, call]() -> void {
|
99
|
+
call(sharedClosureHolder.get());
|
100
|
+
});
|
101
|
+
}
|
102
|
+
inline std::shared_ptr<Func_void_Wrapper> share_Func_void(const Func_void& value) {
|
103
|
+
return std::make_shared<Func_void_Wrapper>(value);
|
104
|
+
}
|
105
|
+
|
78
106
|
// pragma MARK: std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>
|
79
107
|
/**
|
80
108
|
* Specialized version of `std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>`.
|
@@ -143,6 +143,12 @@ namespace margelo::nitro::unistyles {
|
|
143
143
|
inline void registerPlatformListener(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>& callback) override {
|
144
144
|
_swiftPart.registerPlatformListener(callback);
|
145
145
|
}
|
146
|
+
inline void registerImeListener(const std::function<void()>& callback) override {
|
147
|
+
_swiftPart.registerImeListener(callback);
|
148
|
+
}
|
149
|
+
inline void unregisterPlatformListeners() override {
|
150
|
+
_swiftPart.unregisterPlatformListeners();
|
151
|
+
}
|
146
152
|
|
147
153
|
private:
|
148
154
|
Unistyles::HybridNativePlatformSpecCxx _swiftPart;
|
@@ -50,4 +50,6 @@ public protocol HybridNativePlatformSpec: AnyObject, HybridObjectSpec {
|
|
50
50
|
func setImmersiveMode(isEnabled: Bool) throws -> Void
|
51
51
|
func getMiniRuntime() throws -> UnistylesNativeMiniRuntime
|
52
52
|
func registerPlatformListener(callback: @escaping ((_ dependencies: [UnistyleDependency]) -> Void)) throws -> Void
|
53
|
+
func registerImeListener(callback: @escaping (() -> Void)) throws -> Void
|
54
|
+
func unregisterPlatformListeners() throws -> Void
|
53
55
|
}
|
@@ -306,4 +306,31 @@ public class HybridNativePlatformSpecCxx {
|
|
306
306
|
fatalError("Swift errors can currently not be propagated to C++! See https://github.com/swiftlang/swift/issues/75290 (Error: \(__message))")
|
307
307
|
}
|
308
308
|
}
|
309
|
+
|
310
|
+
@inline(__always)
|
311
|
+
public func registerImeListener(callback: bridge.Func_void) -> Void {
|
312
|
+
do {
|
313
|
+
try self.__implementation.registerImeListener(callback: { () -> (() -> Void) in
|
314
|
+
let __sharedClosure = bridge.share_Func_void(callback)
|
315
|
+
return { () -> Void in
|
316
|
+
__sharedClosure.pointee.call()
|
317
|
+
}
|
318
|
+
}())
|
319
|
+
return
|
320
|
+
} catch {
|
321
|
+
let __message = "\(error.localizedDescription)"
|
322
|
+
fatalError("Swift errors can currently not be propagated to C++! See https://github.com/swiftlang/swift/issues/75290 (Error: \(__message))")
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
@inline(__always)
|
327
|
+
public func unregisterPlatformListeners() -> Void {
|
328
|
+
do {
|
329
|
+
try self.__implementation.unregisterPlatformListeners()
|
330
|
+
return
|
331
|
+
} catch {
|
332
|
+
let __message = "\(error.localizedDescription)"
|
333
|
+
fatalError("Swift errors can currently not be propagated to C++! See https://github.com/swiftlang/swift/issues/75290 (Error: \(__message))")
|
334
|
+
}
|
335
|
+
}
|
309
336
|
}
|
@@ -45,6 +45,8 @@ public extension UnistyleDependency {
|
|
45
45
|
self = .statusbar
|
46
46
|
case "NavigationBar":
|
47
47
|
self = .navigationbar
|
48
|
+
case "Ime":
|
49
|
+
self = .ime
|
48
50
|
default:
|
49
51
|
return nil
|
50
52
|
}
|
@@ -83,6 +85,8 @@ public extension UnistyleDependency {
|
|
83
85
|
return "StatusBar"
|
84
86
|
case .navigationbar:
|
85
87
|
return "NavigationBar"
|
88
|
+
case .ime:
|
89
|
+
return "Ime"
|
86
90
|
}
|
87
91
|
}
|
88
92
|
}
|
@@ -32,6 +32,8 @@ namespace margelo::nitro::unistyles {
|
|
32
32
|
prototype.registerHybridMethod("setImmersiveMode", &HybridNativePlatformSpec::setImmersiveMode);
|
33
33
|
prototype.registerHybridMethod("getMiniRuntime", &HybridNativePlatformSpec::getMiniRuntime);
|
34
34
|
prototype.registerHybridMethod("registerPlatformListener", &HybridNativePlatformSpec::registerPlatformListener);
|
35
|
+
prototype.registerHybridMethod("registerImeListener", &HybridNativePlatformSpec::registerImeListener);
|
36
|
+
prototype.registerHybridMethod("unregisterPlatformListeners", &HybridNativePlatformSpec::unregisterPlatformListeners);
|
35
37
|
});
|
36
38
|
}
|
37
39
|
|
@@ -85,6 +85,8 @@ namespace margelo::nitro::unistyles {
|
|
85
85
|
virtual void setImmersiveMode(bool isEnabled) = 0;
|
86
86
|
virtual UnistylesNativeMiniRuntime getMiniRuntime() = 0;
|
87
87
|
virtual void registerPlatformListener(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>& callback) = 0;
|
88
|
+
virtual void registerImeListener(const std::function<void()>& callback) = 0;
|
89
|
+
virtual void unregisterPlatformListeners() = 0;
|
88
90
|
|
89
91
|
protected:
|
90
92
|
// Hybrid Setup
|
@@ -39,6 +39,7 @@ namespace margelo::nitro::unistyles {
|
|
39
39
|
FONTSCALE SWIFT_NAME(fontscale) = 11,
|
40
40
|
STATUSBAR SWIFT_NAME(statusbar) = 12,
|
41
41
|
NAVIGATIONBAR SWIFT_NAME(navigationbar) = 13,
|
42
|
+
IME SWIFT_NAME(ime) = 14,
|
42
43
|
} CLOSED_ENUM;
|
43
44
|
|
44
45
|
} // namespace margelo::nitro::unistyles
|
@@ -69,7 +70,7 @@ namespace margelo::nitro {
|
|
69
70
|
return false;
|
70
71
|
}
|
71
72
|
// Check if we are within the bounds of the enum.
|
72
|
-
return integer >= 0 && integer <=
|
73
|
+
return integer >= 0 && integer <= 14;
|
73
74
|
}
|
74
75
|
};
|
75
76
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-alpha.
|
3
|
+
"version": "3.0.0-alpha.29",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -60,27 +60,27 @@
|
|
60
60
|
"registry": "https://registry.npmjs.org/"
|
61
61
|
},
|
62
62
|
"devDependencies": {
|
63
|
-
"@babel/plugin-syntax-jsx": "7.25.
|
64
|
-
"@biomejs/biome": "1.
|
65
|
-
"@commitlint/config-conventional": "19.
|
66
|
-
"@react-native/normalize-colors": "0.
|
67
|
-
"@release-it/conventional-changelog": "8.0.
|
63
|
+
"@babel/plugin-syntax-jsx": "7.25.9",
|
64
|
+
"@biomejs/biome": "1.9.4",
|
65
|
+
"@commitlint/config-conventional": "19.5.0",
|
66
|
+
"@react-native/normalize-colors": "0.76.0",
|
67
|
+
"@release-it/conventional-changelog": "8.0.2",
|
68
68
|
"@testing-library/react-hooks": "8.0.1",
|
69
|
-
"@types/jest": "29.5.
|
70
|
-
"@types/react": "18.3.
|
69
|
+
"@types/jest": "29.5.14",
|
70
|
+
"@types/react": "18.3.12",
|
71
71
|
"babel-plugin-tester": "11.0.4",
|
72
|
-
"commitlint": "19.
|
72
|
+
"commitlint": "19.5.0",
|
73
73
|
"concurrently": "8.2.2",
|
74
|
-
"husky": "9.1.
|
74
|
+
"husky": "9.1.6",
|
75
75
|
"jest": "29.7.0",
|
76
76
|
"metro-react-native-babel-preset": "0.77.0",
|
77
77
|
"nitro-codegen": "0.13.0",
|
78
78
|
"react": "18.3.1",
|
79
|
-
"react-native": "0.
|
80
|
-
"react-native-builder-bob": "0.30.
|
79
|
+
"react-native": "0.76.0",
|
80
|
+
"react-native-builder-bob": "0.30.2",
|
81
81
|
"react-native-nitro-modules": "0.13.0",
|
82
82
|
"react-test-renderer": "18.3.1",
|
83
|
-
"release-it": "17.
|
83
|
+
"release-it": "17.10.0",
|
84
84
|
"typescript": "5.6.3"
|
85
85
|
},
|
86
86
|
"peerDependencies": {
|
package/plugin/common.js
CHANGED
@@ -104,6 +104,15 @@ function getSecondPropertyName(t, memberExpression) {
|
|
104
104
|
current = current.object
|
105
105
|
}
|
106
106
|
|
107
|
+
// special case for IME
|
108
|
+
if (propertyName && t.isIdentifier(propertyName) && propertyName.name === 'insets') {
|
109
|
+
if (t.isIdentifier(memberExpression.property) && memberExpression.property.name === "ime") {
|
110
|
+
return [memberExpression.property.name]
|
111
|
+
}
|
112
|
+
|
113
|
+
return [propertyName.name]
|
114
|
+
}
|
115
|
+
|
107
116
|
if (propertyName && t.isIdentifier(propertyName)) {
|
108
117
|
return [propertyName.name]
|
109
118
|
}
|
package/plugin/stylesheet.js
CHANGED
@@ -14,7 +14,8 @@ const UnistyleDependency = {
|
|
14
14
|
PixelRatio: 10,
|
15
15
|
FontScale: 11,
|
16
16
|
StatusBar: 12,
|
17
|
-
NavigationBar: 13
|
17
|
+
NavigationBar: 13,
|
18
|
+
Ime: 14
|
18
19
|
}
|
19
20
|
|
20
21
|
function stringToUniqueId(str) {
|
@@ -111,6 +112,11 @@ function analyzeDependencies(t, state, name, unistyleObj, themeName, rtName) {
|
|
111
112
|
|
112
113
|
return
|
113
114
|
}
|
115
|
+
case 'ime': {
|
116
|
+
dependencies.push(UnistyleDependency.Ime)
|
117
|
+
|
118
|
+
return
|
119
|
+
}
|
114
120
|
case 'insets': {
|
115
121
|
dependencies.push(UnistyleDependency.Insets)
|
116
122
|
|
package/src/global.ts
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
import {} from '../types';
|
2
|
+
export var UnistyleDependency;
|
3
|
+
(function (UnistyleDependency) {
|
4
|
+
UnistyleDependency[UnistyleDependency["Theme"] = 0] = "Theme";
|
5
|
+
UnistyleDependency[UnistyleDependency["ThemeName"] = 1] = "ThemeName";
|
6
|
+
UnistyleDependency[UnistyleDependency["AdaptiveThemes"] = 2] = "AdaptiveThemes";
|
7
|
+
UnistyleDependency[UnistyleDependency["Breakpoints"] = 3] = "Breakpoints";
|
8
|
+
UnistyleDependency[UnistyleDependency["Variants"] = 4] = "Variants";
|
9
|
+
UnistyleDependency[UnistyleDependency["ColorScheme"] = 5] = "ColorScheme";
|
10
|
+
UnistyleDependency[UnistyleDependency["Dimensions"] = 6] = "Dimensions";
|
11
|
+
UnistyleDependency[UnistyleDependency["Orientation"] = 7] = "Orientation";
|
12
|
+
UnistyleDependency[UnistyleDependency["ContentSizeCategory"] = 8] = "ContentSizeCategory";
|
13
|
+
UnistyleDependency[UnistyleDependency["Insets"] = 9] = "Insets";
|
14
|
+
UnistyleDependency[UnistyleDependency["PixelRatio"] = 10] = "PixelRatio";
|
15
|
+
UnistyleDependency[UnistyleDependency["FontScale"] = 11] = "FontScale";
|
16
|
+
UnistyleDependency[UnistyleDependency["StatusBar"] = 12] = "StatusBar";
|
17
|
+
UnistyleDependency[UnistyleDependency["NavigationBar"] = 13] = "NavigationBar";
|
18
|
+
})(UnistyleDependency || (UnistyleDependency = {}));
|
@@ -18,7 +18,8 @@ export enum UnistyleDependency {
|
|
18
18
|
PixelRatio = 10,
|
19
19
|
FontScale = 11,
|
20
20
|
StatusBar = 12,
|
21
|
-
NavigationBar = 13
|
21
|
+
NavigationBar = 13,
|
22
|
+
Ime = 14
|
22
23
|
}
|
23
24
|
|
24
25
|
export interface UnistylesNativeMiniRuntime {
|
@@ -58,5 +59,7 @@ export interface NativePlatform extends HybridObject<{ ios: 'swift', android: 'k
|
|
58
59
|
|
59
60
|
// private
|
60
61
|
getMiniRuntime(): UnistylesNativeMiniRuntime,
|
61
|
-
registerPlatformListener(callback: (dependencies: Array<UnistyleDependency>) => void): void
|
62
|
+
registerPlatformListener(callback: (dependencies: Array<UnistyleDependency>) => void): void,
|
63
|
+
registerImeListener(callback: () => void): void,
|
64
|
+
unregisterPlatformListeners(): void
|
62
65
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { UnistyleDependency } from './NativePlatform.nitro';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { processColor } from 'react-native';
|
2
|
+
export const attachNavigationBarJSMethods = (hybridObject) => {
|
3
|
+
const privateHybrid = hybridObject;
|
4
|
+
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
5
|
+
hybridObject.setBackgroundColor = (color) => {
|
6
|
+
const parsedColor = processColor(color) ?? 0;
|
7
|
+
privateHybrid._setBackgroundColor(parsedColor);
|
8
|
+
};
|
9
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
2
|
+
const HybridShadowRegistry = NitroModules.createHybridObject('UnistylesShadowRegistry');
|
3
|
+
const findShadowNodeForHandle = (handle) => {
|
4
|
+
const node = handle?.__internalInstanceHandle?.stateNode?.node
|
5
|
+
?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node
|
6
|
+
?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node;
|
7
|
+
if (!node) {
|
8
|
+
// todo extend log with file name / component name
|
9
|
+
throw new Error('Could not find shadow node for one of your components');
|
10
|
+
}
|
11
|
+
return node;
|
12
|
+
};
|
13
|
+
HybridShadowRegistry.add = (handle, style, variants, args) => {
|
14
|
+
// virtualized nodes can be null
|
15
|
+
if (!handle || !style) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
19
|
+
};
|
20
|
+
HybridShadowRegistry.remove = handle => {
|
21
|
+
if (!handle) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
HybridShadowRegistry.unlink(findShadowNodeForHandle(handle));
|
25
|
+
};
|
26
|
+
export const UnistylesShadowRegistry = HybridShadowRegistry;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { processColor, StatusBar as NativeStatusBar } from 'react-native';
|
2
|
+
import { StatusBarStyle } from '../types';
|
3
|
+
export const attachStatusBarJSMethods = (hybridObject) => {
|
4
|
+
hybridObject.setStyle = (style, animated) => {
|
5
|
+
switch (style) {
|
6
|
+
case StatusBarStyle.Light:
|
7
|
+
return NativeStatusBar.setBarStyle('light-content', animated);
|
8
|
+
case StatusBarStyle.Dark:
|
9
|
+
return NativeStatusBar.setBarStyle('dark-content', animated);
|
10
|
+
case StatusBarStyle.Default:
|
11
|
+
return NativeStatusBar.setBarStyle('default', animated);
|
12
|
+
}
|
13
|
+
};
|
14
|
+
const privateHybrid = hybridObject;
|
15
|
+
privateHybrid._setHidden = hybridObject.setHidden;
|
16
|
+
hybridObject.setHidden = (isHidden, animation) => {
|
17
|
+
NativeStatusBar.setHidden(isHidden, animation);
|
18
|
+
privateHybrid._setHidden(isHidden);
|
19
|
+
};
|
20
|
+
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
21
|
+
hybridObject.setBackgroundColor = (color) => {
|
22
|
+
const parsedColor = processColor(color) ?? 0;
|
23
|
+
privateHybrid._setBackgroundColor(parsedColor);
|
24
|
+
};
|
25
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
import { UnistyleDependency } from '../NativePlatform';
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
2
|
+
import { processColor, StyleSheet as NativeStyleSheet } from 'react-native';
|
3
|
+
const HybridUnistylesStyleSheet = NitroModules
|
4
|
+
.createHybridObject('UnistylesStyleSheet');
|
5
|
+
HybridUnistylesStyleSheet.absoluteFillObject = NativeStyleSheet.absoluteFillObject;
|
6
|
+
HybridUnistylesStyleSheet.absoluteFill = NativeStyleSheet.absoluteFill;
|
7
|
+
HybridUnistylesStyleSheet.flatten = NativeStyleSheet.flatten;
|
8
|
+
HybridUnistylesStyleSheet.compose = NativeStyleSheet.compose;
|
9
|
+
HybridUnistylesStyleSheet.jsMethods = {
|
10
|
+
processColor
|
11
|
+
};
|
12
|
+
HybridUnistylesStyleSheet.init();
|
13
|
+
export const StyleSheet = HybridUnistylesStyleSheet;
|
@@ -0,0 +1 @@
|
|
1
|
+
import './NativeTurboUnistyles';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { processColor } from 'react-native';
|
2
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
3
|
+
import { attachStatusBarJSMethods } from '../StatusBar';
|
4
|
+
import { attachNavigationBarJSMethods } from '../NavigtionBar';
|
5
|
+
import { isIOS } from '../../common';
|
6
|
+
const HybridUnistylesRuntime = NitroModules
|
7
|
+
.createHybridObject('UnistylesRuntime');
|
8
|
+
HybridUnistylesRuntime.statusBar = HybridUnistylesRuntime.createHybridStatusBar();
|
9
|
+
HybridUnistylesRuntime.navigationBar = HybridUnistylesRuntime.createHybridNavigationBar();
|
10
|
+
HybridUnistylesRuntime._setRootViewBackgroundColor = HybridUnistylesRuntime.setRootViewBackgroundColor;
|
11
|
+
HybridUnistylesRuntime.setRootViewBackgroundColor = (color) => {
|
12
|
+
const parsedColor = processColor(color) ?? 0;
|
13
|
+
HybridUnistylesRuntime._setRootViewBackgroundColor(parsedColor);
|
14
|
+
};
|
15
|
+
if (isIOS) {
|
16
|
+
HybridUnistylesRuntime.setImmersiveMode = (isEnabled) => HybridUnistylesRuntime.statusBar.setHidden(isEnabled, 'fade');
|
17
|
+
}
|
18
|
+
attachStatusBarJSMethods(HybridUnistylesRuntime.statusBar);
|
19
|
+
attachNavigationBarJSMethods(HybridUnistylesRuntime.navigationBar);
|
20
|
+
export const Runtime = HybridUnistylesRuntime;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import './TurboUnistyles';
|
2
|
+
import { Runtime } from './UnistylesRuntime';
|
3
|
+
import { StyleSheet } from './StyleSheet';
|
4
|
+
import { UnistylesShadowRegistry } from './ShadowRegistry';
|
5
|
+
import { StatusBarStyle, ColorScheme, Orientation } from './types';
|
6
|
+
import { UnistyleDependency } from './NativePlatform';
|
7
|
+
export { StatusBarStyle, ColorScheme, Orientation, UnistyleDependency };
|
8
|
+
export { UnistylesShadowRegistry, Runtime as UnistylesRuntime, StyleSheet, };
|