react-native-unistyles 3.0.0-alpha.12 → 3.0.0-alpha.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. package/cxx/core/UnistyleWrapper.h +1 -1
  2. package/cxx/core/UnistylesCommitHook.cpp +9 -0
  3. package/cxx/core/UnistylesCommitHook.h +1 -0
  4. package/cxx/core/UnistylesMountHook.cpp +15 -1
  5. package/cxx/core/UnistylesRegistry.h +3 -1
  6. package/cxx/hybridObjects/HybridStyleSheet.cpp +1 -1
  7. package/cxx/hybridObjects/HybridStyleSheet.h +1 -1
  8. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +1 -1
  9. package/cxx/shadowTree/ShadowTrafficController.h +33 -0
  10. package/cxx/shadowTree/ShadowTreeManager.cpp +7 -0
  11. package/cxx/shadowTree/ShadowTreeManager.h +1 -0
  12. package/lib/commonjs/index.js +4 -0
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/specs/ShadowRegistry/index.js +7 -1
  15. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  16. package/lib/commonjs/web/convert/index.js +1 -1
  17. package/lib/commonjs/web/convert/index.js.map +1 -1
  18. package/lib/commonjs/web/create.js +25 -63
  19. package/lib/commonjs/web/create.js.map +1 -1
  20. package/lib/commonjs/web/createUnistylesComponent.js +61 -0
  21. package/lib/commonjs/web/createUnistylesComponent.js.map +1 -0
  22. package/lib/commonjs/web/index.js +12 -3
  23. package/lib/commonjs/web/index.js.map +1 -1
  24. package/lib/commonjs/web/listener/index.js +7 -0
  25. package/lib/commonjs/web/listener/index.js.map +1 -1
  26. package/lib/commonjs/web/listener/listenToDependencies.js +39 -0
  27. package/lib/commonjs/web/listener/listenToDependencies.js.map +1 -0
  28. package/lib/commonjs/web/listener/listener.js +1 -2
  29. package/lib/commonjs/web/listener/listener.js.map +1 -1
  30. package/lib/commonjs/web/mock.js +1 -10
  31. package/lib/commonjs/web/mock.js.map +1 -1
  32. package/lib/commonjs/web/pseudo.js +2 -3
  33. package/lib/commonjs/web/pseudo.js.map +1 -1
  34. package/lib/commonjs/web/registry.js +2 -4
  35. package/lib/commonjs/web/registry.js.map +1 -1
  36. package/lib/commonjs/web/runtime.js +0 -1
  37. package/lib/commonjs/web/runtime.js.map +1 -1
  38. package/lib/commonjs/web/shadowRegistry.js +120 -0
  39. package/lib/commonjs/web/shadowRegistry.js.map +1 -0
  40. package/lib/commonjs/web/state.js +0 -40
  41. package/lib/commonjs/web/state.js.map +1 -1
  42. package/lib/commonjs/web/utils.js +66 -14
  43. package/lib/commonjs/web/utils.js.map +1 -1
  44. package/lib/commonjs/web/variants/useVariants.js +1 -34
  45. package/lib/commonjs/web/variants/useVariants.js.map +1 -1
  46. package/lib/module/index.js +4 -0
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/specs/ShadowRegistry/index.js +7 -1
  49. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  50. package/lib/module/web/convert/index.js +1 -1
  51. package/lib/module/web/convert/index.js.map +1 -1
  52. package/lib/module/web/create.js +26 -64
  53. package/lib/module/web/create.js.map +1 -1
  54. package/lib/module/web/createUnistylesComponent.js +54 -0
  55. package/lib/module/web/createUnistylesComponent.js.map +1 -0
  56. package/lib/module/web/index.js +4 -2
  57. package/lib/module/web/index.js.map +1 -1
  58. package/lib/module/web/listener/index.js +1 -0
  59. package/lib/module/web/listener/index.js.map +1 -1
  60. package/lib/module/web/listener/listenToDependencies.js +34 -0
  61. package/lib/module/web/listener/listenToDependencies.js.map +1 -0
  62. package/lib/module/web/listener/listener.js +1 -1
  63. package/lib/module/web/listener/listener.js.map +1 -1
  64. package/lib/module/web/mock.js +0 -9
  65. package/lib/module/web/mock.js.map +1 -1
  66. package/lib/module/web/pseudo.js +2 -3
  67. package/lib/module/web/pseudo.js.map +1 -1
  68. package/lib/module/web/registry.js +2 -4
  69. package/lib/module/web/registry.js.map +1 -1
  70. package/lib/module/web/runtime.js +0 -1
  71. package/lib/module/web/runtime.js.map +1 -1
  72. package/lib/module/web/shadowRegistry.js +116 -0
  73. package/lib/module/web/shadowRegistry.js.map +1 -0
  74. package/lib/module/web/state.js +0 -40
  75. package/lib/module/web/state.js.map +1 -1
  76. package/lib/module/web/utils.js +59 -12
  77. package/lib/module/web/utils.js.map +1 -1
  78. package/lib/module/web/variants/useVariants.js +1 -34
  79. package/lib/module/web/variants/useVariants.js.map +1 -1
  80. package/lib/typescript/example/App.d.ts.map +1 -1
  81. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  82. package/lib/typescript/src/web/create.d.ts.map +1 -1
  83. package/lib/typescript/src/web/createUnistylesComponent.d.ts +3 -0
  84. package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -0
  85. package/lib/typescript/src/web/index.d.ts +2 -1
  86. package/lib/typescript/src/web/index.d.ts.map +1 -1
  87. package/lib/typescript/src/web/listener/index.d.ts +1 -0
  88. package/lib/typescript/src/web/listener/index.d.ts.map +1 -1
  89. package/lib/typescript/src/web/listener/listenToDependencies.d.ts +12 -0
  90. package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -0
  91. package/lib/typescript/src/web/listener/listener.d.ts +2 -1
  92. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -1
  93. package/lib/typescript/src/web/mock.d.ts +0 -9
  94. package/lib/typescript/src/web/mock.d.ts.map +1 -1
  95. package/lib/typescript/src/web/pseudo.d.ts +4 -2
  96. package/lib/typescript/src/web/pseudo.d.ts.map +1 -1
  97. package/lib/typescript/src/web/registry.d.ts +1 -1
  98. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  99. package/lib/typescript/src/web/runtime.d.ts +0 -1
  100. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  101. package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
  102. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
  103. package/lib/typescript/src/web/state.d.ts +0 -5
  104. package/lib/typescript/src/web/state.d.ts.map +1 -1
  105. package/lib/typescript/src/web/utils.d.ts +22 -7
  106. package/lib/typescript/src/web/utils.d.ts.map +1 -1
  107. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -1
  108. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -3
  109. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +8 -3
  110. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +1 -1
  111. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +1 -1
  112. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +14 -2
  113. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +3 -0
  114. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -0
  115. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +3 -0
  116. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
  117. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -0
  118. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  119. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +4 -1
  120. package/package.json +3 -3
  121. package/src/index.ts +3 -0
  122. package/src/specs/ShadowRegistry/index.ts +7 -1
  123. package/src/web/convert/index.ts +1 -1
  124. package/src/web/create.ts +24 -79
  125. package/src/web/createUnistylesComponent.tsx +56 -0
  126. package/src/web/index.ts +3 -2
  127. package/src/web/listener/index.ts +1 -0
  128. package/src/web/listener/listenToDependencies.ts +50 -0
  129. package/src/web/listener/listener.ts +1 -1
  130. package/src/web/mock.ts +0 -10
  131. package/src/web/pseudo.ts +131 -5
  132. package/src/web/registry.ts +3 -5
  133. package/src/web/runtime.ts +0 -2
  134. package/src/web/shadowRegistry.ts +121 -0
  135. package/src/web/state.ts +0 -44
  136. package/src/web/utils.ts +90 -16
  137. package/src/web/variants/useVariants.ts +1 -37
