react-native-unistyles 3.0.0-alpha.13 → 3.0.0-alpha.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. package/cxx/core/UnistyleWrapper.h +1 -1
  2. package/cxx/core/UnistylesCommitHook.cpp +13 -10
  3. package/cxx/core/UnistylesMountHook.cpp +3 -19
  4. package/cxx/hybridObjects/HybridStyleSheet.cpp +4 -3
  5. package/cxx/hybridObjects/HybridStyleSheet.h +1 -1
  6. package/cxx/parser/Parser.cpp +13 -9
  7. package/cxx/shadowTree/ShadowTreeManager.cpp +5 -5
  8. package/lib/commonjs/index.js +4 -0
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/specs/ShadowRegistry/index.js +7 -1
  11. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  12. package/lib/commonjs/web/convert/index.js +1 -1
  13. package/lib/commonjs/web/convert/index.js.map +1 -1
  14. package/lib/commonjs/web/create.js +25 -63
  15. package/lib/commonjs/web/create.js.map +1 -1
  16. package/lib/commonjs/web/createUnistylesComponent.js +61 -0
  17. package/lib/commonjs/web/createUnistylesComponent.js.map +1 -0
  18. package/lib/commonjs/web/index.js +12 -3
  19. package/lib/commonjs/web/index.js.map +1 -1
  20. package/lib/commonjs/web/listener/index.js +7 -0
  21. package/lib/commonjs/web/listener/index.js.map +1 -1
  22. package/lib/commonjs/web/listener/listenToDependencies.js +39 -0
  23. package/lib/commonjs/web/listener/listenToDependencies.js.map +1 -0
  24. package/lib/commonjs/web/listener/listener.js +1 -2
  25. package/lib/commonjs/web/listener/listener.js.map +1 -1
  26. package/lib/commonjs/web/mock.js +1 -10
  27. package/lib/commonjs/web/mock.js.map +1 -1
  28. package/lib/commonjs/web/pseudo.js +2 -3
  29. package/lib/commonjs/web/pseudo.js.map +1 -1
  30. package/lib/commonjs/web/registry.js +2 -4
  31. package/lib/commonjs/web/registry.js.map +1 -1
  32. package/lib/commonjs/web/runtime.js +0 -1
  33. package/lib/commonjs/web/runtime.js.map +1 -1
  34. package/lib/commonjs/web/shadowRegistry.js +120 -0
  35. package/lib/commonjs/web/shadowRegistry.js.map +1 -0
  36. package/lib/commonjs/web/state.js +0 -40
  37. package/lib/commonjs/web/state.js.map +1 -1
  38. package/lib/commonjs/web/utils.js +66 -14
  39. package/lib/commonjs/web/utils.js.map +1 -1
  40. package/lib/commonjs/web/variants/useVariants.js +15 -31
  41. package/lib/commonjs/web/variants/useVariants.js.map +1 -1
  42. package/lib/module/index.js +4 -0
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/specs/ShadowRegistry/index.js +7 -1
  45. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  46. package/lib/module/web/convert/index.js +1 -1
  47. package/lib/module/web/convert/index.js.map +1 -1
  48. package/lib/module/web/create.js +26 -64
  49. package/lib/module/web/create.js.map +1 -1
  50. package/lib/module/web/createUnistylesComponent.js +54 -0
  51. package/lib/module/web/createUnistylesComponent.js.map +1 -0
  52. package/lib/module/web/index.js +4 -2
  53. package/lib/module/web/index.js.map +1 -1
  54. package/lib/module/web/listener/index.js +1 -0
  55. package/lib/module/web/listener/index.js.map +1 -1
  56. package/lib/module/web/listener/listenToDependencies.js +34 -0
  57. package/lib/module/web/listener/listenToDependencies.js.map +1 -0
  58. package/lib/module/web/listener/listener.js +1 -1
  59. package/lib/module/web/listener/listener.js.map +1 -1
  60. package/lib/module/web/mock.js +0 -9
  61. package/lib/module/web/mock.js.map +1 -1
  62. package/lib/module/web/pseudo.js +2 -3
  63. package/lib/module/web/pseudo.js.map +1 -1
  64. package/lib/module/web/registry.js +2 -4
  65. package/lib/module/web/registry.js.map +1 -1
  66. package/lib/module/web/runtime.js +0 -1
  67. package/lib/module/web/runtime.js.map +1 -1
  68. package/lib/module/web/shadowRegistry.js +116 -0
  69. package/lib/module/web/shadowRegistry.js.map +1 -0
  70. package/lib/module/web/state.js +0 -40
  71. package/lib/module/web/state.js.map +1 -1
  72. package/lib/module/web/utils.js +59 -12
  73. package/lib/module/web/utils.js.map +1 -1
  74. package/lib/module/web/variants/useVariants.js +16 -32
  75. package/lib/module/web/variants/useVariants.js.map +1 -1
  76. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  77. package/lib/typescript/src/web/create.d.ts.map +1 -1
  78. package/lib/typescript/src/web/createUnistylesComponent.d.ts +3 -0
  79. package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -0
  80. package/lib/typescript/src/web/index.d.ts +2 -1
  81. package/lib/typescript/src/web/index.d.ts.map +1 -1
  82. package/lib/typescript/src/web/listener/index.d.ts +1 -0
  83. package/lib/typescript/src/web/listener/index.d.ts.map +1 -1
  84. package/lib/typescript/src/web/listener/listenToDependencies.d.ts +12 -0
  85. package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -0
  86. package/lib/typescript/src/web/listener/listener.d.ts +2 -1
  87. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -1
  88. package/lib/typescript/src/web/mock.d.ts +0 -9
  89. package/lib/typescript/src/web/mock.d.ts.map +1 -1
  90. package/lib/typescript/src/web/pseudo.d.ts +4 -2
  91. package/lib/typescript/src/web/pseudo.d.ts.map +1 -1
  92. package/lib/typescript/src/web/registry.d.ts +1 -1
  93. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  94. package/lib/typescript/src/web/runtime.d.ts +0 -1
  95. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  96. package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
  97. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
  98. package/lib/typescript/src/web/state.d.ts +0 -5
  99. package/lib/typescript/src/web/state.d.ts.map +1 -1
  100. package/lib/typescript/src/web/utils.d.ts +22 -7
  101. package/lib/typescript/src/web/utils.d.ts.map +1 -1
  102. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -1
  103. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -3
  104. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +8 -3
  105. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +1 -1
  106. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +1 -1
  107. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +14 -2
  108. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +3 -0
  109. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -0
  110. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +3 -0
  111. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
  112. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -0
  113. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  114. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +4 -1
  115. package/package.json +3 -3
  116. package/plugin/index.js +31 -0
  117. package/src/index.ts +3 -0
  118. package/src/specs/ShadowRegistry/index.ts +7 -1
  119. package/src/web/convert/index.ts +1 -1
  120. package/src/web/create.ts +24 -79
  121. package/src/web/createUnistylesComponent.tsx +56 -0
  122. package/src/web/index.ts +3 -2
  123. package/src/web/listener/index.ts +1 -0
  124. package/src/web/listener/listenToDependencies.ts +50 -0
  125. package/src/web/listener/listener.ts +1 -1
  126. package/src/web/mock.ts +0 -10
  127. package/src/web/pseudo.ts +131 -5
  128. package/src/web/registry.ts +3 -5
  129. package/src/web/runtime.ts +0 -2
  130. package/src/web/shadowRegistry.ts +121 -0
  131. package/src/web/state.ts +0 -44
  132. package/src/web/utils.ts +90 -16
  133. package/src/web/variants/useVariants.ts +18 -32
