react-native-unistyles 2.0.0-alpha.8 → 2.0.0-alpha.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/cxx/UnistylesRuntime.cpp +24 -31
  2. package/cxx/UnistylesRuntime.h +11 -12
  3. package/ios/UnistylesModule.mm +20 -20
  4. package/lib/commonjs/common.js +1 -1
  5. package/lib/commonjs/common.js.map +1 -1
  6. package/lib/commonjs/core/UnistyleRegistry.js +1 -8
  7. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  8. package/lib/commonjs/core/UnistylesRuntime.js +1 -1
  9. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  10. package/lib/commonjs/hooks/useInitialTheme.js +5 -1
  11. package/lib/commonjs/hooks/useInitialTheme.js.map +1 -1
  12. package/lib/commonjs/index.js +5 -11
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/utils/mqParser.js +2 -2
  15. package/lib/commonjs/utils/mqParser.js.map +1 -1
  16. package/lib/module/common.js +2 -0
  17. package/lib/module/common.js.map +1 -1
  18. package/lib/module/core/UnistyleRegistry.js +1 -8
  19. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  20. package/lib/module/core/UnistylesRuntime.js +1 -1
  21. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  22. package/lib/module/hooks/useInitialTheme.js +5 -1
  23. package/lib/module/hooks/useInitialTheme.js.map +1 -1
  24. package/lib/module/index.js +5 -12
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/utils/mqParser.js +2 -2
  27. package/lib/module/utils/mqParser.js.map +1 -1
  28. package/lib/typescript/src/common.d.ts.map +1 -1
  29. package/lib/typescript/src/core/UnistyleRegistry.d.ts +0 -1
  30. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  31. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -1
  32. package/lib/typescript/src/index.d.ts +2 -4
  33. package/lib/typescript/src/index.d.ts.map +1 -1
  34. package/lib/typescript/src/types/unistyles.d.ts +0 -1
  35. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/src/common.ts +1 -0
  38. package/src/core/UnistyleRegistry.ts +1 -10
  39. package/src/core/UnistylesRuntime.ts +1 -1
  40. package/src/hooks/useInitialTheme.ts +5 -1
  41. package/src/index.ts +8 -13
  42. package/src/types/unistyles.ts +1 -4
  43. package/src/utils/mqParser.ts +2 -2
