react-native-unistyles 3.1.0 → 3.2.0
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 +180 -0
- package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -5
- package/android/src/main/cxx/NativeUnistylesModule.h +1 -7
- package/android/src/main/java/com/unistyles/Equatable.kt +5 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +6 -1
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +21 -3
- package/cxx/core/UnistyleWrapper.h +2 -2
- package/cxx/core/UnistylesRegistry.cpp +57 -48
- package/cxx/core/UnistylesRegistry.h +16 -14
- package/cxx/core/UnistylesState.cpp +22 -20
- package/cxx/core/UnistylesState.h +5 -6
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +14 -3
- package/cxx/hybridObjects/HybridShadowRegistry.h +5 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +71 -45
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +22 -32
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +3 -4
- package/cxx/parser/Parser.cpp +14 -14
- package/ios/UnistylesModuleOnLoad.mm +3 -10
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +4 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +20 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/web/convert/style.js +6 -6
- package/lib/commonjs/web/convert/style.js.map +1 -1
- package/lib/commonjs/web/listener.js +6 -0
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +4 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +20 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/web/convert/style.js +6 -6
- package/lib/module/web/convert/style.js.map +1 -1
- package/lib/module/web/listener.js +6 -0
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/utils/createUnistylesRef.js +1 -1
- package/lib/module/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
- package/nitrogen/generated/android/c++/JDimensions.hpp +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +2 -2
- package/nitrogen/generated/android/c++/JInsets.hpp +1 -1
- package/nitrogen/generated/android/c++/JOrientation.hpp +1 -1
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +1 -1
- package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +1 -1
- package/package.json +3 -3
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +4 -1
- package/src/specs/ShadowRegistry/index.ts +36 -2
- package/src/web/convert/style.ts +6 -6
- package/src/web/listener.ts +6 -0
- package/src/web/utils/createUnistylesRef.ts +1 -1
|
@@ -19,7 +19,7 @@ namespace margelo::nitro::unistyles {
|
|
|
19
19
|
*/
|
|
20
20
|
struct JColorScheme final: public jni::JavaClass<JColorScheme> {
|
|
21
21
|
public:
|
|
22
|
-
static auto
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/ColorScheme;";
|
|
23
23
|
|
|
24
24
|
public:
|
|
25
25
|
/**
|
|
@@ -21,7 +21,7 @@ namespace margelo::nitro::unistyles {
|
|
|
21
21
|
*/
|
|
22
22
|
struct JDimensions final: public jni::JavaClass<JDimensions> {
|
|
23
23
|
public:
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Dimensions;";
|
|
25
25
|
|
|
26
26
|
public:
|
|
27
27
|
/**
|
|
@@ -32,7 +32,7 @@ namespace margelo::nitro::unistyles {
|
|
|
32
32
|
*/
|
|
33
33
|
struct JFunc_void_UnistylesNativeMiniRuntime: public jni::JavaClass<JFunc_void_UnistylesNativeMiniRuntime> {
|
|
34
34
|
public:
|
|
35
|
-
static auto
|
|
35
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime;";
|
|
36
36
|
|
|
37
37
|
public:
|
|
38
38
|
/**
|
|
@@ -68,7 +68,7 @@ namespace margelo::nitro::unistyles {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
public:
|
|
71
|
-
static auto
|
|
71
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime_cxx;";
|
|
72
72
|
static void registerNatives() {
|
|
73
73
|
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_UnistylesNativeMiniRuntime_cxx::invoke_cxx)});
|
|
74
74
|
}
|
|
@@ -35,7 +35,7 @@ namespace margelo::nitro::unistyles {
|
|
|
35
35
|
*/
|
|
36
36
|
struct JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime: public jni::JavaClass<JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime> {
|
|
37
37
|
public:
|
|
38
|
-
static auto
|
|
38
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime;";
|
|
39
39
|
|
|
40
40
|
public:
|
|
41
41
|
/**
|
|
@@ -89,7 +89,7 @@ namespace margelo::nitro::unistyles {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
public:
|
|
92
|
-
static auto
|
|
92
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime_cxx;";
|
|
93
93
|
static void registerNatives() {
|
|
94
94
|
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime_cxx::invoke_cxx)});
|
|
95
95
|
}
|
|
@@ -21,11 +21,11 @@ namespace margelo::nitro::unistyles {
|
|
|
21
21
|
class JHybridNativePlatformSpec: public virtual HybridNativePlatformSpec, public virtual JHybridObject {
|
|
22
22
|
public:
|
|
23
23
|
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/HybridNativePlatformSpec;";
|
|
25
25
|
std::shared_ptr<JHybridNativePlatformSpec> getJHybridNativePlatformSpec();
|
|
26
26
|
};
|
|
27
27
|
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
-
static auto
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/HybridNativePlatformSpec$CxxPart;";
|
|
29
29
|
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
30
|
static void registerNatives();
|
|
31
31
|
using HybridBase::HybridBase;
|
|
@@ -21,7 +21,7 @@ namespace margelo::nitro::unistyles {
|
|
|
21
21
|
*/
|
|
22
22
|
struct JInsets final: public jni::JavaClass<JInsets> {
|
|
23
23
|
public:
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Insets;";
|
|
25
25
|
|
|
26
26
|
public:
|
|
27
27
|
/**
|
|
@@ -19,7 +19,7 @@ namespace margelo::nitro::unistyles {
|
|
|
19
19
|
*/
|
|
20
20
|
struct JOrientation final: public jni::JavaClass<JOrientation> {
|
|
21
21
|
public:
|
|
22
|
-
static auto
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Orientation;";
|
|
23
23
|
|
|
24
24
|
public:
|
|
25
25
|
/**
|
|
@@ -19,7 +19,7 @@ namespace margelo::nitro::unistyles {
|
|
|
19
19
|
*/
|
|
20
20
|
struct JUnistyleDependency final: public jni::JavaClass<JUnistyleDependency> {
|
|
21
21
|
public:
|
|
22
|
-
static auto
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/UnistyleDependency;";
|
|
23
23
|
|
|
24
24
|
public:
|
|
25
25
|
/**
|
|
@@ -27,7 +27,7 @@ namespace margelo::nitro::unistyles {
|
|
|
27
27
|
*/
|
|
28
28
|
struct JUnistylesNativeMiniRuntime final: public jni::JavaClass<JUnistylesNativeMiniRuntime> {
|
|
29
29
|
public:
|
|
30
|
-
static auto
|
|
30
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/unistyles/UnistylesNativeMiniRuntime;";
|
|
31
31
|
|
|
32
32
|
public:
|
|
33
33
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-unistyles",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "NODE_ENV=babel-test jest ./plugin ./src/__tests__",
|
|
@@ -145,13 +145,13 @@
|
|
|
145
145
|
"@babel/plugin-syntax-jsx": "7.28.6",
|
|
146
146
|
"@babel/runtime": "7.28.6",
|
|
147
147
|
"@react-native/babel-preset": "0.83.2",
|
|
148
|
-
"nitrogen": "0.35.
|
|
148
|
+
"nitrogen": "0.35.2",
|
|
149
149
|
"oxfmt": "0.35.0",
|
|
150
150
|
"oxlint": "1.50.0",
|
|
151
151
|
"react": "19.2.0",
|
|
152
152
|
"react-native": "0.83.2",
|
|
153
153
|
"react-native-builder-bob": "0.40.18",
|
|
154
|
-
"react-native-nitro-modules": "0.35.
|
|
154
|
+
"react-native-nitro-modules": "0.35.2",
|
|
155
155
|
"react-native-reanimated": "4.2.2",
|
|
156
156
|
"react-native-web": "0.21.2",
|
|
157
157
|
"typescript": "5.9.3"
|
|
@@ -62,7 +62,10 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
useEffect(() => {
|
|
65
|
-
return () =>
|
|
65
|
+
return () => {
|
|
66
|
+
disposeRef.current?.()
|
|
67
|
+
syncedDependenciesSizeRef.current = -1
|
|
68
|
+
}
|
|
66
69
|
}, [disposeRef])
|
|
67
70
|
|
|
68
71
|
const maybeNewScopedTheme = UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
|
|
@@ -10,6 +10,7 @@ interface ShadowRegistry extends UnistylesShadowRegistrySpec {
|
|
|
10
10
|
// JSI
|
|
11
11
|
link(node: ShadowNode, styles?: Array<Unistyle>): void
|
|
12
12
|
unlink(node: ShadowNode): void
|
|
13
|
+
suspend(node: ShadowNode): void
|
|
13
14
|
flush(): void
|
|
14
15
|
setScopedTheme(themeName?: string): void
|
|
15
16
|
getScopedTheme(): string | undefined
|
|
@@ -17,6 +18,33 @@ interface ShadowRegistry extends UnistylesShadowRegistrySpec {
|
|
|
17
18
|
|
|
18
19
|
const HybridShadowRegistry = NitroModules.createHybridObject<ShadowRegistry>('UnistylesShadowRegistry')
|
|
19
20
|
|
|
21
|
+
const SUSPENSE_TAG = 13
|
|
22
|
+
|
|
23
|
+
const isInsideSuspendedBoundary = (fiber: any): boolean => {
|
|
24
|
+
let current = fiber?.return
|
|
25
|
+
|
|
26
|
+
while (current) {
|
|
27
|
+
if (current.tag === SUSPENSE_TAG && current.memoizedState !== null) {
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
current = current.return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const findFiberForHandle = (handle: ViewHandle) => {
|
|
38
|
+
return (
|
|
39
|
+
handle?.__internalInstanceHandle ??
|
|
40
|
+
handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle ??
|
|
41
|
+
handle?.getNativeScrollRef?.()?.__internalInstanceHandle ??
|
|
42
|
+
handle?._viewRef?.__internalInstanceHandle ??
|
|
43
|
+
handle?.viewRef?.current?.__internalInstanceHandle ??
|
|
44
|
+
handle?._nativeRef?.__internalInstanceHandle
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
20
48
|
const findShadowNodeForHandle = (handle: ViewHandle) => {
|
|
21
49
|
const node =
|
|
22
50
|
handle?.__internalInstanceHandle?.stateNode?.node ??
|
|
@@ -71,10 +99,16 @@ HybridShadowRegistry.remove = (handle) => {
|
|
|
71
99
|
const maybeNode = findShadowNodeForHandle(handle)
|
|
72
100
|
|
|
73
101
|
if (maybeNode) {
|
|
74
|
-
|
|
102
|
+
const fiber = findFiberForHandle(handle)
|
|
103
|
+
|
|
104
|
+
if (fiber && isInsideSuspendedBoundary(fiber)) {
|
|
105
|
+
HybridShadowRegistry.suspend(maybeNode)
|
|
106
|
+
} else {
|
|
107
|
+
HybridShadowRegistry.unlink(maybeNode)
|
|
108
|
+
}
|
|
75
109
|
}
|
|
76
110
|
}
|
|
77
111
|
|
|
78
|
-
type PrivateMethods = 'add' | 'remove' | 'link' | 'unlink'
|
|
112
|
+
type PrivateMethods = 'add' | 'remove' | 'link' | 'unlink' | 'suspend'
|
|
79
113
|
|
|
80
114
|
export const UnistylesShadowRegistry = HybridShadowRegistry as Omit<ShadowRegistry, PrivateMethods>
|
package/src/web/convert/style.ts
CHANGED
|
@@ -98,22 +98,22 @@ const convertMap = {
|
|
|
98
98
|
borderInlineStartWidth: value,
|
|
99
99
|
}),
|
|
100
100
|
end: (value: number) => ({
|
|
101
|
-
|
|
101
|
+
insetInlineEnd: value,
|
|
102
102
|
}),
|
|
103
103
|
start: (value: number) => ({
|
|
104
|
-
|
|
104
|
+
insetInlineStart: value,
|
|
105
105
|
}),
|
|
106
106
|
marginEnd: (value: number) => ({
|
|
107
|
-
|
|
107
|
+
marginInlineEnd: value,
|
|
108
108
|
}),
|
|
109
109
|
marginStart: (value: number) => ({
|
|
110
|
-
|
|
110
|
+
marginInlineStart: value,
|
|
111
111
|
}),
|
|
112
112
|
paddingEnd: (value: number) => ({
|
|
113
|
-
|
|
113
|
+
paddingInlineEnd: value,
|
|
114
114
|
}),
|
|
115
115
|
paddingStart: (value: number) => ({
|
|
116
|
-
|
|
116
|
+
paddingInlineStart: value,
|
|
117
117
|
}),
|
|
118
118
|
transformMatrix: (value: Array<number>) => ({
|
|
119
119
|
transform: `matrix(${value.join(', ')})`,
|
package/src/web/listener.ts
CHANGED
|
@@ -92,6 +92,12 @@ export class UnistylesListener {
|
|
|
92
92
|
|
|
93
93
|
window.addEventListener('orientationchange', () => this.emitChange(UnistyleDependency.Orientation))
|
|
94
94
|
window.addEventListener('resize', () => this.emitChange(UnistyleDependency.Dimensions))
|
|
95
|
+
new MutationObserver(() => {
|
|
96
|
+
this.emitChange(UnistyleDependency.Rtl)
|
|
97
|
+
}).observe(document.documentElement, {
|
|
98
|
+
attributes: true,
|
|
99
|
+
attributeFilter: ['dir'],
|
|
100
|
+
})
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
addListeners = (dependencies: Array<UnistyleDependency>, listener: Listener) => {
|
|
@@ -20,7 +20,7 @@ export const createUnistylesRef = <T>(styles?: Styles, forwardedRef?: React.Forw
|
|
|
20
20
|
? undefined
|
|
21
21
|
: (ref: Nullable<T>) => {
|
|
22
22
|
if (!ref) {
|
|
23
|
-
unistyles.services.shadowRegistry.remove(storedRef, classNames?.hash)
|
|
23
|
+
unistyles.services.shadowRegistry.remove(storedRef.current, classNames?.hash)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
storedRef.current = ref
|