@@ -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
  }
@@ -17,27 +17,30 @@ RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
17
17
  ) noexcept {
18
18
  RootShadowNode::Unshared rootNode = newRootShadowNode;
19
19
  auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootShadowNode);
20
-
20
+
21
21
  // skip only unistyles commits
22
22
  if (unistylesRootNode->hasUnistylesCommitTrait()) {
23
23
  unistylesRootNode->removeUnistylesCommitTrait();
24
24
  unistylesRootNode->addUnistylesMountTrait();
25
-
25
+
26
26
  return newRootShadowNode;
27
27
  }
28
-
29
- unistylesRootNode->removeUnistylesMountTrait();
30
-
28
+
31
29
  auto& registry = core::UnistylesRegistry::get();
30
+
31
+ if (!registry.trafficController.hasUnistylesCommit()) {
32
+ return newRootShadowNode;
33
+ }
34
+
32
35
  auto shadowLeafUpdates = this->getUnistylesUpdates();
33
-
36
+
34
37
  if (shadowLeafUpdates.size() == 0) {
35
38
  return newRootShadowNode;
36
39
  }
37
40
 
38
41
  // this is required, otherwise we end up with old shadow tree in mount hook
39
42
  registry.trafficController.stopUnistylesTraffic();
40
-
43
+
41
44
  auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(*rootNode, shadowLeafUpdates);
