@tamagui/core 1.132.1 → 1.132.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5426,7 +5426,7 @@ var require_getSplitStyles_native = __commonJS({
5426
5426
  var { asChild } = props, { accept } = staticConfig, { noSkip, disableExpandShorthands, noExpand } = styleProps, { webContainerType } = conf.settings, parentVariants = parentStaticConfig == null ? void 0 : parentStaticConfig.variants;
5427
5427
  for (var keyOg in props) _loop(keyOg);
5428
5428
  var avoidNormalize = styleProps.noNormalize === !1;
5429
- if (debug && console.warn("?", avoidNormalize, styleProps.noExpand, styleProps.noMergeStyle, styleState.style), !avoidNormalize) {
5429
+ if (!avoidNormalize) {
5430
5430
  if (styleState.style && ((0, import_expandStyles.fixStyles)(styleState.style), !styleProps.noExpand && !styleProps.noMergeStyle && import_constants.isWeb && (!isReactNative || !animationDriver.supportsCSS) && (0, import_getCSSStylesAtomic.styleToCSS)(styleState.style)), styleState.flatTransforms) {
5431
5431
  var _styleState;
5432
5432
  (_styleState = styleState).style || (_styleState.style = {}), mergeFlatTransforms(styleState.style, styleState.flatTransforms);
@@ -7184,10 +7184,10 @@ var require_createComponent_native = __commonJS({
7184
7184
  } : defaultProps, props = propsIn;
7185
7185
  curDefaultProps && (props = (0, import_mergeProps.mergeProps)(curDefaultProps, propsIn));
7186
7186
  var componentName2 = props.componentName || staticConfig.componentName, componentContext = import_react3.default.useContext(import_ComponentContext.ComponentContext), groupContextParent = import_react3.default.useContext(import_GroupContext.GroupContext), animationDriver = componentContext.animationDriver, useAnimations = animationDriver == null ? void 0 : animationDriver.useAnimations, componentState = (0, import_useComponentState.useComponentState)(props, animationDriver, staticConfig, config), { disabled, groupName, hasAnimationProp, hasEnterStyle, isAnimated, isExiting, isHydrated, presence, presenceState, setState, noClass, state, stateRef, supportsCSS, willBeAnimated, willBeAnimatedClient, startedUnhydrated } = componentState;
7187
- hasAnimationProp && animationDriver != null && animationDriver.avoidReRenders && (0, import_constants.useIsomorphicLayoutEffect)(function() {
7187
+ if (hasAnimationProp && animationDriver != null && animationDriver.avoidReRenders) {
7188
7188
  var pendingState = NextState.get(stateRef);
7189
- pendingState && (setStateShallow(pendingState), NextState.set(stateRef, void 0));
7190
- });
7189
+ pendingState && (NextState.set(stateRef, void 0), componentState.setStateShallow(pendingState));
7190
+ }
7191
7191
  var allGroupContexts = (0, import_react3.useMemo)(function() {
7192
7192
  var _stateRef_current_group;
7193
7193
  if (!groupName || props.passThrough) return groupContextParent;
@@ -7274,31 +7274,30 @@ var require_createComponent_native = __commonJS({
7274
7274
  }
7275
7275
  }
7276
7276
  if (splitStyles && (hasAnimationProp || groupName) && animationDriver != null && animationDriver.avoidReRenders) {
7277
- var useStyleListener = stateRef.current.useStyleListener, ogSetStateShallow = setStateShallow;
7278
- componentContext.mediaEmit = function(next) {
7279
- NextMedia.set(stateRef, next), updateStyleListener();
7280
- };
7281
- var updateStyleListener = function() {
7277
+ var _componentContext, ogSetStateShallow = setStateShallow;
7278
+ stateRef.current.updateStyleListener = function() {
7282
7279
  var updatedState = NextState.get(stateRef) || state, mediaState22 = NextMedia.get(stateRef), { group, hasDynGroupChildren, unmounted, animation, ...childrenGroupState } = updatedState;
7283
7280
  groupContext && notifyGroupSubscribers(groupContext, stateRef.current.group || null, childrenGroupState);
7284
7281
  var nextStyles = (0, import_getSplitStyles.getSplitStyles)(props, staticConfig, theme, themeName, updatedState, mediaState22 ? {
7285
7282
  ...styleProps,
7286
7283
  mediaState: mediaState22
7287
- } : styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp);
7284
+ } : styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp), useStyleListener = stateRef.current.useStyleListener;
7288
7285
  useStyleListener == null || useStyleListener((nextStyles == null ? void 0 : nextStyles.style) || {});
7289
- };
7290
- stateRef.current.setStateShallow = function(nextOrGetNext) {
7286
+ }, (_componentContext = componentContext).mediaEmit || (_componentContext.mediaEmit = function(next) {
7287
+ var _stateRef_current_updateStyleListener, _stateRef_current;
7288
+ NextMedia.set(stateRef, next), (_stateRef_current_updateStyleListener = (_stateRef_current = stateRef.current).updateStyleListener) === null || _stateRef_current_updateStyleListener === void 0 || _stateRef_current_updateStyleListener.call(_stateRef_current);
7289
+ }), stateRef.current.setStateShallow = function(nextOrGetNext) {
7291
7290
  var prev = NextState.get(stateRef) || state, next = typeof nextOrGetNext == "function" ? nextOrGetNext(prev) : nextOrGetNext;
7292
7291
  if (!(next === prev || (0, import_is_equal_shallow.isEqualShallow)(prev, next))) {
7293
7292
  var canAvoidReRender = Object.keys(next).every(function(key3) {
7294
7293
  return avoidReRenderKeys.has(key3);
7295
7294
  });
7296
7295
  if (canAvoidReRender) {
7297
- var updatedState = {
7296
+ var _stateRef_current_updateStyleListener, _stateRef_current, updatedState = {
7298
7297
  ...prev,
7299
7298
  ...next
7300
7299
  };
7301
- NextState.set(stateRef, updatedState), updateStyleListener();
7300
+ NextState.set(stateRef, updatedState), (_stateRef_current_updateStyleListener = (_stateRef_current = stateRef.current).updateStyleListener) === null || _stateRef_current_updateStyleListener === void 0 || _stateRef_current_updateStyleListener.call(_stateRef_current);
7302
7301
  } else ogSetStateShallow(next);
7303
7302
  }
7304
7303
  }, setStateShallow = function(state2) {
@@ -11824,18 +11823,7 @@ var require_index_native12 = __commonJS({
11824
11823
  }));
11825
11824
  }
11826
11825
  if (import_constants.isClient && rAF) {
11827
- layoutOnAnimationFrame = function() {
11828
- if (strategy !== "off") {
11829
- if (frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
11830
- rAF(layoutOnAnimationFrame);
11831
- return;
11832
- }
11833
- frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), Nodes.forEach(function(node) {
11834
- updateLayoutIfChanged(node);
11835
- });
11836
- }
11837
- rAF(layoutOnAnimationFrame);
11838
- }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, supportsCheckVisibility = "checkVisibility" in document.body;
11826
+ supportsCheckVisibility = "checkVisibility" in document.body, BoundingRects = /* @__PURE__ */ new WeakMap();
11839
11827
  async function updateLayoutIfChanged(node) {
11840
11828
  if (IntersectionState.get(node) !== !1 && !(process.env.TAMAGUI_ONLAYOUT_VISIBILITY_CHECK === "1" && supportsCheckVisibility && !node.checkVisibility())) {
11841
11829
  var onLayout = LayoutHandlers.get(node);
@@ -11845,8 +11833,8 @@ var require_index_native12 = __commonJS({
11845
11833
  var nodeRect, parentRect;
11846
11834
  if (strategy === "async") {
11847
11835
  var [nr, pr] = await Promise.all([
11848
- getBoundingClientRectAsync(node),
11849
- getBoundingClientRectAsync(parentNode)
11836
+ BoundingRects.get(node) || getBoundingClientRectAsync(node),
11837
+ BoundingRects.get(parentNode) || getBoundingClientRectAsync(parentNode)
11850
11838
  ]);
11851
11839
  if (nr === !1 || pr === !1) return;
11852
11840
  nodeRect = nr, parentRect = pr;
@@ -11867,8 +11855,56 @@ var require_index_native12 = __commonJS({
11867
11855
  }
11868
11856
  }
11869
11857
  rAF(layoutOnAnimationFrame), frameCount = 0, userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP, RUN_EVERY_X_FRAMES = userSkipVal ? +userSkipVal : 10;
11858
+ async function layoutOnAnimationFrame() {
11859
+ if (strategy !== "off") {
11860
+ if (!Nodes.size || frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
11861
+ rAF(layoutOnAnimationFrame);
11862
+ return;
11863
+ }
11864
+ frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), await new Promise(function(res) {
11865
+ var io = new IntersectionObserver(function(entries) {
11866
+ io.disconnect();
11867
+ var _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
11868
+ try {
11869
+ for (var _iterator2 = entries[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
11870
+ var entry = _step2.value;
11871
+ BoundingRects.set(entry.target, entry.boundingClientRect);
11872
+ }
11873
+ } catch (err) {
11874
+ _didIteratorError2 = !0, _iteratorError2 = err;
11875
+ } finally {
11876
+ try {
11877
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
11878
+ } finally {
11879
+ if (_didIteratorError2) throw _iteratorError2;
11880
+ }
11881
+ }
11882
+ res();
11883
+ }, {
11884
+ threshold: 0
11885
+ }), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
11886
+ try {
11887
+ for (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
11888
+ var node = _step.value;
11889
+ node.parentElement instanceof HTMLElement && (io.observe(node), io.observe(node.parentElement));
11890
+ }
11891
+ } catch (err) {
11892
+ _didIteratorError = !0, _iteratorError = err;
11893
+ } finally {
11894
+ try {
11895
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
11896
+ } finally {
11897
+ if (_didIteratorError) throw _iteratorError;
11898
+ }
11899
+ }
11900
+ }), Nodes.forEach(function(node) {
11901
+ updateLayoutIfChanged(node);
11902
+ });
11903
+ }
11904
+ rAF(layoutOnAnimationFrame);
11905
+ }
11870
11906
  }
11871
- var layoutOnAnimationFrame, layoutOnAnimationFrame2, supportsCheckVisibility, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
11907
+ var supportsCheckVisibility, BoundingRects, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
11872
11908
  return {
11873
11909
  nativeEvent: {
11874
11910
  layout: getRelativeDimensions(nodeRect, parentRect),