react-native-unistyles 2.0.0-alpha.1 → 2.0.0-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. package/README.md +4 -4
  2. package/ios/UnistylesModule.h +10 -0
  3. package/ios/UnistylesModule.mm +108 -0
  4. package/ios/UnistylesRuntime.h +30 -0
  5. package/ios/UnistylesRuntime.mm +191 -0
  6. package/lib/commonjs/UnistyleRegistry.js +37 -0
  7. package/lib/commonjs/UnistyleRegistry.js.map +1 -0
  8. package/lib/commonjs/Unistyles.js +36 -0
  9. package/lib/commonjs/Unistyles.js.map +1 -0
  10. package/lib/commonjs/UnistylesEngine.js +22 -0
  11. package/lib/commonjs/UnistylesEngine.js.map +1 -0
  12. package/lib/commonjs/UnistylesModule.js +9 -0
  13. package/lib/commonjs/UnistylesModule.js.map +1 -0
  14. package/lib/commonjs/UnistylesRuntime.js +52 -0
  15. package/lib/commonjs/UnistylesRuntime.js.map +1 -0
  16. package/lib/commonjs/createStyleSheet.js +14 -0
  17. package/lib/commonjs/createStyleSheet.js.map +1 -0
  18. package/lib/commonjs/global.js +2 -0
  19. package/lib/commonjs/global.js.map +1 -0
  20. package/lib/commonjs/hooks/useDimensions.web.js +3 -2
  21. package/lib/commonjs/hooks/useDimensions.web.js.map +1 -1
  22. package/lib/commonjs/index.js +33 -6
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/types/cxx.js +23 -0
  25. package/lib/commonjs/types/cxx.js.map +1 -0
  26. package/lib/commonjs/types/index.js +26 -0
  27. package/lib/commonjs/types/index.js.map +1 -1
  28. package/lib/commonjs/types/normalizer.js +6 -0
  29. package/lib/commonjs/types/normalizer.js.map +1 -0
  30. package/lib/commonjs/useInitialTheme.js +13 -0
  31. package/lib/commonjs/useInitialTheme.js.map +1 -0
  32. package/lib/commonjs/useStyles.js +48 -0
  33. package/lib/commonjs/useStyles.js.map +1 -0
  34. package/lib/commonjs/useUnistyles.js +59 -0
  35. package/lib/commonjs/useUnistyles.js.map +1 -0
  36. package/lib/commonjs/utils/breakpoints.js +4 -2
  37. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  38. package/lib/commonjs/utils/common.js +3 -3
  39. package/lib/commonjs/utils/common.js.map +1 -1
  40. package/lib/commonjs/utils/index.js +34 -0
  41. package/lib/commonjs/utils/index.js.map +1 -1
  42. package/lib/commonjs/utils/module.d.js +2 -0
  43. package/lib/commonjs/utils/module.d.js.map +1 -0
  44. package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
  45. package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
  46. package/lib/commonjs/utils/normalizer.js +89 -0
  47. package/lib/commonjs/utils/normalizer.js.map +1 -0
  48. package/lib/commonjs/utils/styles.js +7 -7
  49. package/lib/commonjs/utils/styles.js.map +1 -1
  50. package/lib/module/UnistyleRegistry.js +30 -0
  51. package/lib/module/UnistyleRegistry.js.map +1 -0
  52. package/lib/module/Unistyles.js +30 -0
  53. package/lib/module/Unistyles.js.map +1 -0
  54. package/lib/module/UnistylesEngine.js +15 -0
  55. package/lib/module/UnistylesEngine.js.map +1 -0
  56. package/lib/module/UnistylesModule.js +3 -0
  57. package/lib/module/UnistylesModule.js.map +1 -0
  58. package/lib/module/UnistylesRuntime.js +45 -0
  59. package/lib/module/UnistylesRuntime.js.map +1 -0
  60. package/lib/module/createStyleSheet.js +7 -0
  61. package/lib/module/createStyleSheet.js.map +1 -0
  62. package/lib/module/global.js +2 -0
  63. package/lib/module/global.js.map +1 -0
  64. package/lib/module/hooks/useDimensions.web.js +3 -2
  65. package/lib/module/hooks/useDimensions.web.js.map +1 -1
  66. package/lib/module/index.js +18 -2
  67. package/lib/module/index.js.map +1 -1
  68. package/lib/module/types/cxx.js +17 -0
  69. package/lib/module/types/cxx.js.map +1 -0
  70. package/lib/module/types/index.js +2 -1
  71. package/lib/module/types/index.js.map +1 -1
  72. package/lib/module/types/normalizer.js +2 -0
  73. package/lib/module/types/normalizer.js.map +1 -0
  74. package/lib/module/useInitialTheme.js +6 -0
  75. package/lib/module/useInitialTheme.js.map +1 -0
  76. package/lib/module/useStyles.js +42 -0
  77. package/lib/module/useStyles.js.map +1 -0
  78. package/lib/module/useUnistyles.js +52 -0
  79. package/lib/module/useUnistyles.js.map +1 -0
  80. package/lib/module/utils/breakpoints.js +4 -3
  81. package/lib/module/utils/breakpoints.js.map +1 -1
  82. package/lib/module/utils/common.js +2 -1
  83. package/lib/module/utils/common.js.map +1 -1
  84. package/lib/module/utils/index.js +2 -0
  85. package/lib/module/utils/index.js.map +1 -1
  86. package/lib/module/utils/module.d.js +2 -0
  87. package/lib/module/utils/module.d.js.map +1 -0
  88. package/lib/module/utils/normalizeStyles.web.js +13 -13
  89. package/lib/module/utils/normalizeStyles.web.js.map +1 -1
  90. package/lib/module/utils/normalizer.js +79 -0
  91. package/lib/module/utils/normalizer.js.map +1 -0
  92. package/lib/module/utils/styles.js +7 -8
  93. package/lib/module/utils/styles.js.map +1 -1
  94. package/lib/typescript/examples/expo/src/App.d.ts +3 -0
  95. package/lib/typescript/examples/expo/src/App.d.ts.map +1 -0
  96. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts +3 -0
  97. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts.map +1 -0
  98. package/lib/typescript/examples/expo/src/examples/index.d.ts +2 -0
  99. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -0
  100. package/lib/typescript/examples/expo/src/index.d.ts +2 -0
  101. package/lib/typescript/examples/expo/src/index.d.ts.map +1 -0
  102. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +8 -0
  103. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +1 -0
  104. package/lib/typescript/examples/expo/src/styles/index.d.ts +16 -0
  105. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -0
  106. package/lib/typescript/examples/expo/src/styles/theme.d.ts +40 -0
  107. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -0
  108. package/lib/typescript/src/UnistyleRegistry.d.ts +15 -0
  109. package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -0
  110. package/lib/typescript/src/Unistyles.d.ts +16 -0
  111. package/lib/typescript/src/Unistyles.d.ts.map +1 -0
  112. package/lib/typescript/src/UnistylesEngine.d.ts +8 -0
  113. package/lib/typescript/src/UnistylesEngine.d.ts.map +1 -0
  114. package/lib/typescript/src/UnistylesModule.d.ts +6 -0
  115. package/lib/typescript/src/UnistylesModule.d.ts.map +1 -0
  116. package/lib/typescript/src/UnistylesRuntime.d.ts +56 -0
  117. package/lib/typescript/src/UnistylesRuntime.d.ts.map +1 -0
  118. package/lib/typescript/src/createStyleSheet.d.ts +6 -0
  119. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  120. package/lib/typescript/src/global.d.ts +5 -0
  121. package/lib/typescript/src/global.d.ts.map +1 -0
  122. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -1
  123. package/lib/typescript/src/index.d.ts +14 -2
  124. package/lib/typescript/src/index.d.ts.map +1 -1
  125. package/lib/typescript/src/types/breakpoints.d.ts +6 -7
  126. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  127. package/lib/typescript/src/types/core.d.ts +4 -4
  128. package/lib/typescript/src/types/core.d.ts.map +1 -1
  129. package/lib/typescript/src/types/cxx.d.ts +50 -0
  130. package/lib/typescript/src/types/cxx.d.ts.map +1 -0
  131. package/lib/typescript/src/types/index.d.ts +4 -1
  132. package/lib/typescript/src/types/index.d.ts.map +1 -1
  133. package/lib/typescript/src/types/normalizer.d.ts +20 -0
  134. package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
  135. package/lib/typescript/src/useInitialTheme.d.ts +3 -0
  136. package/lib/typescript/src/useInitialTheme.d.ts.map +1 -0
  137. package/lib/typescript/src/useStyles.d.ts +46 -0
  138. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  139. package/lib/typescript/src/useUnistyles.d.ts +45 -0
  140. package/lib/typescript/src/useUnistyles.d.ts.map +1 -0
  141. package/lib/typescript/src/utils/breakpoints.d.ts +5 -4
  142. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  143. package/lib/typescript/src/utils/common.d.ts +2 -1
  144. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  145. package/lib/typescript/src/utils/index.d.ts +2 -0
  146. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  147. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
  148. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
  149. package/lib/typescript/src/utils/normalizer.d.ts +11 -0
  150. package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
  151. package/lib/typescript/src/utils/styles.d.ts +4 -3
  152. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  153. package/package.json +13 -3
  154. package/react-native-unistyles.podspec +21 -0
  155. package/src/UnistyleRegistry.ts +39 -0
  156. package/src/Unistyles.ts +41 -0
  157. package/src/UnistylesEngine.ts +15 -0
  158. package/src/UnistylesModule.ts +7 -0
  159. package/src/UnistylesRuntime.ts +58 -0
  160. package/src/createStyleSheet.ts +12 -0
  161. package/src/global.ts +2 -0
  162. package/src/hooks/useDimensions.web.ts +3 -2
  163. package/src/index.ts +30 -2
  164. package/src/types/breakpoints.ts +9 -11
  165. package/src/types/core.ts +6 -6
  166. package/src/types/cxx.ts +61 -0
  167. package/src/types/index.ts +4 -3
  168. package/src/types/normalizer.ts +29 -0
  169. package/src/useInitialTheme.ts +7 -0
  170. package/src/useStyles.ts +49 -0
  171. package/src/useUnistyles.ts +67 -0
  172. package/src/utils/breakpoints.ts +16 -14
  173. package/src/utils/common.ts +2 -1
  174. package/src/utils/index.ts +2 -0
  175. package/src/utils/module.d.ts +3 -0
  176. package/src/utils/normalizeStyles.web.ts +21 -42
  177. package/src/utils/normalizer.ts +99 -0
  178. package/src/utils/styles.ts +17 -19
  179. package/lib/commonjs/UnistylesTheme.js +0 -21
  180. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  181. package/lib/commonjs/createUnistyles.js +0 -57
  182. package/lib/commonjs/createUnistyles.js.map +0 -1
  183. package/lib/module/UnistylesTheme.js +0 -12
  184. package/lib/module/UnistylesTheme.js.map +0 -1
  185. package/lib/module/createUnistyles.js +0 -50
  186. package/lib/module/createUnistyles.js.map +0 -1
  187. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  188. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  189. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  190. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  191. package/src/UnistylesTheme.tsx +0 -17
  192. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  193. package/src/createUnistyles.ts +0 -70