42
45
 
43
46
  return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
@@ -52,8 +55,8 @@ shadow::ShadowLeafUpdates core::UnistylesCommitHook::getUnistylesUpdates() {
52
55
  auto& registry = core::UnistylesRegistry::get();
53
56
  auto parser = parser::Parser(this->_unistylesRuntime);
54
57
  auto dependencyMap = registry.buildDependencyMap(*this->_rt);
55
-
56
- parser.rebuildUnistylesInDependencyMap(*this->_rt, dependencyMap);
57
-
58
+
59
+ // don't rebuild dependency map, at this point it's already done
60
+
58
61
  return parser.dependencyMapToShadowLeafUpdates(dependencyMap);
59
62
  }
@@ -19,27 +19,11 @@ void core::UnistylesMountHook::shadowTreeDidMount(RootShadowNode::Shared const &
19
19
  return;
20
20
  }
21
21
 
22
- // this is React Native commit
22
+ // React Native commit did mount
23
23
  auto& registry = core::UnistylesRegistry::get();
24
24
 
25
+ // so, resume Unistyles commits
25
26
  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
-
36
- auto shadowLeafUpdates = this->getUnistylesUpdates();
37
-
38
- if (shadowLeafUpdates.size() == 0) {
39
- return;
40
- }
41
-
42
- shadow::ShadowTreeManager::updateShadowTree(*this->_rt, shadowLeafUpdates);
43
27
  }
44
28
 
45
29
  shadow::ShadowLeafUpdates core::UnistylesMountHook::getUnistylesUpdates() {
@@ -47,7 +31,7 @@ shadow::ShadowLeafUpdates core::UnistylesMountHook::getUnistylesUpdates() {
47
31
  auto parser = parser::Parser(this->_unistylesRuntime);
48
32
  auto dependencyMap = registry.buildDependencyMap(*this->_rt);
49
33
 
50
- parser.rebuildUnistylesInDependencyMap(*this->_rt, dependencyMap);
34
+ // don't rebuild dependency map, at this point it's already done
51
35
 
52
36
  return parser.dependencyMapToShadowLeafUpdates(dependencyMap);
53
37
  }
@@ -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
 
@@ -35,8 +35,6 @@ jsi::Value HybridStyleSheet::create(jsi::Runtime& rt, const jsi::Value &thisVal,
35
35
  auto style = std::make_shared<core::HostStyle>(registeredStyleSheet, this->_unistylesRuntime);
36
36
  auto styleHostObject = jsi::Object::createFromHostObject(rt, style);
37
37
 
38
- registry.trafficController.setHasUnistylesCommit(true);
39
-
40
38
  return styleHostObject;
41
39
  }
42
40
 
@@ -238,6 +236,9 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
238
236
 
239
237
  parser.rebuildUnistylesInDependencyMap(rt, dependencyMap);
240
238
 
239
+ // this is required, otherwise shadow tree will ignore Unistyles commit
240
+ registry.trafficController.setHasUnistylesCommit(true);
241
+
241
242
  auto shadowLeafUpdates = parser.dependencyMapToShadowLeafUpdates(dependencyMap);
242
243
 
243
244
  shadow::ShadowTreeManager::updateShadowTree(rt, shadowLeafUpdates);
@@ -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);
@@ -100,20 +100,24 @@ void parser::Parser::rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_
100
100
 
101
101
  // rebuild all unistyles that are affected by platform event
