@tamagui/core 1.132.2 → 1.132.4

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
@@ -7642,7 +7642,8 @@ var require_createComponent_native = __commonJS({
7642
7642
  }
7643
7643
  var allGroupContexts = (0, import_react3.useMemo)(function() {
7644
7644
  var _stateRef_current_group;
7645
- if (!groupName || props.passThrough) return groupContextParent;
7645
+ if (!groupName || props.passThrough || // avoids onLayout
7646
+ props.containerType === "normal") return groupContextParent;
7646
7647
  (_stateRef_current_group = stateRef.current.group) === null || _stateRef_current_group === void 0 || _stateRef_current_group.listeners.clear();
7647
7648
  var listeners = /* @__PURE__ */ new Set();
7648
7649
  return stateRef.current.group = {
@@ -12394,18 +12395,7 @@ var require_index_native12 = __commonJS({
12394
12395
  }));
12395
12396
  }
12396
12397
  if (import_constants.isClient) if (rAF) {
12397
- layoutOnAnimationFrame = function() {
12398
- if (strategy !== "off") {
12399
- if (frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
12400
- rAF(layoutOnAnimationFrame);
12401
- return;
12402
- }
12403
- frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), Nodes.forEach(function(node) {
12404
- updateLayoutIfChanged(node);
12405
- });
12406
- }
12407
- rAF(layoutOnAnimationFrame);
12408
- }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, supportsCheckVisibility = "checkVisibility" in document.body;
12398
+ supportsCheckVisibility = "checkVisibility" in document.body, BoundingRects = /* @__PURE__ */ new WeakMap();
12409
12399
  async function updateLayoutIfChanged(node) {
12410
12400
  if (IntersectionState.get(node) !== !1 && !(process.env.TAMAGUI_ONLAYOUT_VISIBILITY_CHECK === "1" && supportsCheckVisibility && !node.checkVisibility())) {
12411
12401
  var onLayout = LayoutHandlers.get(node);
@@ -12415,8 +12405,8 @@ var require_index_native12 = __commonJS({
12415
12405
  var nodeRect, parentRect;
12416
12406
  if (strategy === "async") {
12417
12407
  var [nr, pr] = await Promise.all([
12418
- getBoundingClientRectAsync(node),
12419
- getBoundingClientRectAsync(parentNode)
12408
+ BoundingRects.get(node) || getBoundingClientRectAsync(node),
12409
+ BoundingRects.get(parentNode) || getBoundingClientRectAsync(parentNode)
12420
12410
  ]);
12421
12411
  if (nr === !1 || pr === !1) return;
12422
12412
  nodeRect = nr, parentRect = pr;
@@ -12437,8 +12427,56 @@ var require_index_native12 = __commonJS({
12437
12427
  }
12438
12428
  }
12439
12429
  rAF(layoutOnAnimationFrame), frameCount = 0, userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP, RUN_EVERY_X_FRAMES = userSkipVal ? +userSkipVal : 10;
12430
+ async function layoutOnAnimationFrame() {
12431
+ if (strategy !== "off") {
12432
+ if (!Nodes.size || frameCount++ % RUN_EVERY_X_FRAMES !== 0) {
12433
+ rAF(layoutOnAnimationFrame);
12434
+ return;
12435
+ }
12436
+ frameCount === Number.MAX_SAFE_INTEGER && (frameCount = 0), await new Promise(function(res) {
12437
+ var io = new IntersectionObserver(function(entries) {
12438
+ io.disconnect();
12439
+ var _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
12440
+ try {
12441
+ for (var _iterator2 = entries[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
12442
+ var entry = _step2.value;
12443
+ BoundingRects.set(entry.target, entry.boundingClientRect);
12444
+ }
12445
+ } catch (err) {
12446
+ _didIteratorError2 = !0, _iteratorError2 = err;
12447
+ } finally {
12448
+ try {
12449
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
12450
+ } finally {
12451
+ if (_didIteratorError2) throw _iteratorError2;
12452
+ }
12453
+ }
12454
+ res();
12455
+ }, {
12456
+ threshold: 0
12457
+ }), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
12458
+ try {
12459
+ for (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
12460
+ var node = _step.value;
12461
+ node.parentElement instanceof HTMLElement && (io.observe(node), io.observe(node.parentElement));
12462
+ }
12463
+ } catch (err) {
12464
+ _didIteratorError = !0, _iteratorError = err;
12465
+ } finally {
12466
+ try {
12467
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
12468
+ } finally {
12469
+ if (_didIteratorError) throw _iteratorError;
12470
+ }
12471
+ }
12472
+ }), Nodes.forEach(function(node) {
12473
+ updateLayoutIfChanged(node);
12474
+ });
12475
+ }
12476
+ rAF(layoutOnAnimationFrame);
12477
+ }
12440
12478
  } else process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly");
12441
- var layoutOnAnimationFrame, layoutOnAnimationFrame2, supportsCheckVisibility, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
12479
+ var supportsCheckVisibility, BoundingRects, frameCount, userSkipVal, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
12442
12480
  return {
12443
12481
  nativeEvent: {
12444
12482
  layout: getRelativeDimensions(nodeRect, parentRect),