react-native-unistyles 3.0.0-alpha.24 → 3.0.0-alpha.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. package/cxx/common/Helpers.h +10 -0
  2. package/cxx/core/UnistylesState.cpp +13 -1
  3. package/cxx/core/UnistylesState.h +2 -1
  4. package/cxx/hybridObjects/HybridStyleSheet.cpp +38 -5
  5. package/cxx/hybridObjects/HybridStyleSheet.h +3 -0
  6. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +23 -3
  7. package/cxx/hybridObjects/HybridUnistylesRuntime.h +5 -0
  8. package/cxx/parser/Parser.cpp +1 -1
  9. package/ios/Equatable.swift +2 -1
  10. package/ios/NativePlatform+ios.swift +4 -1
  11. package/lib/commonjs/core/index.js +20 -0
  12. package/lib/commonjs/core/index.js.map +1 -0
  13. package/lib/commonjs/core/useBreakpoint.js +22 -0
  14. package/lib/commonjs/core/useBreakpoint.js.map +1 -0
  15. package/lib/commonjs/core/useBreakpoint.native.js +24 -0
  16. package/lib/commonjs/core/useBreakpoint.native.js.map +1 -0
  17. package/lib/commonjs/core/useTheme.js +22 -0
  18. package/lib/commonjs/core/useTheme.js.map +1 -0
  19. package/lib/commonjs/core/useTheme.native.js +24 -0
  20. package/lib/commonjs/core/useTheme.native.js.map +1 -0
  21. package/lib/commonjs/index.js +16 -1
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  24. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
  25. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  26. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  27. package/lib/commonjs/specs/index.js +7 -0
  28. package/lib/commonjs/specs/index.js.map +1 -1
  29. package/lib/commonjs/web/runtime.js +13 -9
  30. package/lib/commonjs/web/runtime.js.map +1 -1
  31. package/lib/module/core/index.js +5 -0
  32. package/lib/module/core/index.js.map +1 -0
  33. package/lib/module/core/useBreakpoint.js +17 -0
  34. package/lib/module/core/useBreakpoint.js.map +1 -0
  35. package/lib/module/core/useBreakpoint.native.js +19 -0
  36. package/lib/module/core/useBreakpoint.native.js.map +1 -0
  37. package/lib/module/core/useTheme.js +17 -0
  38. package/lib/module/core/useTheme.js.map +1 -0
  39. package/lib/module/core/useTheme.native.js +19 -0
  40. package/lib/module/core/useTheme.native.js.map +1 -0
  41. package/lib/module/index.js +1 -0
  42. package/lib/module/index.js.map +1 -1
  43. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  44. package/lib/module/specs/NavigtionBar/index.js.map +1 -1
  45. package/lib/module/specs/StatusBar/index.js.map +1 -1
  46. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  47. package/lib/module/specs/index.js +2 -1
  48. package/lib/module/specs/index.js.map +1 -1
  49. package/lib/module/web/runtime.js +13 -9
  50. package/lib/module/web/runtime.js.map +1 -1
  51. package/lib/typescript/example/App.d.ts.map +1 -1
  52. package/lib/typescript/example/Typography.d.ts +28 -5
  53. package/lib/typescript/example/Typography.d.ts.map +1 -1
  54. package/lib/typescript/src/core/index.d.ts +3 -0
  55. package/lib/typescript/src/core/index.d.ts.map +1 -0
  56. package/lib/typescript/src/core/useBreakpoint.d.ts +2 -0
  57. package/lib/typescript/src/core/useBreakpoint.d.ts.map +1 -0
  58. package/lib/typescript/src/core/useBreakpoint.native.d.ts +2 -0
  59. package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +1 -0
  60. package/lib/typescript/src/core/useTheme.d.ts +41 -0
  61. package/lib/typescript/src/core/useTheme.d.ts.map +1 -0
  62. package/lib/typescript/src/core/useTheme.native.d.ts +41 -0
  63. package/lib/typescript/src/core/useTheme.native.d.ts.map +1 -0
  64. package/lib/typescript/src/index.d.ts +2 -0
  65. package/lib/typescript/src/index.d.ts.map +1 -1
  66. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +2 -1
  67. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
  68. package/lib/typescript/src/specs/NavigtionBar/index.d.ts +5 -0
  69. package/lib/typescript/src/specs/NavigtionBar/index.d.ts.map +1 -1
  70. package/lib/typescript/src/specs/StatusBar/index.d.ts +5 -0
  71. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  72. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +2 -0
  73. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  74. package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -1
  75. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  76. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +0 -1
  77. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  78. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +3 -1
  79. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  80. package/lib/typescript/src/specs/index.d.ts +4 -2
  81. package/lib/typescript/src/specs/index.d.ts.map +1 -1
  82. package/lib/typescript/src/types/index.d.ts +1 -1
  83. package/lib/typescript/src/types/index.d.ts.map +1 -1
  84. package/lib/typescript/src/types/variants.d.ts +3 -0
  85. package/lib/typescript/src/types/variants.d.ts.map +1 -1
  86. package/lib/typescript/src/web/runtime.d.ts +1 -0
  87. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  88. package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +8 -6
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +2 -1
  90. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +2 -2
  91. package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +16 -5
  92. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -0
  93. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +6 -3
  94. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +10 -9
  95. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +9 -8
  96. package/package.json +1 -1
  97. package/plugin/common.js +3 -1
  98. package/plugin/stylesheet.js +2 -1
  99. package/src/core/index.ts +2 -0
  100. package/src/core/useBreakpoint.native.ts +21 -0
  101. package/src/core/useBreakpoint.ts +18 -0
  102. package/src/core/useTheme.native.ts +21 -0
  103. package/src/core/useTheme.ts +18 -0
  104. package/src/index.ts +3 -0
  105. package/src/specs/NativePlatform/NativePlatform.nitro.ts +2 -1
  106. package/src/specs/NavigtionBar/index.ts +5 -0
  107. package/src/specs/StatusBar/index.ts +5 -0
  108. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +3 -0
  109. package/src/specs/StyleSheet/index.ts +1 -1
  110. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +0 -1
  111. package/src/specs/UnistylesRuntime/index.ts +3 -1
  112. package/src/specs/index.ts +6 -2
  113. package/src/types/index.ts +1 -1
  114. package/src/types/variants.ts +6 -0
  115. package/src/web/runtime.ts +17 -12
