react-native-unistyles 2.0.0-rc.3 → 2.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +10 -4
- package/ios/UnistylesHelpers.h +0 -2
- package/ios/UnistylesHelpers.mm +0 -47
- package/ios/UnistylesModule.h +7 -1
- package/ios/UnistylesModule.mm +6 -73
- package/ios/platform/Platform_iOS.h +21 -0
- package/ios/platform/Platform_iOS.mm +132 -0
- package/ios/platform/Platform_macOS.h +20 -0
- package/ios/platform/Platform_macOS.mm +83 -0
- package/lib/commonjs/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.macos.js +3 -0
- package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -0
- package/lib/commonjs/utils/index.js +6 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/normalizer/normalizer.js.map +1 -1
- package/lib/module/normalizer/normalizer.macos.js +2 -0
- package/lib/module/normalizer/normalizer.macos.js.map +1 -0
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts +1 -0
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +1 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/package.json +11 -3
- package/react-native-unistyles.podspec +2 -2
- package/src/normalizer/normalizer.macos.ts +1 -0
- package/src/normalizer/normalizer.ts +1 -1
- package/src/utils/index.ts +1 -1
package/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2023 Jacek Pudysz
|
3
|
+
Copyright (c) 2023-2024 Jacek Pudysz
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
6
6
|
in the Software without restriction, including without limitation the rights
|
package/README.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
[<img alt="react-native-unistyles" src="assets/banner.png">](https://reactnativeunistyles.vercel.app/)
|
2
2
|
|
3
3
|

|
4
|
-
[](https://www.npmjs.com/package/react-native-unistyles)
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
6
|
+
<br />
|
7
|
+
[](https://docs.expo.dev/)
|
8
|
+
[](https://www.w3.org/)
|
9
|
+
[](https://developer.apple.com/ios/)
|
10
|
+
[](https://developer.apple.com/macos/)
|
11
|
+
[](https://nextjs.org/)
|
12
|
+
[](https://developer.android.com/)
|
7
13
|
|
8
14
|
## [Documentation](https://reactnativeunistyles.vercel.app/)
|
9
15
|
- [Start here](https://reactnativeunistyles.vercel.app/start/introduction/)
|
@@ -20,7 +26,7 @@
|
|
20
26
|
- ⚛️ No React Context
|
21
27
|
- 🖥️ Supports custom breakpoints, css-like media queries and variants
|
22
28
|
- 🎨 Register multiple themes and change them with single function call
|
23
|
-
- 🥳 Compatible with Expo, Bare React Native, React Native Web and SSR
|
29
|
+
- 🥳 Compatible with Expo, Bare React Native, React Native Web, React Native macOS and SSR
|
24
30
|
- 🛡️ ~99% Test coverage
|
25
31
|
- 🔌 Extend stylesheets with your own plugins
|
26
32
|
- ⚔️ No 3rd party dependencies
|
package/ios/UnistylesHelpers.h
CHANGED
package/ios/UnistylesHelpers.mm
CHANGED
@@ -1,51 +1,4 @@
|
|
1
1
|
#import "UnistylesHelpers.h"
|
2
|
-
#import "UnistylesRuntime.h"
|
3
|
-
|
4
|
-
std::string getColorScheme() {
|
5
|
-
UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
|
6
|
-
|
7
|
-
switch (colorScheme) {
|
8
|
-
case UIUserInterfaceStyleLight:
|
9
|
-
return UnistylesLightScheme;
|
10
|
-
case UIUserInterfaceStyleDark:
|
11
|
-
return UnistylesDarkScheme;
|
12
|
-
case UIUserInterfaceStyleUnspecified:
|
13
|
-
default:
|
14
|
-
return UnistylesUnspecifiedScheme;
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
std::string getContentSizeCategory(UIContentSizeCategory contentSizeCategory) {
|
19
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) {
|
20
|
-
return std::string([@"xxxLarge" UTF8String]);
|
21
|
-
}
|
22
|
-
|
23
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraLarge]) {
|
24
|
-
return std::string([@"xxLarge" UTF8String]);
|
25
|
-
}
|
26
|
-
|
27
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraLarge]) {
|
28
|
-
return std::string([@"xLarge" UTF8String]);
|
29
|
-
}
|
30
|
-
|
31
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryLarge]) {
|
32
|
-
return std::string([@"Large" UTF8String]);
|
33
|
-
}
|
34
|
-
|
35
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryMedium]) {
|
36
|
-
return std::string([@"Medium" UTF8String]);
|
37
|
-
}
|
38
|
-
|
39
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategorySmall]) {
|
40
|
-
return std::string([@"Small" UTF8String]);
|
41
|
-
}
|
42
|
-
|
43
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraSmall]) {
|
44
|
-
return std::string([@"xSmall" UTF8String]);
|
45
|
-
}
|
46
|
-
|
47
|
-
return std::string([@"unspecified" UTF8String]);
|
48
|
-
}
|
49
2
|
|
50
3
|
NSString* cxxStringToNSString(std::string cxxString) {
|
51
4
|
return [NSString stringWithUTF8String:cxxString.c_str()];
|
package/ios/UnistylesModule.h
CHANGED
@@ -2,9 +2,15 @@
|
|
2
2
|
#import <React/RCTEventEmitter.h>
|
3
3
|
#import <string>
|
4
4
|
|
5
|
+
#if TARGET_OS_OSX
|
6
|
+
#import "Platform_macOS.h"
|
7
|
+
#elif TARGET_OS_IOS
|
8
|
+
#import "Platform_iOS.h"
|
9
|
+
#endif
|
10
|
+
|
5
11
|
@interface UnistylesModule : RCTEventEmitter<RCTBridgeModule>
|
6
12
|
|
7
13
|
@property (nonatomic, assign) BOOL hasListeners;
|
8
|
-
@property (nonatomic,
|
14
|
+
@property (nonatomic, strong) Platform *platform;
|
9
15
|
|
10
16
|
@end
|
package/ios/UnistylesModule.mm
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
#import "UnistylesHelpers.h"
|
3
3
|
#import "UnistylesRuntime.h"
|
4
4
|
|
5
|
-
#import <React/RCTAppearance.h>
|
6
5
|
#import <React/RCTBridge+Private.h>
|
7
6
|
#import <jsi/jsi.h>
|
8
7
|
|
@@ -16,73 +15,16 @@ RCT_EXPORT_MODULE(Unistyles)
|
|
16
15
|
|
17
16
|
- (instancetype)init {
|
18
17
|
if ((self = [super init])) {
|
19
|
-
[[
|
20
|
-
selector:@selector(handleOrientationChange:)
|
21
|
-
name:UIDeviceOrientationDidChangeNotification
|
22
|
-
object:nil];
|
23
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
24
|
-
selector:@selector(appearanceChanged:)
|
25
|
-
name:RCTUserInterfaceStyleDidChangeNotification
|
26
|
-
object:nil];
|
27
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
28
|
-
selector:@selector(contentSizeCategoryDidChange:)
|
29
|
-
name:UIContentSizeCategoryDidChangeNotification
|
30
|
-
object:nil];
|
18
|
+
self.platform = [[Platform alloc] init];
|
31
19
|
}
|
32
20
|
|
33
21
|
return self;
|
34
22
|
}
|
35
23
|
|
36
|
-
- (void)dealloc {
|
37
|
-
if (self.unistylesRuntime != nullptr) {
|
38
|
-
self.unistylesRuntime = nullptr;
|
39
|
-
}
|
40
|
-
|
41
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self
|
42
|
-
name: UIContentSizeCategoryDidChangeNotification
|
43
|
-
object: nil];
|
44
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self
|
45
|
-
name: RCTUserInterfaceStyleDidChangeNotification
|
46
|
-
object: nil];
|
47
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self
|
48
|
-
name: UIDeviceOrientationDidChangeNotification
|
49
|
-
object: nil];
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
24
|
+ (BOOL)requiresMainQueueSetup {
|
54
25
|
return YES;
|
55
26
|
}
|
56
27
|
|
57
|
-
#pragma mark - Event handlers
|
58
|
-
|
59
|
-
- (void)handleOrientationChange:(NSNotification *)notification {
|
60
|
-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
61
|
-
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
|
62
|
-
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
|
63
|
-
|
64
|
-
if (self.unistylesRuntime != nullptr) {
|
65
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight);
|
66
|
-
}
|
67
|
-
});
|
68
|
-
}
|
69
|
-
|
70
|
-
- (void)appearanceChanged:(NSNotification *)notification {
|
71
|
-
std::string colorScheme = getColorScheme();
|
72
|
-
|
73
|
-
if (self.unistylesRuntime != nullptr) {
|
74
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
- (void)contentSizeCategoryDidChange:(NSNotification *)notification {
|
79
|
-
UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
80
|
-
|
81
|
-
if (self.unistylesRuntime != nullptr) {
|
82
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleContentSizeCategoryChange(getContentSizeCategory(contentSizeCategory));
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
28
|
#pragma mark - Event emitter
|
87
29
|
- (NSArray<NSString *> *)supportedEvents {
|
88
30
|
return @[@"__unistylesOnChange"];
|
@@ -129,20 +71,11 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
|
|
129
71
|
}
|
130
72
|
|
131
73
|
void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSelf) {
|
132
|
-
CGFloat initialScreenWidth = [UIScreen mainScreen].bounds.size.width;
|
133
|
-
CGFloat initialScreenHeight = [UIScreen mainScreen].bounds.size.height;
|
134
|
-
std::string initialColorScheme = getColorScheme();
|
135
|
-
__block UIContentSizeCategory contentSizeCategory;
|
136
|
-
|
137
|
-
dispatch_sync(dispatch_get_main_queue(), ^{
|
138
|
-
contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
139
|
-
});
|
140
|
-
|
141
74
|
auto unistylesRuntime = std::make_shared<UnistylesRuntime>(
|
142
|
-
(int)
|
143
|
-
(int)
|
144
|
-
initialColorScheme,
|
145
|
-
|
75
|
+
(int)weakSelf.platform.initialWidth,
|
76
|
+
(int)weakSelf.platform.initialWidth,
|
77
|
+
weakSelf.platform.initialColorScheme,
|
78
|
+
weakSelf.platform.initialContentSizeCategory
|
146
79
|
);
|
147
80
|
|
148
81
|
unistylesRuntime.get()->onThemeChange([=](std::string theme) {
|
@@ -193,7 +126,7 @@ void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSel
|
|
193
126
|
[weakSelf emitEvent:@"__unistylesOnChange" withBody:body];
|
194
127
|
});
|
195
128
|
|
196
|
-
weakSelf.unistylesRuntime = unistylesRuntime.get();
|
129
|
+
weakSelf.platform.unistylesRuntime = unistylesRuntime.get();
|
197
130
|
|
198
131
|
auto hostObject = jsi::Object::createFromHostObject(runtime, unistylesRuntime);
|
199
132
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#include <string>
|
2
|
+
|
3
|
+
@interface Platform : NSObject
|
4
|
+
|
5
|
+
@property (nonatomic, assign) CGFloat initialWidth;
|
6
|
+
@property (nonatomic, assign) CGFloat initialHeight;
|
7
|
+
@property (nonatomic, assign) std::string initialColorScheme;
|
8
|
+
@property (nonatomic, assign) std::string initialContentSizeCategory;
|
9
|
+
@property (nonatomic, assign) void* unistylesRuntime;
|
10
|
+
|
11
|
+
- (instancetype)init;
|
12
|
+
|
13
|
+
- (void)setupListeners;
|
14
|
+
- (void)onOrientationChange:(NSNotification *)notification;
|
15
|
+
- (void)onAppearanceChange:(NSNotification *)notification;
|
16
|
+
- (void)onContentSizeCategoryChange:(NSNotification *)notification;
|
17
|
+
|
18
|
+
- (std::string)getColorScheme;
|
19
|
+
- (std::string)getContentSizeCategory:(UIContentSizeCategory)contentSizeCategory;
|
20
|
+
|
21
|
+
@end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#if TARGET_OS_IOS
|
2
|
+
|
3
|
+
#import "Platform_iOS.h"
|
4
|
+
#import "UnistylesRuntime.h"
|
5
|
+
#import <React/RCTAppearance.h>
|
6
|
+
|
7
|
+
@implementation Platform
|
8
|
+
|
9
|
+
- (instancetype)init {
|
10
|
+
self = [super init];
|
11
|
+
if (self) {
|
12
|
+
UIScreen *screen = [UIScreen mainScreen];
|
13
|
+
UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
14
|
+
|
15
|
+
self.initialWidth = screen.bounds.size.width;
|
16
|
+
self.initialHeight = screen.bounds.size.height;
|
17
|
+
self.initialColorScheme = [self getColorScheme];
|
18
|
+
self.initialContentSizeCategory = [self getContentSizeCategory:contentSizeCategory];
|
19
|
+
|
20
|
+
[self setupListeners];
|
21
|
+
}
|
22
|
+
return self;
|
23
|
+
}
|
24
|
+
|
25
|
+
- (void)dealloc {
|
26
|
+
if (self.unistylesRuntime != nullptr) {
|
27
|
+
self.unistylesRuntime = nullptr;
|
28
|
+
}
|
29
|
+
|
30
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self
|
31
|
+
name: UIContentSizeCategoryDidChangeNotification
|
32
|
+
object: nil];
|
33
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self
|
34
|
+
name: RCTUserInterfaceStyleDidChangeNotification
|
35
|
+
object: nil];
|
36
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self
|
37
|
+
name: UIDeviceOrientationDidChangeNotification
|
38
|
+
object: nil];
|
39
|
+
}
|
40
|
+
|
41
|
+
- (void)setupListeners {
|
42
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
43
|
+
selector:@selector(onOrientationChange:)
|
44
|
+
name:UIDeviceOrientationDidChangeNotification
|
45
|
+
object:nil];
|
46
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
47
|
+
selector:@selector(onAppearanceChange:)
|
48
|
+
name:RCTUserInterfaceStyleDidChangeNotification
|
49
|
+
object:nil];
|
50
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
51
|
+
selector:@selector(onContentSizeCategoryChange:)
|
52
|
+
name:UIContentSizeCategoryDidChangeNotification
|
53
|
+
object:nil];
|
54
|
+
}
|
55
|
+
|
56
|
+
- (void)onAppearanceChange:(NSNotification *)notification {
|
57
|
+
std::string colorScheme = [self getColorScheme];
|
58
|
+
|
59
|
+
if (self.unistylesRuntime != nullptr) {
|
60
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
- (void)onContentSizeCategoryChange:(NSNotification *)notification {
|
65
|
+
UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
66
|
+
|
67
|
+
if (self.unistylesRuntime != nullptr) {
|
68
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleContentSizeCategoryChange([self getContentSizeCategory:contentSizeCategory]);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
- (void)onOrientationChange:(NSNotification *)notification {
|
73
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
74
|
+
UIScreen *screen = [UIScreen mainScreen];
|
75
|
+
CGFloat screenWidth = screen.bounds.size.width;
|
76
|
+
CGFloat screenHeight = screen.bounds.size.height;
|
77
|
+
|
78
|
+
if (self.unistylesRuntime != nullptr) {
|
79
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight);
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
- (std::string)getColorScheme {
|
85
|
+
UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
|
86
|
+
|
87
|
+
switch (colorScheme) {
|
88
|
+
case UIUserInterfaceStyleLight:
|
89
|
+
return UnistylesLightScheme;
|
90
|
+
case UIUserInterfaceStyleDark:
|
91
|
+
return UnistylesDarkScheme;
|
92
|
+
case UIUserInterfaceStyleUnspecified:
|
93
|
+
default:
|
94
|
+
return UnistylesUnspecifiedScheme;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
- (std::string)getContentSizeCategory:(UIContentSizeCategory)contentSizeCategory {
|
99
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) {
|
100
|
+
return std::string([@"xxxLarge" UTF8String]);
|
101
|
+
}
|
102
|
+
|
103
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraLarge]) {
|
104
|
+
return std::string([@"xxLarge" UTF8String]);
|
105
|
+
}
|
106
|
+
|
107
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraLarge]) {
|
108
|
+
return std::string([@"xLarge" UTF8String]);
|
109
|
+
}
|
110
|
+
|
111
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryLarge]) {
|
112
|
+
return std::string([@"Large" UTF8String]);
|
113
|
+
}
|
114
|
+
|
115
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryMedium]) {
|
116
|
+
return std::string([@"Medium" UTF8String]);
|
117
|
+
}
|
118
|
+
|
119
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategorySmall]) {
|
120
|
+
return std::string([@"Small" UTF8String]);
|
121
|
+
}
|
122
|
+
|
123
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraSmall]) {
|
124
|
+
return std::string([@"xSmall" UTF8String]);
|
125
|
+
}
|
126
|
+
|
127
|
+
return std::string([@"unspecified" UTF8String]);
|
128
|
+
}
|
129
|
+
|
130
|
+
@end
|
131
|
+
|
132
|
+
#endif
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#include <string>
|
2
|
+
|
3
|
+
@interface Platform : NSObject
|
4
|
+
|
5
|
+
@property (nonatomic, assign) CGFloat initialWidth;
|
6
|
+
@property (nonatomic, assign) CGFloat initialHeight;
|
7
|
+
@property (nonatomic, assign) std::string initialColorScheme;
|
8
|
+
@property (nonatomic, assign) std::string initialContentSizeCategory;
|
9
|
+
@property (nonatomic, assign) void* unistylesRuntime;
|
10
|
+
|
11
|
+
- (instancetype)init;
|
12
|
+
|
13
|
+
- (void)setupListeners;
|
14
|
+
- (void)onWindowResize;
|
15
|
+
- (void)onAppearanceChange;
|
16
|
+
|
17
|
+
- (std::string)getColorScheme;
|
18
|
+
|
19
|
+
@end
|
20
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#if TARGET_OS_OSX
|
2
|
+
|
3
|
+
#import "Platform_macOS.h"
|
4
|
+
#import "UnistylesRuntime.h"
|
5
|
+
#import <React/RCTUtils.h>
|
6
|
+
|
7
|
+
@implementation Platform
|
8
|
+
|
9
|
+
- (instancetype)init {
|
10
|
+
self = [super init];
|
11
|
+
if (self) {
|
12
|
+
NSWindow *window = RCTSharedApplication().mainWindow;
|
13
|
+
|
14
|
+
self.initialWidth = window.frame.size.width;
|
15
|
+
self.initialHeight = window.frame.size.height;
|
16
|
+
self.initialContentSizeCategory = std::string([@"unspecified" UTF8String]);
|
17
|
+
self.initialColorScheme = [self getColorScheme];
|
18
|
+
|
19
|
+
[self setupListeners];
|
20
|
+
}
|
21
|
+
return self;
|
22
|
+
}
|
23
|
+
|
24
|
+
- (void)dealloc {
|
25
|
+
if (self.unistylesRuntime != nullptr) {
|
26
|
+
self.unistylesRuntime = nullptr;
|
27
|
+
}
|
28
|
+
|
29
|
+
NSWindow *window = RCTSharedApplication().mainWindow;
|
30
|
+
|
31
|
+
[window removeObserver:self forKeyPath:@"effectiveAppearance"];
|
32
|
+
[window removeObserver:self forKeyPath:@"frame"];
|
33
|
+
}
|
34
|
+
|
35
|
+
- (void)setupListeners {
|
36
|
+
NSWindow *window = RCTSharedApplication().mainWindow;
|
37
|
+
|
38
|
+
[window addObserver:self forKeyPath:@"effectiveAppearance" options:NSKeyValueObservingOptionNew context:nil];
|
39
|
+
[window addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
|
40
|
+
}
|
41
|
+
|
42
|
+
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
|
43
|
+
if ([keyPath isEqualToString:@"effectiveAppearance"]) {
|
44
|
+
return [self onAppearanceChange];
|
45
|
+
}
|
46
|
+
|
47
|
+
if ([keyPath isEqualToString:@"frame"]) {
|
48
|
+
return [self onWindowResize];
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
- (void)onAppearanceChange {
|
53
|
+
std::string colorScheme = [self getColorScheme];
|
54
|
+
|
55
|
+
if (self.unistylesRuntime != nullptr) {
|
56
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
- (void)onWindowResize {
|
61
|
+
NSWindow *window = RCTSharedApplication().mainWindow;
|
62
|
+
|
63
|
+
CGFloat screenWidth = window.frame.size.width;
|
64
|
+
CGFloat screenHeight = window.frame.size.height;
|
65
|
+
|
66
|
+
if (self.unistylesRuntime != nullptr) {
|
67
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
- (std::string)getColorScheme {
|
72
|
+
NSAppearance *appearance = RCTSharedApplication().effectiveAppearance;
|
73
|
+
|
74
|
+
if (appearance.name == NSAppearanceNameDarkAqua) {
|
75
|
+
return UnistylesDarkScheme;
|
76
|
+
}
|
77
|
+
|
78
|
+
return UnistylesLightScheme;
|
79
|
+
}
|
80
|
+
|
81
|
+
@end
|
82
|
+
|
83
|
+
#endif
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","integer","normalizeColors","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","undefined","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,cAAc,GAAGA,CAACC,KAAa,EAAEC,OAAe,GAAG,CAAC,KAAK;EAClE;EACA,IAAIA,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAME,OAAO,GAAG,IAAAC,wBAAe,EAACH,KAAK,CAAqB;;EAE1D;EACA,IAAIE,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOF,KAAK;EAChB;EAEA,MAAMI,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACG,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGP,GAAG,CACnCQ,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC;IAE/B,OAAQ,QAAOT,CAAE,IAAGC,CAAE,IAAGC,CAAE,IAAKC,CAAC,GAAc,GAAG,GAAIV,OAAQ,GAAE;EACpE;EAEA,OAAOD,KAAK;AAChB,CAAC;AAAAmB,OAAA,CAAApB,cAAA,GAAAA,cAAA;AAEM,MAAMqB,qBAAqB,GAAIC,KAAa,IAAKA,KAAK,GAAI,GAAEA,KAAM,IAAG,GAAGA,KAAK;AAAAF,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEpF,MAAME,kBAAkB,GAAGA,
|
1
|
+
{"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","integer","normalizeColors","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","undefined","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,cAAc,GAAGA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AAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmByB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEvB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDL,MAAM,CAAC+B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA7B,OAAA,CAAA6B,YAAA,GAAG;EACtCvB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["normalizer/normalizer.macos.ts"],"mappings":"AAAA;AAAA"}
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
|
|
21
21
|
return _breakpoints.getValueForBreakpoint;
|
22
22
|
}
|
23
23
|
});
|
24
|
+
Object.defineProperty(exports, "isPlatformColor", {
|
25
|
+
enumerable: true,
|
26
|
+
get: function () {
|
27
|
+
return _styles.isPlatformColor;
|
28
|
+
}
|
29
|
+
});
|
24
30
|
Object.defineProperty(exports, "isUnistylesMq", {
|
25
31
|
enumerable: true,
|
26
32
|
get: function () {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins","_generateId"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"
|
1
|
+
{"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins","_generateId"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["normalizeColors","normalizeColor","color","opacity","integer","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","undefined","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAAGA,CAACC,KAAa,EAAEC,OAAe,GAAG,CAAC,KAAK;EAClE;EACA,IAAIA,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAME,OAAO,GAAGJ,eAAe,CAACE,KAAK,CAAqB;;EAE1D;EACA,IAAIE,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOF,KAAK;EAChB;EAEA,MAAMG,GAAG,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACG,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGP,GAAG,CACnCQ,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC;IAE/B,OAAQ,QAAOT,CAAE,IAAGC,CAAE,IAAGC,CAAE,IAAKC,CAAC,GAAc,GAAG,GAAIT,OAAQ,GAAE;EACpE;EAEA,OAAOD,KAAK;AAChB,CAAC;AAED,OAAO,MAAMkB,qBAAqB,GAAIC,KAAa,IAAKA,KAAK,GAAI,GAAEA,KAAM,IAAG,GAAGA,KAAK;AAEpF,MAAMC,kBAAkB,GAAGA,
|
1
|
+
{"version":3,"names":["normalizeColors","normalizeColor","color","opacity","integer","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","undefined","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAAGA,CAACC,KAAa,EAAEC,OAAe,GAAG,CAAC,KAAK;EAClE;EACA,IAAIA,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAME,OAAO,GAAGJ,eAAe,CAACE,KAAK,CAAqB;;EAE1D;EACA,IAAIE,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOF,KAAK;EAChB;EAEA,MAAMG,GAAG,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACG,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGP,GAAG,CACnCQ,KAAK,CA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AAC,GAAGb,KAAK;EACxE,MAAMI,OAAO,GAAGV,qBAAqB,CAACiB,YAAY,CAACN,KAAK,CAAC;EACzD,MAAMC,OAAO,GAAGZ,qBAAqB,CAACiB,YAAY,CAACJ,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGd,qBAAqB,CAACmB,YAAY,CAAC;EAClD,MAAMrC,KAAK,GAAGD,cAAc,CAACmC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGhC,KAAM,EAAC;AACrD,CAAC;AAED,MAAMsC,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D3B,GAAG,CAAC4B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOsB,SAAS;EACpB;EAEA,MAAMxB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmByB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEvB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDJ,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCvB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["normalizer/normalizer.macos.ts"],"mappings":"AAAA"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
export { mq } from './mq';
|
2
2
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser';
|
3
3
|
export { getValueForBreakpoint } from './breakpoints';
|
4
|
-
export { proxifyFunction, parseStyle } from './styles';
|
4
|
+
export { proxifyFunction, parseStyle, isPlatformColor } from './styles';
|
5
5
|
export { withPlugins } from './withPlugins';
|
6
6
|
export { generateReactNativeWebId } from './generateId';
|
7
7
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["mq","getKeyForUnistylesMediaQuery","isWithinTheWidthAndHeight","isValidMq","parseMq","isUnistylesMq","getValueForBreakpoint","proxifyFunction","parseStyle","withPlugins","generateReactNativeWebId"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,EAAE,QAAQ,MAAM;AAEzB,SAASC,4BAA4B,EAAEC,yBAAyB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,aAAa,QAAQ,YAAY;AACvH,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;
|
1
|
+
{"version":3,"names":["mq","getKeyForUnistylesMediaQuery","isWithinTheWidthAndHeight","isValidMq","parseMq","isUnistylesMq","getValueForBreakpoint","proxifyFunction","parseStyle","isPlatformColor","withPlugins","generateReactNativeWebId"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,EAAE,QAAQ,MAAM;AAEzB,SAASC,4BAA4B,EAAEC,yBAAyB,EAAEC,SAAS,EAAEC,OAAO,EAAEC,aAAa,QAAQ,YAAY;AACvH,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,EAAEC,UAAU,EAAEC,eAAe,QAAQ,UAAU;AACvE,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,wBAAwB,QAAQ,cAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=normalizer.macos.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizer.macos.d.ts","sourceRoot":"","sources":["../../../../src/normalizer/normalizer.macos.ts"],"names":[],"mappings":""}
|
@@ -2,7 +2,7 @@ export { mq } from './mq';
|
|
2
2
|
export type { UnistylesParsedMq } from './mqParser';
|
3
3
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser';
|
4
4
|
export { getValueForBreakpoint } from './breakpoints';
|
5
|
-
export { proxifyFunction, parseStyle } from './styles';
|
5
|
+
export { proxifyFunction, parseStyle, isPlatformColor } from './styles';
|
6
6
|
export { withPlugins } from './withPlugins';
|
7
7
|
export { generateReactNativeWebId } from './generateId';
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "2.0.0-rc.
|
3
|
+
"version": "2.0.0-rc.4",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -37,7 +37,10 @@
|
|
37
37
|
"keywords": [
|
38
38
|
"react-native",
|
39
39
|
"ios",
|
40
|
-
"android"
|
40
|
+
"android",
|
41
|
+
"react-native-macos",
|
42
|
+
"react-native-web",
|
43
|
+
"expo"
|
41
44
|
],
|
42
45
|
"repository": "https://github.com/jpudysz/react-native-unistyles",
|
43
46
|
"author": "Jacek Pudysz <jacekpudysz@gmail.com> (https://github.com/jpudysz)",
|
@@ -88,15 +91,20 @@
|
|
88
91
|
"@react-native/normalize-colors": "*",
|
89
92
|
"react": "*",
|
90
93
|
"react-native": "*",
|
94
|
+
"react-native-macos": "*",
|
91
95
|
"react-native-web": "*"
|
92
96
|
},
|
93
97
|
"peerDependenciesMeta": {
|
98
|
+
"react-native-macos": {
|
99
|
+
"optional": true
|
100
|
+
},
|
94
101
|
"react-native-web": {
|
95
102
|
"optional": true
|
96
103
|
}
|
97
104
|
},
|
98
105
|
"workspaces": [
|
99
106
|
"examples/expo",
|
107
|
+
"examples/macos",
|
100
108
|
"docs"
|
101
109
|
],
|
102
110
|
"packageManager": "yarn@3.6.1",
|
@@ -107,7 +115,7 @@
|
|
107
115
|
"preset": "react-native",
|
108
116
|
"modulePathIgnorePatterns": [
|
109
117
|
"<rootDir>/examples/expo/node_modules",
|
110
|
-
"<rootDir>/examples/
|
118
|
+
"<rootDir>/examples/macos/node_modules",
|
111
119
|
"<rootDir>/docs/node_modules",
|
112
120
|
"<rootDir>/lib/"
|
113
121
|
],
|
@@ -10,11 +10,11 @@ Pod::Spec.new do |s|
|
|
10
10
|
s.license = package["license"]
|
11
11
|
s.authors = package["author"]
|
12
12
|
|
13
|
-
s.platforms = { :ios => min_ios_version_supported }
|
13
|
+
s.platforms = { :ios => min_ios_version_supported, :osx => "10.14" }
|
14
14
|
s.source = { :git => package["repository"], :tag => "#{s.version}" }
|
15
15
|
|
16
16
|
s.source_files = [
|
17
|
-
"ios
|
17
|
+
"ios/**/*.{h,mm}",
|
18
18
|
"cxx/*.{h,cpp}"
|
19
19
|
]
|
20
20
|
|
@@ -0,0 +1 @@
|
|
1
|
+
// keep it empty for macOS
|
@@ -38,7 +38,7 @@ export const normalizeColor = (color: string, opacity: number = 1) => {
|
|
38
38
|
|
39
39
|
export const normalizeNumericValue = (value: number) => value ? `${value}px` : value
|
40
40
|
|
41
|
-
const normalizeTransform = (key: string, value:
|
41
|
+
const normalizeTransform = <T>(key: string, value: T) => {
|
42
42
|
if (key.includes('scale')) {
|
43
43
|
return value
|
44
44
|
}
|
package/src/utils/index.ts
CHANGED
@@ -2,6 +2,6 @@ export { mq } from './mq'
|
|
2
2
|
export type { UnistylesParsedMq } from './mqParser'
|
3
3
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser'
|
4
4
|
export { getValueForBreakpoint } from './breakpoints'
|
5
|
-
export { proxifyFunction, parseStyle } from './styles'
|
5
|
+
export { proxifyFunction, parseStyle, isPlatformColor } from './styles'
|
6
6
|
export { withPlugins } from './withPlugins'
|
7
7
|
export { generateReactNativeWebId } from './generateId'
|