react-native-unistyles 2.0.0-alpha.3 → 2.0.0-alpha.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/ios/UnistylesHelpers.h +4 -0
  2. package/ios/UnistylesHelpers.mm +20 -0
  3. package/ios/UnistylesModule.h +1 -3
  4. package/ios/UnistylesModule.mm +62 -67
  5. package/lib/commonjs/UnistyleRegistry.js +12 -1
  6. package/lib/commonjs/UnistyleRegistry.js.map +1 -1
  7. package/lib/commonjs/UnistylesRuntime.js +5 -2
  8. package/lib/commonjs/UnistylesRuntime.js.map +1 -1
  9. package/lib/commonjs/hooks/useDimensions.web.js +7 -5
  10. package/lib/commonjs/hooks/useDimensions.web.js.map +1 -1
  11. package/lib/commonjs/index.js +2 -1
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/types/cxx.js +5 -2
  14. package/lib/commonjs/types/cxx.js.map +1 -1
  15. package/lib/commonjs/useInitialTheme.js +1 -1
  16. package/lib/commonjs/useInitialTheme.js.map +1 -1
  17. package/lib/commonjs/useStyles.js.map +1 -1
  18. package/lib/commonjs/useUnistyles.js +9 -15
  19. package/lib/commonjs/useUnistyles.js.map +1 -1
  20. package/lib/commonjs/utils/breakpoints.js +12 -2
  21. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  22. package/lib/commonjs/utils/common.js +6 -1
  23. package/lib/commonjs/utils/common.js.map +1 -1
  24. package/lib/commonjs/utils/index.js +7 -0
  25. package/lib/commonjs/utils/index.js.map +1 -1
  26. package/lib/commonjs/utils/mediaQueries.js +9 -2
  27. package/lib/commonjs/utils/mediaQueries.js.map +1 -1
  28. package/lib/module/UnistyleRegistry.js +12 -1
  29. package/lib/module/UnistyleRegistry.js.map +1 -1
  30. package/lib/module/UnistylesRuntime.js +5 -2
  31. package/lib/module/UnistylesRuntime.js.map +1 -1
  32. package/lib/module/hooks/useDimensions.web.js +8 -6
  33. package/lib/module/hooks/useDimensions.web.js.map +1 -1
  34. package/lib/module/index.js +1 -0
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/module/types/cxx.js +5 -2
  37. package/lib/module/types/cxx.js.map +1 -1
  38. package/lib/module/useInitialTheme.js +2 -2
  39. package/lib/module/useInitialTheme.js.map +1 -1
  40. package/lib/module/useStyles.js.map +1 -1
  41. package/lib/module/useUnistyles.js +9 -15
  42. package/lib/module/useUnistyles.js.map +1 -1
  43. package/lib/module/utils/breakpoints.js +13 -3
  44. package/lib/module/utils/breakpoints.js.map +1 -1
  45. package/lib/module/utils/common.js +5 -0
  46. package/lib/module/utils/common.js.map +1 -1
  47. package/lib/module/utils/index.js +1 -1
  48. package/lib/module/utils/index.js.map +1 -1
  49. package/lib/module/utils/mediaQueries.js +9 -2
  50. package/lib/module/utils/mediaQueries.js.map +1 -1
  51. package/lib/typescript/src/UnistyleRegistry.d.ts +2 -0
  52. package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -1
  53. package/lib/typescript/src/UnistylesRuntime.d.ts +3 -39
  54. package/lib/typescript/src/UnistylesRuntime.d.ts.map +1 -1
  55. package/lib/typescript/src/global.d.ts +2 -0
  56. package/lib/typescript/src/global.d.ts.map +1 -1
  57. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -1
  58. package/lib/typescript/src/index.d.ts +1 -0
  59. package/lib/typescript/src/index.d.ts.map +1 -1
  60. package/lib/typescript/src/types/cxx.d.ts +15 -15
  61. package/lib/typescript/src/types/cxx.d.ts.map +1 -1
  62. package/lib/typescript/src/useStyles.d.ts +3 -39
  63. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  64. package/lib/typescript/src/useUnistyles.d.ts +4 -38
  65. package/lib/typescript/src/useUnistyles.d.ts.map +1 -1
  66. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  67. package/lib/typescript/src/utils/common.d.ts +5 -0
  68. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  69. package/lib/typescript/src/utils/index.d.ts +1 -1
  70. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  71. package/lib/typescript/src/utils/mediaQueries.d.ts.map +1 -1
  72. package/package.json +12 -13
  73. package/react-native-unistyles.podspec +2 -1
  74. package/src/UnistyleRegistry.ts +16 -1
  75. package/src/UnistylesRuntime.ts +6 -2
  76. package/src/global.ts +4 -1
  77. package/src/hooks/useDimensions.web.ts +9 -6
  78. package/src/index.ts +2 -0
  79. package/src/types/cxx.ts +18 -17
  80. package/src/useInitialTheme.ts +2 -2
  81. package/src/useStyles.ts +2 -2
  82. package/src/useUnistyles.ts +12 -24
  83. package/src/utils/breakpoints.ts +18 -4
  84. package/src/utils/common.ts +6 -0
  85. package/src/utils/index.ts +1 -1
  86. package/src/utils/mediaQueries.ts +18 -6
  87. package/ios/UnistylesRuntime.h +0 -48
  88. package/ios/UnistylesRuntime.mm +0 -228
  89. package/lib/typescript/examples/expo/src/App.d.ts +0 -3
  90. package/lib/typescript/examples/expo/src/App.d.ts.map +0 -1
  91. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts +0 -3
  92. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts.map +0 -1
  93. package/lib/typescript/examples/expo/src/examples/index.d.ts +0 -2
  94. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +0 -1
  95. package/lib/typescript/examples/expo/src/index.d.ts +0 -2
  96. package/lib/typescript/examples/expo/src/index.d.ts.map +0 -1
  97. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +0 -8
  98. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +0 -1
  99. package/lib/typescript/examples/expo/src/styles/index.d.ts +0 -16
  100. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +0 -1
  101. package/lib/typescript/examples/expo/src/styles/theme.d.ts +0 -40
  102. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +0 -1