@@ -90,6 +90,16 @@ inline bool isPlatformColor(jsi::Runtime& rt, jsi::Object& maybePlatformColor) {
90
90
  return true;
91
91
  }
92
92
 
93
+ auto isIOSDynamicColor =
94
+ maybePlatformColor.hasProperty(rt, "dynamic") &&
95
+ maybePlatformColor.getProperty(rt, "dynamic").isObject() &&
96
+ maybePlatformColor.getProperty(rt, "dynamic").asObject(rt).hasProperty(rt, "dark") &&
97
+ maybePlatformColor.getProperty(rt, "dynamic").asObject(rt).hasProperty(rt, "light");
98
+
99
+ if (isIOSDynamicColor) {
100
+ return true;
101
+ }
102
+
93
103
  // Android
94
104
  return maybePlatformColor.hasProperty(rt, "resource_paths") && maybePlatformColor.getProperty(rt, "resource_paths").isObject();
95
105
  }
@@ -23,7 +23,7 @@ std::optional<std::string>& core::UnistylesState::getCurrentThemeName() {
23
23
  return this->_currentThemeName;
24
24
  }
25
25
 
26
- jsi::Object core::UnistylesState::getJSTheme() {
26
+ jsi::Object core::UnistylesState::getCurrentJSTheme() {
27
27
  auto hasSomeThemes = _registeredThemeNames.size() > 0;
28
28
 
29
29
  // return empty object, if user didn't register any themes
@@ -44,6 +44,18 @@ jsi::Object core::UnistylesState::getJSTheme() {
44
44
  return maybeTheme.asObject(*_rt);
45
45
  }
46
46
 
47
+ jsi::Object core::UnistylesState::getJSThemeByName(std::string& themeName) {
48
+ auto it = this->_jsThemes.find(themeName);
49
+
50
+ helpers::assertThat(*_rt, it != this->_jsThemes.end(), "Unistyles: You're trying to get theme '" + themeName + "', but it was not registered. Did you forget to register it with StyleSheet.configure?");
51
+
52
+ auto maybeTheme = it->second.lock(*_rt);
53
+
54
+ helpers::assertThat(*_rt, maybeTheme.isObject(), "Unistyles: Unable to retrieve your theme from C++ as it has already been garbage collected, likely due to multiple hot reloads. Please live reload the app.");
55
+
56
+ return maybeTheme.asObject(*_rt);
57
+ }
58
+
47
59
  void core::UnistylesState::computeCurrentBreakpoint(int screenWidth) {
48
60
  this->_currentBreakpointName = helpers::getBreakpointFromScreenWidth(
49
61
  screenWidth,
@@ -28,7 +28,8 @@ struct UnistylesState {
28
28
  std::optional<std::string> getCurrentBreakpointName();
29
29
  std::vector<std::pair<std::string, double>> getSortedBreakpointPairs();
30
30
 
31
- jsi::Object getJSTheme();
31
+ jsi::Object getCurrentJSTheme();
32
+ jsi::Object getJSThemeByName(std::string& themeName);
32
33
  int parseColor(jsi::Value& color);
33
34
  void computeCurrentBreakpoint(int screenWidth);
34
35
  void registerProcessColorFunction(jsi::Function&& fn);
@@ -216,15 +216,27 @@ void HybridStyleSheet::loadExternalMethods(const jsi::Value& thisValue, jsi::Run
216
216
  state.registerProcessColorFunction(std::move(processColorFn));
217
217
  }
218
218
 
219
+ void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
220
+ this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager, this->_unistylesRuntime, rt);
221
+ this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager, this->_unistylesRuntime, rt);
222
+ }
223
+
219
224
  void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies) {
220
225
  auto& registry = core::UnistylesRegistry::get();
221
226
  auto parser = parser::Parser(this->_unistylesRuntime);
222
227
  auto& rt = this->_unistylesRuntime->getRuntime();
228
+
229
+ // re-compute new breakpoint
230
+ auto dimensionsIt = std::find(dependencies.begin(), dependencies.end(), UnistyleDependency::DIMENSIONS);
231
+
232
+ if (dimensionsIt != dependencies.end()) {
233
+ registry.getState(rt).computeCurrentBreakpoint(this->_unistylesRuntime->getScreen().width);
234
+ }
223
235
 
224
236
  // check if color scheme changed and then if Unistyles state depend on it (adaptive themes)
225
237
  auto colorSchemeIt = std::find(dependencies.begin(), dependencies.end(), UnistyleDependency::COLORSCHEME);
226
238
  auto hasNewColorScheme = colorSchemeIt != dependencies.end();
227
-
239
+
228
240
  // in a later step, we will rebuild only Unistyles with mounted StyleSheets
229
241
  // however, user may have StyleSheets with components that haven't mounted yet
230
242
  // we need to rebuild all dependent StyleSheets as well
@@ -233,7 +245,9 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
233
245
  if (hasNewColorScheme) {
234
246
  this->_unistylesRuntime->includeDependenciesForColorSchemeChange(dependencies);
235
247
  }
236
-
248
+
249
+ this->notifyJSListeners(dependencies);
250
+
237
251
  auto dependencyMap = registry.buildDependencyMap(rt, dependencies);
238
252
 
239
253
  if (dependencyMap.size() == 0) {
@@ -250,7 +264,26 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
250
264
  shadow::ShadowTreeManager::updateShadowTree(rt, shadowLeafUpdates);
251
265
  }
252
266
 
253
- void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
254
- this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager, this->_unistylesRuntime, rt);
255
- this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager, this->_unistylesRuntime, rt);
267
+ void HybridStyleSheet::notifyJSListeners(std::vector<UnistyleDependency>& dependencies) {
268
+ if (dependencies.size() > 0) {
269
+ std::for_each(this->_changeListeners.begin(), this->_changeListeners.end(), [&](auto& listener){
270
+ (*listener)(dependencies);
271
+ });
272
+ }
273
+ }
274
+
275
+ std::function<void ()> HybridStyleSheet::addChangeListener(const std::function<void (const std::vector<UnistyleDependency>&)>& onChanged) {
276
+ auto listener = std::make_unique<std::function<void(std::vector<UnistyleDependency>&)>>(onChanged);
277
+
278
+ this->_changeListeners.push_back(std::move(listener));
279
+
280
+ return [this, listenerPtr = this->_changeListeners.back().get()](){
281
+ auto it = std::find_if(this->_changeListeners.begin(), this->_changeListeners.end(), [listenerPtr](auto& ptr) {
282
+ return ptr.get() == listenerPtr;
283
+ });
284
+
285
+ if (it != this->_changeListeners.end()) {
286
+ this->_changeListeners.erase(it);
287
+ }
288
+ };
256
289
  }