@@ -60,7 +60,7 @@ inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, Unistyle::Shared un
60
60
  auto hostFn = jsi::Value(rt, unistyleFn->proxiedFunction.value()).asObject(rt).asFunction(rt);
61
61
 
62
62
  hostFn.setNativeState(rt, std::move(wrappedUnistyle));
63
- hostFn.setProperty(rt, helpers::UNISTYLES_ID.c_str(), unistyleFn->styleKey);
63
+ helpers::defineHiddenProperty(rt, hostFn, helpers::UNISTYLES_ID.c_str(), unistyleFn->styleKey);
64
64
 
65
65
  return std::move(hostFn);
66
66
  }
@@ -26,11 +26,20 @@ RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
26
26
  return newRootShadowNode;
27
27
  }
28
28
 
29
+ auto& registry = core::UnistylesRegistry::get();
30
+
31
+ if (!registry.trafficController.hasUnistylesCommit()) {
32
+ return newRootShadowNode;
33
+ }
34
+
29
35
  auto shadowLeafUpdates = this->getUnistylesUpdates();
30
36
 
31
37
  if (shadowLeafUpdates.size() == 0) {
32
38
  return newRootShadowNode;
33
39
  }
40
+
41
+ // this is required, otherwise we end up with old shadow tree in mount hook
42
+ registry.trafficController.stopUnistylesTraffic();
34
43
 
35
44
  auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(*rootNode, shadowLeafUpdates);
36
45
 
@@ -5,6 +5,7 @@
5
5
  #include "HybridUnistylesRuntime.h"
6
6
  #include "Parser.h"
7
7
  #include "ShadowTreeManager.h"
8
+ #include "ShadowTrafficController.h"
8
9
 