@@ -0,0 +1,4 @@
1
+ #include <string>
2
+
3
+ std::string getColorScheme();
4
+ NSString* cxxStringToNSString(std::string);
@@ -0,0 +1,20 @@
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
+ NSString* cxxStringToNSString(std::string cxxString) {
19
+ return [NSString stringWithUTF8String:cxxString.c_str()];
20
+ }
@@ -2,11 +2,9 @@
2
2
  #import <React/RCTEventEmitter.h>
3
3
  #import <string>
4
4
 
5
- typedef void(^UnistylesThemeChangeEvent)(std::string);
6
- typedef void(^UnistylesBreakpointChangeEvent)(std::string);
7
-
8
5
  @interface UnistylesModule : RCTEventEmitter<RCTBridgeModule>
9
6
 
7
+ @property (nonatomic, assign) BOOL hasListeners;
10
8
  @property (nonatomic, assign) void* unistylesRuntime;
11
9
 
12
10
  @end
@@ -1,35 +1,49 @@
1
1
  #import "UnistylesModule.h"
2
+ #import "UnistylesHelpers.h"
2
3
  #import "UnistylesRuntime.h"
3
- #import "UnistylesModule.h"
4
-
5
4
 
6
5
  #import <React/RCTAppearance.h>
7
6
  #import <React/RCTBridge+Private.h>
8
7
  #import <jsi/jsi.h>
9
8
 
10
- @implementation UnistylesModule
11
-
12
- BOOL hasListeners;
13
-
14
9
  using namespace facebook;
15
10
 
11
+ @implementation UnistylesModule
12
+
16
13
  RCT_EXPORT_MODULE(Unistyles)
17
14
 
15
+ #pragma mark - Lifecycle
16
+
18
17
  - (instancetype)init {
19
18
  if ((self = [super init])) {
20
19
  [[NSNotificationCenter defaultCenter] addObserver:self
21
20
  selector:@selector(handleOrientationChange:)
22
21
  name:UIDeviceOrientationDidChangeNotification
23
22
  object:nil];
24
- // todo from iOS 13
25
23
  [[NSNotificationCenter defaultCenter] addObserver:self
26
- selector:@selector(appearanceChanged:)
27
- name:RCTUserInterfaceStyleDidChangeNotification
28
- object:nil];
24
+ selector:@selector(appearanceChanged:)
25
+ name:RCTUserInterfaceStyleDidChangeNotification
26
+ object:nil];
29
27
  }
28
+
30
29
  return self;
31
30
  }
32
31
 
32
+ - (void)dealloc {
33
+ if (self.unistylesRuntime != nullptr) {
34
+ delete (UnistylesRuntime*)self.unistylesRuntime;
35
+ }
36
+
37
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
38
+ }
39
+
40
+
41
+ + (BOOL)requiresMainQueueSetup {
42
+ return YES;
43
+ }
44
+
45
+ #pragma mark - Event handlers
46
+
33
47
  - (void)handleOrientationChange:(NSNotification *)notification {
34
48
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
35
49
  CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
@@ -39,38 +53,33 @@ RCT_EXPORT_MODULE(Unistyles)
39
53
  });
40
54
  }
41
55
 