@@ -44,6 +44,7 @@ struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
44
44
 
45
45
  double getHairlineWidth() override;
46
46
  double getUnid() override;
47
+ std::function<void ()> addChangeListener(const std::function<void (const std::vector<UnistyleDependency> &)>& onChanged) override;
47
48
 
48
49
  private:
49
50
  void parseSettings(jsi::Runtime& rt, jsi::Object settings);
@@ -54,8 +55,10 @@ private:
54
55
  void loadExternalMethods(const jsi::Value& thisValue, jsi::Runtime& rt);
55
56
  void registerHooks(jsi::Runtime& rt);
56
57
  void onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies);
58
+ void notifyJSListeners(std::vector<UnistyleDependency>& dependencies);
57
59
 
58
60
  double __unid = -1;
61
+ std::vector<std::unique_ptr<const std::function<void(std::vector<UnistyleDependency>&)>>> _changeListeners{};
59
62
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
60
63
  std::shared_ptr<core::UnistylesCommitHook> _unistylesCommitHook;
61
64
  std::shared_ptr<core::UnistylesMountHook> _unistylesMountHook;
@@ -112,6 +112,24 @@ void HybridUnistylesRuntime::calculateNewThemeAndDependencies(std::vector<Unisty
112
112
  }
113
113
  }
114
114
 
115
+ jsi::Value HybridUnistylesRuntime::getTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
116
+ helpers::assertThat(rt, count <= 1, "UnistylesRuntime.getTheme expected to be called with 0 or 1 argument.");
117
+
118
+ auto& state = core::UnistylesRegistry::get().getState(*_rt);
119
+
120
+ if (count == 1) {
121
+ helpers::assertThat(rt, args[0].isString(), "UnistylesRuntime.getTheme expected to be called with string.");
122
+
123
+ auto themeName = args[0].asString(rt).utf8(rt);
124
+
125
+ helpers::assertThat(rt, state.hasTheme(themeName), "Unistyles: You're trying to get theme '" + themeName + "' but it wasn't registered.");
126
+
127
+ return state.getJSThemeByName(themeName);
128
+ }
129
+
130
+ return state.getCurrentJSTheme();
131
+ }
132
+
115
133
  jsi::Value HybridUnistylesRuntime::updateTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
116
134
  helpers::assertThat(rt, count == 2, "UnistylesRuntime.updateTheme expected to be called with 2 arguments.");
117
135
  helpers::assertThat(rt, args[0].isString(), "UnistylesRuntime.updateTheme expected first argument to be a string.");