package/README.md CHANGED
@@ -8,10 +8,9 @@
8
8
 
9
9
  ![GitHub package.json version](https://img.shields.io/github/package-json/v/jpudysz/react-native-unistyles?style=for-the-badge)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/react-native-unistyles.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-unistyles)
11
- ![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20iOS%20%7C%20RNWeb-blue.svg?style=for-the-badge)
11
+ ![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20IOS%20%7C%20SSR%20%7C%20Web-blue.svg?style=for-the-badge)
12
12
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
13
13
 
14
-
15
14
  ## Features
16
15
  - ⚡ Blazing fast, adds around ~3ms on top of StyleSheet*
17
16
  - 🎳 Share up to 100% of your styles across platforms in monorepo
@@ -19,7 +18,8 @@
19
18
  - 🖥️ Supports custom breakpoints and css-like media queries
20
19
  - 🎨 Access theme in your StyleSheets and components
21
20
  - 🪄 Supports dynamic functions to access values from JSX
22
- - 🥳 Compatible with Expo, Expo Go, Bare React Native and React Native Web
21
+ - 🥳 Compatible with Expo, Expo Go, Bare React Native, React Native Web and SSR
22
+ - 🛡️ ~99% Test coverage
23
23
  - ⚔️ No 3rd party dependencies
24
24
 
25
25
  *-based on this [benchmark](https://github.com/efstathiosntonas/react-native-style-libraries-benchmark)
@@ -41,7 +41,7 @@ There is ongoing work on branch [2.0](https://github.com/jpudysz/react-native-un
41
41
 
42
42
  ---
43
43
 
44
- Join early testers and discussion [here](https://github.com/jpudysz/react-native-unistyles/discussions/41)
44
+ Join early testers and discussion [here](https://github.com/jpudysz/react-native-unistyles/discussions/41).
45
45
 
46
46
  ```cmd
47
47
  yarn add react-native-unistyles@next
@@ -0,0 +1,10 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+
4
+ typedef void(^UnistylesEventHandler)(NSDictionary *);
5
+
6
+ @interface UnistylesModule : RCTEventEmitter<RCTBridgeModule>
7
+
8
+ @property (nonatomic, assign) void* unistylesRuntime;
9
+
10
+ @end
@@ -0,0 +1,108 @@
1
+ #import "UnistylesModule.h"
2
+ #import "UnistylesRuntime.h"
3
+
4
+ #import <React/RCTBridge+Private.h>
5
+ #import <React/RCTUtils.h>
6
+ #import <jsi/jsi.h>
7
+
8
+ @implementation UnistylesModule
9
+
10
+ BOOL hasListeners;
11
+
12
+ using namespace facebook;
13
+
14
+ RCT_EXPORT_MODULE(Unistyles)
15
+
16
+ - (instancetype)init {
17
+ if ((self = [super init])) {
18
+ [[NSNotificationCenter defaultCenter] addObserver:self
19
+ selector:@selector(handleOrientationChange:)
20
+ name:UIDeviceOrientationDidChangeNotification
21
+ object:nil];
22
+ }
23
+ return self;
24
+ }
25
+
26
+ - (void)handleOrientationChange:(NSNotification *)notification {
27
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
28
+ CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
29
+ CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
30
+
31
+ ((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChangeWithWidth(screenWidth, screenHeight);
32
+ });
33
+ }
34
+
35
+ - (void)dealloc {
36
+ delete (UnistylesRuntime*)self.unistylesRuntime;
37
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
38
+ }
39
+
40
+ + (BOOL)requiresMainQueueSetup
41
+ {
42
+ return YES;
43
+ }
44
+
45
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
46
+ {
47
+ NSLog(@"Installing Unistyles 🦄...");
48
+
49
+ RCTBridge* bridge = [RCTBridge currentBridge];
50
+ RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
51
+
52
+ if (cxxBridge == nil) {
53
+ return @false;
54
+ }
55
+
56
+ auto jsiRuntime = (jsi::Runtime*)cxxBridge.runtime;
57
+
58
+ if (jsiRuntime == nil) {
59
+ return @false;
60
+ }
61
+
62
+ auto& runtime = *jsiRuntime;
63
+ UnistylesModule *__weak weakSelf = self;
64
+
65
+ registerUnistylesHostObject(runtime, weakSelf);
66
+
67
+ NSLog(@"Installed Unistyles 🦄!");
68
+
69
+ return @true;
70
+ }
71
+
72
+ - (NSArray<NSString *> *)supportedEvents {
73
+ return @[@"onChange"];
74
+ }
75
+
76
+ - (void)startObserving
77
+ {
78
+ hasListeners = YES;
79
+ }
80
+
81
+ - (void)stopObserving
82
+ {
83
+ hasListeners = NO;
84
+ }
85
+
86
+ - (void)emitEvent:(NSString *)eventName withBody:(NSDictionary *)body {
87
+ if (hasListeners) {
88
+ [self sendEventWithName:@"onChange" body:body];
89
+ }
90
+ }
91
+
92
+ void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSelf) {
93
+ CGFloat initialScreenWidth = [UIScreen mainScreen].bounds.size.width;
94
+ CGFloat initialScreenHeight = [UIScreen mainScreen].bounds.size.height;
95
+ UnistylesEventHandler eventHandler = ^(NSDictionary *body) {
96
+ [weakSelf emitEvent:@"onChange" withBody:body];
97
+ };
98
+
99
+ auto unistylesRuntime = std::make_shared<UnistylesRuntime>(eventHandler, initialScreenWidth, initialScreenHeight);
100
+
101
+ weakSelf.unistylesRuntime = unistylesRuntime.get();
102
+
103
+ auto hostObject = jsi::Object::createFromHostObject(runtime, unistylesRuntime);
104
+
105
+ runtime.global().setProperty(runtime, "__UNISTYLES__", std::move(hostObject));
106
+ }
107
+
108
+ @end
@@ -0,0 +1,30 @@
1
+ #pragma once
2
+
3
+ #import "UnistylesModule.h"
4
+ #import <jsi/jsi.h>
5
+ #import <vector>
6
+
7
+ using namespace facebook;
8
+
9
+ class JSI_EXPORT UnistylesRuntime : public jsi::HostObject {
10
+ private:
11
+ UnistylesEventHandler eventHandler;
12
+ float screenWidth;
13
+ float screenHeight;
14
+
15
+ public:
16
+ UnistylesRuntime(UnistylesEventHandler handler, CGFloat screenWidth, CGFloat screenHeight)
17
+ : eventHandler(handler), screenWidth(screenWidth), screenHeight(screenHeight) {}
18
+
19
+ std::string theme;
20
+ std::string breakpoint;
21
+ std::string colorScheme;
22
+ std::vector<std::string> featureFlags;
23
+ std::vector<std::pair<std::string, double>> sortedBreakpointEntries;
24
+
25
+ jsi::Value get(jsi::Runtime&, const jsi::PropNameID& name) override;
26
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& rt) override;
27
+
28
+ void handleScreenSizeChangeWithWidth(CGFloat width, CGFloat height);
29
+ std::string getBreakpointFromScreenWidth(double width, const std::vector<std::pair<std::string, double>>& sortedBreakpointEntries);
30
+ };
@@ -0,0 +1,191 @@
1
+ #import "UnistylesRuntime.h"
2
+
3
+ std::vector<jsi::PropNameID> UnistylesRuntime::getPropertyNames(jsi::Runtime& rt) {
4
+ std::vector<jsi::PropNameID> properties;
5
+
6
+ // getters
7
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("theme")));
8
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("breakpoint")));
9
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("colorScheme")));
10
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("sortedBreakpointPairs")));
11
+
12
+ // setters
13
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useBreakpoints")));
14
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useTheme")));
15
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useColorScheme")));
16
+ properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useFeatureFlags")));
17
+
18
+ return properties;
19
+ }
20
+
21
+
22
+ jsi::Value UnistylesRuntime::get(jsi::Runtime& runtime, const jsi::PropNameID& propNameId) {
23
+ std::string propName = propNameId.utf8(runtime);
24
+
25
+ if (propName == "theme") {
26
+ return !this->theme.empty()
27
+ ? jsi::Value(jsi::String::createFromUtf8(runtime, this->theme))
28
+ : jsi::Value::undefined();
29
+ }
30
+
31
+ if (propName == "breakpoint") {
32
+ return !this->breakpoint.empty()
33
+ ? jsi::Value(jsi::String::createFromUtf8(runtime, this->breakpoint))
34
+ : jsi::Value::undefined();
35
+ }
36
+
37
+ if (propName == "colorScheme") {
38
+ return !this->colorScheme.empty()
39
+ ? jsi::Value(jsi::String::createFromUtf8(runtime, this->colorScheme))
40
+ : jsi::Value::undefined();
41
+ }
42
+
43
+ if (propName == "sortedBreakpointPairs") {
44
+ std::unique_ptr<jsi::Array> sortedBreakpointEntriesArray = std::make_unique<jsi::Array>(runtime, this->sortedBreakpointEntries.size());
45
+
46
+ for (size_t i = 0; i < this->sortedBreakpointEntries.size(); ++i) {
47
+ std::unique_ptr<jsi::Array> pairArray = std::make_unique<jsi::Array>(runtime, 2);
48
+ jsi::String nameValue = jsi::String::createFromUtf8(runtime, this->sortedBreakpointEntries[i].first);
49
+
50
+ pairArray->setValueAtIndex(runtime, 0, nameValue);
51
+ pairArray->setValueAtIndex(runtime, 1, jsi::Value(this->sortedBreakpointEntries[i].second));
52
+ sortedBreakpointEntriesArray->setValueAtIndex(runtime, i, *pairArray);
53
+ }
54
+
55
+ return jsi::Value(runtime, *sortedBreakpointEntriesArray);
56
+ }
57
+
58
+ if (propName == "useBreakpoints") {
59
+ return jsi::Function::createFromHostFunction(
60
+ runtime,
61
+ jsi::PropNameID::forAscii(runtime, "useBreakpoints"),
62
+ 1,
63
+ [this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
64
+ jsi::Object breakpointsObj = arguments[0].asObject(runtime);
65
+ jsi::Array propertyNames = breakpointsObj.getPropertyNames(runtime);
66
+ std::vector<std::pair<std::string, double>> sortedBreakpointEntriesVec;
67
+
68
+ for (size_t i = 0; i < propertyNames.size(runtime); ++i) {
69
+ jsi::Value propNameValue = propertyNames.getValueAtIndex(runtime, i);
70
+ std::string name = propNameValue.asString(runtime).utf8(runtime);
71
+ jsi::PropNameID propNameID = jsi::PropNameID::forUtf8(runtime, name);
72
+ jsi::Value value = breakpointsObj.getProperty(runtime, propNameID);
73
+
74
+ if (value.isNumber()) {
75
+ double breakpointValue = value.asNumber();
76
+ sortedBreakpointEntriesVec.push_back(std::make_pair(name, breakpointValue));
77
+ }
78
+ }
79
+
80
+ std::sort(sortedBreakpointEntriesVec.begin(), sortedBreakpointEntriesVec.end(), [](const std::pair<std::string, double>& a, const std::pair<std::string, double>& b) {
81
+ return a.second < b.second;
82
+ });
83
+
84
+ this->sortedBreakpointEntries = sortedBreakpointEntriesVec;
85
+
86
+ std::string breakpoint = this->getBreakpointFromScreenWidth(this->screenWidth, sortedBreakpointEntriesVec);
87
+
88
+ this->breakpoint = breakpoint;
89
+
90
+ return jsi::Value::undefined();
91
+ }
92
+ );
93
+ }
94
+
95
+ if (propName == "useTheme") {
96
+ return jsi::Function::createFromHostFunction(runtime,
97
+ jsi::PropNameID::forAscii(runtime, "useTheme"),
98
+ 1,
99
+ [this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
100
+ std::string themeName = arguments[0].asString(runtime).utf8(runtime);
101
+ NSString *currentTheme = [NSString stringWithUTF8String:themeName.c_str()];
102
+
103
+ this->theme = themeName;
104
+
105
+ NSDictionary *body = @{
106
+ @"type": @"theme",
107
+ @"payload": @{
108
+ @"currentTheme": currentTheme
109
+ }
110
+ };
111
+ this->eventHandler(body);
112
+
113
+ return jsi::Value::undefined();
114
+ }
115
+ );
116
+ }
117
+
118
+ if (propName == "useColorScheme") {
119
+ return jsi::Function::createFromHostFunction(runtime,
120
+ jsi::PropNameID::forAscii(runtime, "useColorScheme"),
121
+ 1,
122
+ [this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
123
+ std::string colorScheme = arguments[0].asString(runtime).utf8(runtime);
124
+
125
+ this->colorScheme = colorScheme;
126
+
127
+ return jsi::Value::undefined();
128
+ }
129
+ );
130
+ }
131
+
132
+ if (propName == "useFeatureFlags") {
133
+ return jsi::Function::createFromHostFunction(runtime,
134
+ jsi::PropNameID::forAscii(runtime, "useFeatureFlags"),
135
+ 1,
136
+ [this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
137
+ jsi::Array featureFlagsArray = arguments[0].asObject(runtime).asArray(runtime);
138
+ size_t length = featureFlagsArray.size(runtime);
139
+ std::vector<std::string> featureFlags;
140
+ featureFlags.reserve(length);
141
+
142
+ for (size_t i = 0; i < length; ++i) {
143
+ jsi::Value element = featureFlagsArray.getValueAtIndex(runtime, i);
144
+
145
+ if (element.isString()) {
146
+ std::string featureFlag = element.asString(runtime).utf8(runtime);
147
+ featureFlags.push_back(featureFlag);
148
+ }
149
+ }
150
+
151
+ this->featureFlags = featureFlags;
152
+
153
+ return jsi::Value::undefined();
154
+ }
155
+ );
156
+ }
157
+
158
+ return jsi::Value::undefined();
159
+ }
160
+
161
+ std::string UnistylesRuntime::getBreakpointFromScreenWidth(double width, const std::vector<std::pair<std::string, double>>& sortedBreakpointEntries) {
162
+ for (size_t i = 0; i < sortedBreakpointEntries.size(); ++i) {
163
+ const auto& [key, value] = sortedBreakpointEntries[i];
164
+ const double maxVal = (i + 1 < sortedBreakpointEntries.size()) ? sortedBreakpointEntries[i + 1].second : std::numeric_limits<double>::infinity();
165
+
166
+ if (width >= value && width < maxVal) {
167
+ return key;
168
+ }
169
+ }
170
+
171
+ return sortedBreakpointEntries.empty() ? "" : sortedBreakpointEntries.back().first;
172
+ }
173
+
174
+ void UnistylesRuntime::handleScreenSizeChangeWithWidth(CGFloat width, CGFloat height) {
175
+ std::string currentBreakpoint = this->breakpoint;
176
+ std::string nextBreakpoint = this->getBreakpointFromScreenWidth(width, this->sortedBreakpointEntries);
177
+
178
+ if (currentBreakpoint != nextBreakpoint) {
179
+ this->breakpoint = nextBreakpoint;
180
+
181
+ NSString *breakpoint = [NSString stringWithUTF8String:nextBreakpoint.c_str()];
182
+ NSDictionary *body = @{
183
+ @"type": @"breakpoint",
184
+ @"payload": @{
185
+ @"currentBreakpoint": breakpoint
186
+ }
187
+ };
188
+
189
+ this->eventHandler(body);
190
+ }
191
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistyleRegistry = void 0;
7
+ class UnistyleRegistry {
8
+ isClosed = false;
9
+ themes = {};
10
+ breakpoints = {};
11
+ sortedBreakpointPairs = [];
12
+ config = {};
13
+ constructor(unistylesBridge) {
14
+ this.unistylesBridge = unistylesBridge;
15
+ }
16
+ addThemes = themes => {
17
+ this.themes = themes;
18
+ return this;
19
+ };
20
+ addBreakpoints = breakpoints => {
21
+ this.unistylesBridge.useBreakpoints(breakpoints);
22
+ this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
23
+ return this;
24
+ };
25
+ addConfig = config => {
26
+ this.config = config;
27
+ if (config.featureFlags && config.featureFlags.length > 0) {
28
+ this.unistylesBridge.useFeatureFlags(config.featureFlags);
29
+ }
30
+ if (config.colorScheme) {
31
+ this.unistylesBridge.useColorScheme(config.colorScheme);
32
+ }
33
+ return this;
34
+ };
35
+ }
36
+ exports.UnistyleRegistry = UnistyleRegistry;
37
+ //# sourceMappingURL=UnistyleRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistyleRegistry","isClosed","themes","breakpoints","sortedBreakpointPairs","config","constructor","unistylesBridge","addThemes","addBreakpoints","useBreakpoints","addConfig","featureFlags","length","useFeatureFlags","colorScheme","useColorScheme","exports"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":";;;;;;AAGO,MAAMA,gBAAgB,CAAC;EACnBC,QAAQ,GAAG,KAAK;EAChBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EACjHC,MAAM,GAAoB,CAAC,CAAC;EAEnCC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIN,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,OAAO,IAAI;EACf,CAAC;EAEMO,cAAc,GAAIN,WAAiC,IAAK;IAC3D,IAAI,CAACI,eAAe,CAACG,cAAc,CAACP,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACG,eAAe,CAACH,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMO,SAAS,GAAIN,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACO,YAAY,IAAIP,MAAM,CAACO,YAAY,CAACC,MAAM,GAAG,CAAC,EAAE;MACvD,IAAI,CAACN,eAAe,CAACO,eAAe,CAACT,MAAM,CAACO,YAAY,CAAC;IAC7D;IAEA,IAAIP,MAAM,CAACU,WAAW,EAAE;MACpB,IAAI,CAACR,eAAe,CAACS,cAAc,CAACX,MAAM,CAACU,WAAW,CAAC;IAC3D;IAEA,OAAO,IAAI;EACf,CAAC;AACL;AAACE,OAAA,CAAAjB,gBAAA,GAAAA,gBAAA"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.unistyles = void 0;
7
+ var _UnistylesModule = require("./UnistylesModule");
8
+ var _UnistylesRuntime = require("./UnistylesRuntime");
9
+ var _UnistylesEngine = require("./UnistylesEngine");
10
+ var _UnistyleRegistry = require("./UnistyleRegistry");
11
+ var _types = require("./types");
12
+ class Unistyles {
13
+ constructor() {
14
+ const isInstalled = _UnistylesModule.UnistylesModule?.install() ?? false;
15
+ if (!isInstalled) {
16
+ throw new Error(_types.UnistylesError.RuntimeUnavailable);
17
+ }
18
+
19
+ // @ts-ignore
20
+ this._bridge = global.__UNISTYLES__;
21
+ this._registry = new _UnistyleRegistry.UnistyleRegistry(this._bridge);
22
+ this._runtime = new _UnistylesRuntime.UnistylesRuntime(this._bridge, this._registry);
23
+ this._engine = new _UnistylesEngine.UnistylesEngine(this._registry, this._runtime);
24
+ }
25
+ get registry() {
26
+ return this._registry;
27
+ }
28
+ get runtime() {
29
+ return this._runtime;
30
+ }
31
+ get engine() {
32
+ return this._engine;
33
+ }
34
+ }
35
+ const unistyles = exports.unistyles = new Unistyles();
36
+ //# sourceMappingURL=Unistyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistylesEngine","_UnistyleRegistry","_types","Unistyles","constructor","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","UnistyleRegistry","_runtime","UnistylesRuntime","_engine","UnistylesEngine","registry","runtime","engine","unistyles","exports"],"sourceRoot":"../../src","sources":["Unistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,CAAC;EAMZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGC,gCAAe,EAAEC,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACF,WAAW,EAAE;MACd,MAAM,IAAIG,KAAK,CAACC,qBAAc,CAACC,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACJ,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACN,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;IAClE,IAAI,CAACI,OAAO,GAAG,IAAIC,gCAAe,CAAC,IAAI,CAACL,SAAS,EAAE,IAAI,CAACE,QAAQ,CAAC;EACrE;EAEA,IAAWI,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACN,SAAS;EACzB;EAEA,IAAWO,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACL,QAAQ;EACxB;EAEA,IAAWM,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACJ,OAAO;EACvB;AACJ;AAEO,MAAMK,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIpB,SAAS,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesEngine = void 0;
7
+ // todo implement engine
8
+ class UnistylesEngine {
9
+ // @ts-ignore
10
+ constructor(registry, runtime) {
11
+ this.registry = registry;
12
+ this.runtime = runtime;
13
+ this.registry = registry;
14
+ this.runtime = runtime;
15
+ }
16
+
17
+ // UnistylesEngine.parseStyleSheet
18
+ // UnistylesEngine.parseStyle
19
+ // UnistylesEngine.proxify
20
+ }
21
+ exports.UnistylesEngine = UnistylesEngine;
22
+ //# sourceMappingURL=UnistylesEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistylesEngine","constructor","registry","runtime","exports"],"sourceRoot":"../../src","sources":["UnistylesEngine.ts"],"mappings":";;;;;;AAGA;AACO,MAAMA,eAAe,CAAC;EACzB;EACAC,WAAWA,CAASC,QAA0B,EAAUC,OAAyB,EAAE;IAAA,KAA/DD,QAA0B,GAA1BA,QAA0B;IAAA,KAAUC,OAAyB,GAAzBA,OAAyB;IAC7E,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;;EAEA;EACA;EACA;AACJ;AAACC,OAAA,CAAAJ,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesModule = void 0;
7
+ var _reactNative = require("react-native");
8
+ const UnistylesModule = exports.UnistylesModule = _reactNative.NativeModules?.Unistyles;
9
+ //# sourceMappingURL=UnistylesModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","UnistylesModule","exports","NativeModules","Unistyles"],"sourceRoot":"../../src","sources":["UnistylesModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,0BAAa,EAAEC,SAAkC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesRuntime = void 0;
7
+ var _types = require("./types");
8
+ class UnistylesRuntime {
9
+ constructor(unistylesBridge, registry) {
10
+ this.unistylesBridge = unistylesBridge;
11
+ this.registry = registry;
12
+ }
13
+ get colorScheme() {
14
+ return this.unistylesBridge.colorScheme;
15
+ }
16
+ get breakpoints() {
17
+ return this.registry.breakpoints;
18
+ }
19
+ get sortedBreakpoints() {
20
+ return this.registry.sortedBreakpointPairs;
21
+ }
22
+ get config() {
23
+ return this.registry.config;
24
+ }
25
+ get theme() {
26
+ return this.unistylesBridge.theme;
27
+ }
28
+ get currentBreakpoint() {
29
+ return this.unistylesBridge.breakpoint;
30
+ }
31
+ setColorScheme = scheme => {
32
+ if (scheme !== this.colorScheme) {
33
+ this.unistylesBridge.useColorScheme(scheme);
34
+ }
35
+ };
36
+ setTheme = name => {
37
+ if (name !== this.theme && this.hasTheme(name)) {
38
+ this.unistylesBridge.useTheme(name);
39
+ return true;
40
+ }
41
+ return false;
42
+ };
43
+ hasTheme = name => name in this.registry.themes;
44
+ getTheme = forName => {
45
+ if (!this.hasTheme(forName)) {
46
+ throw new Error(_types.UnistylesError.ThemeNotFound);
47
+ }
48
+ return this.registry.themes[forName];
49
+ };
50
+ }
51
+ exports.UnistylesRuntime = UnistylesRuntime;
52
+ //# sourceMappingURL=UnistylesRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","breakpoints","sortedBreakpoints","sortedBreakpointPairs","config","theme","currentBreakpoint","breakpoint","setColorScheme","scheme","useColorScheme","setTheme","name","hasTheme","useTheme","themes","getTheme","forName","Error","UnistylesError","ThemeNotFound","exports"],"sourceRoot":"../../src","sources":["UnistylesRuntime.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,QAA0B,EAAE;IAAA,KAAtED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,QAA0B,GAA1BA,QAA0B;EAAG;EAE3F,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,QAAQ,CAACE,WAAW;EACpC;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,QAAQ,CAACI,qBAAqB;EAC9C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACL,QAAQ,CAACK,MAAM;EAC/B;EAEA,IAAWC,KAAKA,CAAA,EAAG;IACf,OAAO,IAAI,CAACP,eAAe,CAACO,KAAK;EACrC;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACR,eAAe,CAACS,UAAU;EAC1C;EAEOC,cAAc,GAAIC,MAA4B,IAAK;IACtD,IAAIA,MAAM,KAAK,IAAI,CAACT,WAAW,EAAE;MAC7B,IAAI,CAACF,eAAe,CAACY,cAAc,CAACD,MAAM,CAAC;IAC/C;EACJ,CAAC;EAEME,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAIA,IAAI,KAAK,IAAI,CAACP,KAAK,IAAI,IAAI,CAACQ,QAAQ,CAACD,IAAI,CAAC,EAAE;MAC5C,IAAI,CAACd,eAAe,CAACgB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,OAAO,KAAK;EAChB,CAAC;EAEMC,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACb,QAAQ,CAACgB,MAAM;EAExEC,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,CAAC,IAAI,CAACJ,QAAQ,CAACI,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIC,KAAK,CAACC,qBAAc,CAACC,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAACrB,QAAQ,CAACgB,MAAM,CAACE,OAAO,CAAC;EACxC,CAAC;AACL;AAACI,OAAA,CAAAzB,gBAAA,GAAAA,gBAAA"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createStyleSheet = void 0;
7
+ const createStyleSheet = styles => {
8
+ if (typeof styles === 'function') {
9
+ return styles;
10
+ }
11
+ return styles;
12
+ };
13
+ exports.createStyleSheet = createStyleSheet;
14
+ //# sourceMappingURL=createStyleSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStyleSheet","styles","exports"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":";;;;;;AAKO,MAAMA,gBAAgB,GAAuCC,MAA+E,IAAY;EAC3J,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM;EACjB;EAEA,OAAOA,MAAM;AACjB,CAAC;AAAAC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":""}
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useDimensions = void 0;
7
7
  var _react = require("react");
8
+ var _utils = require("../utils");
8
9
  const useDimensions = () => {
9
10
  const timerRef = (0, _react.useRef)();
10
11
  const [screenSize, setScreenSize] = (0, _react.useState)({
11
- width: window.innerWidth,
12
- height: window.innerHeight
12
+ width: _utils.isServer ? 0 : window.innerWidth,
13
+ height: _utils.isServer ? 0 : window.innerHeight
13
14
  });
14
15
  (0, _react.useEffect)(() => {
15
16
  const handleResize = () => {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","useDimensions","timerRef","useRef","screenSize","setScreenSize","useState","width","window","innerWidth","height","innerHeight","useEffect","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener","exports"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAG,IAAAC,aAAM,EAAgC,CAAC;EACxD,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAAa;IACrDC,KAAK,EAAEC,MAAM,CAACC,UAAU;IACxBC,MAAM,EAAEF,MAAM,CAACG;EACnB,CAAC,CAAC;EAEF,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACZ,QAAQ,CAACa,OAAO,CAAC;MAE9Bb,QAAQ,CAACa,OAAO,GAAGC,UAAU,CAAC,MAAMX,aAAa,CAAC;QAC9CE,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACS,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTL,MAAM,CAACU,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACZ,QAAQ,CAACa,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOX,UAAU;AACrB,CAAC;AAAAe,OAAA,CAAAlB,aAAA,GAAAA,aAAA"}
1
+ {"version":3,"names":["_react","require","_utils","useDimensions","timerRef","useRef","screenSize","setScreenSize","useState","width","isServer","window","innerWidth","height","innerHeight","useEffect","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener","exports"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAG,IAAAC,aAAM,EAAgC,CAAC;EACxD,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAAa;IACrDC,KAAK,EAAEC,eAAQ,GAAG,CAAC,GAAGC,MAAM,CAACC,UAAU;IACvCC,MAAM,EAAEH,eAAQ,GAAG,CAAC,GAAGC,MAAM,CAACG;EAClC,CAAC,CAAC;EAEF,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACb,QAAQ,CAACc,OAAO,CAAC;MAE9Bd,QAAQ,CAACc,OAAO,GAAGC,UAAU,CAAC,MAAMZ,aAAa,CAAC;QAC9CE,KAAK,EAAEE,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACS,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTL,MAAM,CAACU,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACb,QAAQ,CAACc,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOZ,UAAU;AACrB,CAAC;AAAAgB,OAAA,CAAAnB,aAAA,GAAAA,aAAA"}
@@ -3,18 +3,45 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "UnistylesTheme", {
6
+ Object.defineProperty(exports, "UnistylesColorScheme", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _UnistylesTheme.UnistylesTheme;
9
+ return _types.UnistylesColorScheme;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "createUnistyles", {
12
+ exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
13
+ Object.defineProperty(exports, "createStyleSheet", {
13
14
  enumerable: true,
14
15
  get: function () {
15
- return _createUnistyles.createUnistyles;
16
+ return _createStyleSheet.createStyleSheet;
16
17
  }
17
18
  });
18
- var _UnistylesTheme = require("./UnistylesTheme");
19
- var _createUnistyles = require("./createUnistyles");
19
+ Object.defineProperty(exports, "useInitialTheme", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _useInitialTheme.useInitialTheme;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "useStyles", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _useStyles.useStyles;
29
+ }
30
+ });
31
+ var _Unistyles = require("./Unistyles");
32
+ var _types = require("./types");
33
+ var _useInitialTheme = require("./useInitialTheme");
34
+ var _useStyles = require("./useStyles");
35
+ var _createStyleSheet = require("./createStyleSheet");
36
+ const {
37
+ addThemes,
38
+ addBreakpoints,
39
+ addConfig
40
+ } = _Unistyles.unistyles.registry;
41
+ const UnistylesRuntime = exports.UnistylesRuntime = _Unistyles.unistyles.runtime;
42
+ const UnistylesRegistry = exports.UnistylesRegistry = {
43
+ addThemes,
44
+ addBreakpoints,
45
+ addConfig
46
+ };
20
47
  //# sourceMappingURL=index.js.map