42
- - (void)appearanceChanged:(NSNotification *)notification
43
- {
44
- std::string colorScheme = [self getColorScheme];
56
+ - (void)appearanceChanged:(NSNotification *)notification {
57
+ std::string colorScheme = getColorScheme();
45
58
 
46
- ((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
59
+ ((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
47
60
  }
48
61
 
49
- - (std::string)getColorScheme {
50
- UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
51
-
52
- // todo enums
53
- switch (colorScheme) {
54
- case UIUserInterfaceStyleLight:
55
- return "light";
56
- case UIUserInterfaceStyleDark:
57
- return "dark";
58
- case UIUserInterfaceStyleUnspecified:
59
- default:
60
- return "";
61
- }
62
+ #pragma mark - Event emitter
63
+ - (NSArray<NSString *> *)supportedEvents {
64
+ return @[@"onChange"];
62
65
  }
63
66
 
64
- - (void)dealloc {
65
- delete (UnistylesRuntime*)self.unistylesRuntime;
66
- [[NSNotificationCenter defaultCenter] removeObserver:self];
67
+ - (void)startObserving {
68
+ self.hasListeners = YES;
67
69
  }
68
70
 
69
- + (BOOL)requiresMainQueueSetup
70
- {
71
- return YES;
71
+ - (void)stopObserving {
72
+ self.hasListeners = NO;
72
73
  }
73
74
 
75
+ - (void)emitEvent:(NSString *)eventName withBody:(NSDictionary *)body {
76
+ if (self.hasListeners) {
77
+ [self sendEventWithName:@"onChange" body:body];
78
+ }
79
+ }
80
+
81
+ #pragma mark - Core
82
+
74
83
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
75
84
  {
76
85
  NSLog(@"Installing Unistyles 🦄...");
@@ -79,13 +88,13 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
79
88
  RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
80
89
 
81
90
  if (cxxBridge == nil) {
82
- return @false;
91
+ return @false;
83
92
  }
84
93
 
85
94
  auto jsiRuntime = (jsi::Runtime*)cxxBridge.runtime;
86
95
 
87
96
  if (jsiRuntime == nil) {
88
- return @false;
97
+ return @false;
89
98
  }
90
99
 
91
100
  auto& runtime = *jsiRuntime;
@@ -98,66 +107,52 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
98
107
  return @true;
99
108
  }
100
109
 
101
- - (NSArray<NSString *> *)supportedEvents {
102
- return @[@"onChange"];
103
- }
104
-
105
- - (void)startObserving
106
- {
107
- hasListeners = YES;
108
- }
109
-
110
- - (void)stopObserving
111
- {
112
- hasListeners = NO;
113
- }
114
-
115
- - (void)emitEvent:(NSString *)eventName withBody:(NSDictionary *)body {
116
- if (hasListeners) {
117
- [self sendEventWithName:@"onChange" body:body];
118
- }
119
- }
120
110
 
121
111
  void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSelf) {
122
112
  CGFloat initialScreenWidth = [UIScreen mainScreen].bounds.size.width;
123
113
  CGFloat initialScreenHeight = [UIScreen mainScreen].bounds.size.height;
124
- std::string initalColorScheme = [weakSelf getColorScheme];
114
+ std::string initialColorScheme = getColorScheme();
125
115
  UnistylesThemeChangeEvent onThemeChange = ^(std::string theme) {
126
- NSString *nextTheme = [NSString stringWithUTF8String:theme.c_str()];
127
116
  NSDictionary *body = @{
128
117
  @"type": @"theme",
129
118
  @"payload": @{
130
- @"themeName": nextTheme
119
+ @"themeName": cxxStringToNSString(theme)
131
120
  }
132
121
  };
133
-
122
+
134
123
  [weakSelf emitEvent:@"onChange" withBody:body];
135
124
  };
136
- UnistylesBreakpointChangeEvent onBreakpointChange = ^(std::string breakpoint) {
137
- NSString *nextBreakpoint = [NSString stringWithUTF8String:breakpoint.c_str()];
125
+ UnistylesBreakpointChangeEvent onBreakpointChange = ^(std::string breakpoint, int orientation, int width, int height) {
138
126
  NSDictionary *body = @{
139
- @"type": @"breakpoint",
127
+ @"type": @"layout",
140
128
  @"payload": @{
141
- @"breakpoint": nextBreakpoint
129
+ @"breakpoint": cxxStringToNSString(breakpoint),
130
+ @"orientation": @(orientation),
131
+ @"screen": @{
132
+ @"width": @(width),
133
+ @"height": @(height)
134
+ }
142
135
  }
143
136
  };
144
-
137
+
145
138
  [weakSelf emitEvent:@"onChange" withBody:body];
146
139
  };
147
-
140
+
148
141
  auto unistylesRuntime = std::make_shared<UnistylesRuntime>(
149
142
  onThemeChange,
150
143
  onBreakpointChange,
151
144
  (int)initialScreenWidth,
152
145
  (int)initialScreenHeight,
153
- initalColorScheme
146
+ initialColorScheme
154
147
  );
155
-
148
+
156
149
  weakSelf.unistylesRuntime = unistylesRuntime.get();
157
150
 
158
151
  auto hostObject = jsi::Object::createFromHostObject(runtime, unistylesRuntime);
159
-
152
+
160
153
  runtime.global().setProperty(runtime, "__UNISTYLES__", std::move(hostObject));
161
154
  }
162
155
 
163
156
  @end
157
+
158
+ #pragma mark - End
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.UnistyleRegistry = void 0;
7
7
  class UnistyleRegistry {
8
8
  config = {};
9
+ themeNames = [];
9
10
  themes = {};
10
11
  breakpoints = {};
11
12
  sortedBreakpointPairs = [];
@@ -14,7 +15,9 @@ class UnistyleRegistry {
14
15
  }
15
16
  addThemes = themes => {
16
17
  this.themes = themes;
17
- this.unistylesBridge.themes = Object.keys(themes);
18
+ const keys = Object.keys(themes);
19
+ this.unistylesBridge.themes = keys;
20
+ this.themeNames = keys;
18
21
  return this;
19
22
  };
20
23
  addBreakpoints = breakpoints => {
@@ -29,6 +32,14 @@ class UnistyleRegistry {
29
32
  }
30
33
  return this;
31
34
  };
35
+ dangerouslyUnregister = () => {
36
+ this.config = {};
37
+ this.themeNames = [];
38
+ this.themes = {};
39
+ this.breakpoints = {};
40
+ this.sortedBreakpointPairs = [];
41
+ this.unistylesBridge.unregister();
42
+ };
32
43
  }
33
44
  exports.UnistyleRegistry = UnistyleRegistry;
34
45
  //# sourceMappingURL=UnistyleRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["UnistyleRegistry","config","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","Object","keys","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","exports"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":";;;;;;AAGO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,MAAM,CAACC,IAAI,CAACP,MAAM,CAAiC;IAEjF,OAAO,IAAI;EACf,CAAC;EAEMQ,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACG,eAAe,CAACK,cAAc,CAACR,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMQ,SAAS,GAAIX,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACY,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACb,MAAM,CAACY,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;AACL;AAACE,OAAA,CAAAf,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","dangerouslyUnregister","unregister","exports"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":";;;;;;AAGO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO,IAAI;EACf,CAAC;EAEME,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACG,eAAe,CAACK,cAAc,CAACR,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMQ,SAAS,GAAIZ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACa,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACd,MAAM,CAACa,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;EAEME,qBAAqB,GAAGA,CAAA,KAAM;IACjC,IAAI,CAACf,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAACC,UAAU,GAAG,EAAE;IACpB,IAAI,CAACC,MAAM,GAAG,CAAC,CAAoB;IACnC,IAAI,CAACC,WAAW,GAAG,CAAC,CAAyB;IAC7C,IAAI,CAACC,qBAAqB,GAAG,EAAE;IAE/B,IAAI,CAACE,eAAe,CAACU,UAAU,CAAC,CAAC;EACrC,CAAC;AACL;AAACC,OAAA,CAAAlB,gBAAA,GAAAA,gBAAA"}
@@ -20,7 +20,7 @@ class UnistylesRuntime {
20
20
  return this.registry.sortedBreakpointPairs;
21
21
  }
22
22
  get themeName() {
23
- return this.unistylesBridge.theme;
23
+ return this.unistylesBridge.themeName;
24
24
  }
25
25
  get breakpoint() {
26
26
  return this.unistylesBridge.breakpoint;
@@ -46,9 +46,12 @@ class UnistylesRuntime {
46
46
  this.unistylesBridge.useTheme(name);
47
47
  return true;
48
48
  }
49
- return false;
49
+ throw new Error(_types.UnistylesError.ThemeNotRegistered);
50
50
  };
51
51
  getTheme = forName => {
52
+ if (this.registry.themeNames.length === 0) {
53
+ return {};
54
+ }
52
55
  if (!this.hasTheme(forName)) {
53
56
  throw new Error(_types.UnistylesError.ThemeNotFound);
54
57
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","theme","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","getTheme","forName","Error","UnistylesError","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes","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,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,QAAQ,CAACI,qBAAqB;EAC9C;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACN,eAAe,CAACO,KAAK;EACrC;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACR,eAAe,CAACQ,UAAU;EAC1C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACV,eAAe,CAACW,WAAW;MACvCC,MAAM,EAAE,IAAI,CAACZ,eAAe,CAACa;IACjC,CAAC;EACL;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,MAAM;MAAEJ,KAAK;MAAEE;IAAO,CAAC,GAAG,IAAI,CAACH,MAAM;IAErC,IAAIC,KAAK,GAAGE,MAAM,EAAE;MAChB,OAAOG,wBAAiB,CAACC,SAAS;IACtC;IAEA,OAAOD,wBAAiB,CAACE,QAAQ;EACrC;EAEOC,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAIA,IAAI,KAAK,IAAI,CAACb,SAAS,IAAI,IAAI,CAACc,QAAQ,CAACD,IAAI,CAAC,EAAE;MAChD,IAAI,CAACnB,eAAe,CAACqB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,OAAO,KAAK;EAChB,CAAC;EAEMG,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,CAAC,IAAI,CAACH,QAAQ,CAACG,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIC,KAAK,CAACC,qBAAc,CAACC,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAACzB,QAAQ,CAAC0B,MAAM,CAACJ,OAAO,CAAC;EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC7B,eAAe,CAAC8B,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOT,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAClB,QAAQ,CAAC0B,MAAM;AACpF;AAACI,OAAA,CAAAjC,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_types","require","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes","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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,QAAQ,CAACM,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIJ,KAAK,CAACC,qBAAc,CAACM,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAAC3B,QAAQ,CAAC4B,MAAM,CAACJ,OAAO,CAAC;EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC/B,eAAe,CAACgC,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOZ,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACjB,QAAQ,CAAC4B,MAAM;AACpF;AAACI,OAAA,CAAAnC,gBAAA,GAAAA,gBAAA"}
@@ -5,13 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useDimensions = void 0;
7
7
  var _react = require("react");
8
- var _utils = require("../utils");
9
8
  const useDimensions = () => {
10
9
  const timerRef = (0, _react.useRef)();
11
- const [screenSize, setScreenSize] = (0, _react.useState)({
12
- width: _utils.isServer ? 0 : window.innerWidth,
13
- height: _utils.isServer ? 0 : window.innerHeight
14
- });
10
+ const [screenSize, setScreenSize] = (0, _react.useState)({});
11
+ (0, _react.useLayoutEffect)(() => {
12
+ setScreenSize({
13
+ width: window.innerWidth,
14
+ height: window.innerHeight
15
+ });
16
+ }, []);
15
17
  (0, _react.useEffect)(() => {
16
18
  const handleResize = () => {
17
19
  clearTimeout(timerRef.current);
@@ -1 +1 @@
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"}
1
+ {"version":3,"names":["_react","require","useDimensions","timerRef","useRef","screenSize","setScreenSize","useState","useLayoutEffect","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,CAAC,CAAe,CAAC;EAE1E,IAAAC,sBAAe,EAAC,MAAM;IAClBF,aAAa,CAAC;MACVG,KAAK,EAAEC,MAAM,CAACC,UAAU;MACxBC,MAAM,EAAEF,MAAM,CAACG;IACnB,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAEN,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;QAC9CG,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,CAACb,QAAQ,CAACc,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOZ,UAAU;AACrB,CAAC;AAAAgB,OAAA,CAAAnB,aAAA,GAAAA,aAAA"}
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "ScreenOrientation", {
9
9
  return _types.ScreenOrientation;
10
10
  }
11
11
  });
12
- exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
12
+ exports.__dangerouslyUnregister = exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
13
13
  Object.defineProperty(exports, "createStyleSheet", {
14
14
  enumerable: true,
15
15
  get: function () {
@@ -44,4 +44,5 @@ const UnistylesRegistry = exports.UnistylesRegistry = {
44
44
  addBreakpoints,
45
45
  addConfig
46
46
  };
47
+ const __dangerouslyUnregister = exports.__dangerouslyUnregister = _Unistyles.unistyles.registry.dangerouslyUnregister;
47
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Unistyles","require","_types","_useInitialTheme","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,MAAM;EAAEK,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGC,oBAAS,CAACC,QAAQ;AACpE,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGF,oBAAS,CAACI,OAAO;AAC1C,MAAMC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,GAAG;EACtBR,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC"}
1
+ {"version":3,"names":["_Unistyles","require","_types","_useInitialTheme","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,MAAM;EAAEK,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGC,oBAAS,CAACC,QAAQ;AACpE,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGF,oBAAS,CAACI,OAAO;AAC1C,MAAMC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,GAAG;EACtBR,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC;AAEM,MAAMO,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAGN,oBAAS,CAACC,QAAQ,CAACM,qBAAqB"}
@@ -11,13 +11,16 @@ let ScreenOrientation = exports.ScreenOrientation = /*#__PURE__*/function (Scree
11
11
  }({});
12
12
  let CxxUnistylesEventTypes = exports.CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
13
13
  CxxUnistylesEventTypes["Theme"] = "theme";
14
- CxxUnistylesEventTypes["Size"] = "size";
15
- CxxUnistylesEventTypes["Breakpoint"] = "breakpoint";
14
+ CxxUnistylesEventTypes["Layout"] = "layout";
16
15
  return CxxUnistylesEventTypes;
17
16
  }({});
18
17
  let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesError) {
19
18
  UnistylesError["RuntimeUnavailable"] = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE";
20
19
  UnistylesError["ThemeNotFound"] = "UNISTYLES_ERROR_THEME_NOT_FOUND";
20
+ UnistylesError["ThemeNotRegistered"] = "UNISTYLES_ERROR_THEME_NOT_REGISTERED";
21
+ UnistylesError["ThemesCannotBeEmpty"] = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY";
22
+ UnistylesError["BreakpointsCannotBeEmpty"] = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY";
23
+ UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
21
24
  return UnistylesError;
22
25
  }({});
23
26
  //# sourceMappingURL=cxx.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ScreenOrientation","exports","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":";;;;;;IASYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAsBjBE,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IA8BtBC,cAAc,GAAAF,OAAA,CAAAE,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
1
+ {"version":3,"names":["ScreenOrientation","exports","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":";;;;;;IAUYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAyBjBE,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAuBtBC,cAAc,GAAAF,OAAA,CAAAE,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
@@ -7,7 +7,7 @@ exports.useInitialTheme = void 0;
7
7
  var _react = require("react");
8
8
  var _Unistyles = require("./Unistyles");
9
9
  const useInitialTheme = forName => {
10
- (0, _react.useRef)(_Unistyles.unistyles.runtime.setTheme(forName));
10
+ (0, _react.useMemo)(() => _Unistyles.unistyles.runtime.setTheme(forName), []);
11
11
  };
12
12
  exports.useInitialTheme = useInitialTheme;
13
13
  //# sourceMappingURL=useInitialTheme.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Unistyles","useInitialTheme","forName","useRef","unistyles","runtime","setTheme","exports"],"sourceRoot":"../../src","sources":["useInitialTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,eAAe,GAAIC,OAA8B,IAAK;EAC/D,IAAAC,aAAM,EAACC,oBAAS,CAACC,OAAO,CAACC,QAAQ,CAACJ,OAAO,CAAC,CAAC;AAC/C,CAAC;AAAAK,OAAA,CAAAN,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["_react","require","_Unistyles","useInitialTheme","forName","useMemo","unistyles","runtime","setTheme","exports"],"sourceRoot":"../../src","sources":["useInitialTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,eAAe,GAAIC,OAA8B,IAAK;EAC/D,IAAAC,cAAO,EAAC,MAAMC,oBAAS,CAACC,OAAO,CAACC,QAAQ,CAACJ,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1D,CAAC;AAAAK,OAAA,CAAAN,eAAA,GAAAA,eAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","_utils","_useUnistyles","useStyles","stylesheet","theme","breakpoint","screenSize","useUnistyles","styles","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","proxifyFunction","StyleSheet","create","parseStyle","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAGA;;AAGO,MAAMI,SAAS,GAAsCC,UAA4C,IAAK;EACzG,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAG,IAAAC,0BAAY,EAAC,CAAC;EAExD,IAAI,CAACJ,UAAU,EAAE;IACb,OAAO;MACHC,KAAK;MACLC,UAAU;MACVG,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOP,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACC,KAAM,CAAC,GAClBD,UAAU,EAAE,CAACC,KAAK,EAAED,UAAU,CAAC,CAAC;EAEtC,MAAMQ,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAME,MAAM,CACzCC,OAAO,CAACJ,YAAY,CAAC,CACrBK,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,MAAMG,KAAK,GAAGD,KAA8B;IAE5C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAG,IAAAG,sBAAe,EAACF,KAAK,EAAEb,UAAU,EAAGC,UAAU;MACzD,CAAC;IACL;IAEA,OAAOe,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGP,GAAG;MACN,CAACE,GAAG,GAAG,IAAAM,iBAAU,EAAKJ,KAAK,EAAEd,UAAU,EAAGC,UAAU;IACxD,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACD,UAAU,EAAEC,UAAU,EAAEG,YAAY,CAAC,CAAC;EAEzD,OAAO;IACHL,KAAK;IACLC,UAAU;IACVG,MAAM,EAAEG;EACZ,CAAC;AACL,CAAC;AAAAa,OAAA,CAAAtB,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_react","require","_reactNative","_utils","_useUnistyles","useStyles","stylesheet","theme","breakpoint","screenSize","useUnistyles","styles","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","proxifyFunction","StyleSheet","create","parseStyle","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,M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,CAAC;AACL,CAAC;AAAAa,OAAA,CAAAtB,SAAA,GAAAA,SAAA"}
@@ -10,11 +10,12 @@ var _types = require("./types");
10
10
  var _Unistyles = require("./Unistyles");
11
11
  const unistylesEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Unistyles);
12
12
  const useUnistyles = () => {
13
+ const [orientation, setOrientation] = (0, _react.useState)(_Unistyles.unistyles.runtime.orientation);
13
14
  const [theme, setTheme] = (0, _react.useState)(_Unistyles.unistyles.runtime.getTheme(_Unistyles.unistyles.runtime.themeName));
14
15
  const [breakpoint, setBreakpoint] = (0, _react.useState)(_Unistyles.unistyles.runtime.breakpoint);
15
16
  const [screenSize, setScreenSize] = (0, _react.useState)({
16
- width: 0,
17
- height: 0
17
+ width: _Unistyles.unistyles.runtime.screen.width,
18
+ height: _Unistyles.unistyles.runtime.screen.height
18
19
  });
19
20
  (0, _react.useEffect)(() => {
20
21
  const subscription = unistylesEvents.addListener('onChange', event => {
@@ -25,20 +26,12 @@ const useUnistyles = () => {
25
26
  setTheme(_Unistyles.unistyles.runtime.getTheme(themeEvent.payload.themeName));
26
27
  return;
27
28
  }
28
- // this event is not available on mobile
29
- case _types.CxxUnistylesEventTypes.Size:
29
+ case _types.CxxUnistylesEventTypes.Layout:
30
30
  {
31
- const sizeEvent = event;
32
- setScreenSize({
33
- width: sizeEvent.payload.width,
34
- height: sizeEvent.payload.height
35
- });
36
- return;
37
- }
38
- case _types.CxxUnistylesEventTypes.Breakpoint:
39
- {
40
- const breakpointEvent = event;
41
- setBreakpoint(breakpointEvent.payload.breakpoint);
31
+ const layoutEvent = event;
32
+ setBreakpoint(layoutEvent.payload.breakpoint);
33
+ setOrientation(layoutEvent.payload.orientation);
34
+ setScreenSize(layoutEvent.payload.screen);
42
35
  return;
43
36
  }
44
37
  default:
@@ -49,6 +42,7 @@ const useUnistyles = () => {
49
42
  }, []);
50
43
  return {
51
44
  theme,
45
+ orientation,
52
46
  breakpoint,
53
47
  screenSize
54
48
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_react","_types","_Unistyles","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","theme","setTheme","useState","unistyles","runtime","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","height","useEffect","subscription","addListener","event","type","CxxUnistylesEventTypes","Theme","themeEvent","payload","Size","sizeEvent","Breakpoint","breakpointEvent","remove","exports"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,oBAAS,CAACC,OAAO,CAACC,QAAQ,CAACF,oBAAS,CAACC,OAAO,CAACE,SAAS,CAAC,CAAC;EAC3F,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAN,eAAQ,EAACC,oBAAS,CAACC,OAAO,CAACG,UAAU,CAAC;EAC1E,MAAM,CAACE,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAR,eAAQ,EAAC;IACzCS,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC,CAAC;EAEF,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,YAAY,GAAGnB,eAAe,CAACoB,WAAW,CAC5C,UAAU,EACTC,KAAsB,IAAK;MACxB,QAAQA,KAAK,CAACC,IAAI;QACd,KAAKC,6BAAsB,CAACC,KAAK;UAAE;YAC/B,MAAMC,UAAU,GAAGJ,KAA+B;YAElDf,QAAQ,CAACE,oBAAS,CAACC,OAAO,CAACC,QAAQ,CAACe,UAAU,CAACC,OAAO,CAACf,SAAS,CAAC,CAAC;YAElE;UACJ;QACA;QACA,KAAKY,6BAAsB,CAACI,IAAI;UAAE;YAC9B,MAAMC,SAAS,GAAGP,KAA8B;YAEhDN,aAAa,CAAC;cACVC,KAAK,EAAEY,SAAS,CAACF,OAAO,CAACV,KAAK;cAC9BC,MAAM,EAAEW,SAAS,CAACF,OAAO,CAACT;YAC9B,CAAC,CAAC;YAEF;UACJ;QACA,KAAKM,6BAAsB,CAACM,UAAU;UAAE;YACpC,MAAMC,eAAe,GAAGT,KAAoC;YAE5DR,aAAa,CAACiB,eAAe,CAACJ,OAAO,CAACd,UAAU,CAAC;YAEjD;UACJ;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOO,YAAY,CAACY,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACH1B,KAAK;IACLO,UAAU;IACVE;EACJ,CAAC;AACL,CAAC;AAAAkB,OAAA,CAAA5B,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["_reactNative","require","_react","_types","_Unistyles","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","orientation","setOrientation","useState","unistyles","runtime","theme","setTheme","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","screen","height","useEffect","subscription","addListener","event","type","CxxUnistylesEventTypes","Theme","themeEvent","payload","Layout","layoutEvent","remove","exports"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAAoBC,oBAAS,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IACXS,UAAU;IACVE;EACJ,CAAC;AACL,CAAC;AAAAiB,OAAA,CAAA7B,YAAA,GAAAA,YAAA"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.sortAndValidateBreakpoints = exports.getValueForBreakpoint = exports.getBreakpointFromScreenWidth = void 0;
7
7
  var _Unistyles = require("../Unistyles");
8
8
  var _common = require("./common");
9
+ var _types = require("../types");
9
10
  var _mediaQueries = require("./mediaQueries");
10
11
  /**
11
12
  * Sorts the breakpoints object based on its numeric values in ascending order and validates them.
@@ -109,7 +110,16 @@ const getValueForBreakpoint = (value, breakpoint, screenSize) => {
109
110
  return value[customMediaQueryKey];
110
111
  }
111
112
 
112
- // if no custom media query, or didn't match, proceed with defined breakpoints
113
+ // at this point user didn't use custom media queries (:w, :h)
114
+ // check if user defined any breakpoints
115
+ const hasBreakpoints = _Unistyles.unistyles.runtime.sortedBreakpoints.length > 0;
116
+
117
+ // if not then we can fallback to horizontal and portrait (mobile only)
118
+ if (!hasBreakpoints && _common.isMobile && (_common.Orientation.Landscape in value || _common.Orientation.Portrait in value)) {
119
+ return value[_Unistyles.unistyles.runtime.orientation === _types.ScreenOrientation.Portrait ? _common.Orientation.Portrait : _common.Orientation.Landscape];
120
+ }
121
+
122
+ // if user defined breakpoints, then we look for the valid one
113
123
  const unifiedKey = breakpoint?.toLowerCase();
114
124
  const directBreakpoint = value[unifiedKey];
115
125
 
@@ -118,7 +128,7 @@ const getValueForBreakpoint = (value, breakpoint, screenSize) => {
118
128
  return directBreakpoint;
119
129
  }
120
130
 
121
- // there is no direct hit for breakpoint nor media-query, so let's simulate CSS cascading
131
+ // there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
122
132
  const breakpointPairs = _Unistyles.unistyles.runtime.sortedBreakpoints;
123
133
  const currentBreakpoint = breakpointPairs.findIndex(_ref3 => {
124
134
  let [key] = _ref3;
@@ -1 +1 @@
1
- {"version":3,"names":["_Unistyles","require","_common","_mediaQueries","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","isMediaQuery","customMediaQueryKey","getKeyForCustomMediaQuery","unifiedKey","toLowerCase","directBreakpoint","breakpointPairs","unistyles","runtime","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,eAAe,CAAC,GAAGF,gBAAgB;EAE1C,IAAIE,eAAe,KAAK,CAAC,EAAE;IACvB,IAAAC,kBAAU,EAAC,oCAAoC,CAAC;EACpD;EAEA,IAAIH,gBAAg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AmB,GAAG,IAAAC,uCAAyB,EAACL,kBAAkB,EAAED,UAAU,CAAuB;EAE3G,IAAIK,mBAAmB,IAAIA,mBAAmB,IAAIV,KAAK,EAAE;IACrD,OAAOA,KAAK,CAACU,mBAAmB,CAAC;EACrC;;EAEA;EACA,MAAME,UAAU,GAAGR,UAAU,EAAES,WAAW,CAAC,CAAuB;EAClE,MAAMC,gBAAgB,GAAGd,KAAK,CAACY,UAAU,CAAC;;EAE1C;EACA,IAAIE,gBAAgB,IAAKF,UAAU,IAAIZ,KAAM,EAAE;IAC3C,OAAOc,gBAAgB;EAC3B;;EAEA;EACA,MAAMC,eAAe,GAAGC,oBAAS,CAACC,OAAO,CAACpC,iBAAiB;EAC3D,MAAMqC,iBAAiB,GAAGH,eAAe,CACpCI,SAAS,CAACC,KAAA;IAAA,IAAC,CAACzB,GAAG,CAAC,GAAAyB,KAAA;IAAA,OAAKzB,GAAG,KAAKiB,UAAU;EAAA,EAAC;EAE7C,MAAMS,oBAAoB,GAAGN,eAAe,CACvCR,MAAM,CAAC,CAAAe,KAAA,EAAQxB,KAAK;IAAA,IAAZ,CAACH,GAAG,CAAC,GAAA2B,KAAA;IAAA,OAAYxB,KAAK,GAAGoB,iBAAiB,IAAIvB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1EuB,GAAG,CAACC,KAAA;IAAA,IAAC,CAAC7B,GAAG,CAAC,GAAA6B,KAAA;IAAA,OAAK7B,GAAG;EAAA,EAAC;EAExB,OAAOoB,eAAe,CAAC3B,MAAM,GAAG,CAAC,GAC3BY,KAAK,CAACqB,oBAAoB,CAACA,oBAAoB,CAACjC,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnGqC,SAAS;AACnB,CAAC;AAAAlC,OAAA,CAAAY,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_Unistyles","require","_common","_types","_mediaQueries","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","isMediaQuery","customMediaQueryKey","getKeyForCustomMediaQuery","hasBreakpoints","unistyles","runtime","isMobile","Orientation","Landscape","Portrait","orientation","ScreenOrientation","unifiedKey","toLowerCase","directBreakpoint","breakpointPairs","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,eAAe,CAAC,GAAGF,gBAAgB;EAE1C,IAAIE,eAAe,KAAK,CAAC,EAAE;IACvB,IAAAC,kBAAU,EAAC,oCAAoC,CAAC;EAC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A,EAAC,CAC1E8B,GAAG,CAACC,KAAA;IAAA,IAAC,CAACpC,GAAG,CAAC,GAAAoC,KAAA;IAAA,OAAKpC,GAAG;EAAA,EAAC;EAExB,OAAO6B,eAAe,CAACpC,MAAM,GAAG,CAAC,GAC3BY,KAAK,CAAC4B,oBAAoB,CAACA,oBAAoB,CAACxC,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnG4C,SAAS;AACnB,CAAC;AAAAzC,OAAA,CAAAY,qBAAA,GAAAA,qBAAA"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.warn = exports.throwError = exports.isWeb = exports.isServer = void 0;
6
+ exports.warn = exports.throwError = exports.isWeb = exports.isServer = exports.isMobile = exports.Orientation = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  const throwError = message => {
9
9
  throw new Error(`🦄 [react-native-unistyles]: ${message}`);
@@ -13,6 +13,11 @@ const warn = message => {
13
13
  console.warn(`🦄 [react-native-unistyles]: ${message}`);
14
14
  };
15
15
  exports.warn = warn;
16
+ const isMobile = exports.isMobile = _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios';
16
17
  const isWeb = exports.isWeb = _reactNative.Platform.OS === 'web';
17
18
  const isServer = exports.isServer = typeof window === 'undefined';
19
+ const Orientation = exports.Orientation = {
20
+ Landscape: 'landscape',
21
+ Portrait: 'portrait'
22
+ };
18
23
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","isWeb","Platform","OS","isServer","window"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAAAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEM,MAAMI,IAAI,GAAIH,OAAe,IAAK;EACrCI,OAAO,CAACD,IAAI,CAAE,gCAA+BH,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAEM,MAAME,KAAK,GAAAH,OAAA,CAAAG,KAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMC,QAAQ,GAAAN,OAAA,CAAAM,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW"}
1
+ {"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","isMobile","Platform","OS","isWeb","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAAAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEM,MAAMI,IAAI,GAAIH,OAAe,IAAK;EACrCI,OAAO,CAACD,IAAI,CAAE,gCAA+BH,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAEM,MAAME,QAAQ,GAAAH,OAAA,CAAAG,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAN,OAAA,CAAAM,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,QAAQ,GAAAP,OAAA,CAAAO,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,WAAW,GAAAT,OAAA,CAAAS,WAAA,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
@@ -11,6 +11,7 @@ var _exportNames = {
11
11
  proxifyFunction: true,
12
12
  parseStyle: true,
13
13
  isServer: true,
14
+ Orientation: true,
14
15
  extractValues: true,
15
16
  getKeyForCustomMediaQuery: true,
16
17
  isMediaQuery: true,
@@ -18,6 +19,12 @@ var _exportNames = {
18
19
  isWithinTheWidth: true,
19
20
  isWithinTheWidthAndHeight: true
20
21
  };
22
+ Object.defineProperty(exports, "Orientation", {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _common.Orientation;
26
+ }
27
+ });
21
28
  Object.defineProperty(exports, "extractValues", {
22
29
  enumerable: true,
23
30
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_breakpoints","_styles","_common","_mediaQueries"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,YAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA"}
1
+ {"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_breakpoints","_styles","_common","_mediaQueries"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,YAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA"}