react-native-unistyles 3.0.0-nightly-20250221 → 3.0.0-nightly-20250226
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 +14 -0
- package/android/CMakeLists.txt +2 -1
- package/cxx/core/UnistylesMountHook.cpp +2 -2
- package/cxx/core/UnistylesMountHook.h +1 -4
- package/cxx/hybridObjects/HybridStyleSheet.cpp +1 -1
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +2 -2
- package/lib/commonjs/core/createUnistylesElement.native.js +4 -0
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +4 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +14 -7
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +4 -0
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +4 -0
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +14 -7
- package/lib/module/core/withUnistyles/withUnistyles.native.js.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/withUnistyles/withUnistyles.native.d.ts.map +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.cpp +19 -19
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +22 -22
- package/nitrogen/generated/android/unistyles+autolinking.cmake +16 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -1
- package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -0
- package/nitrogen/generated/shared/c++/Insets.hpp +1 -0
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -0
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -0
- package/package.json +3 -3
- package/plugin/index.js +6 -0
- package/src/core/createUnistylesElement.native.tsx +5 -0
- package/src/core/createUnistylesImageBackground.tsx +5 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +40 -14
package/README.md
CHANGED
@@ -18,6 +18,20 @@
|
|
18
18
|
yarn add react-native-unistyles@beta
|
19
19
|
```
|
20
20
|
|
21
|
+
Install dependencies:
|
22
|
+
|
23
|
+
```shell
|
24
|
+
yarn add react-native-edge-to-edge react-native-nitro-modules@0.22.1
|
25
|
+
```
|
26
|
+
|
27
|
+
> Always use fixed version of `react-native-nitro-modules` to avoid unexpected behaviors.
|
28
|
+
|
29
|
+
| react-native-unistyles | react-native-nitro-modules |
|
30
|
+
|------------------------|----------------------------|
|
31
|
+
| 3.0.0.beta.7 | 0.22.1 |
|
32
|
+
| 3.0.0.nightly-20250221 | 0.22.1 |
|
33
|
+
| 3.0.0.nightly-20250226 | 0.24.1 |
|
34
|
+
|
21
35
|
Then follow [installation guides](https://unistyl.es/v3/start/getting-started) for your platform.
|
22
36
|
|
23
37
|
## [Documentation](https://unistyl.es/)
|
package/android/CMakeLists.txt
CHANGED
@@ -23,7 +23,8 @@ include_directories(
|
|
23
23
|
../cxx/shadowTree
|
24
24
|
)
|
25
25
|
|
26
|
-
|
26
|
+
# Nitro appends all Folly Flags, leaving it empty
|
27
|
+
string(APPEND CMAKE_CXX_FLAGS " ")
|
27
28
|
|
28
29
|
set_target_properties(unistyles PROPERTIES
|
29
30
|
CXX_STANDARD 20
|
@@ -22,7 +22,7 @@ void core::UnistylesMountHook::shadowTreeDidMount(RootShadowNode::Shared const &
|
|
22
22
|
// one more time merge Unistyles changes
|
23
23
|
auto& registry = core::UnistylesRegistry::get();
|
24
24
|
|
25
|
-
if (
|
26
|
-
|
25
|
+
if (registry.trafficController.shouldStop()) {
|
26
|
+
registry.trafficController.resumeUnistylesTraffic();
|
27
27
|
}
|
28
28
|
}
|
@@ -3,15 +3,13 @@
|
|
3
3
|
#include <react/renderer/uimanager/UIManager.h>
|
4
4
|
#include <react/renderer/uimanager/UIManagerMountHook.h>
|
5
5
|
#include "ShadowTreeManager.h"
|
6
|
-
#include "HybridUnistylesRuntime.h"
|
7
6
|
|
8
7
|
namespace margelo::nitro::unistyles::core {
|
9
8
|
|
10
9
|
using namespace facebook::react;
|
11
10
|
|
12
11
|
struct UnistylesMountHook : public UIManagerMountHook {
|
13
|
-
UnistylesMountHook(std::shared_ptr<UIManager> uiManager
|
14
|
-
: _uiManager{uiManager}, _unistylesRuntime{unistylesRuntime} {
|
12
|
+
UnistylesMountHook(std::shared_ptr<UIManager> uiManager): _uiManager{uiManager} {
|
15
13
|
_uiManager->registerMountHook(*this);
|
16
14
|
}
|
17
15
|
|
@@ -21,7 +19,6 @@ struct UnistylesMountHook : public UIManagerMountHook {
|
|
21
19
|
|
22
20
|
private:
|
23
21
|
std::shared_ptr<UIManager> _uiManager;
|
24
|
-
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
25
22
|
};
|
26
23
|
|
27
24
|
}
|
@@ -261,7 +261,7 @@ void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
|
|
261
261
|
core::UnistylesRegistry::get().trafficController.restore();
|
262
262
|
|
263
263
|
this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager);
|
264
|
-
this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager
|
264
|
+
this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager);
|
265
265
|
}
|
266
266
|
|
267
267
|
void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies) {
|
@@ -73,11 +73,11 @@ void HybridUnistylesRuntime::setTheme(const std::string &themeName) {
|
|
73
73
|
helpers::assertThat(*_rt, !this->getHasAdaptiveThemes(), "Unistyles: You're trying to set theme to: '" + themeName + "', but adaptiveThemes are enabled.");
|
74
74
|
|
75
75
|
auto& state = core::UnistylesRegistry::get().getState(*_rt);
|
76
|
-
auto
|
76
|
+
auto currentThemeName = state.getCurrentThemeName();
|
77
77
|
|
78
78
|
state.setTheme(themeName);
|
79
79
|
|
80
|
-
if (currentThemeName != themeName) {
|
80
|
+
if (currentThemeName.value() != themeName) {
|
81
81
|
this->_onDependenciesChange({UnistyleDependency::THEME, UnistyleDependency::THEMENAME});
|
82
82
|
}
|
83
83
|
};
|
@@ -45,6 +45,10 @@ const createUnistylesElement = Component => {
|
|
45
45
|
|
46
46
|
// @ts-ignore we don't know the type of the component
|
47
47
|
(0, _warn.maybeWarnAboutMultipleUnistyles)(props.style, Component.displayName);
|
48
|
+
return () => {
|
49
|
+
// @ts-ignore
|
50
|
+
_specs.UnistylesShadowRegistry.remove(ref);
|
51
|
+
};
|
48
52
|
}
|
49
53
|
});
|
50
54
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_utils","_passForwardRef","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getNativeRef","Component","ref","name","viewRef","current","getNativeScrollRef","getScrollRef","createUnistylesElement","UnistylesComponent","React","forwardRef","props","forwardedRef","storedRef","useRef","useLayoutEffect","UnistylesShadowRegistry","remove","jsx","passForwardedRef","maybeWarnAboutM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_react","_interopRequireWildcard","require","_specs","_utils","_passForwardRef","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getNativeRef","Component","ref","name","viewRef","current","getNativeScrollRef","getScrollRef","createUnistylesElement","UnistylesComponent","React","forwardRef","props","forwardedRef","storedRef","useRef","useLayoutEffect","UnistylesShadowRegistry","remove","jsx","passForwardedRef","maybeWarnAboutMultipleUnistyles","style","displayName","copyComponentProperties","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAAwD,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAA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AK;MACTV,GAAG,EAAGA,GAAY,IAAK;QACnB,IAAIA,GAAG,EAAE;UACLY,SAAS,CAACT,OAAO,GAAGL,YAAY,CAACC,SAAS,EAAEC,GAAG,CAAC;QACpD;QAEA,IAAAkB,gCAAgB,EAACR,KAAK,EAAEV,GAAG,EAAEW,YAAY,CAAC;;QAE1C;QACA,IAAAQ,qCAA+B,EAACT,KAAK,CAACU,KAAK,EAAErB,SAAS,CAACsB,WAAW,CAAC;QAEnE,OAAO,MAAM;UACT;UACAN,8BAAuB,CAACC,MAAM,CAAChB,GAAG,CAAC;QACvC,CAAC;MACL;IAAE,CACL,CAAC;EAEV,CAAC,CAAC;EAEF,OAAO,IAAAsB,8BAAuB,EAACvB,SAAS,EAAEQ,kBAAkB,CAAC;AACjE,CAAC;AAAAgB,OAAA,CAAAjB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
@@ -35,6 +35,10 @@ const createUnistylesImageBackground = Component => {
|
|
35
35
|
return () => {
|
36
36
|
// @ts-ignore
|
37
37
|
_specs.UnistylesShadowRegistry.remove(ref);
|
38
|
+
if (storedImageRef.current) {
|
39
|
+
// @ts-ignore
|
40
|
+
_specs.UnistylesShadowRegistry.remove(storedImageRef.current);
|
41
|
+
}
|
38
42
|
};
|
39
43
|
},
|
40
44
|
imageRef: ref => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_utils","_passForwardRef","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","createUnistylesImageBackground","Component","UnistylesImageBackground","React","forwardRef","props","forwardedRef","storedImageRef","useRef","useLayoutEffect","current","UnistylesShadowRegistry","remove","maybeWarnAboutMultipleUnistyles","style","imageStyle","jsx","ref","passForwardedRef","imageRef","add","copyComponentProperties","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesImageBackground.tsx"],"mappings":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AA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAEjD,MAAMW,8BAA8B,GAAIC,SAAiC,IAAK;EACjF,MAAMC,wBAAwB,gBAAGC,cAAK,CAACC,UAAU,CAAwC,CAACC,KAAK,EAAEC,YAAY,KAAK;IAC9G,MAAMC,cAAc,GAAG,IAAAC,aAAM,EAAe,IAAI,CAAC;IAEjD,IAAAC,sBAAe,EAAC,MAAM;MAClB,OAAO,MAAM;QACT,IAAIF,cAAc,CAACG,OAAO,EAAE;UACxB;UACAC,8BAAuB,CAACC,MAAM,CAACL,cAAc,CAACG,OAAO,CAAC;QAC1D;MACJ,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;;IAEN;IACA,IAAAG,qCAA+B,EAACR,KAAK,CAACS,KAAK,EAAE,iBAAiB,CAAC;IAC/D;IACA,IAAAD,qCAA+B,EAACR,KAAK,CAACU,UAAU,EAAE,iBAAiB,CAAC;IAEpE,oBACI,IAAApC,WAAA,CAAAqC,GAAA,EAACf,SAAS;MAAA,GACFI,KAAK;MACTY,GAAG,EAAEA,GAAG,IAAI;QACR,IAAAC,gCAAgB,EAACb,KAAK,EAAEY,GAAG,EAAEX,YAAY,CAAC;QAE1C,OAAO,MAAM;UACT;UACAK,8BAAuB,CAACC,MAAM,CAACK,GAAG,CAAC;
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_utils","_passForwardRef","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","createUnistylesImageBackground","Component","UnistylesImageBackground","React","forwardRef","props","forwardedRef","storedImageRef","useRef","useLayoutEffect","current","UnistylesShadowRegistry","remove","maybeWarnAboutMultipleUnistyles","style","imageStyle","jsx","ref","passForwardedRef","imageRef","add","copyComponentProperties","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesImageBackground.tsx"],"mappings":";;;;;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AACvE,CAAC;AAAAoB,OAAA,CAAAtB,8BAAA,GAAAA,8BAAA","ignoreList":[]}
|
@@ -18,10 +18,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
18
18
|
|
19
19
|
const withUnistyles = (Component, mappings) => {
|
20
20
|
const getSecrets = (styleProps = {}) => {
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
const styles = Array.isArray(styleProps) ? styleProps : [styleProps];
|
22
|
+
const secrets = styles.filter(Boolean).reduce((acc, style) => {
|
23
|
+
const unistyleKey = Object.keys(style).find(key => key.startsWith('unistyles_'));
|
24
|
+
return acc.concat([unistyleKey ? style[unistyleKey] : {
|
25
|
+
uni__getStyles: () => styleProps,
|
26
|
+
uni__dependencies: []
|
27
|
+
}]);
|
28
|
+
}, []);
|
29
|
+
return {
|
30
|
+
styles: secrets.reduce((acc, secret) => Object.assign(acc, secret.uni__getStyles()), {}),
|
31
|
+
dependencies: secrets.flatMap(secret => secret.uni__dependencies)
|
25
32
|
};
|
26
33
|
};
|
27
34
|
return /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
@@ -41,7 +48,7 @@ const withUnistyles = (Component, mappings) => {
|
|
41
48
|
(0, _react.useEffect)(() => {
|
42
49
|
const styleSecrets = getSecrets(narrowedProps.style);
|
43
50
|
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle);
|
44
|
-
addDependencies(Array.from(new Set([...styleSecrets.
|
51
|
+
addDependencies(Array.from(new Set([...styleSecrets.dependencies, ...contentContainerStyleSecrets.dependencies])));
|
45
52
|
}, [narrowedProps.style, narrowedProps.contentContainerStyle]);
|
46
53
|
const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {};
|
47
54
|
const unistyleProps = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {};
|
@@ -50,10 +57,10 @@ const withUnistyles = (Component, mappings) => {
|
|
50
57
|
const finalProps = {
|
51
58
|
...(0, _utils.deepMergeObjects)(mappingsProps, unistyleProps, props),
|
52
59
|
...(narrowedProps.style ? {
|
53
|
-
style: styleSecrets.
|
60
|
+
style: styleSecrets.styles
|
54
61
|
} : {}),
|
55
62
|
...(narrowedProps.contentContainerStyle ? {
|
56
|
-
contentContainerStyle: contentContainerStyleSecrets.
|
63
|
+
contentContainerStyle: contentContainerStyleSecrets.styles
|
57
64
|
} : {})
|
58
65
|
};
|
59
66
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeComponent, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_utils","_useProxifiedUnistyles","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","withUnistyles","Component","mappings","getSecrets","styleProps","unistyleKey","keys","find","key","startsWith","uni__getStyles","uni__dependencies","forwardRef","props","ref","narrowedProps","NativeComponent","maybeWarnAboutMultipleUnistyles","
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_utils","_useProxifiedUnistyles","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","withUnistyles","Component","mappings","getSecrets","styleProps","styles","Array","isArray","secrets","filter","Boolean","reduce","acc","style","unistyleKey","keys","find","key","startsWith","concat","uni__getStyles","uni__dependencies","secret","assign","dependencies","flatMap","forwardRef","props","ref","narrowedProps","NativeComponent","maybeWarnAboutMultipleUnistyles","displayName","name","contentContainerStyle","scopedTheme","useRef","UnistylesShadowRegistry","getScopedTheme","proxifiedRuntime","proxifiedTheme","addDependencies","useProxifiedUnistyles","current","useEffect","styleSecrets","contentContainerStyleSecrets","from","Set","mappingsProps","unistyleProps","uniProps","finalProps","deepMergeObjects","jsx","exports"],"sourceRoot":"../../../../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CAAC0B,aAAa,CAACK,qBAAqB,CAAC;IAEpF,MAAMkB,UAAU,GAAG;MACf,GAAG,IAAAC,uBAAgB,EAACJ,aAAa,EAAEC,aAAa,EAAEvB,KAAK,CAAC;MACxD,IAAGE,aAAa,CAAChB,KAAK,GAAG;QACrBA,KAAK,EAAEgC,YAAY,CAACxC;MACxB,CAAC,GAAG,CAAC,CAAC;MACN,IAAGwB,aAAa,CAACK,qBAAqB,GAAG;QACrCA,qBAAqB,EAAEY,4BAA4B,CAACzC;MACxD,CAAC,GAAG,CAAC,CAAC;IACV,CAAQ;IAER,oBAAO,IAAA1B,WAAA,CAAA2E,GAAA,EAACxB,eAAe;MAAA,GAAKsB,UAAU;MAAYxB,GAAG,EAAEA;IAAI,CAAE,CAAC;EAClE,CAAC,CAAC;AACN,CAAC;AAAA2B,OAAA,CAAAvD,aAAA,GAAAA,aAAA","ignoreList":[]}
|
@@ -39,6 +39,10 @@ export const createUnistylesElement = Component => {
|
|
39
39
|
|
40
40
|
// @ts-ignore we don't know the type of the component
|
41
41
|
maybeWarnAboutMultipleUnistyles(props.style, Component.displayName);
|
42
|
+
return () => {
|
43
|
+
// @ts-ignore
|
44
|
+
UnistylesShadowRegistry.remove(ref);
|
45
|
+
};
|
42
46
|
}
|
43
47
|
});
|
44
48
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useLayoutEffect","useRef","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","getNativeRef","Component","ref","name","viewRef","current","getNativeScrollRef","getScrollRef","createUnistylesElement","UnistylesComponent","forwardRef","props","forwardedRef","storedRef","remove","style","displayName"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AACtD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,YAAY,GAAGA,CAACC,SAAc,EAAEC,GAAQ,KAAK;EAC/C,QAAQD,SAAS,CAACE,IAAI;IAClB,KAAK,sBAAsB;MACvB,OAAOD,GAAG,CAACE,OAAO,EAAEC,OAAO;IAC/B,KAAK,UAAU;MACX,OAAOH,GAAG,CAACI,kBAAkB,GAAG,CAAC;IACrC,KAAK,iBAAiB;MAClB,OAAOJ,GAAG,CAACK,YAAY,GAAG,CAAC;IAC/B;MACI,OAAOL,GAAG;EAClB;AACJ,CAAC;AAED,OAAO,MAAMM,sBAAsB,GAAIP,SAAc,IAAK;EACtD,MAAMQ,kBAAkB,gBAAGlB,KAAK,CAACmB,UAAU,CAAC,CAACC,KAAK,EAAEC,YAAY,KAAK;IACjE,MAAMC,SAAS,GAAGpB,MAAM,CAAU,IAAI,CAAC;IAEvCD,eAAe,CAAC,MAAM;MAClB,OAAO,MAAM;QACT,IAAIqB,SAAS,CAACR,OAAO,EAAE;UACnB;UACAX,uBAAuB,CAACoB,MAAM,CAACD,SAAS,CAACR,OAAO,CAAC;QACrD;MACJ,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;IAEN,oBACIN,IAAA,CAACE,SAAS;MAAA,GACFU,KAAK;MACTT,GAAG,EAAGA,GAAY,IAAK;QACnB,IAAIA,GAAG,EAAE;UACLW,SAAS,CAACR,OAAO,GAAGL,YAAY,CAACC,SAAS,EAAEC,GAAG,CAAC;QACpD;QAEAN,gBAAgB,CAACe,KAAK,EAAET,GAAG,EAAEU,YAAY,CAAC;;QAE1C;QACAf,+BAA+B,CAACc,KAAK,CAACI,KAAK,EAAEd,SAAS,CAACe,WAAW,CAAC;
|
1
|
+
{"version":3,"names":["React","useLayoutEffect","useRef","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","getNativeRef","Component","ref","name","viewRef","current","getNativeScrollRef","getScrollRef","createUnistylesElement","UnistylesComponent","forwardRef","props","forwardedRef","storedRef","remove","style","displayName"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AACtD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,YAAY,GAAGA,CAACC,SAAc,EAAEC,GAAQ,KAAK;EAC/C,QAAQD,SAAS,CAACE,IAAI;IAClB,KAAK,sBAAsB;MACvB,OAAOD,GAAG,CAACE,OAAO,EAAEC,OAAO;IAC/B,KAAK,UAAU;MACX,OAAOH,GAAG,CAACI,kBAAkB,GAAG,CAAC;IACrC,KAAK,iBAAiB;MAClB,OAAOJ,GAAG,CAACK,YAAY,GAAG,CAAC;IAC/B;MACI,OAAOL,GAAG;EAClB;AACJ,CAAC;AAED,OAAO,MAAMM,sBAAsB,GAAIP,SAAc,IAAK;EACtD,MAAMQ,kBAAkB,gBAAGlB,KAAK,CAACmB,UAAU,CAAC,CAACC,KAAK,EAAEC,YAAY,KAAK;IACjE,MAAMC,SAAS,GAAGpB,MAAM,CAAU,IAAI,CAAC;IAEvCD,eAAe,CAAC,MAAM;MAClB,OAAO,MAAM;QACT,IAAIqB,SAAS,CAACR,OAAO,EAAE;UACnB;UACAX,uBAAuB,CAACoB,MAAM,CAACD,SAAS,CAACR,OAAO,CAAC;QACrD;MACJ,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;IAEN,oBACIN,IAAA,CAACE,SAAS;MAAA,GACFU,KAAK;MACTT,GAAG,EAAGA,GAAY,IAAK;QACnB,IAAIA,GAAG,EAAE;UACLW,SAAS,CAACR,OAAO,GAAGL,YAAY,CAACC,SAAS,EAAEC,GAAG,CAAC;QACpD;QAEAN,gBAAgB,CAACe,KAAK,EAAET,GAAG,EAAEU,YAAY,CAAC;;QAE1C;QACAf,+BAA+B,CAACc,KAAK,CAACI,KAAK,EAAEd,SAAS,CAACe,WAAW,CAAC;QAEnE,OAAO,MAAM;UACT;UACAtB,uBAAuB,CAACoB,MAAM,CAACZ,GAAG,CAAC;QACvC,CAAC;MACL;IAAE,CACL,CAAC;EAEV,CAAC,CAAC;EAEF,OAAOP,uBAAuB,CAACM,SAAS,EAAEQ,kBAAkB,CAAC;AACjE,CAAC","ignoreList":[]}
|
@@ -29,6 +29,10 @@ export const createUnistylesImageBackground = Component => {
|
|
29
29
|
return () => {
|
30
30
|
// @ts-ignore
|
31
31
|
UnistylesShadowRegistry.remove(ref);
|
32
|
+
if (storedImageRef.current) {
|
33
|
+
// @ts-ignore
|
34
|
+
UnistylesShadowRegistry.remove(storedImageRef.current);
|
35
|
+
}
|
32
36
|
};
|
33
37
|
},
|
34
38
|
imageRef: ref => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useLayoutEffect","useRef","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesImageBackground","Component","UnistylesImageBackground","forwardRef","props","forwardedRef","storedImageRef","current","remove","style","imageStyle","ref","imageRef","add"],"sourceRoot":"../../../src","sources":["core/createUnistylesImageBackground.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAEtD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,OAAO,MAAMC,8BAA8B,GAAIC,SAAiC,IAAK;EACjF,MAAMC,wBAAwB,gBAAGX,KAAK,CAACY,UAAU,CAAwC,CAACC,KAAK,EAAEC,YAAY,KAAK;IAC9G,MAAMC,cAAc,GAAGb,MAAM,CAAe,IAAI,CAAC;IAEjDD,eAAe,CAAC,MAAM;MAClB,OAAO,MAAM;QACT,IAAIc,cAAc,CAACC,OAAO,EAAE;UACxB;UACAb,uBAAuB,CAACc,MAAM,CAACF,cAAc,CAACC,OAAO,CAAC;QAC1D;MACJ,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;;IAEN;IACAV,+BAA+B,CAACO,KAAK,CAACK,KAAK,EAAE,iBAAiB,CAAC;IAC/D;IACAZ,+BAA+B,CAACO,KAAK,CAACM,UAAU,EAAE,iBAAiB,CAAC;IAEpE,oBACIX,IAAA,CAACE,SAAS;MAAA,GACFG,KAAK;MACTO,GAAG,EAAEA,GAAG,IAAI;QACRf,gBAAgB,CAACQ,KAAK,EAAEO,GAAG,EAAEN,YAAY,CAAC;QAE1C,OAAO,MAAM;UACT;UACAX,uBAAuB,CAACc,MAAM,CAACG,GAAG,CAAC;
|
1
|
+
{"version":3,"names":["React","useLayoutEffect","useRef","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesImageBackground","Component","UnistylesImageBackground","forwardRef","props","forwardedRef","storedImageRef","current","remove","style","imageStyle","ref","imageRef","add"],"sourceRoot":"../../../src","sources":["core/createUnistylesImageBackground.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAEtD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,OAAO,MAAMC,8BAA8B,GAAIC,SAAiC,IAAK;EACjF,MAAMC,wBAAwB,gBAAGX,KAAK,CAACY,UAAU,CAAwC,CAACC,KAAK,EAAEC,YAAY,KAAK;IAC9G,MAAMC,cAAc,GAAGb,MAAM,CAAe,IAAI,CAAC;IAEjDD,eAAe,CAAC,MAAM;MAClB,OAAO,MAAM;QACT,IAAIc,cAAc,CAACC,OAAO,EAAE;UACxB;UACAb,uBAAuB,CAACc,MAAM,CAACF,cAAc,CAACC,OAAO,CAAC;QAC1D;MACJ,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;;IAEN;IACAV,+BAA+B,CAACO,KAAK,CAACK,KAAK,EAAE,iBAAiB,CAAC;IAC/D;IACAZ,+BAA+B,CAACO,KAAK,CAACM,UAAU,EAAE,iBAAiB,CAAC;IAEpE,oBACIX,IAAA,CAACE,SAAS;MAAA,GACFG,KAAK;MACTO,GAAG,EAAEA,GAAG,IAAI;QACRf,gBAAgB,CAACQ,KAAK,EAAEO,GAAG,EAAEN,YAAY,CAAC;QAE1C,OAAO,MAAM;UACT;UACAX,uBAAuB,CAACc,MAAM,CAACG,GAAG,CAAC;UAEnC,IAAIL,cAAc,CAACC,OAAO,EAAE;YACxB;YACAb,uBAAuB,CAACc,MAAM,CAACF,cAAc,CAACC,OAAO,CAAC;UAC1D;QACJ,CAAC;MACL,CAAE;MACFK,QAAQ,EAAED,GAAG,IAAI;QACb,IAAIA,GAAG,EAAE;UACLL,cAAc,CAACC,OAAO,GAAGI,GAAG;QAChC;;QAEA;QACAjB,uBAAuB,CAACmB,GAAG,CAACF,GAAG,EAAEP,KAAK,CAACM,UAAU,CAAC;MACtD;IAAE,CACL,CAAC;EAEV,CAAC,CAAC;EAEF,OAAOf,uBAAuB,CAACM,SAAS,EAAEC,wBAAwB,CAAC;AACvE,CAAC","ignoreList":[]}
|
@@ -12,10 +12,17 @@ import { maybeWarnAboutMultipleUnistyles } from '../warn';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
13
|
export const withUnistyles = (Component, mappings) => {
|
14
14
|
const getSecrets = (styleProps = {}) => {
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
const styles = Array.isArray(styleProps) ? styleProps : [styleProps];
|
16
|
+
const secrets = styles.filter(Boolean).reduce((acc, style) => {
|
17
|
+
const unistyleKey = Object.keys(style).find(key => key.startsWith('unistyles_'));
|
18
|
+
return acc.concat([unistyleKey ? style[unistyleKey] : {
|
19
|
+
uni__getStyles: () => styleProps,
|
20
|
+
uni__dependencies: []
|
21
|
+
}]);
|
22
|
+
}, []);
|
23
|
+
return {
|
24
|
+
styles: secrets.reduce((acc, secret) => Object.assign(acc, secret.uni__getStyles()), {}),
|
25
|
+
dependencies: secrets.flatMap(secret => secret.uni__dependencies)
|
19
26
|
};
|
20
27
|
};
|
21
28
|
return /*#__PURE__*/forwardRef((props, ref) => {
|
@@ -35,7 +42,7 @@ export const withUnistyles = (Component, mappings) => {
|
|
35
42
|
useEffect(() => {
|
36
43
|
const styleSecrets = getSecrets(narrowedProps.style);
|
37
44
|
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle);
|
38
|
-
addDependencies(Array.from(new Set([...styleSecrets.
|
45
|
+
addDependencies(Array.from(new Set([...styleSecrets.dependencies, ...contentContainerStyleSecrets.dependencies])));
|
39
46
|
}, [narrowedProps.style, narrowedProps.contentContainerStyle]);
|
40
47
|
const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {};
|
41
48
|
const unistyleProps = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {};
|
@@ -44,10 +51,10 @@ export const withUnistyles = (Component, mappings) => {
|
|
44
51
|
const finalProps = {
|
45
52
|
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
46
53
|
...(narrowedProps.style ? {
|
47
|
-
style: styleSecrets.
|
54
|
+
style: styleSecrets.styles
|
48
55
|
} : {}),
|
49
56
|
...(narrowedProps.contentContainerStyle ? {
|
50
|
-
contentContainerStyle: contentContainerStyleSecrets.
|
57
|
+
contentContainerStyle: contentContainerStyleSecrets.styles
|
51
58
|
} : {})
|
52
59
|
};
|
53
60
|
return /*#__PURE__*/_jsx(NativeComponent, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useEffect","useRef","UnistylesShadowRegistry","deepMergeObjects","useProxifiedUnistyles","maybeWarnAboutMultipleUnistyles","jsx","_jsx","withUnistyles","Component","mappings","getSecrets","styleProps","unistyleKey","Object","keys","find","key","startsWith","uni__getStyles","uni__dependencies","props","ref","narrowedProps","NativeComponent","
|
1
|
+
{"version":3,"names":["React","forwardRef","useEffect","useRef","UnistylesShadowRegistry","deepMergeObjects","useProxifiedUnistyles","maybeWarnAboutMultipleUnistyles","jsx","_jsx","withUnistyles","Component","mappings","getSecrets","styleProps","styles","Array","isArray","secrets","filter","Boolean","reduce","acc","style","unistyleKey","Object","keys","find","key","startsWith","concat","uni__getStyles","uni__dependencies","secret","assign","dependencies","flatMap","props","ref","narrowedProps","NativeComponent","displayName","name","contentContainerStyle","scopedTheme","getScopedTheme","proxifiedRuntime","proxifiedTheme","addDependencies","current","styleSecrets","contentContainerStyleSecrets","from","Set","mappingsProps","unistyleProps","uniProps","finalProps"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/withUnistyles.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAsBC,MAAM,QAAQ,OAAO;AAChF,SAAkCC,uBAAuB,QAAQ,aAAa;AAG9E,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,+BAA+B,QAAQ,SAAS;;AAGzD;;AAEA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAaA,OAAO,MAAMC,aAAa,GAAGA,CAAkEC,SAAqB,EAAEC,QAA8B,KAAK;EAKrJ,MAAMC,UAAU,GAAGA,CAACC,UAA+B,GAAG,CAAC,CAAC,KAAoB;IACxE,MAAMC,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACH,UAAU,CAAC,GAClCA,UAAU,GACV,CAACA,UAAU,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IAAA,CAAC+B,eAAe;MAAA,GAAKiB,UAAU;MAAYnB,GAAG,EAAEA;IAAI,CAAE,CAAC;EAClE,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sBAAsB,cAAe,GAAG,
|
1
|
+
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sBAAsB,cAAe,GAAG,QAoCpD,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createUnistylesImageBackground.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesImageBackground.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,eAAe,EAAwB,MAAM,cAAc,CAAA;AAMhF,eAAO,MAAM,8BAA8B,cAAe,OAAO,eAAe,
|
1
|
+
{"version":3,"file":"createUnistylesImageBackground.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesImageBackground.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,eAAe,EAAwB,MAAM,cAAc,CAAA;AAMhF,eAAO,MAAM,8BAA8B,cAAe,OAAO,eAAe,QA+C/E,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withUnistyles.native.d.ts","sourceRoot":"","sources":["../../../../../src/core/withUnistyles/withUnistyles.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAOhF,OAAO,KAAK,EAAE,QAAQ,EAAuB,MAAM,SAAS,CAAA;AAG5D,KAAK,qBAAqB,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"withUnistyles.native.d.ts","sourceRoot":"","sources":["../../../../../src/core/withUnistyles/withUnistyles.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAOhF,OAAO,KAAK,EAAE,QAAQ,EAAuB,MAAM,SAAS,CAAA;AAG5D,KAAK,qBAAqB,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAA;AAcjD,eAAO,MAAM,aAAa,GAAI,UAAU,EAAE,SAAS,SAAS,qBAAqB,CAAC,UAAU,CAAC,aAAa,UAAU,aAAa,QAAQ,CAAC,SAAS,CAAC;eAGjI,QAAQ,mBAAQ;0CAoElC,CAAA"}
|
@@ -38,7 +38,7 @@ namespace margelo::nitro::unistyles {
|
|
38
38
|
* Invokes the function this `JFunc_void_UnistylesNativeMiniRuntime` instance holds through JNI.
|
39
39
|
*/
|
40
40
|
void invoke(const UnistylesNativeMiniRuntime& miniRuntime) const {
|
41
|
-
static const auto method =
|
41
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JUnistylesNativeMiniRuntime> /* miniRuntime */)>("invoke");
|
42
42
|
method(self(), JUnistylesNativeMiniRuntime::fromCpp(miniRuntime));
|
43
43
|
}
|
44
44
|
};
|
@@ -69,7 +69,7 @@ namespace margelo::nitro::unistyles {
|
|
69
69
|
public:
|
70
70
|
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime_cxx;";
|
71
71
|
static void registerNatives() {
|
72
|
-
registerHybrid({makeNativeMethod("
|
72
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_UnistylesNativeMiniRuntime_cxx::invoke_cxx)});
|
73
73
|
}
|
74
74
|
|
75
75
|
private:
|
@@ -41,7 +41,7 @@ namespace margelo::nitro::unistyles {
|
|
41
41
|
* Invokes the function this `JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime` instance holds through JNI.
|
42
42
|
*/
|
43
43
|
void invoke(const std::vector<UnistyleDependency>& dependencies, const UnistylesNativeMiniRuntime& miniRuntime) const {
|
44
|
-
static const auto method =
|
44
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JUnistyleDependency>> /* dependencies */, jni::alias_ref<JUnistylesNativeMiniRuntime> /* miniRuntime */)>("invoke");
|
45
45
|
method(self(), [&]() {
|
46
46
|
size_t __size = dependencies.size();
|
47
47
|
jni::local_ref<jni::JArrayClass<JUnistyleDependency>> __array = jni::JArrayClass<JUnistyleDependency>::newArray(__size);
|
@@ -89,7 +89,7 @@ namespace margelo::nitro::unistyles {
|
|
89
89
|
public:
|
90
90
|
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime_cxx;";
|
91
91
|
static void registerNatives() {
|
92
|
-
registerHybrid({makeNativeMethod("
|
92
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime_cxx::invoke_cxx)});
|
93
93
|
}
|
94
94
|
|
95
95
|
private:
|
@@ -51,7 +51,7 @@ namespace margelo::nitro::unistyles {
|
|
51
51
|
}
|
52
52
|
|
53
53
|
size_t JHybridNativePlatformSpec::getExternalMemorySize() noexcept {
|
54
|
-
static const auto method =
|
54
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
55
55
|
return method(_javaPart);
|
56
56
|
}
|
57
57
|
|
@@ -60,86 +60,86 @@ namespace margelo::nitro::unistyles {
|
|
60
60
|
|
61
61
|
// Methods
|
62
62
|
Insets JHybridNativePlatformSpec::getInsets() {
|
63
|
-
static const auto method =
|
63
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JInsets>()>("getInsets");
|
64
64
|
auto __result = method(_javaPart);
|
65
65
|
return __result->toCpp();
|
66
66
|
}
|
67
67
|
ColorScheme JHybridNativePlatformSpec::getColorScheme() {
|
68
|
-
static const auto method =
|
68
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JColorScheme>()>("getColorScheme");
|
69
69
|
auto __result = method(_javaPart);
|
70
70
|
return __result->toCpp();
|
71
71
|
}
|
72
72
|
double JHybridNativePlatformSpec::getFontScale() {
|
73
|
-
static const auto method =
|
73
|
+
static const auto method = javaClassStatic()->getMethod<double()>("getFontScale");
|
74
74
|
auto __result = method(_javaPart);
|
75
75
|
return __result;
|
76
76
|
}
|
77
77
|
double JHybridNativePlatformSpec::getPixelRatio() {
|
78
|
-
static const auto method =
|
78
|
+
static const auto method = javaClassStatic()->getMethod<double()>("getPixelRatio");
|
79
79
|
auto __result = method(_javaPart);
|
80
80
|
return __result;
|
81
81
|
}
|
82
82
|
Orientation JHybridNativePlatformSpec::getOrientation() {
|
83
|
-
static const auto method =
|
83
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JOrientation>()>("getOrientation");
|
84
84
|
auto __result = method(_javaPart);
|
85
85
|
return __result->toCpp();
|
86
86
|
}
|
87
87
|
std::string JHybridNativePlatformSpec::getContentSizeCategory() {
|
88
|
-
static const auto method =
|
88
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getContentSizeCategory");
|
89
89
|
auto __result = method(_javaPart);
|
90
90
|
return __result->toStdString();
|
91
91
|
}
|
92
92
|
Dimensions JHybridNativePlatformSpec::getScreenDimensions() {
|
93
|
-
static const auto method =
|
93
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JDimensions>()>("getScreenDimensions");
|
94
94
|
auto __result = method(_javaPart);
|
95
95
|
return __result->toCpp();
|
96
96
|
}
|
97
97
|
Dimensions JHybridNativePlatformSpec::getStatusBarDimensions() {
|
98
|
-
static const auto method =
|
98
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JDimensions>()>("getStatusBarDimensions");
|
99
99
|
auto __result = method(_javaPart);
|
100
100
|
return __result->toCpp();
|
101
101
|
}
|
102
102
|
Dimensions JHybridNativePlatformSpec::getNavigationBarDimensions() {
|
103
|
-
static const auto method =
|
103
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JDimensions>()>("getNavigationBarDimensions");
|
104
104
|
auto __result = method(_javaPart);
|
105
105
|
return __result->toCpp();
|
106
106
|
}
|
107
107
|
bool JHybridNativePlatformSpec::getPrefersRtlDirection() {
|
108
|
-
static const auto method =
|
108
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("getPrefersRtlDirection");
|
109
109
|
auto __result = method(_javaPart);
|
110
110
|
return static_cast<bool>(__result);
|
111
111
|
}
|
112
112
|
void JHybridNativePlatformSpec::setRootViewBackgroundColor(double color) {
|
113
|
-
static const auto method =
|
113
|
+
static const auto method = javaClassStatic()->getMethod<void(double /* color */)>("setRootViewBackgroundColor");
|
114
114
|
method(_javaPart, color);
|
115
115
|
}
|
116
116
|
void JHybridNativePlatformSpec::setNavigationBarHidden(bool isHidden) {
|
117
|
-
static const auto method =
|
117
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* isHidden */)>("setNavigationBarHidden");
|
118
118
|
method(_javaPart, isHidden);
|
119
119
|
}
|
120
120
|
void JHybridNativePlatformSpec::setStatusBarHidden(bool isHidden) {
|
121
|
-
static const auto method =
|
121
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* isHidden */)>("setStatusBarHidden");
|
122
122
|
method(_javaPart, isHidden);
|
123
123
|
}
|
124
124
|
void JHybridNativePlatformSpec::setImmersiveMode(bool isEnabled) {
|
125
|
-
static const auto method =
|
125
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* isEnabled */)>("setImmersiveMode");
|
126
126
|
method(_javaPart, isEnabled);
|
127
127
|
}
|
128
128
|
UnistylesNativeMiniRuntime JHybridNativePlatformSpec::getMiniRuntime() {
|
129
|
-
static const auto method =
|
129
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JUnistylesNativeMiniRuntime>()>("getMiniRuntime");
|
130
130
|
auto __result = method(_javaPart);
|
131
131
|
return __result->toCpp();
|
132
132
|
}
|
133
133
|
void JHybridNativePlatformSpec::registerPlatformListener(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */, const UnistylesNativeMiniRuntime& /* miniRuntime */)>& callback) {
|
134
|
-
static const auto method =
|
134
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime::javaobject> /* callback */)>("registerPlatformListener_cxx");
|
135
135
|
method(_javaPart, JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime_cxx::fromCpp(callback));
|
136
136
|
}
|
137
137
|
void JHybridNativePlatformSpec::registerImeListener(const std::function<void(const UnistylesNativeMiniRuntime& /* miniRuntime */)>& callback) {
|
138
|
-
static const auto method =
|
138
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_UnistylesNativeMiniRuntime::javaobject> /* callback */)>("registerImeListener_cxx");
|
139
139
|
method(_javaPart, JFunc_void_UnistylesNativeMiniRuntime_cxx::fromCpp(callback));
|
140
140
|
}
|
141
141
|
void JHybridNativePlatformSpec::unregisterPlatformListeners() {
|
142
|
-
static const auto method =
|
142
|
+
static const auto method = javaClassStatic()->getMethod<void()>("unregisterPlatformListeners");
|
143
143
|
method(_javaPart);
|
144
144
|
}
|
145
145
|
|
@@ -40,7 +40,7 @@ fun interface Func_void_UnistylesNativeMiniRuntime: (UnistylesNativeMiniRuntime)
|
|
40
40
|
@Keep
|
41
41
|
@Suppress(
|
42
42
|
"KotlinJniMissingFunction", "unused",
|
43
|
-
"RedundantSuppression", "RedundantUnitReturnType",
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
44
44
|
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
45
45
|
)
|
46
46
|
class Func_void_UnistylesNativeMiniRuntime_cxx: Func_void_UnistylesNativeMiniRuntime {
|
@@ -54,8 +54,13 @@ class Func_void_UnistylesNativeMiniRuntime_cxx: Func_void_UnistylesNativeMiniRun
|
|
54
54
|
mHybridData = hybridData
|
55
55
|
}
|
56
56
|
|
57
|
+
@DoNotStrip
|
58
|
+
@Keep
|
59
|
+
override fun invoke(miniRuntime: UnistylesNativeMiniRuntime): Unit
|
60
|
+
= invoke_cxx(miniRuntime)
|
61
|
+
|
57
62
|
@FastNative
|
58
|
-
external
|
63
|
+
private external fun invoke_cxx(miniRuntime: UnistylesNativeMiniRuntime): Unit
|
59
64
|
}
|
60
65
|
|
61
66
|
/**
|
@@ -40,7 +40,7 @@ fun interface Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRunti
|
|
40
40
|
@Keep
|
41
41
|
@Suppress(
|
42
42
|
"KotlinJniMissingFunction", "unused",
|
43
|
-
"RedundantSuppression", "RedundantUnitReturnType",
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
44
44
|
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
45
45
|
)
|
46
46
|
class Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime_cxx: Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime {
|
@@ -54,8 +54,13 @@ class Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime_cxx:
|
|
54
54
|
mHybridData = hybridData
|
55
55
|
}
|
56
56
|
|
57
|
+
@DoNotStrip
|
58
|
+
@Keep
|
59
|
+
override fun invoke(dependencies: Array<UnistyleDependency>, miniRuntime: UnistylesNativeMiniRuntime): Unit
|
60
|
+
= invoke_cxx(dependencies,miniRuntime)
|
61
|
+
|
57
62
|
@FastNative
|
58
|
-
external
|
63
|
+
private external fun invoke_cxx(dependencies: Array<UnistyleDependency>, miniRuntime: UnistylesNativeMiniRuntime): Unit
|
59
64
|
}
|
60
65
|
|
61
66
|
/**
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt
CHANGED
@@ -37,87 +37,87 @@ abstract class HybridNativePlatformSpec: HybridObject() {
|
|
37
37
|
}
|
38
38
|
|
39
39
|
// Properties
|
40
|
-
|
40
|
+
|
41
41
|
|
42
42
|
// Methods
|
43
43
|
@DoNotStrip
|
44
44
|
@Keep
|
45
45
|
abstract fun getInsets(): Insets
|
46
|
-
|
46
|
+
|
47
47
|
@DoNotStrip
|
48
48
|
@Keep
|
49
49
|
abstract fun getColorScheme(): ColorScheme
|
50
|
-
|
50
|
+
|
51
51
|
@DoNotStrip
|
52
52
|
@Keep
|
53
53
|
abstract fun getFontScale(): Double
|
54
|
-
|
54
|
+
|
55
55
|
@DoNotStrip
|
56
56
|
@Keep
|
57
57
|
abstract fun getPixelRatio(): Double
|
58
|
-
|
58
|
+
|
59
59
|
@DoNotStrip
|
60
60
|
@Keep
|
61
61
|
abstract fun getOrientation(): Orientation
|
62
|
-
|
62
|
+
|
63
63
|
@DoNotStrip
|
64
64
|
@Keep
|
65
65
|
abstract fun getContentSizeCategory(): String
|
66
|
-
|
66
|
+
|
67
67
|
@DoNotStrip
|
68
68
|
@Keep
|
69
69
|
abstract fun getScreenDimensions(): Dimensions
|
70
|
-
|
70
|
+
|
71
71
|
@DoNotStrip
|
72
72
|
@Keep
|
73
73
|
abstract fun getStatusBarDimensions(): Dimensions
|
74
|
-
|
74
|
+
|
75
75
|
@DoNotStrip
|
76
76
|
@Keep
|
77
77
|
abstract fun getNavigationBarDimensions(): Dimensions
|
78
|
-
|
78
|
+
|
79
79
|
@DoNotStrip
|
80
80
|
@Keep
|
81
81
|
abstract fun getPrefersRtlDirection(): Boolean
|
82
|
-
|
82
|
+
|
83
83
|
@DoNotStrip
|
84
84
|
@Keep
|
85
85
|
abstract fun setRootViewBackgroundColor(color: Double): Unit
|
86
|
-
|
86
|
+
|
87
87
|
@DoNotStrip
|
88
88
|
@Keep
|
89
89
|
abstract fun setNavigationBarHidden(isHidden: Boolean): Unit
|
90
|
-
|
90
|
+
|
91
91
|
@DoNotStrip
|
92
92
|
@Keep
|
93
93
|
abstract fun setStatusBarHidden(isHidden: Boolean): Unit
|
94
|
-
|
94
|
+
|
95
95
|
@DoNotStrip
|
96
96
|
@Keep
|
97
97
|
abstract fun setImmersiveMode(isEnabled: Boolean): Unit
|
98
|
-
|
98
|
+
|
99
99
|
@DoNotStrip
|
100
100
|
@Keep
|
101
101
|
abstract fun getMiniRuntime(): UnistylesNativeMiniRuntime
|
102
|
-
|
102
|
+
|
103
103
|
abstract fun registerPlatformListener(callback: (dependencies: Array<UnistyleDependency>, miniRuntime: UnistylesNativeMiniRuntime) -> Unit): Unit
|
104
|
-
|
104
|
+
|
105
105
|
@DoNotStrip
|
106
106
|
@Keep
|
107
|
-
fun registerPlatformListener_cxx(callback: Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime): Unit {
|
107
|
+
private fun registerPlatformListener_cxx(callback: Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime): Unit {
|
108
108
|
val __result = registerPlatformListener(callback)
|
109
109
|
return __result
|
110
110
|
}
|
111
|
-
|
111
|
+
|
112
112
|
abstract fun registerImeListener(callback: (miniRuntime: UnistylesNativeMiniRuntime) -> Unit): Unit
|
113
|
-
|
113
|
+
|
114
114
|
@DoNotStrip
|
115
115
|
@Keep
|
116
|
-
fun registerImeListener_cxx(callback: Func_void_UnistylesNativeMiniRuntime): Unit {
|
116
|
+
private fun registerImeListener_cxx(callback: Func_void_UnistylesNativeMiniRuntime): Unit {
|
117
117
|
val __result = registerImeListener(callback)
|
118
118
|
return __result
|
119
119
|
}
|
120
|
-
|
120
|
+
|
121
121
|
@DoNotStrip
|
122
122
|
@Keep
|
123
123
|
abstract fun unregisterPlatformListeners(): Unit
|
@@ -40,6 +40,22 @@ target_sources(
|
|
40
40
|
# Define a flag to check if we are building properly
|
41
41
|
add_definitions(-DBUILDING_UNISTYLES_WITH_GENERATED_CMAKE_PROJECT)
|
42
42
|
|
43
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
44
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
45
|
+
target_compile_definitions(
|
46
|
+
unistyles PRIVATE
|
47
|
+
-DFOLLY_NO_CONFIG=1
|
48
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
49
|
+
-DFOLLY_USE_LIBCPP=1
|
50
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
51
|
+
-DFOLLY_MOBILE=1
|
52
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
53
|
+
-DFOLLY_HAVE_PTHREAD=1
|
54
|
+
# Once we target android-23 above, we can comment
|
55
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
56
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
57
|
+
)
|
58
|
+
|
43
59
|
# Add all libraries required by the generated specs
|
44
60
|
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
45
61
|
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
@@ -44,7 +44,6 @@ namespace margelo::nitro::unistyles { struct UnistylesNativeMiniRuntime; }
|
|
44
44
|
// Common C++ types used in Swift
|
45
45
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
46
46
|
#include <NitroModules/AnyMapHolder.hpp>
|
47
|
-
#include <NitroModules/HybridContext.hpp>
|
48
47
|
#include <NitroModules/RuntimeError.hpp>
|
49
48
|
|
50
49
|
// Forward declarations of Swift defined types
|
@@ -36,6 +36,7 @@ namespace margelo::nitro::unistyles {
|
|
36
36
|
double ime SWIFT_PRIVATE;
|
37
37
|
|
38
38
|
public:
|
39
|
+
Insets() = default;
|
39
40
|
explicit Insets(double top, double bottom, double left, double right, double ime): top(top), bottom(bottom), left(left), right(right), ime(ime) {}
|
40
41
|
};
|
41
42
|
|
@@ -54,6 +54,7 @@ namespace margelo::nitro::unistyles {
|
|
54
54
|
bool isLandscape SWIFT_PRIVATE;
|
55
55
|
|
56
56
|
public:
|
57
|
+
UnistylesCxxMiniRuntime() = default;
|
57
58
|
explicit UnistylesCxxMiniRuntime(std::optional<std::string> themeName, std::optional<std::string> breakpoint, bool hasAdaptiveThemes, ColorScheme colorScheme, Dimensions screen, std::string contentSizeCategory, Insets insets, double pixelRatio, double fontScale, bool rtl, Dimensions statusBar, Dimensions navigationBar, bool isPortrait, bool isLandscape): themeName(themeName), breakpoint(breakpoint), hasAdaptiveThemes(hasAdaptiveThemes), colorScheme(colorScheme), screen(screen), contentSizeCategory(contentSizeCategory), insets(insets), pixelRatio(pixelRatio), fontScale(fontScale), rtl(rtl), statusBar(statusBar), navigationBar(navigationBar), isPortrait(isPortrait), isLandscape(isLandscape) {}
|
58
59
|
};
|
59
60
|
|
@@ -50,6 +50,7 @@ namespace margelo::nitro::unistyles {
|
|
50
50
|
bool isLandscape SWIFT_PRIVATE;
|
51
51
|
|
52
52
|
public:
|
53
|
+
UnistylesNativeMiniRuntime() = default;
|
53
54
|
explicit UnistylesNativeMiniRuntime(ColorScheme colorScheme, Dimensions screen, std::string contentSizeCategory, Insets insets, double pixelRatio, double fontScale, bool rtl, Dimensions statusBar, Dimensions navigationBar, bool isPortrait, bool isLandscape): colorScheme(colorScheme), screen(screen), contentSizeCategory(contentSizeCategory), insets(insets), pixelRatio(pixelRatio), fontScale(fontScale), rtl(rtl), statusBar(statusBar), navigationBar(navigationBar), isPortrait(isPortrait), isLandscape(isLandscape) {}
|
54
55
|
};
|
55
56
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-nightly-
|
3
|
+
"version": "3.0.0-nightly-20250226",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -105,11 +105,11 @@
|
|
105
105
|
"husky": "9.1.7",
|
106
106
|
"jest": "29.7.0",
|
107
107
|
"metro-react-native-babel-preset": "0.77.0",
|
108
|
-
"nitro-codegen": "0.
|
108
|
+
"nitro-codegen": "0.24.1",
|
109
109
|
"react": "18.3.1",
|
110
110
|
"react-native": "0.77.1",
|
111
111
|
"react-native-builder-bob": "0.37.0",
|
112
|
-
"react-native-nitro-modules": "0.
|
112
|
+
"react-native-nitro-modules": "0.24.1",
|
113
113
|
"react-native-web": "0.19.13",
|
114
114
|
"react-test-renderer": "18.3.1",
|
115
115
|
"release-it": "17.11.0",
|
package/plugin/index.js
CHANGED
@@ -523,6 +523,12 @@ function getStylesDependenciesFromFunction(path) {
|
|
523
523
|
usedLabel = "ime";
|
524
524
|
}
|
525
525
|
}
|
526
|
+
if (usedLabel === "insets" && (memberExpr.parentPath.isBinaryExpression() || memberExpr.parentPath.isLogicalExpression())) {
|
527
|
+
const secondPropPath = memberExpr.node.property;
|
528
|
+
if (t4.isIdentifier(secondPropPath) && secondPropPath.name === "ime") {
|
529
|
+
usedLabel = "ime";
|
530
|
+
}
|
531
|
+
}
|
526
532
|
}
|
527
533
|
}
|
528
534
|
const containerProp = refPath.findParent((parent2) => parent2.isObjectProperty() && parent2.parentPath === returnedObjectPath);
|
@@ -42,6 +42,11 @@ export const createUnistylesElement = (Component: any) => {
|
|
42
42
|
|
43
43
|
// @ts-ignore we don't know the type of the component
|
44
44
|
maybeWarnAboutMultipleUnistyles(props.style, Component.displayName)
|
45
|
+
|
46
|
+
return () => {
|
47
|
+
// @ts-ignore
|
48
|
+
UnistylesShadowRegistry.remove(ref)
|
49
|
+
}
|
45
50
|
}}
|
46
51
|
/>
|
47
52
|
)
|
@@ -32,6 +32,11 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
|
|
32
32
|
return () => {
|
33
33
|
// @ts-ignore
|
34
34
|
UnistylesShadowRegistry.remove(ref)
|
35
|
+
|
36
|
+
if (storedImageRef.current) {
|
37
|
+
// @ts-ignore
|
38
|
+
UnistylesShadowRegistry.remove(storedImageRef.current)
|
39
|
+
}
|
35
40
|
}
|
36
41
|
}}
|
37
42
|
imageRef={ref => {
|
@@ -12,22 +12,48 @@ type GenericComponentProps<P> = ComponentProps<P>
|
|
12
12
|
// @ts-expect-error
|
13
13
|
type GenericComponentRef<T> = ComponentRef<T>
|
14
14
|
|
15
|
+
type UnistylesSecrets = {
|
16
|
+
uni__getStyles: () => Record<string, any>,
|
17
|
+
uni__dependencies: Array<UnistyleDependency>
|
18
|
+
}
|
19
|
+
|
20
|
+
type MappedSecrets = {
|
21
|
+
styles: Record<string, any>,
|
22
|
+
dependencies: Array<UnistyleDependency>
|
23
|
+
}
|
24
|
+
|
15
25
|
export const withUnistyles = <TComponent, TMappings extends GenericComponentProps<TComponent>>(Component: TComponent, mappings?: Mappings<TMappings>) => {
|
16
26
|
type TProps = GenericComponentProps<TComponent>
|
17
27
|
type PropsWithUnistyles = PartialBy<TProps, keyof TMappings | SupportedStyleProps> & {
|
18
28
|
uniProps?: Mappings<TProps>
|
19
29
|
}
|
20
|
-
const getSecrets = (styleProps: Record<string, any> = {}):
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets => {
|
31
|
+
const styles = Array.isArray(styleProps)
|
32
|
+
? styleProps
|
33
|
+
: [styleProps]
|
34
|
+
|
35
|
+
const secrets: Array<UnistylesSecrets> = styles
|
36
|
+
.filter(Boolean)
|
37
|
+
.reduce((acc, style) => {
|
38
|
+
const unistyleKey = Object
|
39
|
+
.keys(style)
|
40
|
+
.find(key => key.startsWith('unistyles_'))
|
41
|
+
|
42
|
+
return acc.concat([
|
43
|
+
unistyleKey
|
44
|
+
? style[unistyleKey]
|
45
|
+
: {
|
46
|
+
uni__getStyles: () => styleProps,
|
47
|
+
uni__dependencies: [],
|
48
|
+
}
|
49
|
+
])
|
50
|
+
}, [])
|
51
|
+
|
52
|
+
return {
|
53
|
+
styles: secrets.reduce((acc, secret) => Object
|
54
|
+
.assign(acc, secret.uni__getStyles()), {} as Record<string, any>),
|
55
|
+
dependencies: secrets.flatMap(secret => secret.uni__dependencies),
|
56
|
+
}
|
31
57
|
}
|
32
58
|
|
33
59
|
return forwardRef<GenericComponentRef<TComponent>, PropsWithUnistyles>((props, ref) => {
|
@@ -46,7 +72,7 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
46
72
|
const styleSecrets = getSecrets(narrowedProps.style)
|
47
73
|
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)
|
48
74
|
|
49
|
-
addDependencies(Array.from(new Set([...styleSecrets.
|
75
|
+
addDependencies(Array.from(new Set([...styleSecrets.dependencies, ...contentContainerStyleSecrets.dependencies])))
|
50
76
|
}, [narrowedProps.style, narrowedProps.contentContainerStyle])
|
51
77
|
|
52
78
|
const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
|
@@ -58,10 +84,10 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
58
84
|
const finalProps = {
|
59
85
|
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
60
86
|
...narrowedProps.style ? {
|
61
|
-
style: styleSecrets.
|
87
|
+
style: styleSecrets.styles,
|
62
88
|
} : {},
|
63
89
|
...narrowedProps.contentContainerStyle ? {
|
64
|
-
contentContainerStyle: contentContainerStyleSecrets.
|
90
|
+
contentContainerStyle: contentContainerStyleSecrets.styles,
|
65
91
|
} : {},
|
66
92
|
} as any
|
67
93
|
|