@@ -158,7 +176,6 @@ UnistylesCxxMiniRuntime HybridUnistylesRuntime::getMiniRuntime() {
158
176
  UnistylesCxxMiniRuntime cxxMiniRuntime{
159
177
  this->getThemeName(),
160
178
  this->getBreakpoint(),
161
- nativeMiniRuntime.orientation,
162
179
  this->getHasAdaptiveThemes(),
163
180
  nativeMiniRuntime.colorScheme,
164
181
  nativeMiniRuntime.screen,
@@ -168,7 +185,9 @@ UnistylesCxxMiniRuntime HybridUnistylesRuntime::getMiniRuntime() {
168
185
  nativeMiniRuntime.fontScale,
169
186
  nativeMiniRuntime.rtl,
170
187
  nativeMiniRuntime.statusBar,
171
- nativeMiniRuntime.navigationBar
188
+ nativeMiniRuntime.navigationBar,
189
+ nativeMiniRuntime.isPortrait,
190
+ nativeMiniRuntime.isLandscape
172
191
  };
173
192
 
174
193
  return cxxMiniRuntime;
@@ -181,7 +200,6 @@ jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
181
200
  // auto generated by nitro, but can't be accessed due to static inline function
182
201
  obj.setProperty(rt, "themeName", JSIConverter<std::optional<std::string>>::toJSI(rt, miniRuntime.themeName));
183
202
  obj.setProperty(rt, "breakpoint", JSIConverter<std::optional<std::string>>::toJSI(rt, miniRuntime.breakpoint));
184
- obj.setProperty(rt, "orientation", JSIConverter<Orientation>::toJSI(rt, miniRuntime.orientation));
185
203
  obj.setProperty(rt, "hasAdaptiveThemes", JSIConverter<bool>::toJSI(rt, miniRuntime.hasAdaptiveThemes));
186
204
  obj.setProperty(rt, "colorScheme", JSIConverter<ColorScheme>::toJSI(rt, miniRuntime.colorScheme));
187
205
  obj.setProperty(rt, "screen", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.screen));
@@ -192,6 +210,8 @@ jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
192
210
  obj.setProperty(rt, "rtl", JSIConverter<bool>::toJSI(rt, miniRuntime.rtl));
193
211
  obj.setProperty(rt, "statusBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.statusBar));
194
212
  obj.setProperty(rt, "navigationBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.navigationBar));
213
+ obj.setProperty(rt, "isPortrait", JSIConverter<bool>::toJSI(rt, miniRuntime.isPortrait));
214
+ obj.setProperty(rt, "isLandscape", JSIConverter<bool>::toJSI(rt, miniRuntime.isLandscape));
195
215
 
196
216
  return obj;
197
217
  }
@@ -15,6 +15,10 @@ namespace margelo::nitro::unistyles {
15
15
  struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
16
16
  HybridUnistylesRuntime(Unistyles::HybridNativePlatformSpecCxx nativePlatform, jsi::Runtime& rt) : HybridObject(TAG), _nativePlatform{nativePlatform}, _rt{&rt} {}
17
17
 
18
+ jsi::Value getTheme(jsi::Runtime& rt,
19
+ const jsi::Value& thisValue,
20
+ const jsi::Value* args,
21
+ size_t count);
18
22
  jsi::Value updateTheme(jsi::Runtime& rt,
19
23
  const jsi::Value& thisValue,
20
24
  const jsi::Value* args,
@@ -32,6 +36,7 @@ struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
32
36
  HybridUnistylesRuntimeSpec::loadHybridMethods();
33
37
 
34
38
  registerHybrids(this, [](Prototype& prototype) {
39
+ prototype.registerRawHybridMethod("getTheme", 1, &HybridUnistylesRuntime::getTheme);
35
40
  prototype.registerRawHybridMethod("updateTheme", 1, &HybridUnistylesRuntime::updateTheme);
36
41
  prototype.registerRawHybridMethod("createHybridStatusBar", 0, &HybridUnistylesRuntime::createHybridStatusBar);
37
42
  prototype.registerRawHybridMethod("createHybridNavigationBar", 0, &HybridUnistylesRuntime::createHybridNavigationBar);
@@ -47,7 +47,7 @@ jsi::Object parser::Parser::unwrapStyleSheet(jsi::Runtime& rt, std::shared_ptr<S
47
47
 
48
48
  // StyleSheet is a function
49
49
  auto& state = core::UnistylesRegistry::get().getState(rt);
50
- auto theme = state.getJSTheme();
50
+ auto theme = state.getCurrentJSTheme();
51
51
 
52
52
  if (styleSheet->type == StyleSheetType::Themable) {
53
53
  return styleSheet->rawValue
@@ -36,7 +36,8 @@ extension UnistylesNativeMiniRuntime {
36
36
  dependencies.append(UnistyleDependency.breakpoints)
37
37
  }
38
38
 
39
- if (lhs.orientation != rhs.orientation) {
39
+ // no need to check isLandscape, as it's always opposite
40
+ if (lhs.isPortrait != rhs.isPortrait) {
40
41
  dependencies.append(UnistyleDependency.orientation)
41
42
  }
42
43
 
@@ -31,6 +31,8 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
31
31
  }
32
32
 
33
33
  func buildMiniRuntime() -> UnistylesNativeMiniRuntime {
34
+ let orientation = self.getOrientation()
35
+
34
36
  return UnistylesNativeMiniRuntime(
35
37
  colorScheme: self.getColorScheme(),
36
38
  screen: self.getScreenDimensions(),
@@ -41,7 +43,8 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
41
43
  rtl: self.getPrefersRtlDirection(),
42
44
  statusBar: self.getStatusBarDimensions(),
43
45
  navigationBar: self.getNavigationBarDimensions(),
44
- orientation: self.getOrientation()
46
+ isPortrait: orientation == .portrait,
47
+ isLandscape: orientation == .landscape
45
48
  )
46
49
  }
47
50
 
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useBreakpoint", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _useBreakpoint.useBreakpoint;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "useTheme", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _useTheme.useTheme;
16
+ }
17
+ });
18
+ var _useBreakpoint = require("./useBreakpoint");
19
+ var _useTheme = require("./useTheme");
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_useBreakpoint","require","_useTheme"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useBreakpoint = void 0;
7
+ var _react = require("react");
8
+ var _web = require("../web");
9
+ var _listener = require("../web/listener");
10
+ var _NativePlatform = require("../specs/NativePlatform");
11
+ const useBreakpoint = () => {
12
+ const [breakpoint, setBreakpoint] = (0, _react.useState)(_web.UnistylesRuntime.breakpoint);
13
+ (0, _react.useEffect)(() => {
14
+ const removeChangeListener = _listener.UnistylesListener.addListeners([_NativePlatform.UnistyleDependency.Breakpoints], () => setBreakpoint(_web.UnistylesRuntime.breakpoint));
15
+ return () => {
16
+ removeChangeListener();
17
+ };
18
+ }, []);
19
+ return breakpoint;
20
+ };
21
+ exports.useBreakpoint = useBreakpoint;
22
+ //# sourceMappingURL=useBreakpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_web","_listener","_NativePlatform","useBreakpoint","breakpoint","setBreakpoint","useState","UnistylesRuntime","useEffect","removeChangeListener","UnistylesListener","addListeners","UnistyleDependency","Breakpoints","exports"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEO,MAAMI,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAACC,qBAAgB,CAACH,UAAU,CAAC;EAEzE,IAAAI,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAGC,2BAAiB,CAACC,YAAY,CAAC,CAACC,kCAAkB,CAACC,WAAW,CAAC,EAAE,MAAMR,aAAa,CAACE,qBAAgB,CAACH,UAAU,CAAC,CAAC;IAE/I,OAAO,MAAM;MACTK,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,UAAU;AACrB,CAAC;AAAAU,OAAA,CAAAX,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useBreakpoint = void 0;
7
+ var _react = require("react");
8
+ var _specs = require("../specs");
9
+ const useBreakpoint = () => {
10
+ const [breakpoint, setBreakpoint] = (0, _react.useState)(_specs.UnistylesRuntime.breakpoint);
11
+ (0, _react.useEffect)(() => {
12
+ const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
13
+ if (dependencies.includes(_specs.UnistyleDependency.Breakpoints)) {
14
+ setBreakpoint(_specs.UnistylesRuntime.breakpoint);
15
+ }
16
+ });
17
+ return () => {
18
+ removeChangeListener();
19
+ };
20
+ }, []);
21
+ return breakpoint;
22
+ };
23
+ exports.useBreakpoint = useBreakpoint;
24
+ //# sourceMappingURL=useBreakpoint.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_specs","useBreakpoint","breakpoint","setBreakpoint","useState","UnistylesRuntime","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Breakpoints","exports"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.native.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAACC,uBAAgB,CAACH,UAAU,CAAC;EAEzE,IAAAI,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACC,yBAAkB,CAACC,WAAW,CAAC,EAAE;QACvDV,aAAa,CAACE,uBAAgB,CAACH,UAAU,CAAC;MAC9C;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTK,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,UAAU;AACrB,CAAC;AAAAY,OAAA,CAAAb,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTheme = void 0;
7
+ var _react = require("react");
8
+ var _web = require("../web");
9
+ var _listener = require("../web/listener");
10
+ var _NativePlatform = require("../specs/NativePlatform");
11
+ const useTheme = () => {
12
+ const [theme, setTheme] = (0, _react.useState)(_web.UnistylesRuntime.getTheme());
13
+ (0, _react.useEffect)(() => {
14
+ const removeChangeListener = _listener.UnistylesListener.addListeners([_NativePlatform.UnistyleDependency.Theme], () => setTheme(_web.UnistylesRuntime.getTheme()));
15
+ return () => {
16
+ removeChangeListener();
17
+ };
18
+ }, []);
19
+ return theme;
20
+ };
21
+ exports.useTheme = useTheme;
22
+ //# sourceMappingURL=useTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_web","_listener","_NativePlatform","useTheme","theme","setTheme","useState","UnistylesRuntime","getTheme","useEffect","removeChangeListener","UnistylesListener","addListeners","UnistyleDependency","Theme","exports"],"sourceRoot":"../../../src","sources":["core/useTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEO,MAAMI,QAAQ,GAAGA,CAAA,KAAM;EAC1B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAE/D,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAGC,2BAAiB,CAACC,YAAY,CAAC,CAACC,kCAAkB,CAACC,KAAK,CAAC,EAAE,MAAMT,QAAQ,CAACE,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEpI,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAON,KAAK;AAChB,CAAC;AAAAW,OAAA,CAAAZ,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTheme = void 0;
7
+ var _react = require("react");
8
+ var _specs = require("../specs");
9
+ const useTheme = () => {
10
+ const [theme, setTheme] = (0, _react.useState)(_specs.UnistylesRuntime.getTheme());
11
+ (0, _react.useEffect)(() => {
12
+ const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
13
+ if (dependencies.includes(_specs.UnistyleDependency.Theme)) {
14
+ setTheme(_specs.UnistylesRuntime.getTheme());
15
+ }
16
+ });
17
+ return () => {
18
+ removeChangeListener();
19
+ };
20
+ }, []);
21
+ return theme;
22
+ };
23
+ exports.useTheme = useTheme;
24
+ //# sourceMappingURL=useTheme.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_specs","useTheme","theme","setTheme","useState","UnistylesRuntime","getTheme","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Theme","exports"],"sourceRoot":"../../../src","sources":["core/useTheme.native.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,QAAQ,GAAGA,CAAA,KAAM;EAC1B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAE/D,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACC,yBAAkB,CAACC,KAAK,CAAC,EAAE;QACjDX,QAAQ,CAACE,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;MACzC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAON,KAAK;AAChB,CAAC;AAAAa,OAAA,CAAAd,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- mq: true
7
+ mq: true,
8
+ useTheme: true,
9
+ useBreakpoint: true
8
10
  };
