@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.
package/dist/native.js CHANGED
@@ -5791,7 +5791,7 @@ var require_getSplitStyles_native = __commonJS({
5791
5791
  for (var keyOg in props) _loop(keyOg);
5792
5792
  process.env.NODE_ENV === "development" && debug === "profile" && time`split-styles-propsend`;
5793
5793
  var avoidNormalize = styleProps.noNormalize === !1;
5794
- if (debug && console.warn("?", avoidNormalize, styleProps.noExpand, styleProps.noMergeStyle, styleState.style), !avoidNormalize) {
5794
+ if (!avoidNormalize) {
5795
5795
  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) {
5796
5796
  var _styleState;
5797
5797
  (_styleState = styleState).style || (_styleState.style = {}), mergeFlatTransforms(styleState.style, styleState.flatTransforms);
@@ -7636,10 +7636,10 @@ var require_createComponent_native = __commonJS({
7636
7636
  componentName2
7637
7637
  ]);
7638
7638
  var 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;
7639
- hasAnimationProp && animationDriver != null && animationDriver.avoidReRenders && (0, import_constants.useIsomorphicLayoutEffect)(function() {
7639
+ if (hasAnimationProp && animationDriver != null && animationDriver.avoidReRenders) {
7640
7640
  var pendingState = NextState.get(stateRef);
7641
- pendingState && (setStateShallow(pendingState), NextState.set(stateRef, void 0));
7642
- });
7641
+ pendingState && (NextState.set(stateRef, void 0), componentState.setStateShallow(pendingState));
7642
+ }
7643
7643
  var allGroupContexts = (0, import_react3.useMemo)(function() {
7644
7644
  var _stateRef_current_group;
7645
7645
  if (!groupName || props.passThrough) return groupContextParent;
@@ -7756,34 +7756,33 @@ var require_createComponent_native = __commonJS({
7756
7756
  }
7757
7757
  }
7758
7758
  if (splitStyles && (hasAnimationProp || groupName) && animationDriver != null && animationDriver.avoidReRenders) {
7759
- var useStyleListener = stateRef.current.useStyleListener, ogSetStateShallow = setStateShallow;
7760
- componentContext.mediaEmit = function(next) {
7761
- NextMedia.set(stateRef, next), updateStyleListener();
7762
- };
7763
- var updateStyleListener = function() {
7759
+ var _componentContext, ogSetStateShallow = setStateShallow;
7760
+ stateRef.current.updateStyleListener = function() {
7764
7761
  var updatedState = NextState.get(stateRef) || state, mediaState22 = NextMedia.get(stateRef), { group, hasDynGroupChildren, unmounted, animation, ...childrenGroupState } = updatedState;
7765
7762
  groupContext && notifyGroupSubscribers(groupContext, stateRef.current.group || null, childrenGroupState);
7766
7763
  var nextStyles = (0, import_getSplitStyles.getSplitStyles)(props, staticConfig, theme, themeName, updatedState, mediaState22 ? {
7767
7764
  ...styleProps,
7768
7765
  mediaState: mediaState22
7769
- } : styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp);
7766
+ } : styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp), useStyleListener = stateRef.current.useStyleListener;
7770
7767
  useStyleListener == null || useStyleListener((nextStyles == null ? void 0 : nextStyles.style) || {});
7771
- };
7772
- stateRef.current.setStateShallow = function(nextOrGetNext) {
7768
+ }, (_componentContext = componentContext).mediaEmit || (_componentContext.mediaEmit = function(next) {
7769
+ var _stateRef_current_updateStyleListener, _stateRef_current;
7770
+ NextMedia.set(stateRef, next), (_stateRef_current_updateStyleListener = (_stateRef_current = stateRef.current).updateStyleListener) === null || _stateRef_current_updateStyleListener === void 0 || _stateRef_current_updateStyleListener.call(_stateRef_current);
7771
+ }), stateRef.current.setStateShallow = function(nextOrGetNext) {
7773
7772
  var prev = NextState.get(stateRef) || state, next = typeof nextOrGetNext == "function" ? nextOrGetNext(prev) : nextOrGetNext;
7774
7773
  if (!(next === prev || (0, import_is_equal_shallow.isEqualShallow)(prev, next))) {
7775
7774
  var canAvoidReRender = Object.keys(next).every(function(key3) {
7776
7775
  return avoidReRenderKeys.has(key3);
7777
7776
  });
7778
7777
  if (canAvoidReRender) {
7779
- var updatedState = {
7778
+ var _stateRef_current_updateStyleListener, _stateRef_current, updatedState = {
7780
7779
  ...prev,
7781
7780
  ...next
7782
7781
  };
7783
7782
  NextState.set(stateRef, updatedState), process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile" && (console.groupCollapsed("[\u26A1\uFE0F] avoid setState", next, {
7784
7783
  updatedState,
7785
7784
  props
7786
- }), console.info(stateRef.current.host), console.groupEnd()), updateStyleListener();
7785
+ }), console.info(stateRef.current.host), console.groupEnd()), (_stateRef_current_updateStyleListener = (_stateRef_current = stateRef.current).updateStyleListener) === null || _stateRef_current_updateStyleListener === void 0 || _stateRef_current_updateStyleListener.call(_stateRef_current);
7787
7786
  } else process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile" && console.info("[\u{1F40C}] re-render", {
7788
7787
  canAvoidReRender,
7789
7788
  next
@@ -12395,18 +12394,7 @@ var require_index_native12 = __commonJS({
12395
12394
  }));
12396
12395
  }
12397
12396
  if (import_constants.isClient) if (rAF) {
12398
- layoutOnAnimationFrame = function() {
12399
- if (strategy !== "off") {
12400
- if (frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
12401
- rAF(layoutOnAnimationFrame);
12402
- return;
12403
- }
12404
- frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), Nodes.forEach(function(node) {
12405
- updateLayoutIfChanged(node);
12406
- });
12407
- }
12408
- rAF(layoutOnAnimationFrame);
12409
- }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, supportsCheckVisibility = "checkVisibility" in document.body;
12397
+ supportsCheckVisibility = "checkVisibility" in document.body, BoundingRects = /* @__PURE__ */ new WeakMap();
12410
12398
  async function updateLayoutIfChanged(node) {
12411
12399
  if (IntersectionState.get(node) !== !1 && !(process.env.TAMAGUI_ONLAYOUT_VISIBILITY_CHECK === "1" && supportsCheckVisibility && !node.checkVisibility())) {
12412
12400
  var onLayout = LayoutHandlers.get(node);
@@ -12416,8 +12404,8 @@ var require_index_native12 = __commonJS({
12416
12404
  var nodeRect, parentRect;
12417
12405
  if (strategy === "async") {
12418
12406
  var [nr, pr] = await Promise.all([
12419
- getBoundingClientRectAsync(node),
12420
- getBoundingClientRectAsync(parentNode)
12407
+ BoundingRects.get(node) || getBoundingClientRectAsync(node),
12408
+ BoundingRects.get(parentNode) || getBoundingClientRectAsync(parentNode)
12421
12409
  ]);
12422
12410
  if (nr === !1 || pr === !1) return;
12423
12411
  nodeRect = nr, parentRect = pr;
@@ -12438,8 +12426,56 @@ var require_index_native12 = __commonJS({
12438
12426
  }
12439
12427
  }
12440
12428
  rAF(layoutOnAnimationFrame), frameCount = 0, userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP, RUN_EVERY_X_FRAMES = userSkipVal ? +userSkipVal : 10;
12429
+ async function layoutOnAnimationFrame() {
12430
+ if (strategy !== "off") {
12431
+ if (!Nodes.size || frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
12432
+ rAF(layoutOnAnimationFrame);
12433
+ return;
12434
+ }
12435
+ frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), await new Promise(function(res) {
12436
+ var io = new IntersectionObserver(function(entries) {
12437
+ io.disconnect();
12438
+ var _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
12439
+ try {
12440
+ for (var _iterator2 = entries[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
12441
+ var entry = _step2.value;
12442
+ BoundingRects.set(entry.target, entry.boundingClientRect);
12443
+ }
12444
+ } catch (err) {
12445
+ _didIteratorError2 = !0, _iteratorError2 = err;
12446
+ } finally {
12447
+ try {
12448
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
12449
+ } finally {
12450
+ if (_didIteratorError2) throw _iteratorError2;
12451
+ }
12452
+ }
12453
+ res();
12454
+ }, {
12455
+ threshold: 0
12456
+ }), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
12457
+ try {
12458
+ for (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
12459
+ var node = _step.value;
12460
+ node.parentElement instanceof HTMLElement && (io.observe(node), io.observe(node.parentElement));
12461
+ }
12462
+ } catch (err) {
12463
+ _didIteratorError = !0, _iteratorError = err;
12464
+ } finally {
12465
+ try {
12466
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
12467
+ } finally {
12468
+ if (_didIteratorError) throw _iteratorError;
12469
+ }
12470
+ }
12471
+ }), Nodes.forEach(function(node) {
12472
+ updateLayoutIfChanged(node);
12473
+ });
12474
+ }
12475
+ rAF(layoutOnAnimationFrame);
12476
+ }
12441
12477
  } else process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly");
12442
- var layoutOnAnimationFrame, layoutOnAnimationFrame2, supportsCheckVisibility, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
12478
+ var supportsCheckVisibility, BoundingRects, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
12443
12479
  return {
12444
12480
  nativeEvent: {
12445
12481
  layout: getRelativeDimensions(nodeRect, parentRect),