9
10
  namespace margelo::nitro::unistyles::core {
10
11
 
@@ -12,13 +12,27 @@ void core::UnistylesMountHook::shadowTreeDidMount(RootShadowNode::Shared const &
12
12
  auto rootNode = std::const_pointer_cast<RootShadowNode>(rootShadowNode);
13
13
  auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(rootNode);
14
14
 
15
- // skip only unistyles commits
15
+ // if this is Unistyles commit, do nothing
16
16
  if (unistylesRootNode->hasUnistylesMountTrait()) {
17
17
  unistylesRootNode->removeUnistylesMountTrait();
18
18
 
19
19
  return;
20
20
  }
21
21
 
22
+ // this is React Native commit
23
+ auto& registry = core::UnistylesRegistry::get();
24
+
25
+ registry.trafficController.resumeUnistylesTraffic();
26
+
27
+ // this will prevent crash when re-rendering view
28
+ // as Unistyles has nothing to commit yet, but dependency map
29
+ // will build all the shadow nodes
30
+ if (!registry.trafficController.hasUnistylesCommit()) {
31
+ return;
32
+ }
33
+
34
+ registry.trafficController.setHasUnistylesCommit(false);
35
+
22
36
  auto shadowLeafUpdates = this->getUnistylesUpdates();
23
37
 
24
38
  if (shadowLeafUpdates.size() == 0) {
@@ -11,6 +11,7 @@
11
11
  #include "StyleSheet.h"
12
12
  #include "Unistyle.h"
13
13
  #include "UnistyleData.h"
14
+ #include "ShadowTrafficController.h"
14
15
 
15
16
  namespace margelo::nitro::unistyles::core {
16
17
 
@@ -40,7 +41,8 @@ struct UnistylesRegistry: public StyleSheetRegistry {
40
41
  std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
41
42
  DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
42
43
  DependencyMap buildDependencyMap(jsi::Runtime& rt);
43
-
44
+ shadow::ShadowTrafficController trafficController{};
45
+
44
46
  private:
45
47
  UnistylesRegistry() = default;
46
48
 
@@ -9,7 +9,7 @@ double HybridStyleSheet::getHairlineWidth() {
9
9
  return nearestPixel / pixelRatio;
10
10
  }
11
11
 
12
- double HybridStyleSheet::get___unid() {
12
+ double HybridStyleSheet::get__unid() {
13
13
  return this->__unid;
14
14
  }
15
15
 
@@ -43,7 +43,7 @@ struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
43
43
  };
44
44
 
45
45
  double getHairlineWidth() override;
46
- double get___unid() override;
46
+ double get__unid() override;
47
47
 
48
48
  private:
49
49
  void parseSettings(jsi::Runtime& rt, jsi::Object settings);
@@ -192,7 +192,7 @@ jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
192
192
  obj.setProperty(rt, "rtl", JSIConverter<bool>::toJSI(rt, miniRuntime.rtl));
193
193
  obj.setProperty(rt, "statusBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.statusBar));
194
194
  obj.setProperty(rt, "navigationBar", JSIConverter<Dimensions>::toJSI(rt, miniRuntime.navigationBar));
195
-
195
+
196
196
  return obj;
197
197
  }
198
198
 
@@ -0,0 +1,33 @@
1
+ #pragma once
2
+
3
+ namespace margelo::nitro::unistyles::shadow {
4
+
5
+ // Like a traffic officer managing a jam, this struct ensures everything
6
+ // is synchronized within a set timeframe, controlling flow and preventing chaos.
7
+ struct ShadowTrafficController {
8
+ inline bool hasUnistylesCommit() {
9
+ return _hasCommit;
10
+ }
11
+
12
+ inline void setHasUnistylesCommit(bool hasCommit) {
13
+ this->_hasCommit = hasCommit;
14
+ }
15
+
16
+ inline bool shouldStop() {
17
+ return !_canCommit;
18
+ }
19
+
20
+ inline void stopUnistylesTraffic() {
21
+ this->_canCommit = false;
22
+ }
23
+
24
+ inline void resumeUnistylesTraffic() {
25
+ this->_canCommit = true;
26
+ }
27
+
28
+ private:
29
+ bool _hasCommit = false;
30
+ bool _canCommit = false;
31
+ };
32
+
33
+ }
@@ -9,6 +9,13 @@ using AffectedNodes = std::unordered_map<const ShadowNodeFamily*, std::unordered
9
9
  void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt, shadow::ShadowLeafUpdates& updates) {
10
10
  auto& uiManager = UIManagerBinding::getBinding(rt)->getUIManager();
11
11
  const auto &shadowTreeRegistry = uiManager.getShadowTreeRegistry();
12
+ auto& registry = core::UnistylesRegistry::get();
13
+
14
+ if (registry.trafficController.shouldStop()) {
15
+ registry.trafficController.setHasUnistylesCommit(true);
16
+
17
+ return;
18
+ }
12
19
 
13
20
  shadowTreeRegistry.enumerate([&updates, &rt](const ShadowTree& shadowTree, bool& stop){
14
21
  // we could iterate via updates and create multiple commits
@@ -6,6 +6,7 @@
6
6
  #include <ranges>
7
7
  #include "ShadowLeafUpdate.h"
8
8
  #include "UnistylesCommitShadowNode.h"
9
+ #include "UnistylesRegistry.h"
9
10
 
10
11
  namespace margelo::nitro::unistyles::shadow {
11
12
 
@@ -27,6 +27,10 @@ Object.keys(_specs).forEach(function (key) {
27
27
  });
28
28
  var _mq = require("./mq");
29
29
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
+ // TODO: export Native createUnistylesComponent
31
+ // can't import it this way, it will break native build
32
+ // export { createUnistylesComponent } from './web/createUnistylesComponent'
33
+
30
34
  // todo verify true min version
31
35
  const minReactVersionRequiredByUnistyles = '18.3.1';
32
36
  if (_react.default.version < minReactVersionRequiredByUnistyles) {
@@ -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;AAGzB;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","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":[]}
@@ -15,7 +15,13 @@ const findShadowNodeForHandle = handle => {
15
15
  return node;
16
16
  };
17
17
  HybridShadowRegistry.add = (handle, style, variants, args) => {
18
- if (!handle) {
18
+ // virtualized nodes can be null
19
+ if (!handle || !style) {
20
+ return;
21
+ }
22
+
23
+ // at this point unistyle can be only object or dynamic function
24
+ if (typeof style !== 'object' && typeof style !== 'function') {
19
25
  return;
20
26
  }
21
27
  HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAaA,MAAMC,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDL,oBAAoB,CAACW,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D,IAAI,CAACV,MAAM,EAAE;IACT;EACJ;EAEAJ,oBAAoB,CAACe,IAAI,CAACZ,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDd,oBAAoB,CAACgB,MAAM,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEK,MAAM,EAAE;IAC3B;EACJ;EAEAjB,oBAAoB,CAACkB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQM,MAAMO,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGnB,oBAA4D","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAaA,MAAMC,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDL,oBAAoB,CAACW,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D;EACA,IAAI,CAACV,MAAM,IAAI,CAACQ,KAAK,EAAE;IACnB;EACJ;;EAEA;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;IAC1D;EACJ;EAEAZ,oBAAoB,CAACe,IAAI,CAACZ,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDd,oBAAoB,CAACgB,MAAM,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEK,MAAM,EAAE;IAC3B;EACJ;EAEAjB,oBAAoB,CAACkB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQM,MAAMO,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGnB,oBAA4D","ignoreList":[]}
@@ -23,7 +23,7 @@ const convertToTypeStyle = value => {
23
23
  ...value._web
24
24
  }).flatMap(([unistylesKey, unistylesValue]) => {
25
25
  // Keys to omit
26
- if (['_css', '_web', 'variants', 'compoundVariants', 'uni__dependencies'].includes(unistylesKey)) {
26
+ if (['_css', '_web', 'variants', 'compoundVariants', 'uni__dependencies', '__unistyles-secrets__'].includes(unistylesKey) || unistylesKey.startsWith('variant-')) {
27
27
  return [];
28
28
  }
29
29
 
@@ -1 +1 @@
1
- {"version":3,"names":["_typestyle","require","_pseudo","_breakpoint","_style","_utils","_transform","_utils2","_textShadow","_boxShadow","convertToTypeStyle","value","hasTextShadow","hasBoxShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","isPseudo","typestyleValues","$nest","replace","isTextShadow","getTextShadowStyle","isBoxShadow","getBoxShadowStyle","isTransform","getTransformStyle","map","breakpointKey","breakpointValue","media","convertBreakpoint","getStyle","deepMergeObjects","exports"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAEO,MAAMS,kBAAkB,GAAIC,KAAsB,IAAK;EAC1D;EACA,IAAIC,aAAa,GAAG,KAAK;EACzB;EACA,IAAIC,YAAY,GAAG,KAAK;EAExB,MAAMC,WAAW,GAAGC,MAAM,CAACC,OAAO,CAAC;IAC/B,GAAGL,KAAK;IACR,GAAGA,KAAK,CAACM;EACb,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,CAACC,YAAY,EAAEC,cAAc,CAAC,KAAK;IAC3C;IACA,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,EAAE;MAC9F,OAAO,EAAE;IACb;;IAEA;IACA,IAAI,IAAAG,gBAAQ,EAACH,YAAY,CAAC,EAAE;MACxB,MAAMI,eAAe,GAAGb,kBAAkB,CAACU,cAAiC,CAAC;MAE7E,OAAO;QACHI,KAAK,EAAE;UACH,CAACL,YAAY,CAACM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,GAAGF;QACvC;MACJ,CAAC;IACL;;IAEA;IACA,IAAI,IAAAG,oBAAY,EAACP,YAAY,CAAC,EAAE;MAC5B,IAAIP,aAAa,EAAE;QACf,OAAO,EAAE;MACb;MAEAA,aAAa,GAAG,IAAI;MAEpB,OAAO,IAAAe,8BAAkB,EAAChB,KAAK,CAAC;IACpC;;IAEA;IACA,IAAI,IAAAiB,mBAAW,EAACT,YAAY,CAAC,EAAE;MAC3B,IAAIN,YAAY,EAAE;QACd,OAAO,EAAE;MACb;MAEAA,YAAY,GAAG,IAAI;MAEnB,OAAO,IAAAgB,4BAAiB,EAAClB,KAAK,CAAC;IACnC;;IAEA;IACA,IAAI,IAAAmB,mBAAW,EAACX,YAAY,EAAEC,cAAc,CAAC,EAAE;MAC3C,OAAO,IAAAW,4BAAiB,EAACX,cAAc,CAAC;IAC5C;;IAEA;IACA,IAAI,OAAOA,cAAc,KAAK,QAAQ,IAAIA,cAAc,KAAK,IAAI,EAAE;MAC/D,OAAOL,MAAM,CAACC,OAAO,CAACI,cAAc,CAAC,CAACY,GAAG,CAAC,CAAC,CAACC,aAAa,EAAEC,eAAe,CAAC,KAAK;QAC5E,OAAO,IAAAC,gBAAK,EAAC,IAAAC,6BAAiB,EAACH,aAAa,CAAC,EAAE,IAAAI,eAAQ,EAAClB,YAAY,EAAEe,eAAe,CAAC,CAAC;MAC3F,CAAC,CAAC;IACN;;IAEA;IACA,OAAO,IAAAG,eAAQ,EAAClB,YAAY,EAAEC,cAAc,CAAC;EACjD,CAAC,CAA+B;EAEhC,OAAO,IAAAkB,uBAAgB,EAAC,GAAGxB,WAAW,CAAC;AAC3C,CAAC;AAAAyB,OAAA,CAAA7B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_typestyle","require","_pseudo","_breakpoint","_style","_utils","_transform","_utils2","_textShadow","_boxShadow","convertToTypeStyle","value","hasTextShadow","hasBoxShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","startsWith","isPseudo","typestyleValues","$nest","replace","isTextShadow","getTextShadowStyle","isBoxShadow","getBoxShadowStyle","isTransform","getTransformStyle","map","breakpointKey","breakpointValue","media","convertBreakpoint","getStyle","deepMergeObjects","exports"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAEO,MAAMS,kBAAkB,GAAIC,KAAsB,IAAK;EAC1D;EACA,IAAIC,aAAa,GAAG,KAAK;EACzB;EACA,IAAIC,YAAY,GAAG,KAAK;EAExB,MAAMC,WAAW,GAAGC,MAAM,CAACC,OAAO,CAAC;IAC/B,GAAGL,KAAK;IACR,GAAGA,KAAK,CAACM;EACb,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,CAACC,YAAY,EAAEC,cAAc,CAAC,KAAK;IAC3C;IACA,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,uBAAuB,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,IAAIA,YAAY,CAACG,UAAU,CAAC,UAAU,CAAC,EAAE;MAC9J,OAAO,EAAE;IACb;;IAEA;IACA,IAAI,IAAAC,gBAAQ,EAACJ,YAAY,CAAC,EAAE;MACxB,MAAMK,eAAe,GAAGd,kBAAkB,CAACU,cAAiC,CAAC;MAE7E,OAAO;QACHK,KAAK,EAAE;UACH,CAACN,YAAY,CAACO,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,GAAGF;QACvC;MACJ,CAAC;IACL;;IAEA;IACA,IAAI,IAAAG,oBAAY,EAACR,YAAY,CAAC,EAAE;MAC5B,IAAIP,aAAa,EAAE;QACf,OAAO,EAAE;MACb;MAEAA,aAAa,GAAG,IAAI;MAEpB,OAAO,IAAAgB,8BAAkB,EAACjB,KAAK,CAAC;IACpC;;IAEA;IACA,IAAI,IAAAkB,mBAAW,EAACV,YAAY,CAAC,EAAE;MAC3B,IAAIN,YAAY,EAAE;QACd,OAAO,EAAE;MACb;MAEAA,YAAY,GAAG,IAAI;MAEnB,OAAO,IAAAiB,4BAAiB,EAACnB,KAAK,CAAC;IACnC;;IAEA;IACA,IAAI,IAAAoB,mBAAW,EAACZ,YAAY,EAAEC,cAAc,CAAC,EAAE;MAC3C,OAAO,IAAAY,4BAAiB,EAACZ,cAAc,CAAC;IAC5C;;IAEA;IACA,IAAI,OAAOA,cAAc,KAAK,QAAQ,IAAIA,cAAc,KAAK,IAAI,EAAE;MAC/D,OAAOL,MAAM,CAACC,OAAO,CAACI,cAAc,CAAC,CAACa,GAAG,CAAC,CAAC,CAACC,aAAa,EAAEC,eAAe,CAAC,KAAK;QAC5E,OAAO,IAAAC,gBAAK,EAAC,IAAAC,6BAAiB,EAACH,aAAa,CAAC,EAAE,IAAAI,eAAQ,EAACnB,YAAY,EAAEgB,eAAe,CAAC,CAAC;MAC3F,CAAC,CAAC;IACN;;IAEA;IACA,OAAO,IAAAG,eAAQ,EAACnB,YAAY,EAAEC,cAAc,CAAC;EACjD,CAAC,CAA+B;EAEhC,OAAO,IAAAmB,uBAAgB,EAAC,GAAGzB,WAAW,CAAC;AAC3C,CAAC;AAAA0B,OAAA,CAAA9B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -4,85 +4,47 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.create = void 0;
7
- var _registry = require("./registry");
8
7
  var _utils = require("./utils");
9
8
  var _runtime = require("./runtime");
10
9
  var _variants = require("./variants");
11
- var _listener = require("./listener");
12
10
  const create = stylesheet => {
13
11
  const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
14
- let lastlySelectedVariants = {};
15
- const listenToDependencies = ({
16
- key,
17
- className,
18
- unistyles,
19
- value,
20
- args = []
21
- }) => {
22
- const dependencies = 'uni__dependencies' in value ? value['uni__dependencies'] : [];
23
- if (dependencies.length === 0) {
24
- return;
25
- }
26
- return _listener.UnistylesListener.addListeners(dependencies, () => {
27
- const newComputedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
28
- if (!(0, _utils.keyInObject)(newComputedStylesheet, key)) {
29
- return;
30
- }
31
- const value = newComputedStylesheet[key];
32
- const result = typeof value === 'function' ? value(...args) : value;
33
- _registry.UnistylesRegistry.updateStyles(unistyles, result, className);
34
- });
35
- };
36
- const styles = (0, _utils.reduceObject)(computedStylesheet, (value, key) => {
12
+ const selectedVariants = new Map();
13
+ const copyVariants = () => Object.fromEntries(selectedVariants.entries());
14
+ const addSecrets = (value, key, args) => (0, _utils.assignSecrets)(value, {
15
+ __uni__key: key,
16
+ __uni__refs: new Set(),
17
+ __uni__stylesheet: stylesheet,
18
+ __uni__args: args,
19
+ __uni__variants: copyVariants()
20
+ });
21
+ const styles = (0, _utils.reduceObject)(computedStylesheet, (value, _key) => {
22
+ const key = String(_key);
37
23
  if (typeof value === 'function') {
38
- const webUnistyleByRef = new Map();
39
- const disposeByRef = new Map();
40
- return (...args) => {
41
- const [ref] = args.slice(-1);
24
+ const dynamicStyle = (...args) => {
42
25
  const result = value(...args);
43
26
  const variants = Object.fromEntries((0, _variants.getVariants)({
44
27
  [key]: result
45
- }, lastlySelectedVariants));
28
+ }, copyVariants()));
46
29
  const resultWithVariants = {
47
30
  ...result,
48
31
  ...variants[key]
49
32
  };
50
- if (ref instanceof HTMLElement) {
51
- const storedWebUnistyle = webUnistyleByRef.get(ref);
52
- const webUnistyle = storedWebUnistyle ?? _registry.UnistylesRegistry.createStyles(resultWithVariants, key);
53
- webUnistyleByRef.set(ref, webUnistyle);
54
- disposeByRef.get(ref)?.();
55
- disposeByRef.set(ref, listenToDependencies({
56
- key,
57
- value,
58
- unistyles: webUnistyle.unistyles,
59
- className: webUnistyle.className,
60
- args
61
- }));
62
- ref.classList.add(webUnistyle.className);
63
- if (storedWebUnistyle) {
64
- _registry.UnistylesRegistry.updateStyles(webUnistyle.unistyles, resultWithVariants, webUnistyle.className);
65
- }
66
- return;
67
- }
68
- return (0, _utils.toReactNativeClassName)(null, resultWithVariants);
33
+
34
+ // Add secrets to result of dynamic styles function
35
+ return addSecrets((0, _utils.getStyles)(resultWithVariants), key, args);
69
36
  };
37
+
38
+ // Add secrets to dynamic styles function
39
+ return addSecrets(dynamicStyle, key);
70
40
  }
71
- const {
72
- className,
73
- unistyles
74
- } = _registry.UnistylesRegistry.createStyles(value, key);
75
- listenToDependencies({
76
- key,
77
- value,
78
- unistyles,
79
- className
80
- });
81
- return (0, _utils.toReactNativeClassName)(className, value);
82
- });
83
- (0, _variants.createUseVariants)(styles, newVariants => {
84
- lastlySelectedVariants = newVariants;
41
+
42
+ // Add secrets to static styles
43
+ return addSecrets((0, _utils.getStyles)(value), key);
85
44
  });
45
+
46
+ // Inject useVariants hook to styles
47
+ (0, _variants.createUseVariants)(styles, newVariants => Object.entries(newVariants).forEach(([key, value]) => selectedVariants.set(key, value)));
86
48
  return styles;
87
49
  };
88
50
  exports.create = create;
@@ -1 +1 @@
1
- {"version":3,"names":["_registry","require","_utils","_runtime","_variants","_listener","create","stylesheet","computedStylesheet","UnistylesRuntime","theme","miniRuntime","lastlySelectedVariants","listenToDependencies","key","className","unistyles","value","args","dependencies","length","UnistylesListener","addListeners","newComputedStylesheet","keyInObject","result","UnistylesRegistry","updateStyles","styles","reduceObject","webUnistyleByRef","Map","disposeByRef","ref","slice","variants","Object","fromEntries","getVariants","resultWithVariants","HTMLElement","storedWebUnistyle","get","webUnistyle","createStyles","set","classList","add","toReactNativeClassName","createUseVariants","newVariants","exports"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAaO,MAAMK,MAAM,GAAIC,UAAiD,IAAK;EACzE,MAAMC,kBAAkB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACE,yBAAgB,CAACC,KAAK,EAAED,yBAAgB,CAACE,WAAW,CAAC,GAChEJ,UAAU;EAChB,IAAIK,sBAA2C,GAAG,CAAC,CAAC;EAEpD,MAAMC,oBAAoB,GAAGA,CAAC;IAAEC,GAAG;IAAEC,SAAS;IAAEC,SAAS;IAAEC,KAAK;IAAEC,IAAI,GAAG;EAA+B,CAAC,KAAK;IAC1G,MAAMC,YAAY,GAAI,mBAAmB,IAAIF,KAAK,GAAGA,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAgC;IAElH,IAAIE,YAAY,CAACC,MAAM,KAAK,CAAC,EAAE;MAC3B;IACJ;IAEA,OAAOC,2BAAiB,CAACC,YAAY,CAACH,YAAY,EAAE,MAAM;MACtD,MAAMI,qBAAqB,GAAG,OAAOhB,UAAU,KAAK,UAAU,GACxDA,UAAU,CAACE,yBAAgB,CAACC,KAAK,EAAED,yBAAgB,CAACE,WAAW,CAAC,GAChEJ,UAAU;MAEhB,IAAI,CAAC,IAAAiB,kBAAW,EAACD,qBAAqB,EAAET,GAAG,CAAC,EAAE;QAC1C;MACJ;MAEA,MAAMG,KAAK,GAAGM,qBAAqB,CAACT,GAAG,CAAE;MACzC,MAAMW,MAAM,GAAG,OAAOR,KAAK,KAAK,UAAU,GACpCA,KAAK,CAAC,GAAGC,IAAI,CAAC,GACdD,KAAK;MAEXS,2BAAiB,CAACC,YAAY,CAACX,SAAS,EAAES,M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;UACHe,GAAG,CAACa,SAAS,CAACC,GAAG,CAACJ,WAAW,CAAC5B,SAAS,CAAC;UAExC,IAAI0B,iBAAiB,EAAE;YACnBf,2BAAiB,CAACC,YAAY,CAACgB,WAAW,CAAC3B,SAAS,EAAEuB,kBAAkB,EAAEI,WAAW,CAAC5B,SAAS,CAAC;UACpG;UAGA;QACJ;QAEA,OAAO,IAAAiC,6BAAsB,EAAC,IAAI,EAAET,kBAAkB,CAAC;MAC3D,CAAC;IACL;IAEA,MAAM;MAAExB,SAAS;MAAEC;IAAU,CAAC,GAAGU,2BAAiB,CAACkB,YAAY,CAAC3B,KAAK,EAAEH,GAAG,CAAC;IAE3ED,oBAAoB,CAAC;MAAEC,GAAG;MAAEG,KAAK;MAAED,SAAS;MAAED;IAAU,CAAC,CAAC;IAE1D,OAAO,IAAAiC,6BAAsB,EAACjC,SAAS,EAAEE,KAAK,CAAC;EACnD,CAAC,CAAsC;EAEvC,IAAAgC,2BAAiB,EAACrB,MAAM,EAAEsB,WAAW,IAAI;IACrCtC,sBAAsB,GAAGsC,WAAW;EACxC,CAAC,CAAC;EAEF,OAAOtB,MAAM;AACjB,CAAC;AAAAuB,OAAA,CAAA7C,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["_utils","require","_runtime","_variants","create","stylesheet","computedStylesheet","UnistylesRuntime","theme","miniRuntime","selectedVariants","Map","copyVariants","Object","fromEntries","entries","addSecrets","value","key","args","assignSecrets","__uni__key","__uni__refs","Set","__uni__stylesheet","__uni__args","__uni__variants","styles","reduceObject","_key","String","dynamicStyle","result","variants","getVariants","resultWithVariants","getStyles","createUseVariants","newVariants","forEach","set","exports"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,MAAM,GAAIC,UAAiD,IAAK;EACzE,MAAMC,kBAAk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A,OAAOH,UAAU,CAACe,YAAY,EAAEb,GAAG,CAAC;IACxC;;IAEA;IACA,OAAOF,UAAU,CAAC,IAAAoB,gBAAS,EAACnB,KAAK,CAAC,EAAEC,GAAG,CAAC;EAC5C,CAAC,CAAsC;;EAEvC;EACA,IAAAmB,2BAAiB,EAACV,MAAM,EAAEW,WAAW,IAAIzB,MAAM,CAACE,OAAO,CAACuB,WAAW,CAAC,CAACC,OAAO,CAAC,CAAC,CAACrB,GAAG,EAAED,KAAK,CAAC,KAAKP,gBAAgB,CAAC8B,GAAG,CAACtB,GAAG,EAAED,KAAK,CAAC,CAAC,CAAC;EAEjI,OAAOU,MAAM;AACjB,CAAC;AAAAc,OAAA,CAAArC,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createUnistylesComponent = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _utils = require("./utils");
9
+ var _runtime = require("./runtime");
10
+ var _variants = require("./variants");
11
+ var _listener = require("./listener");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ const getStyles = value => {
16
+ const secrets = (0, _utils.extractSecrets)(value);
17
+ if (secrets.length === 0) {
18
+ return undefined;
19
+ }
20
+ return secrets.reduce((acc, {
21
+ __uni__stylesheet,
22
+ __uni__key,
23
+ __uni__args = [],
24
+ __uni__variants
25
+ }) => {
26
+ const newComputedStylesheet = typeof __uni__stylesheet === 'function' ? __uni__stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : __uni__stylesheet;
27
+ const style = newComputedStylesheet[__uni__key];
28
+ const resultHidden = typeof style === 'function' ? style(...__uni__args) : style;
29
+ const result = (0, _utils.extractHiddenProperties)(resultHidden);
30
+ const {
31
+ variants
32
+ } = Object.fromEntries((0, _variants.getVariants)({
33
+ variants: result
34
+ }, __uni__variants));
35
+ const resultWithVariants = {
36
+ ...result,
37
+ ...variants
38
+ };
39
+ return {
40
+ ...acc,
41
+ ...resultWithVariants
42
+ };
43
+ }, {});
44
+ };
45
+ const createUnistylesComponent = Component => props => {
46
+ const passedStyles = props.style ?? {};
47
+ const [style, setStyle] = (0, _react.useState)(getStyles(passedStyles));
48
+ (0, _react.useEffect)(() => {
49
+ const newStyles = getStyles(passedStyles);
50
+ const dependencies = newStyles?.['uni__dependencies'] ?? [];
51
+ const dispose = _listener.UnistylesListener.addListeners(dependencies, () => setStyle(getStyles(passedStyles)));
52
+ setStyle(newStyles);
53
+ return dispose;
54
+ }, [passedStyles]);
55
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
56
+ ...props,
57
+ style: style
58
+ });
59
+ };
60
+ exports.createUnistylesComponent = createUnistylesComponent;
61
+ //# sourceMappingURL=createUnistylesComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_utils","_runtime","_variants","_listener","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getStyles","value","secrets","extractSecrets","length","undefined","reduce","acc","__uni__stylesheet","__uni__key","__uni__args","__uni__variants","newComputedStylesheet","UnistylesRuntime","theme","miniRuntime","style","resultHidden","result","extractHiddenProperties","variants","fromEntries","getVariants","resultWithVariants","createUnistylesComponent","Component","props","passedStyles","setStyle","useState","useEffect","newStyles","dependencies","dispose","UnistylesListener","addListeners","jsx","exports"],"sourceRoot":"../../../src","sources":["web/createUnistylesComponent.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAA8C,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAA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,CAAwB,CAAC;AACjC,CAAC;AAEM,MAAMC,wBAAwB,GAA2BC,SAAsC,IAAMC,KAAa,IAAK;EAC1H,MAAMC,YAAY,GAAID,KAAK,CAA6CV,KAAK,IAAI,CAAC,CAAC;EACnF,MAAM,CAACA,KAAK,EAAEY,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAC7B,SAAS,CAAC2B,YAAY,CAAC,CAAC;EAE3D,IAAAG,gBAAS,EAAC,MAAM;IACZ,MAAMC,SAAS,GAAG/B,SAAS,CAAC2B,YAAY,CAAC;IACzC,MAAMK,YAAY,GAAGD,SAAS,GAAG,mBAAmB,CAAC,IAAI,EAAE;IAC3D,MAAME,OAAO,GAAGC,2BAAiB,CAACC,YAAY,CAACH,YAAY,EAAE,MAAMJ,QAAQ,CAAC5B,SAAS,CAAC2B,YAAY,CAAC,CAAC,CAAC;IAErGC,QAAQ,CAACG,SAAS,CAAC;IAEnB,OAAOE,OAAO;EAClB,CAAC,EAAE,CAACN,YAAY,CAAC,CAAC;EAElB,oBACI,IAAAhD,WAAA,CAAAyD,GAAA,EAACX,SAAS;IAAA,GACFC,KAAK;IACTV,KAAK,EAAEA;EAAM,CAChB,CAAC;AAEV,CAAC;AAAAqB,OAAA,CAAAb,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  StyleSheet: true,
8
8
  getSSRUnistyles: true,
9
- UnistylesRuntime: true
9
+ UnistylesRuntime: true,
10
+ UnistylesShadowRegistry: true
10
11
  };
11
12
  exports.StyleSheet = void 0;
12
13
  Object.defineProperty(exports, "UnistylesRuntime", {
@@ -15,11 +16,18 @@ Object.defineProperty(exports, "UnistylesRuntime", {
15
16
  return _runtime.UnistylesRuntime;
16
17
  }
17
18
  });
19
+ Object.defineProperty(exports, "UnistylesShadowRegistry", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _shadowRegistry.UnistylesShadowRegistry;
23
+ }
24
+ });
18
25
  exports.getSSRUnistyles = void 0;
19
26
  var _create = require("./create");
20
- var _runtime = require("./runtime");
21
27
  var _state = require("./state");
22
28
  var _utils = require("./utils");
29
+ var _runtime = require("./runtime");
30
+ var _shadowRegistry = require("./shadowRegistry");
23
31
  var _mock = require("./mock");
24
32
  Object.keys(_mock).forEach(function (key) {
25
33
  if (key === "default" || key === "__esModule") return;
@@ -46,6 +54,7 @@ const StyleSheet = exports.StyleSheet = {
46
54
  flatten: (...styles) => (0, _utils.deepMergeObjects)(...styles),
47
55
  hairlineWidth: 1
48
56
  };
49
- const getSSRUnistyles = () => _runtime.UnistylesRuntime.getSSRUnistyles();
57
+ // TODO: Work on SSR
58
+ const getSSRUnistyles = () => [];
50
59
  exports.getSSRUnistyles = getSSRUnistyles;
51
60
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_create","require","_runtime","_state","_utils","_mock","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","StyleSheet","configure","UnistylesState","init","create","absoluteFill","position","left","top","right","bottom","compose","a","b","deepMergeObjects","flatten","styles","hairlineWidth","getSSRUnistyles","UnistylesRuntime"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAkBA,IAAAI,KAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,KAAA,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,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAhBO,MAAMS,UAAU,GAAAJ,OAAA,CAAAI,UAAA,GAAG;EACtBC,SAAS,EAAEC,qBAAc,CAACC,IAAI;EAC9BC,MAAM,EAANA,cAAM;EACNC,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAK,IAAAC,uBAAgB,EAACF,CAAC,EAAEC,CAAC,CAAC;EACzDE,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAK,IAAAF,uBAAgB,EAAC,GAAGE,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAKM,MAAMC,eAAe,GAAGA,CAAA,KAAMC,yBAAgB,CAACD,eAAe,CAAC,CAAC;AAAAtB,OAAA,CAAAsB,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_create","require","_state","_utils","_runtime","_shadowRegistry","_mock","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","StyleSheet","configure","UnistylesState","init","create","absoluteFill","position","left","top","right","bottom","compose","a","b","deepMergeObjects","flatten","styles","hairlineWidth","getSSRUnistyles"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAiBA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAF,KAAA,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,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAjBO,MAAMS,UAAU,GAAAJ,OAAA,CAAAI,UAAA,GAAG;EACtBC,SAAS,EAAEC,qBAAc,CAACC,IAAI;EAC9BC,MAAM,EAANA,cAAM;EACNC,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAK,IAAAC,uBAAgB,EAACF,CAAC,EAAEC,CAAC,CAAC;EACzDE,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAK,IAAAF,uBAAgB,EAAC,GAAGE,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAMD;AACO,MAAMC,eAAe,GAAGA,CAAA,KAAM,EAAE;AAAAtB,OAAA,CAAAsB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -9,5 +9,12 @@ Object.defineProperty(exports, "UnistylesListener", {
9
9
  return _listener.UnistylesListener;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "listenToDependencies", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _listenToDependencies.listenToDependencies;
16
+ }
17
+ });
12
18
  var _listener = require("./listener");
19
+ var _listenToDependencies = require("./listenToDependencies");
13
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_listener","require"],"sourceRoot":"../../../../src","sources":["web/listener/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_listener","require","_listenToDependencies"],"sourceRoot":"../../../../src","sources":["web/listener/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.listenToDependencies = void 0;
7
+ var _listener = require("./listener");
8
+ var _runtime = require("../runtime");
9
+ var _utils = require("../utils");
10
+ var _registry = require("../registry");
11
+ const listenToDependencies = ({
12
+ key,
13
+ className,
14
+ unistyles,
15
+ args = [],
16
+ stylesheet
17
+ }) => {
18
+ const newComputedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
19
+ const _value = (0, _utils.keyInObject)(newComputedStylesheet, key) ? newComputedStylesheet[key] : undefined;
20
+ if (!_value) {
21
+ return;
22
+ }
23
+ const value = typeof _value === 'function' ? _value(...args) : _value;
24
+ const dependencies = 'uni__dependencies' in value ? value['uni__dependencies'] : [];
25
+ if (dependencies.length === 0) {
26
+ return;
27
+ }
28
+ return _listener.UnistylesListener.addListeners(dependencies, () => {
29
+ const newComputedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
30
+ if (!(0, _utils.keyInObject)(newComputedStylesheet, key)) {
31
+ return;
32
+ }
33
+ const value = newComputedStylesheet[key];
34
+ const result = typeof value === 'function' ? value(...args) : value;
35
+ _registry.UnistylesRegistry.updateStyles(unistyles, result, className);
36
+ });
37
+ };
38
+ exports.listenToDependencies = listenToDependencies;
39
+ //# sourceMappingURL=listenToDependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_listener","require","_runtime","_utils","_registry","listenToDependencies","key","className","unistyles","args","stylesheet","newComputedStylesheet","UnistylesRuntime","theme","miniRuntime","_value","keyInObject","undefined","value","dependencies","length","UnistylesListener","addListeners","result","UnistylesRegistry","updateStyles","exports"],"sourceRoot":"../../../../src","sources":["web/listener/listenToDependencies.ts"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAUO,MAAMI,oBAAoB,GAAGA,CAAC;EAAEC,GAAG;EAAEC,SAAS;EAAEC,SAAS;EAAEC,IAAI,GAAG,EAAE;EAAEC;AAAsC,CAAC,KAAK;EACrH,MAAMC,qBAAqB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACxDA,UAAU,CAACE,yBAAgB,CAACC,KAAK,EAAED,yBAAgB,CAACE,WAAW,CAAC,GAChEJ,UAAU;EAChB,MAAMK,MAAM,GAAG,IAAAC,kBAAW,EAACL,qBAAqB,EAAEL,GAAG,CAAC,GAAGK,qBAAqB,CAACL,GAAG,CAAC,GAAGW,SAAS;EAE/F,IAAI,CAACF,MAAM,EAAE;IACT;EACJ;EAEA,MAAMG,KAAK,GAAG,OAAOH,MAAM,KAAK,UAAU,GAAGA,MAAM,CAAC,GAAGN,IAAI,CAAC,GAAGM,MAAM;EACrE,MAAMI,YAAY,GAAI,mBAAmB,IAAID,KAAK,GAAGA,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAgC;EAElH,IAAIC,YAAY,CAACC,MAAM,KAAK,CAAC,EAAE;IAC3B;EACJ;EAEA,OAAOC,2BAAiB,CAACC,YAAY,CAACH,YAAY,EAAE,MAAM;IACtD,MAAMR,qBAAqB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACxDA,UAAU,CAACE,yBAAgB,CAACC,KAAK,EAAED,yBAAgB,CAACE,WAAW,CAAC,GAChEJ,UAAU;IAEhB,IAAI,CAAC,IAAAM,kBAAW,EAACL,qBAAqB,EAAEL,GAAG,CAAC,EAAE;MAC1C;IACJ;IAEA,MAAMY,KAAK,GAAGP,qBAAqB,CAACL,GAAG,CAAE;IACzC,MAAMiB,MAAM,GAAG,OAAOL,KAAK,KAAK,UAAU,GACpCA,KAAK,CAAC,GAAGT,IAAI,CAAC,GACdS,KAAK;IAEXM,2BAAiB,CAACC,YAAY,CAACjB,SAAS,EAAEe,MAAM,EAAEhB,SAAS,CAAC;EAChE,CAAC,CAAC;AACN,CAAC;AAAAmB,OAAA,CAAArB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.UnistylesListenerBuilder = exports.UnistylesListener = void 0;
6
+ exports.UnistylesListener = void 0;
7
7
  var _NativePlatform = require("../../specs/NativePlatform");
8
8
  var _runtime = require("../runtime");
9
9
  class UnistylesListenerBuilder {
@@ -31,6 +31,5 @@ class UnistylesListenerBuilder {
31
31
  };
32
32
  };
33
33
  }
34
- exports.UnistylesListenerBuilder = UnistylesListenerBuilder;
35
34
  const UnistylesListener = exports.UnistylesListener = new UnistylesListenerBuilder();
36
35
  //# sourceMappingURL=listener.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","exports","UnistylesListener"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,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ACS,UAAU,CAAC,EAAEe,MAAM,CAACb,QAAQ,CAAC,CAAC;IACpF,CAAC;EACL,CAAC;AACL;AAACc,OAAA,CAAA3B,wBAAA,GAAAA,wBAAA;AAEM,MAAM4B,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,IAAI5B,wBAAwB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","UnistylesListener","exports"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,kCAAkB,CAAC,CAACH,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAII,GAAG,CAAe,CAAC,CAAC;EAErHC,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;EAC/D,CAAC;EAEDC,aAAa,GAAGA,CAAA,KAAM;IAClB,IAAI,IAAI,CAACb,aAAa,EAAE;MACpB;IACJ;IAEA,IAAI,CAACA,aAAa,GAAG,IAAI;IACzBc,yBAAgB,CAACC,SAAS,EAAEC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACU,WAAW,CAAC,CAAC;IAC7GH,yBAAgB,CAACI,UAAU,EAAEF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,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