9
11
  Object.defineProperty(exports, "mq", {
10
12
  enumerable: true,
@@ -12,6 +14,18 @@ Object.defineProperty(exports, "mq", {
12
14
  return _mq.mq;
13
15
  }
14
16
  });
17
+ Object.defineProperty(exports, "useBreakpoint", {
18
+ enumerable: true,
19
+ get: function () {
20
+ return _core.useBreakpoint;
21
+ }
22
+ });
23
+ Object.defineProperty(exports, "useTheme", {
24
+ enumerable: true,
25
+ get: function () {
26
+ return _core.useTheme;
27
+ }
28
+ });
15
29
  var _react = _interopRequireDefault(require("react"));
16
30
  var _specs = require("./specs");
17
31
  Object.keys(_specs).forEach(function (key) {
@@ -26,6 +40,7 @@ Object.keys(_specs).forEach(function (key) {
26
40
  });
27
41
  });
28
42
  var _mq = require("./mq");
43
+ var _core = require("./core");
29
44
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
45
  // TODO: export Native createUnistylesComponent
31
46
  // can't import it this way, it will break native build
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_specs","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","e","__esModule","default","minReactVersionRequiredByUnistyles","React","version","Error"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,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,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAd,OAAA;AAAyB,SAAAD,uBAAAgB,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzB;AACA;AACA;;AAEA;AACA,MAAMG,kCAAkC,GAAG,QAAQ;AAEnD,IAAIC,cAAK,CAACC,OAAO,GAAGF,kCAAkC,EAAE;EACpD,MAAM,IAAIG,KAAK,CAAC;AACpB,sDAAsDF,cAAK,CAACC,OAAO;AACnE,4CAA4CF,kCAAkC;AAC9E,KAAK,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_specs","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_core","e","__esModule","default","minReactVersionRequiredByUnistyles","React","version","Error"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,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,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAd,OAAA;AAEA,IAAAe,KAAA,GAAAf,OAAA;AAAgD,SAAAD,uBAAAiB,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGhD;AACA;AACA;;AAEA;AACA,MAAMG,kCAAkC,GAAG,QAAQ;AAEnD,IAAIC,cAAK,CAACC,OAAO,GAAGF,kCAAkC,EAAE;EACpD,MAAM,IAAIG,KAAK,CAAC;AACpB,sDAAsDF,cAAK,CAACC,OAAO;AACnE,4CAA4CF,kCAAkC;AAC9E,KAAK,CAAC;AACN","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["UnistyleDependency","exports"],"sourceRoot":"../../../../src","sources":["specs/NativePlatform/NativePlatform.nitro.ts"],"mappings":";;;;;;IAMYA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,OA8B9B;AACA","ignoreList":[]}
1
+ {"version":3,"names":["UnistyleDependency","exports"],"sourceRoot":"../../../../src","sources":["specs/NativePlatform/NativePlatform.nitro.ts"],"mappings":";;;;;;IAMYA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,OA+B9B;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","attachNavigationBarJSMethods","hybridObject","privateHybrid","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/NavigtionBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASO,MAAMC,4BAA4B,GAAIC,YAAoC,IAAK;EAClF,MAAMC,aAAa,GAAGD,YAA6C;EAEnEC,aAAa,CAACC,mBAAmB,GAAGF,YAAY,CAACG,kBAAkB;EACnEH,YAAY,CAACG,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;IAE5CH,aAAa,CAACC,mBAAmB,CAACG,WAAqB,CAAC;EAC5D,CAAC;AACL,CAAC;AAAAE,OAAA,CAAAR,4BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","attachNavigationBarJSMethods","hybridObject","privateHybrid","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/NavigtionBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAcO,MAAMC,4BAA4B,GAAIC,YAAoC,IAAK;EAClF,MAAMC,aAAa,GAAGD,YAA6C;EAEnEC,aAAa,CAACC,mBAAmB,GAAGF,YAAY,CAACG,kBAAkB;EACnEH,YAAY,CAACG,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;IAE5CH,aAAa,CAACC,mBAAmB,CAACG,WAAqB,CAAC;EAC5D,CAAC;AACL,CAAC;AAAAE,OAAA,CAAAR,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_types","attachStatusBarJSMethods","hybridObject","setStyle","style","animated","StatusBarStyle","Light","NativeStatusBar","setBarStyle","Dark","Default","privateHybrid","_setHidden","setHidden","isHidden","animation","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/StatusBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAYO,MAAME,wBAAwB,GAAIC,YAAgC,IAAK;EAC1EA,YAAY,CAACC,QAAQ,GAAG,CAACC,KAAqB,EAAEC,QAAkB,KAAK;IACnE,QAAQD,KAAK;MACT,KAAKE,qBAAc,CAACC,KAAK;QACrB,OAAOC,sBAAe,CAACC,WAAW,CAAC,eAAe,EAAEJ,QAAQ,CAAC;MACjE,KAAKC,qBAAc,CAACI,IAAI;QACpB,OAAOF,sBAAe,CAACC,WAAW,CAAC,cAAc,EAAEJ,QAAQ,CAAC;MAChE,KAAKC,qBAAc,CAACK,OAAO;QACvB,OAAOH,sBAAe,CAACC,WAAW,CAAC,SAAS,EAAEJ,QAAQ,CAAC;IAC/D;EACJ,CAAC;EAED,MAAMO,aAAa,GAAGV,YAAyC;EAE/DU,aAAa,CAACC,UAAU,GAAGX,YAAY,CAACY,SAAS;EACjDZ,YAAY,CAACY,SAAS,GAAG,CAACC,QAAiB,EAAEC,SAAoC,KAAK;IAClFR,sBAAe,CAACM,SAAS,CAACC,QAAQ,EAAEC,SAAS,CAAC;IAC9CJ,aAAa,CAACC,UAAU,CAACE,QAAQ,CAAC;EACtC,CAAC;EAEDH,aAAa,CAACK,mBAAmB,GAAGf,YAAY,CAACgB,kBAAkB;EACnEhB,YAAY,CAACgB,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;IAE5CP,aAAa,CAACK,mBAAmB,CAACG,WAAqB,CAAC;EAC5D,CAAC;AACL,CAAC;AAAAE,OAAA,CAAArB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_types","attachStatusBarJSMethods","hybridObject","setStyle","style","animated","StatusBarStyle","Light","NativeStatusBar","setBarStyle","Dark","Default","privateHybrid","_setHidden","setHidden","isHidden","animation","_setBackgroundColor","setBackgroundColor","color","parsedColor","processColor","exports"],"sourceRoot":"../../../../src","sources":["specs/StatusBar/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAiBO,MAAME,wBAAwB,GAAIC,YAAgC,IAAK;EAC1EA,YAAY,CAACC,QAAQ,GAAG,CAACC,KAAqB,EAAEC,QAAkB,KAAK;IACnE,QAAQD,KAAK;MACT,KAAKE,qBAAc,CAACC,KAAK;QACrB,OAAOC,sBAAe,CAACC,WAAW,CAAC,eAAe,EAAEJ,QAAQ,CAAC;MACjE,KAAKC,qBAAc,CAACI,IAAI;QACpB,OAAOF,sBAAe,CAACC,WAAW,CAAC,cAAc,EAAEJ,QAAQ,CAAC;MAChE,KAAKC,qBAAc,CAACK,OAAO;QACvB,OAAOH,sBAAe,CAACC,WAAW,CAAC,SAAS,EAAEJ,QAAQ,CAAC;IAC/D;EACJ,CAAC;EAED,MAAMO,aAAa,GAAGV,YAAyC;EAE/DU,aAAa,CAACC,UAAU,GAAGX,YAAY,CAACY,SAAS;EACjDZ,YAAY,CAACY,SAAS,GAAG,CAACC,QAAiB,EAAEC,SAAoC,KAAK;IAClFR,sBAAe,CAACM,SAAS,CAACC,QAAQ,EAAEC,SAAS,CAAC;IAC9CJ,aAAa,CAACC,UAAU,CAACE,QAAQ,CAAC;EACtC,CAAC;EAEDH,aAAa,CAACK,mBAAmB,GAAGf,YAAY,CAACgB,kBAAkB;EACnEhB,YAAY,CAACgB,kBAAkB,GAAIC,KAAc,IAAK;IAClD,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;IAE5CP,aAAa,CAACK,mBAAmB,CAACG,WAAqB,CAAC;EAC5D,CAAC;AACL,CAAC;AAAAE,OAAA,CAAArB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_reactNativeNitroModules","_StatusBar","_NavigtionBar","_common","HybridUnistylesRuntime","NitroModules","createHybridObject","statusBar","createHybridStatusBar","navigationBar","createHybridNavigationBar","_setRootViewBackgroundColor","setRootViewBackgroundColor","color","parsedColor","processColor","isIOS","setImmersiveMode","isEnabled","setHidden","attachStatusBarJSMethods","attachNavigationBarJSMethods","Runtime","exports"],"sourceRoot":"../../../../src","sources":["specs/UnistylesRuntime/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAgCA,MAAMK,sBAAsB,GAAGC,qCAAY,CACtCC,kBAAkB,CAA0B,kBAAkB,CAAC;AAEpEF,sBAAsB,CAACG,SAAS,GAAGH,sBAAsB,CAACI,qBAAqB,CAAC,CAAC;AACjFJ,sBAAsB,CAACK,aAAa,GAAGL,sBAAsB,CAACM,yBAAyB,CAAC,CAAC;AACzFN,sBAAsB,CAACO,2BAA2B,GAAGP,sBAAsB,CAACQ,0BAA0B;AAEtGR,sBAAsB,CAACQ,0BAA0B,GAAIC,KAAc,IAAK;EACpE,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;EAE5CT,sBAAsB,CAACO,2BAA2B,CAACG,WAAqB,CAAC;AAC7E,CAAC;AAED,IAAIE,aAAK,EAAE;EACPZ,sBAAsB,CAACa,gBAAgB,GAAIC,SAAkB,IAAKd,sBAAsB,CAACG,SAAS,CAACY,SAAS,CAACD,SAAS,EAAE,MAAM,CAAC;AACnI;AAEA,IAAAE,mCAAwB,EAAChB,sBAAsB,CAACG,SAAS,CAAC;AAC1D,IAAAc,0CAA4B,EAACjB,sBAAsB,CAACK,aAAa,CAAC;AAE3D,MAAMa,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAGlB,sBAA0C","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_reactNativeNitroModules","_StatusBar","_NavigtionBar","_common","HybridUnistylesRuntime","NitroModules","createHybridObject","statusBar","createHybridStatusBar","navigationBar","createHybridNavigationBar","_setRootViewBackgroundColor","setRootViewBackgroundColor","color","parsedColor","processColor","isIOS","setImmersiveMode","isEnabled","setHidden","attachStatusBarJSMethods","attachNavigationBarJSMethods","Runtime","exports"],"sourceRoot":"../../../../src","sources":["specs/UnistylesRuntime/index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAkCA,MAAMK,sBAAsB,GAAGC,qCAAY,CACtCC,kBAAkB,CAA0B,kBAAkB,CAAC;AAEpEF,sBAAsB,CAACG,SAAS,GAAGH,sBAAsB,CAACI,qBAAqB,CAAC,CAAC;AACjFJ,sBAAsB,CAACK,aAAa,GAAGL,sBAAsB,CAACM,yBAAyB,CAAC,CAAC;AACzFN,sBAAsB,CAACO,2BAA2B,GAAGP,sBAAsB,CAACQ,0BAA0B;AAEtGR,sBAAsB,CAACQ,0BAA0B,GAAIC,KAAc,IAAK;EACpE,MAAMC,WAAW,GAAG,IAAAC,yBAAY,EAACF,KAAK,CAAC,IAAI,CAAC;EAE5CT,sBAAsB,CAACO,2BAA2B,CAACG,WAAqB,CAAC;AAC7E,CAAC;AAED,IAAIE,aAAK,EAAE;EACPZ,sBAAsB,CAACa,gBAAgB,GAAIC,SAAkB,IAAKd,sBAAsB,CAACG,SAAS,CAACY,SAAS,CAACD,SAAS,EAAE,MAAM,CAAC;AACnI;AAEA,IAAAE,mCAAwB,EAAChB,sBAAsB,CAACG,SAAS,CAAC;AAC1D,IAAAc,0CAA4B,EAACjB,sBAAsB,CAACK,aAAa,CAAC;AAE3D,MAAMa,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAGlB,sBAA0C","ignoreList":[]}
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "StyleSheet", {
27
27
  return _StyleSheet.StyleSheet;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "UnistyleDependency", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _NativePlatform.UnistyleDependency;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "UnistylesRuntime", {
31
37
  enumerable: true,
32
38
  get: function () {
@@ -44,4 +50,5 @@ var _UnistylesRuntime = require("./UnistylesRuntime");
44
50
  var _StyleSheet = require("./StyleSheet");
45
51
  var _ShadowRegistry = require("./ShadowRegistry");
46
52
  var _types = require("./types");
53
+ var _NativePlatform = require("./NativePlatform");
47
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["require","_UnistylesRuntime","_StyleSheet","_ShadowRegistry","_types"],"sourceRoot":"../../../src","sources":["specs/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["require","_UnistylesRuntime","_StyleSheet","_ShadowRegistry","_types","_NativePlatform"],"sourceRoot":"../../../src","sources":["specs/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA","ignoreList":[]}
@@ -58,14 +58,7 @@ class UnistylesRuntimeBuilder {
58
58
  return screen.orientation.type.includes('portrait') ? _types.Orientation.Portrait : _types.Orientation.Landscape;
59
59
  }
60
60
  get theme() {
61
- if (!this.themeName) {
62
- throw new Error('🦄 No theme selected!');
63
- }
64
- const theme = _state.UnistylesState.themes.get(this.themeName);
65
- if (!theme) {
66
- throw new Error(`🦄 Theme "${this.themeName}" is not registered!`);
67
- }
68
- return theme;
61
+ return this.getTheme(this.themeName);
69
62
  }
70
63
  get pixelRatio() {
71
64
  return (0, _utils.isServer)() ? 1 : window.devicePixelRatio;
@@ -112,7 +105,8 @@ class UnistylesRuntimeBuilder {
112
105
  themeName: this.themeName,
113
106
  contentSizeCategory: this.contentSizeCategory,
114
107
  breakpoint: this.breakpoint,
115
- orientation: this.orientation,
108
+ isLandscape: this.orientation === _types.Orientation.Landscape,
109
+ isPortrait: this.orientation === _types.Orientation.Portrait,
116
110
  pixelRatio: this.pixelRatio,
117
111
  screen: this.screen,
118
112
  fontScale: this.fontScale,
@@ -158,6 +152,16 @@ class UnistylesRuntimeBuilder {
158
152
  }
159
153
  _state.UnistylesState.themes.set(themeName, updater(oldTheme));
160
154
  };
155
+ getTheme = (themeName = this.themeName) => {
156
+ if (!themeName) {
157
+ throw new Error('🦄 No theme selected!');
158
+ }
159
+ const theme = _state.UnistylesState.themes.get(themeName);
160
+ if (!theme) {
161
+ throw new Error(`🦄 Theme "${this.themeName}" is not registered!`);
162
+ }
163
+ return theme;
164
+ };
161
165
  }
162
166
  const UnistylesRuntime = exports.UnistylesRuntime = new UnistylesRuntimeBuilder();
163
167
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_NativePlatform","require","_types","_types2","_listener","_mock","_state","_utils","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","isServer","window","matchMedia","colorScheme","matches","ColorScheme","Light","Dark","Unspecified","themeName","UnistylesState","contentSizeCategory","WebContentSizeCategory","breakpoint","orientation","Orientation","Portrait","screen","type","includes","Landscape","theme","Error","themes","get","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","StatusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","NavigationBar","miniRuntime","setTheme","UnistylesRuntime","UnistylesListener","emitChange","UnistyleDependency","Theme","ThemeName","setAdaptiveThemes","isEnabled","schemeToTheme","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","hexToRGBA","setImmersiveMode","updateTheme","updater","oldTheme","set","exports"],"sourceRoot":"../../../src","sources":["web/runtime.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SA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B,CAACC,KAAK,CAAC;IACtDH,2BAAiB,CAACC,UAAU,CAACC,kCAAkB,CAACE,SAAS,CAAC;EAC9D,CAAC;EAEDC,iBAAiB,GAAIC,SAAkB,IAAK;IACxC9C,qBAAc,CAACkC,iBAAiB,GAAGY,SAAS;IAE5C,IAAI,CAACA,SAAS,EAAE;MACZ;IACJ;IAEA,IAAI,CAACR,QAAQ,CAAC,IAAAS,oBAAa,EAACR,gBAAgB,CAAC9C,WAAW,CAAC,CAAC;EAC9D,CAAC;EAEDuD,0BAA0B,GAAGA,CAACC,GAAW,EAAEC,KAAc,KAAK;IAC1D,IAAI,IAAA5D,eAAQ,EAAC,CAAC,EAAE;MACZ;IACJ;IAEAyC,QAAQ,CAACC,eAAe,CAACmB,KAAK,CAACC,eAAe,GAAGF,KAAK,GAAG,IAAAG,gBAAS,EAACJ,GAAG,EAAEC,KAAK,CAAC,GAAGD,GAAG;EACxF,CAAC;EAEDK,gBAAgB,GAAGA,CAAA,KAAM,CAAC,CAAC;EAE3BC,WAAW,GAAGA,CAACxD,SAAuB,EAAEyD,OAA6C,KAAK;IACtF,MAAMC,QAAQ,GAAGzD,qBAAc,CAACa,MAAM,CAACC,GAAG,CAACf,SAAS,CAAC;IAErD,IAAI,CAAC0D,QAAQ,EAAE;MACX,MAAM,IAAI7C,KAAK,CAAC,aAAab,SAAS,sBAAsB,CAAC;IACjE;IAEAC,qBAAc,CAACa,MAAM,CAAC6C,GAAG,CAAC3D,SAAS,EAAEyD,OAAO,CAACC,QAAQ,CAAC,CAAC;EAC3D,CAAC;AACL;AAEO,MAAMlB,gBAAgB,GAAAoB,OAAA,CAAApB,gBAAA,GAAG,IAAItD,uBAAuB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_NativePlatform","require","_types","_types2","_listener","_mock","_state","_utils","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","isServer","window","matchMedia","colorScheme","matches","ColorScheme","Light","Dark","Unspecified","themeName","UnistylesState","contentSizeCategory","WebContentSizeCategory","breakpoint","orientation","Orientation","Portrait","screen","type","includes","Landscape","theme","getTheme","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","StatusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","NavigationBar","miniRuntime","isLandscape","isPortrait","setTheme","UnistylesRuntime","UnistylesListener","emitChange","UnistyleDependency","Theme","ThemeName","setAdaptiveThemes","isEnabled","schemeToTheme","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","hexToRGBA","setImmersiveMode","updateTheme","updater","oldTheme","themes","get","Error","set","exports"],"sourceRoot":"../../../src","sources":["web/runtime.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA,MAAMO,uBAAuB,CAAC;EAC1BC,UAAU,GAAG,IAAI,CAACC,aAAa,CAAC,CAAC;EACjCC,SAAS,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;EAEvBF,aAAaA,CAAA,EAA0B;IAC3C,IAAI,IAAAG,eAAQ,EAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,IAAI,CAAC,IAAI,CAACJ,UAAU,EAAE;MAClB,IAAI,CAACA,UAAU,GAAGK,MAAM,CAACC,UAAU,CAAC,+BAA+B,CAAC;IACxE;IAEA,OAAO,IAAI,CAACN,UAAU;EAC1B;EAEQG,YAAYA,CAAA,EAA0B;IAC1C,IAAI,IAAAC,eAAQ,EAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,IAAI,CAAC,IAAI,CAACF,SAAS,EAAE;MACjB,IAAI,CAACA,SAAS,GAAGG,MAAM,CAACC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,aAAa7D,SAAS,sBAAsB,CAAC;IACjE;IAEAC,qBAAc,CAAC0D,MAAM,CAACG,GAAG,CAAC9D,SAAS,EAAEyD,OAAO,CAACC,QAAQ,CAAC,CAAC;EAC3D,CAAC;EAED7C,QAAQ,GAAGA,CAACb,SAAS,GAAG,IAAI,CAACA,SAAS,KAAK;IACvC,IAAI,CAACA,SAAS,EAAE;MACZ,MAAM,IAAI6D,KAAK,CAAC,uBAAuB,CAAC;IAC5C;IAEA,MAAMjD,KAAK,GAAGX,qBAAc,CAAC0D,MAAM,CAACC,GAAG,CAAC5D,SAAS,CAAC;IAElD,IAAI,CAACY,KAAK,EAAE;MACR,MAAM,IAAIiD,KAAK,CAAC,aAAa,IAAI,CAAC7D,SAAS,sBAAsB,CAAC;IACtE;IAEA,OAAOY,KAAK;EAChB,CAAC;AACL;AAEO,MAAM4B,gBAAgB,GAAAuB,OAAA,CAAAvB,gBAAA,GAAG,IAAItD,uBAAuB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { useBreakpoint } from './useBreakpoint';
4
+ export { useTheme } from './useTheme';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useBreakpoint","useTheme"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,QAAQ,QAAQ,YAAY","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { UnistylesRuntime } from '../web';
5
+ import { UnistylesListener } from '../web/listener';
6
+ import { UnistyleDependency } from '../specs/NativePlatform';
7
+ export const useBreakpoint = () => {
8
+ const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
9
+ useEffect(() => {
10
+ const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint));
11
+ return () => {
12
+ removeChangeListener();
13
+ };
14
+ }, []);
15
+ return breakpoint;
16
+ };
17
+ //# sourceMappingURL=useBreakpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","UnistylesRuntime","UnistylesListener","UnistyleDependency","useBreakpoint","breakpoint","setBreakpoint","removeChangeListener","addListeners","Breakpoints"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,gBAAgB,QAAQ,QAAQ;AACzC,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGN,QAAQ,CAACC,gBAAgB,CAACI,UAAU,CAAC;EAEzEN,SAAS,CAAC,MAAM;IACZ,MAAMQ,oBAAoB,GAAGL,iBAAiB,CAACM,YAAY,CAAC,CAACL,kBAAkB,CAACM,WAAW,CAAC,EAAE,MAAMH,aAAa,CAACL,gBAAgB,CAACI,UAAU,CAAC,CAAC;IAE/I,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,UAAU;AACrB,CAAC","ignoreList":[]}