@@ -98,11 +98,11 @@ jsi::Value UnistylesRuntime::get(jsi::Runtime& runtime, const jsi::PropNameID& p
98
98
  std::sort(sortedBreakpointEntriesVec.begin(), sortedBreakpointEntriesVec.end(), [](const std::pair<std::string, double>& a, const std::pair<std::string, double>& b) {
99
99
  return a.second < b.second;
100
100
  });
101
-
101
+
102
102
  if (sortedBreakpointEntriesVec.size() == 0) {
103
103
  throw jsi::JSError(runtime, UnistylesErrorBreakpointsCannotBeEmpty);
104
104
  }
105
-
105
+
106
106
  if (sortedBreakpointEntriesVec.at(0).second != 0) {
107
107
  throw jsi::JSError(runtime, UnistylesErrorBreakpointsMustStartFromZero);
108
108
  }
@@ -125,9 +125,11 @@ jsi::Value UnistylesRuntime::get(jsi::Runtime& runtime, const jsi::PropNameID& p
125
125
  [this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
126
126
  std::string themeName = arguments[0].asString(runtime).utf8(runtime);
127
127
 
128
- this->themeName = themeName;
129
- this->onThemeChange(themeName);
130
-
128
+ if (this->themeName != themeName) {
129
+ this->themeName = themeName;
130
+ this->onThemeChangeCallback(themeName);
131
+ }
132
+
131
133
  return jsi::Value::undefined();
132
134
  }
133
135
  );
@@ -145,26 +147,11 @@ jsi::Value UnistylesRuntime::get(jsi::Runtime& runtime, const jsi::PropNameID& p
145
147
  if (!enableAdaptiveThemes || !this->supportsAutomaticColorScheme) {
146
148
  return jsi::Value::undefined();
147
149
  }
148
-
149
- this->themeName = this->colorScheme;
150
- this->onThemeChange(this->themeName);
151
-
152
- return jsi::Value::undefined();
153
- }
154
- );
155
- }
156
-
157
- if (propName == "unregister") {
158
- return jsi::Function::createFromHostFunction(runtime,
159
- jsi::PropNameID::forAscii(runtime, "unregister"),
160
- 1,
161
- [this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
162
- this->hasAdaptiveThemes = false;
163
- this->supportsAutomaticColorScheme = false;
164
- this->themeName = "";
165
- this->breakpoint = "";
166
- this->themes.clear();
167
- this->sortedBreakpointPairs.clear();
150
+
151
+ if (this->themeName != this->colorScheme) {
152
+ this->themeName = this->colorScheme;
153
+ this->onThemeChangeCallback(this->themeName);
154
+ }
168
155
 
169
156
  return jsi::Value::undefined();
170
157
  }
@@ -190,12 +177,13 @@ void UnistylesRuntime::set(jsi::Runtime& runtime, const jsi::PropNameID& propNam
190
177
  themesVector.push_back(theme);
191
178
  }
192
179
  }
193
-
180
+
194
181
  if (themesVector.size() == 0) {
195
182
  throw jsi::JSError(runtime, UnistylesErrorThemesCannotBeEmpty);
196
183
  }
197
184
 
198
185
  this->themes = themesVector;
186
+ this->themeName = "";
199
187
 
200
188
  bool hasLightTheme = std::find(themesVector.begin(), themesVector.end(), "light") != themesVector.end();
201
189
  bool hasDarkTheme = std::find(themesVector.begin(), themesVector.end(), "dark") != themesVector.end();
@@ -224,16 +212,19 @@ std::string UnistylesRuntime::getBreakpointFromScreenWidth(int width, const std:
224
212
 
225
213
  void UnistylesRuntime::handleScreenSizeChange(int width, int height) {
226
214
  std::string breakpoint = this->getBreakpointFromScreenWidth(width, this->sortedBreakpointPairs);
215
+ bool shouldNotify = this->breakpoint != breakpoint || this->screenWidth != width || this->screenHeight != height;
227
216
 
228
217
  this->breakpoint = breakpoint;
229
218
  this->screenWidth = width;
230
219
  this->screenHeight = height;
231
-
220
+
232
221
  int orientation = width > height
233
222
  ? UnistylesOrientationLandscape
234
223
  : UnistylesOrientationPortrait;
235
224
 
236
- this->onBreakpointChange(breakpoint, orientation, width, height);
225
+ if (shouldNotify) {
226
+ this->onLayoutChangeCallback(breakpoint, orientation, width, height);
227
+ }
237
228
  }
238
229
 
239
230
  void UnistylesRuntime::handleAppearanceChange(std::string colorScheme) {
@@ -242,9 +233,11 @@ void UnistylesRuntime::handleAppearanceChange(std::string colorScheme) {
242
233
  if (!this->supportsAutomaticColorScheme || !this->hasAdaptiveThemes) {
243
234
  return;
244
235
  }
245
-
246
- this->themeName = this->colorScheme;
247
- this->onThemeChange(this->themeName);
236
+
237
+ if (this->themeName != this->colorScheme) {
238
+ this->onThemeChangeCallback(this->colorScheme);
239
+ this->themeName = this->colorScheme;
240
+ }
248
241
  }
249
242
 
250
243
  jsi::Value UnistylesRuntime::getThemeOrFail(jsi::Runtime& runtime) {
@@ -16,13 +16,10 @@ const std::string UnistylesErrorBreakpointsCannotBeEmpty = "UNISTYLES_ERROR_BREA
16
16
  const std::string UnistylesErrorBreakpointsMustStartFromZero = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZER0";
17
17
  const std::string UnistylesErrorThemesCannotBeEmpty = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY";
18
18
 
19
- typedef void(^UnistylesThemeChangeEvent)(std::string themeName);
20
- typedef void(^UnistylesBreakpointChangeEvent)(std::string breakpoint, int layout, int screenWidth, int screenHeight);
21
-
22
19
  class JSI_EXPORT UnistylesRuntime : public jsi::HostObject {
23
20
  private:
24
- UnistylesThemeChangeEvent onThemeChange;
25
- UnistylesBreakpointChangeEvent onBreakpointChange;
21
+ std::function<void(std::string)> onThemeChangeCallback;
22
+ std::function<void(std::string breakpoint, int layout, int screenWidth, int screenHeight)> onLayoutChangeCallback;
26
23
 
27
24
  int screenWidth;
28
25
  int screenHeight;
@@ -30,16 +27,10 @@ private:
30
27
 
31
28
  public:
32
29
  UnistylesRuntime(
33
- UnistylesThemeChangeEvent onThemeChange,
34
- UnistylesBreakpointChangeEvent onBreakpointChange,
35
30
  int screenWidth,
36
31
  int screenHeight,
37
32
  std::string colorScheme
38
- ): onThemeChange(onThemeChange),
39
- onBreakpointChange(onBreakpointChange),
40
- screenWidth(screenWidth),
41
- screenHeight(screenHeight),
42
- colorScheme(colorScheme) {}
33
+ ): screenWidth(screenWidth), screenHeight(screenHeight), colorScheme(colorScheme) {}
43
34
 
44
35
  bool hasAdaptiveThemes;
45
36
  bool supportsAutomaticColorScheme;
@@ -48,6 +39,14 @@ public:
48
39
  std::string breakpoint;
49
40
  std::vector<std::string> themes;
50
41
  std::vector<std::pair<std::string, double>> sortedBreakpointPairs;
42
+
43
+ void onThemeChange(std::function<void(std::string)> callback) {
44
+ this->onThemeChangeCallback = callback;
45
+ }
46
+
47
+ void onLayoutChange(std::function<void(std::string breakpoint, int layout, int screenWidth, int screenHeight)> callback) {
48
+ this->onLayoutChangeCallback = callback;
49
+ }
51
50
 
52
51
  jsi::Value get(jsi::Runtime&, const jsi::PropNameID& name) override;
53
52
  void set(jsi::Runtime& runtime, const jsi::PropNameID& propNameId, const jsi::Value& value) override;
@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE(Unistyles)
31
31
 
32
32
  - (void)dealloc {
33
33
  if (self.unistylesRuntime != nullptr) {
34
- delete (UnistylesRuntime*)self.unistylesRuntime;
34
+ self.unistylesRuntime = nullptr;
35
35
  }
36
36
 
37
37
  [[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -49,14 +49,18 @@ RCT_EXPORT_MODULE(Unistyles)
49
49
  CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
50
50
  CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
51
51
 
52
- ((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight);
52
+ if (self.unistylesRuntime != nullptr) {
53
+ ((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight);
54
+ }
53
55
  });
54
56
  }
55
57
 
56
58
  - (void)appearanceChanged:(NSNotification *)notification {
57
59
  std::string colorScheme = getColorScheme();
58
60
 
59
- ((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
61
+ if (self.unistylesRuntime != nullptr) {
62
+ ((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
63
+ }
60
64
  }
61
65
 
62
66
  #pragma mark - Event emitter
@@ -80,10 +84,7 @@ RCT_EXPORT_MODULE(Unistyles)
80
84
 
81
85
  #pragma mark - Core
82
86
 
83
- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
84
- {
85
- NSLog(@"Installing Unistyles 🦄...");
86
-
87
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
87
88
  RCTBridge* bridge = [RCTBridge currentBridge];
88
89
  RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
89
90
 
@@ -107,12 +108,18 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
107
108
  return @true;
108
109
  }
109
110
 
110
-
111
111
  void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSelf) {
112
112
  CGFloat initialScreenWidth = [UIScreen mainScreen].bounds.size.width;
113
113
  CGFloat initialScreenHeight = [UIScreen mainScreen].bounds.size.height;
114
114
  std::string initialColorScheme = getColorScheme();
115
- UnistylesThemeChangeEvent onThemeChange = ^(std::string theme) {
115
+
116
+ auto unistylesRuntime = std::make_shared<UnistylesRuntime>(
117
+ (int)initialScreenWidth,
118
+ (int)initialScreenHeight,
119
+ initialColorScheme
120
+ );
121
+
122
+ unistylesRuntime.get()->onThemeChange([=](std::string theme) {
116
123
  NSDictionary *body = @{
117
124
  @"type": @"theme",
118
125
  @"payload": @{
@@ -121,8 +128,9 @@ void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSel
121
128
  };
122
129
 
123
130
  [weakSelf emitEvent:@"onChange" withBody:body];
124
- };
125
- UnistylesBreakpointChangeEvent onBreakpointChange = ^(std::string breakpoint, int orientation, int width, int height) {
131
+ });
132
+
133
+ unistylesRuntime.get()->onLayoutChange([=](std::string breakpoint, int orientation, int width, int height) {
126
134
  NSDictionary *body = @{
127
135
  @"type": @"layout",
128
136
  @"payload": @{
@@ -136,15 +144,7 @@ void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSel
136
144
  };
137
145
 
138
146
  [weakSelf emitEvent:@"onChange" withBody:body];
139
- };
140
-
141
- auto unistylesRuntime = std::make_shared<UnistylesRuntime>(
142
- onThemeChange,
143
- onBreakpointChange,
144
- (int)initialScreenWidth,
145
- (int)initialScreenHeight,
146
- initialColorScheme
147
- );
147
+ });
148
148
 
149
149
  weakSelf.unistylesRuntime = unistylesRuntime.get();
150
150
 
@@ -17,7 +17,7 @@ let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesEr
17
17
  UnistylesError["BreakpointsCannotBeEmpty"] = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY";
18
18
  UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
19
19
  return UnistylesError;
20
- }({});
20
+ }({}); // todo to string?
21
21
  let ScreenOrientation = exports.ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
22
22
  ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
23
23
  ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
@@ -1 +1 @@
1
- {"version":3,"names":["CxxUnistylesEventTypes","exports","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;IAAYA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAKtBE,cAAc,GAAAD,OAAA,CAAAC,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAAA,IASdC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
1
+ {"version":3,"names":["CxxUnistylesEventTypes","exports","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;IAAYA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAKtBE,cAAc,GAAAD,OAAA,CAAAC,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA,OAS1B;AAAA,IACYC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
@@ -21,6 +21,7 @@ class UnistyleRegistry {
21
21
  return this;
22
22
  };
23
23
  addBreakpoints = breakpoints => {
24
+ this.breakpoints = breakpoints;
24
25
  this.unistylesBridge.useBreakpoints(breakpoints);
25
26
  this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
26
27
  return this;
@@ -32,14 +33,6 @@ class UnistyleRegistry {
32
33
  }
33
34
  return this;
34
35
  };
35
- dangerouslyUnregister = () => {
36
- this.config = {};
37
- this.themeNames = [];
38
- this.themes = {};
39
- this.breakpoints = {};
40
- this.sortedBreakpointPairs = [];
41
- this.unistylesBridge.unregister();
42
- };
43
36
  }
44
37
  exports.UnistyleRegistry = UnistyleRegistry;
45
38
  //# sourceMappingURL=UnistyleRegistry.js.map
@@ -1 +1 @@
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":["core/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"}
1
+ {"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","exports"],"sourceRoot":"../../../src","sources":["core/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,CAACA,WAAW,GAAGA,WAAW;IAC9B,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;AACL;AAACE,OAAA,CAAAhB,gBAAA,GAAAA,gBAAA"}
@@ -42,7 +42,7 @@ class UnistylesRuntime {
42
42
  return _common.ScreenOrientation.Portrait;
43
43
  }
44
44
  setTheme = name => {
45
- if (name !== this.themeName && this.hasTheme(name)) {
45
+ if (this.hasTheme(name)) {
46
46
  this.unistylesBridge.useTheme(name);
47
47
  return true;
48
48
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_common","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":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,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,C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CAAC;EAClD,CAAC;EAEOZ,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACjB,QAAQ,CAAC4B,MAAM;AACpF;AAACI,OAAA,CAAAnC,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_common","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":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,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,CAACM,SAAS;EACzC;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACP,eAAe,CAACO,UAAU;EAC1C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACT,eAAe,CAACU,WAAW;MACvCC,MAAM,EAAE,IAAI,CAACX,eAAe,CAACY;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,yBAAiB,CAACC,SAAS;IACtC;IAEA,OAAOD,yBAAiB,CAACE,QAAQ;EACrC;EAEOC,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAI,IAAI,CAACC,QAAQ,CAACD,IAAI,CAAC,EAAE;MACrB,IAAI,CAAClB,eAAe,CAACoB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,MAAM,IAAIG,KAAK,CAACC,sBAAc,CAACC,kBAAkB,CAAC;EACtD,CAAC;EAEMC,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,IAAI,CAACxB,QAAQ,CAACyB,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;MACvC,OAAO,CAAC,CAAC;IACb;IAEA,IAAI,CAAC,IAAI,CAACR,QAAQ,CAACM,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIJ,KAAK,CAACC,sBAAc,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"}
@@ -7,7 +7,11 @@ exports.useInitialTheme = void 0;
7
7
  var _react = require("react");
8
8
  var _core = require("../core");
9
9
  const useInitialTheme = forName => {
10
- (0, _react.useMemo)(() => _core.unistyles.runtime.setTheme(forName), []);
10
+ (0, _react.useMemo)(() => {
11
+ if (!_core.unistyles.runtime.themeName) {
12
+ _core.unistyles.runtime.setTheme(forName);
13
+ }
14
+ }, []);
11
15
  };
12
16
  exports.useInitialTheme = useInitialTheme;
13
17
  //# sourceMappingURL=useInitialTheme.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_core","useInitialTheme","forName","useMemo","unistyles","runtime","setTheme","exports"],"sourceRoot":"../../../src","sources":["hooks/useInitialTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAGO,MAAME,eAAe,GAAIC,OAA8B,IAAK;EAC/D,IAAAC,cAAO,EAAC,MAAMC,eAAS,CAACC,OAAO,CAACC,QAAQ,CAACJ,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1D,CAAC;AAAAK,OAAA,CAAAN,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["_react","require","_core","useInitialTheme","forName","useMemo","unistyles","runtime","themeName","setTheme","exports"],"sourceRoot":"../../../src","sources":["hooks/useInitialTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAGO,MAAME,eAAe,GAAIC,OAA8B,IAAK;EAC/D,IAAAC,cAAO,EAAC,MAAM;IACV,IAAI,CAACC,eAAS,CAACC,OAAO,CAACC,SAAS,EAAE;MAC9BF,eAAS,CAACC,OAAO,CAACE,QAAQ,CAACL,OAAO,CAAC;IACvC;EACJ,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAAAM,OAAA,CAAAP,eAAA,GAAAA,eAAA"}
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "ScreenOrientation", {
9
9
  return _common.ScreenOrientation;
10
10
  }
11
11
  });
12
- exports.__dangerouslyUnregister = exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
12
+ exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
13
13
  Object.defineProperty(exports, "createStyleSheet", {
14
14
  enumerable: true,
15
15
  get: function () {
@@ -40,16 +40,10 @@ var _hooks = require("./hooks");
40
40
  var _common = require("./common");
41
41
  var _useStyles = require("./useStyles");
42
42
  var _createStyleSheet = require("./createStyleSheet");
43
- const {
44
- addThemes,
45
- addBreakpoints,
46
- addConfig
47
- } = _core.unistyles.registry;
48
- const UnistylesRuntime = exports.UnistylesRuntime = _core.unistyles.runtime;
49
43
  const UnistylesRegistry = exports.UnistylesRegistry = {
50
- addThemes,
51
- addBreakpoints,
52
- addConfig
44
+ addThemes: _core.unistyles.registry.addThemes,
45
+ addBreakpoints: _core.unistyles.registry.addBreakpoints,
46
+ addConfig: _core.unistyles.registry.addConfig
53
47
  };
54
- const __dangerouslyUnregister = exports.__dangerouslyUnregister = _core.unistyles.registry.dangerouslyUnregister;
48
+ const UnistylesRuntime = exports.UnistylesRuntime = _core.unistyles.runtime;
55
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_core","require","_utils","_hooks","_common","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,MAAM;EAAEM,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGC,eAAS,CAACC,QAAQ;AACpE,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGF,eAAS,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,eAAS,CAACC,QAAQ,CAACM,qBAAqB"}
1
+ {"version":3,"names":["_core","require","_utils","_hooks","_common","_useStyles","_createStyleSheet","UnistylesRegistry","exports","addThemes","unistyles","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,MAAMM,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EACtBE,SAAS,EAAEC,eAAS,CAACC,QAAQ,CAACF,SAAS;EACvCG,cAAc,EAAEF,eAAS,CAACC,QAAQ,CAACC,cAAc;EACjDC,SAAS,EAAEH,eAAS,CAACC,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAAN,OAAA,CAAAM,gBAAA,GAAGJ,eAAS,CAACK,OAAO"}
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getKeyForUnistylesMediaQuery = void 0;
7
7
  const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
8
- const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/g;
9
- const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/g;
8
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
9
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
10
10
  const parseMq = mq => {
11
11
  const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
12
12
  const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
@@ -1 +1 @@
1
- {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at","exports"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,sCAAsC;AACpE,MAAMC,sBAAsB,GAAG,sCAAsC;AAYrE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,IAAI,EAAEC,MAAM,CAACH,KAAK,CAAC;MACnBI,EAAE,EAAED,MAAM,CAACF,GAAG;IAClB,CAAC,GAAGI;EACR,CAAC;AACL,CAAC;AAED,MAAMC,aAAa,GAAIZ,EAAU,IAAKJ,kBAAkB,CAACiB,IAAI,CAACb,EA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B,YAAoB,KAAc;EAC9F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOgB,YAAY,IAAIb,IAAI,IAAIa,YAAY,IAAIX,EAAE;AACrD,CAAC;AAEM,MAAMY,4BAA4B,GAAGA,CAACC,YAAwB,EAAEN,UAAsB,KAAK;EAC9F,MAAMjB,EAAE,GAAGuB,YAAY,CAACC,IAAI,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IAC/B,IAAI,CAACb,aAAa,CAACc,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMX,QAAQ,GAAGhB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACZ,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAC,OAAA,CAAAN,4BAAA,GAAAA,4BAAA"}
1
+ {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at","exports"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAA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,CAAAN,4BAAA,GAAAA,4BAAA"}
@@ -12,6 +12,8 @@ export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
12
12
  UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
13
13
  return UnistylesError;
14
14
  }({});
15
+
16
+ // todo to string?
15
17
  export let ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
16
18
  ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
17
19
  ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
@@ -1 +1 @@
1
- {"version":3,"names":["CxxUnistylesEventTypes","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAKlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAS1B,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
1
+ {"version":3,"names":["CxxUnistylesEventTypes","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAKlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;;AAS1B;AACA,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
@@ -15,6 +15,7 @@ export class UnistyleRegistry {
15
15
  return this;
16
16
  };
17
17
  addBreakpoints = breakpoints => {
18
+ this.breakpoints = breakpoints;
18
19
  this.unistylesBridge.useBreakpoints(breakpoints);
19
20
  this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
20
21
  return this;
@@ -26,13 +27,5 @@ export class UnistyleRegistry {
26
27
  }
27
28
  return this;
28
29
  };
29
- dangerouslyUnregister = () => {
30
- this.config = {};
31
- this.themeNames = [];
32
- this.themes = {};
33
- this.breakpoints = {};
34
- this.sortedBreakpointPairs = [];
35
- this.unistylesBridge.unregister();
36
- };
37
30
  }
38
31
  //# sourceMappingURL=UnistyleRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","dangerouslyUnregister","unregister"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,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"}
1
+ {"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,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,CAACA,WAAW,GAAGA,WAAW;IAC9B,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;AACL"}
@@ -36,7 +36,7 @@ export class UnistylesRuntime {
36
36
  return ScreenOrientation.Portrait;
37
37
  }
38
38
  setTheme = name => {
39
- if (name !== this.themeName && this.hasTheme(name)) {
39
+ if (this.hasTheme(name)) {
40
40
  this.unistylesBridge.useTheme(name);
41
41
  return true;
42
42
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ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,CAAC;EACtD,CAAC;EAEMC,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,IAAI,CAACtB,QAAQ,CAACuB,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;MACvC,OAAO,CAAC,CAAC;IACb;IAEA,IAAI,CAAC,IAAI,CAACP,QAAQ,CAACK,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIH,KAAK,CAACvB,cAAc,CAAC6B,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;EAEOX,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAChB,QAAQ,CAAC0B,MAAM;AACpF"}
1
+ {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D,OAAO,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,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EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC7B,eAAe,CAAC8B,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOX,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAChB,QAAQ,CAAC0B,MAAM;AACpF"}
@@ -1,6 +1,10 @@
1
1
  import { useMemo } from 'react';
2
2
  import { unistyles } from '../core';
3
3
  export const useInitialTheme = forName => {
4
- useMemo(() => unistyles.runtime.setTheme(forName), []);
4
+ useMemo(() => {
5
+ if (!unistyles.runtime.themeName) {
6
+ unistyles.runtime.setTheme(forName);
7
+ }
8
+ }, []);
5
9
  };
6
10
  //# sourceMappingURL=useInitialTheme.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","unistyles","useInitialTheme","forName","runtime","setTheme"],"sourceRoot":"../../../src","sources":["hooks/useInitialTheme.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,SAAS,QAAQ,SAAS;AAGnC,OAAO,MAAMC,eAAe,GAAIC,OAA8B,IAAK;EAC/DH,OAAO,CAAC,MAAMC,SAAS,CAACG,OAAO,CAACC,QAAQ,CAACF,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"names":["useMemo","unistyles","useInitialTheme","forName","runtime","themeName","setTheme"],"sourceRoot":"../../../src","sources":["hooks/useInitialTheme.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,SAAS,QAAQ,SAAS;AAGnC,OAAO,MAAMC,eAAe,GAAIC,OAA8B,IAAK;EAC/DH,OAAO,CAAC,MAAM;IACV,IAAI,CAACC,SAAS,CAACG,OAAO,CAACC,SAAS,EAAE;MAC9BJ,SAAS,CAACG,OAAO,CAACE,QAAQ,CAACH,OAAO,CAAC;IACvC;EACJ,CAAC,EAAE,EAAE,CAAC;AACV,CAAC"}
@@ -4,18 +4,11 @@ import { useInitialTheme } from './hooks';
4
4
  import { ScreenOrientation } from './common';
5
5
  import { useStyles } from './useStyles';
6
6
  import { createStyleSheet } from './createStyleSheet';
7
- const {
8
- addThemes,
9
- addBreakpoints,
10
- addConfig
11
- } = unistyles.registry;
12
- const UnistylesRuntime = unistyles.runtime;
13
7
  const UnistylesRegistry = {
14
- addThemes,
15
- addBreakpoints,
16
- addConfig
8
+ addThemes: unistyles.registry.addThemes,
9
+ addBreakpoints: unistyles.registry.addBreakpoints,
10
+ addConfig: unistyles.registry.addConfig
17
11
  };
18
- export const __dangerouslyUnregister = unistyles.registry.dangerouslyUnregister;
19
- export { UnistylesRuntime, UnistylesRegistry };
20
- export { mq, useInitialTheme, useStyles, createStyleSheet, ScreenOrientation };
12
+ const UnistylesRuntime = unistyles.runtime;
13
+ export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, UnistylesRegistry, UnistylesRuntime };
21
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","mq","useInitialTheme","ScreenOrientation","useStyles","createStyleSheet","addThemes","addBreakpoints","addConfig","registry","UnistylesRuntime","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,SAAS;AAEzC,SAASC,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAM;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGR,SAAS,CAACS,QAAQ;AACpE,MAAMC,gBAAgB,GAAGV,SAAS,CAACW,OAAO;AAC1C,MAAMC,iBAAiB,GAAG;EACtBN,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC;AAED,OAAO,MAAMK,uBAAuB,GAAGb,SAAS,CAACS,QAAQ,CAACK,qBAAqB;AAE/E,SACIJ,gBAAgB,EAChBE,iBAAiB;AAGrB,SACIX,EAAE,EACFC,eAAe,EACfE,SAAS,EACTC,gBAAgB,EAChBF,iBAAiB"}
1
+ {"version":3,"names":["unistyles","mq","useInitialTheme","ScreenOrientation","useStyles","createStyleSheet","UnistylesRegistry","addThemes","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,SAAS;AAEzC,SAASC,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,iBAAiB,GAAG;EACtBC,SAAS,EAAEP,SAAS,CAACQ,QAAQ,CAACD,SAAS;EACvCE,cAAc,EAAET,SAAS,CAACQ,QAAQ,CAACC,cAAc;EACjDC,SAAS,EAAEV,SAAS,CAACQ,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAGX,SAAS,CAACY,OAAO;AAE1C,SACIX,EAAE,EACFG,SAAS,EACTF,eAAe,EACfG,gBAAgB,EAChBF,iBAAiB,EACjBG,iBAAiB,EACjBK,gBAAgB"}
@@ -1,6 +1,6 @@
1
1
  const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
2
- const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/g;
3
- const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/g;
2
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
3
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
4
4
  const parseMq = mq => {
5
5
  const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
6
6
  const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
@@ -1 +1 @@
1
- {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":"AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,sCAAsC;AACpE,MAAMC,sBAAsB,GAAG,sCAAsC;AAYrE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,IAAI,EAAEC,MAAM,CAACH,KAAK,CAAC;MACnBI,EAAE,EAAED,MAAM,CAACF,GAAG;IAClB,CAAC,GAAGI;EACR,CAAC;AACL,CAAC;AAED,MAAMC,aAAa,GAAIZ,EAAU,IAAKJ,kBAAkB,CAACiB,IAAI,CAACb,EAAE,CAAC;AAEjE,MAAMc,SAAS,GAAIC,QAA2B,IAAK;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AAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOgB,YAAY,IAAIb,IAAI,IAAIa,YAAY,IAAIX,EAAE;AACrD,CAAC;AAED,OAAO,MAAMY,4BAA4B,GAAGA,CAACC,YAAwB,EAAEN,UAAsB,KAAK;EAC9F,MAAMjB,EAAE,GAAGuB,YAAY,CAACC,IAAI,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IAC/B,IAAI,CAACb,aAAa,CAACc,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMX,QAAQ,GAAGhB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACZ,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC"}
1
+ {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":"AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAA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IAC9B,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,wCAAwC;IAC1D,aAAa,oCAAoC;IACjD,kBAAkB,yCAAyC;IAC3D,mBAAmB,2CAA2C;IAC9D,wBAAwB,gDAAgD;IACxE,4BAA4B,qDAAqD;CACpF;AAED,oBAAY,iBAAiB;IACzB,QAAQ,IAAI;IACZ,SAAS,IAAI;CAChB"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAAA,oBAAY,sBAAsB;IAC9B,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,wCAAwC;IAC1D,aAAa,oCAAoC;IACjD,kBAAkB,yCAAyC;IAC3D,mBAAmB,2CAA2C;IAC9D,wBAAwB,gDAAgD;IACxE,4BAA4B,qDAAqD;CACpF;AAGD,oBAAY,iBAAiB;IACzB,QAAQ,IAAI;IACZ,SAAS,IAAI;CAChB"}
@@ -11,6 +11,5 @@ export declare class UnistyleRegistry {
11
11
  addThemes: (themes: UnistylesThemes) => this;
12
12
  addBreakpoints: (breakpoints: UnistylesBreakpoints) => this;
13
13
  addConfig: (config: UnistylesConfig) => this;
14
- dangerouslyUnregister: () => void;
15
14
  }
16
15
  //# sourceMappingURL=UnistyleRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEtE,qBAAa,gBAAgB;IAOb,OAAO,CAAC,eAAe;IAN5B,MAAM,EAAE,eAAe,CAAK;IAC5B,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe,UAS1C;IAEM,cAAc,gBAAiB,oBAAoB,UAKzD;IAEM,SAAS,WAAY,eAAe,UAQ1C;IAEM,qBAAqB,aAQ3B;CACJ"}
1
+ {"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEtE,qBAAa,gBAAgB;IAOb,OAAO,CAAC,eAAe;IAN5B,MAAM,EAAE,eAAe,CAAK;IAC5B,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe,UAS1C;IAEM,cAAc,gBAAiB,oBAAoB,UAMzD;IAEM,SAAS,WAAY,eAAe,UAQ1C;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"useInitialTheme.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useInitialTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEhD,eAAO,MAAM,eAAe,YAAa,MAAM,eAAe,SAE7D,CAAA"}
1
+ {"version":3,"file":"useInitialTheme.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useInitialTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEhD,eAAO,MAAM,eAAe,YAAa,MAAM,eAAe,SAM7D,CAAA"}
@@ -4,14 +4,12 @@ import type { UnistylesThemes, UnistylesBreakpoints } from './global';
4
4
  import { ScreenOrientation } from './common';
5
5
  import { useStyles } from './useStyles';
6
6
  import { createStyleSheet } from './createStyleSheet';
7
- declare const UnistylesRuntime: import("./core/UnistylesRuntime").UnistylesRuntime;
8
7
  declare const UnistylesRegistry: {
9
8
  addThemes: (themes: UnistylesThemes) => import("./core/UnistyleRegistry").UnistyleRegistry;
10
9
  addBreakpoints: (breakpoints: UnistylesBreakpoints) => import("./core/UnistyleRegistry").UnistyleRegistry;
11
10
  addConfig: (config: import("./types").UnistylesConfig) => import("./core/UnistyleRegistry").UnistyleRegistry;
12
11
  };
13
- export declare const __dangerouslyUnregister: () => void;
14
- export { UnistylesRuntime, UnistylesRegistry };
15
- export { mq, useInitialTheme, useStyles, createStyleSheet, ScreenOrientation };
12
+ declare const UnistylesRuntime: import("./core/UnistylesRuntime").UnistylesRuntime;
13
+ export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, UnistylesRegistry, UnistylesRuntime };
16
14
  export type { UnistylesThemes, UnistylesBreakpoints };
17
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,QAAA,MAAM,gBAAgB,oDAAoB,CAAA;AAC1C,QAAA,MAAM,iBAAiB;;;;CAItB,CAAA;AAED,eAAO,MAAM,uBAAuB,YAA2C,CAAA;AAE/E,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACpB,CAAA;AAED,OAAO,EACH,EAAE,EACF,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACpB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACvB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,QAAA,MAAM,iBAAiB;;;;CAItB,CAAA;AAED,QAAA,MAAM,gBAAgB,oDAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACvB,CAAA"}
@@ -18,7 +18,6 @@ export type UnistylesBridge = {
18
18
  useBreakpoints(breakpoints: UnistylesBreakpoints): void;
19
19
  useTheme(name: keyof UnistylesThemes): void;
20
20
  useAdaptiveThemes(enable: boolean): void;
21
- unregister(): void;
22
21
  };
23
22
  export type UnistylesThemeEvent = {
24
23
  type: CxxUnistylesEventTypes.Theme;
@@ -1 +1 @@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CAAC,CAAC;IAG7G,MAAM,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAC;IACrC,cAAc,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IAC5C,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;CAC3C,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC;IACnC,OAAO,EAAE;QACL,SAAS,EAAE,MAAM,eAAe,CAAA;KACnC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC;QACnB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,iBAAiB,CAAA;KACjC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,CAAA;AAE9E,MAAM,WAAW,eAAe;IAC5B,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
package/src/common.ts CHANGED
@@ -12,6 +12,7 @@ export enum UnistylesError {
12
12
  BreakpointsMustStartFromZero = 'UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO',
13
13
  }
14
14
 
15
+ // todo to string?
15
16
  export enum ScreenOrientation {
16
17
  Portrait = 1,
17
18
  Landscape = 2
@@ -22,6 +22,7 @@ export class UnistyleRegistry {
22
22
  }
23
23
 
24
24
  public addBreakpoints = (breakpoints: UnistylesBreakpoints) => {
25
+ this.breakpoints = breakpoints
25
26
  this.unistylesBridge.useBreakpoints(breakpoints)
26
27
  this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs
27
28
 
@@ -37,14 +38,4 @@ export class UnistyleRegistry {
37
38
 
38
39
  return this
39
40
  }
40
-
41
- public dangerouslyUnregister = () => {
42
- this.config = {}
43
- this.themeNames = []
44
- this.themes = {} as UnistylesThemes
45
- this.breakpoints = {} as UnistylesBreakpoints
46
- this.sortedBreakpointPairs = []
47
-
48
- this.unistylesBridge.unregister()
49
- }
50
41
  }
@@ -44,7 +44,7 @@ export class UnistylesRuntime {
44
44
  }
45
45
 
46
46
  public setTheme = (name: keyof UnistylesThemes) => {
47
- if (name !== this.themeName && this.hasTheme(name)) {
47
+ if (this.hasTheme(name)) {
48
48
  this.unistylesBridge.useTheme(name)
49
49
 
50
50
  return true
@@ -3,5 +3,9 @@ import { unistyles } from '../core'
3
3
  import type { UnistylesThemes } from '../global'
4
4
 
5
5
  export const useInitialTheme = (forName: keyof UnistylesThemes) => {
6
- useMemo(() => unistyles.runtime.setTheme(forName), [])
6
+ useMemo(() => {
7
+ if (!unistyles.runtime.themeName) {
8
+ unistyles.runtime.setTheme(forName)
9
+ }
10
+ }, [])
7
11
  }
package/src/index.ts CHANGED
@@ -6,27 +6,22 @@ import { ScreenOrientation } from './common'
6
6
  import { useStyles } from './useStyles'
7
7
  import { createStyleSheet } from './createStyleSheet'
8
8
 
9
- const { addThemes, addBreakpoints, addConfig } = unistyles.registry
10
- const UnistylesRuntime = unistyles.runtime
11
9
  const UnistylesRegistry = {
12
- addThemes,
13
- addBreakpoints,
14
- addConfig
10
+ addThemes: unistyles.registry.addThemes,
11
+ addBreakpoints: unistyles.registry.addBreakpoints,
12
+ addConfig: unistyles.registry.addConfig
15
13
  }
16
14
 
17
- export const __dangerouslyUnregister = unistyles.registry.dangerouslyUnregister
18
-
19
- export {
20
- UnistylesRuntime,
21
- UnistylesRegistry
22
- }
15
+ const UnistylesRuntime = unistyles.runtime
23
16
 
24
17
  export {
25
18
  mq,
26
- useInitialTheme,
27
19
  useStyles,
20
+ useInitialTheme,
28
21
  createStyleSheet,
29
- ScreenOrientation
22
+ ScreenOrientation,
23
+ UnistylesRegistry,
24
+ UnistylesRuntime
30
25
  }
31
26
 
32
27
  export type {
@@ -23,10 +23,7 @@ export type UnistylesBridge = {
23
23
  themes: Array<keyof UnistylesThemes>,
24
24
  useBreakpoints(breakpoints: UnistylesBreakpoints): void,
25
25
  useTheme(name: keyof UnistylesThemes): void,
26
- useAdaptiveThemes(enable: boolean): void,
27
-
28
- // other
29
- unregister(): void
26
+ useAdaptiveThemes(enable: boolean): void
30
27
  }
31
28
 
32
29
  export type UnistylesThemeEvent = {
@@ -1,8 +1,8 @@
1
1
  import type { NestedKeys, Optional, ScreenSize } from '../types'
2
2
 
3
3
  const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
4
- const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/g
5
- const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/g
4
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
5
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/
6
6
 
7
7
  type ParsedMqDimension = {
8
8
  from: number,