102
102
  void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, DependencyMap& dependencyMap) {
103
+ std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value> parsedStyleSheets{};
104
+
103
105
  for (auto& [shadowNode, unistyles] : dependencyMap) {
104
106
  auto styleSheet = unistyles.begin()->get()->unistyle->parent;
105
-
106
- jsi::Object unwrappedStyleSheet = this->unwrapStyleSheet(rt, styleSheet);
107
+
108
+ if (!parsedStyleSheets.contains(styleSheet)) {
109
+ parsedStyleSheets.emplace(styleSheet, this->unwrapStyleSheet(rt, styleSheet));
110
+ }
107
111
 
108
112
  for (auto& unistyleData : unistyles) {
109
113
  auto& unistyle = unistyleData->unistyle;
110
114
 
111
115
  // StyleSheet might have styles that are not affected
112
- if (!unwrappedStyleSheet.hasProperty(rt, unistyle->styleKey.c_str())) {
116
+ if (!parsedStyleSheets[styleSheet].asObject(rt).hasProperty(rt, unistyle->styleKey.c_str())) {
113
117
  continue;
114
118
  }
115
119
 
116
- unistyle->rawValue = unwrappedStyleSheet.getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
120
+ unistyle->rawValue = parsedStyleSheets[styleSheet].asObject(rt).getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
117
121
  this->rebuildUnistyle(rt, styleSheet, unistyle, unistyleData->variants, unistyleData->dynamicFunctionMetadata);
118
122
  unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
119
123
  }
@@ -162,10 +166,10 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleShee
162
166
  shadow::ShadowLeafUpdates parser::Parser::dependencyMapToShadowLeafUpdates(core::DependencyMap& dependencyMap) {
163
167
  shadow::ShadowLeafUpdates updates;
164
168
  auto& rt = this->_unistylesRuntime->getRuntime();
165
-
169
+
166
170
  for (const auto& [shadowNode, unistyles] : dependencyMap) {
167
171
  auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyles);
168
-
172
+
169
173
  updates.emplace(shadowNode, std::move(rawProps));
170
174
  }
171
175
 
@@ -285,7 +289,7 @@ jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unist
285
289
  [this, unistylesRuntime, unistyle](jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
286
290
  auto thisObject = thisVal.asObject(rt);
287
291
  auto parser = parser::Parser(unistylesRuntime);
288
-
292
+
289
293
  // call user function
290
294
  auto result = unistyle->rawValue.asFunction(rt).call(rt, args, count);
291
295
 
@@ -300,7 +304,7 @@ jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unist
300
304
  std::optional<Variants> variants = rawVariants.isUndefined()
301
305
  ? std::nullopt
302
306
  : std::optional<Variants>(helpers::variantsToPairs(rt, rawVariants.asObject(rt)));
303
-
307
+
304
308
  unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn, variants);
305
309
  unistyleFn->seal();
306
310
 
@@ -615,7 +619,7 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
615
619
  RawProps parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles) {
616
620
  jsi::Object convertedStyles = jsi::Object(rt);
617
621
  auto& state = core::UnistylesRegistry::get().getState(rt);
618
-
622
+
619
623
  for (const auto& unistyleData : unistyles) {
620
624
  helpers::enumerateJSIObject(rt, unistyleData->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
621
625
  if (this->isColor(propertyName)) {
@@ -10,10 +10,10 @@ void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt, sha
10
10
  auto& uiManager = UIManagerBinding::getBinding(rt)->getUIManager();
11
11
  const auto &shadowTreeRegistry = uiManager.getShadowTreeRegistry();
12
12
  auto& registry = core::UnistylesRegistry::get();
13
-
13
+
14
14
  if (registry.trafficController.shouldStop()) {
15
15
  registry.trafficController.setHasUnistylesCommit(true);
16
-
16
+
17
17
  return;
18
18
  }
19
19
 
@@ -29,10 +29,10 @@ void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt, sha
29
29
  updates,
30
30
  affectedNodes
31
31
  ));
32
-
32
+
33
33
  // set unistyles commit trait
34
34
  auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootNode);
35
-
35
+
36
36
  unistylesRootNode->addUnistylesCommitTrait();
37
37
 
38
38
  return newRootNode;
@@ -43,7 +43,7 @@ void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt, sha
43
43
  // enableStateReconciliation: https://reactnative.dev/architecture/render-pipeline#react-native-renderer-state-updates
44
44
  // mountSynchronously: must be true as this is update from C++ not React
45
45
  shadowTree.commit(transaction, {false, true});
46
-
46
+
47
47
 
48
48
  // for now we're assuming single surface, can be improved in the future
49
49
  // stop = true means stop enumerating next shadow tree
@@ -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 || typeof style !== 'object') {
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,IAAI,OAAOQ,KAAK,KAAK,QAAQ,EAAE;IACtC;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":[]}
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","ex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G,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,kBAAkB,GAAG,OAAOD,UAAU,KAAK,UAAU,G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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,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,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AMC,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