@tamagui/core 1.130.1 → 1.130.2

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
@@ -6298,7 +6298,9 @@ var require_useThemeState_native = __commonJS({
6298
6298
  var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, id = arguments.length > 4 ? arguments[4] : void 0, parentId = arguments.length > 5 ? arguments[5] : void 0, needsUpdate = arguments.length > 6 ? arguments[6] : void 0, pendingUpdate = arguments.length > 7 ? arguments[7] : void 0, { debug } = props, parentState = states.get(parentId);
6299
6299
  if (props.passThrough) return [
6300
6300
  !1,
6301
- lastState ?? parentState
6301
+ lastState || parentState || {
6302
+ name: ""
6303
+ }
6302
6304
  ];
6303
6305
  themes || (themes = (0, import_config.getConfig)().themes);
6304
6306
  var name = !propsKey && (!lastState || !(lastState != null && lastState.isNew)) ? null : getNewThemeName(parentState == null ? void 0 : parentState.name, props, pendingUpdate === "force" ? !0 : !!needsUpdate), isSameAsParent = parentState && (!name || name === parentState.name), shouldRerender = !!(needsUpdate && (pendingUpdate || (lastState == null ? void 0 : lastState.name) !== (parentState == null ? void 0 : parentState.name)));
@@ -6645,10 +6647,10 @@ var require_useTheme_native = __commonJS({
6645
6647
  return res;
6646
6648
  }, useThemeWithState = function(props) {
6647
6649
  var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, keys = (0, import_react3.useRef)(null), themeState = (0, import_useThemeState.useThemeState)(props, isRoot, keys);
6648
- process.env.NODE_ENV === "development" && (themeState != null && themeState.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.error(`[tamagui] No theme found, this could be due to an invalid theme name (given theme props ${JSON.stringify(props)}).
6650
+ process.env.NODE_ENV === "development" && !props.passThrough && !(themeState != null && themeState.theme) && process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.error(`[tamagui] No theme found, this could be due to an invalid theme name (given theme props ${JSON.stringify(props)}).
6649
6651
 
6650
- If this is intended and you are using Tamagui without any themes, you can disable this warning by setting the environment variable TAMAGUI_DISABLE_NO_THEME_WARNING=1`));
6651
- var themeProxied = (0, import_getThemeProxied.getThemeProxied)(props, themeState, keys);
6652
+ If this is intended and you are using Tamagui without any themes, you can disable this warning by setting the environment variable TAMAGUI_DISABLE_NO_THEME_WARNING=1`);
6653
+ var themeProxied = props.passThrough ? {} : (0, import_getThemeProxied.getThemeProxied)(props, themeState, keys);
6652
6654
  return [
6653
6655
  themeProxied,
6654
6656
  themeState
@@ -6812,7 +6814,7 @@ var require_Theme_native = __commonJS({
6812
6814
  })) : child;
6813
6815
  });
6814
6816
  }
6815
- if (process.env.NODE_ENV === "development" && props.debug && console.warn(" getThemedChildren", {
6817
+ if (process.env.NODE_ENV === "development" && !passThrough && props.debug && console.warn(" getThemedChildren", {
6816
6818
  requiresExtraWrapper,
6817
6819
  forceClassName,
6818
6820
  themeState,
@@ -6820,7 +6822,7 @@ var require_Theme_native = __commonJS({
6820
6822
  ...getThemeClassNameAndStyle(themeState, props, isRoot)
6821
6823
  }), forceClassName === !1) return children;
6822
6824
  if (import_constants.isWeb) {
6823
- var { className, style } = getThemeClassNameAndStyle(themeState, props, isRoot);
6825
+ var { className = "", style } = passThrough ? {} : getThemeClassNameAndStyle(themeState, props, isRoot);
6824
6826
  if (children = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
6825
6827
  className: `${className} _dsp_contents is_Theme`,
6826
6828
  style: passThrough ? void 0 : style,
@@ -7684,7 +7686,7 @@ var require_createComponent_native = __commonJS({
7684
7686
  });
7685
7687
  }
7686
7688
  }
7687
- if (splitStyles && (!hasAnimationProp || groupName) && animationDriver != null && animationDriver.avoidReRenders) {
7689
+ if (splitStyles && (hasAnimationProp || groupName) && animationDriver != null && animationDriver.avoidReRenders) {
7688
7690
  var useStyleListener = stateRef.current.useStyleListener, ogSetStateShallow = setStateShallow;
7689
7691
  stateRef.current.setStateShallow = function(nextOrGetNext) {
7690
7692
  var prev = NextState.get(stateRef) || state, next = typeof nextOrGetNext == "function" ? nextOrGetNext(prev) : nextOrGetNext;
@@ -7702,9 +7704,9 @@ var require_createComponent_native = __commonJS({
7702
7704
  props
7703
7705
  }), console.info(stateRef.current.host), console.groupEnd());
7704
7706
  var { group, hasDynGroupChildren, unmounted, animation, ...childrenGroupState } = updatedState;
7705
- if (groupContext && notifyGroupSubscribers(groupContext, stateRef.current.group || null, childrenGroupState), !hasAnimationProp || !useStyleListener) return;
7707
+ groupContext && notifyGroupSubscribers(groupContext, stateRef.current.group || null, childrenGroupState);
7706
7708
  var nextStyles = (0, import_getSplitStyles.getSplitStyles)(props, staticConfig, theme, themeName, updatedState, styleProps, null, componentContext, allGroupContexts, elementType, startedUnhydrated, debugProp);
7707
- useStyleListener((nextStyles == null ? void 0 : nextStyles.style) || {});
7709
+ useStyleListener == null || useStyleListener((nextStyles == null ? void 0 : nextStyles.style) || {});
7708
7710
  } else process.env.NODE_ENV === "development" && debugProp && debugProp !== "profile" && console.info("[\u{1F40C}] re-render", {
7709
7711
  canAvoidReRender,
7710
7712
  next
@@ -12283,7 +12285,7 @@ var require_index_native12 = __commonJS({
12283
12285
  }
12284
12286
  });
12285
12287
  module2.exports = __toCommonJS2(index_exports2);
12286
- var import_constants = require_index_native2(), import_is_equal_shallow = require_index_native5(), LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set(), strategy = "async";
12288
+ var import_constants = require_index_native2(), import_is_equal_shallow = require_index_native5(), LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set(), IntersectionState = /* @__PURE__ */ new WeakMap(), globalIntersectionObserver = null, strategy = "async";
12287
12289
  function setOnLayoutStrategy2(state) {
12288
12290
  strategy = state;
12289
12291
  }
@@ -12294,52 +12296,64 @@ var require_index_native12 = __commonJS({
12294
12296
  }), queuedUpdates.clear()));
12295
12297
  }
12296
12298
  var expectedFrameTime = 16.67, numDroppedFramesUntilPause = 10;
12299
+ function startGlobalIntersectionObserver() {
12300
+ !import_constants.isClient || globalIntersectionObserver || (globalIntersectionObserver = new IntersectionObserver(function(entries) {
12301
+ entries.forEach(function(entry) {
12302
+ var node = entry.target;
12303
+ IntersectionState.get(node) !== entry.isIntersecting && IntersectionState.set(node, entry.isIntersecting);
12304
+ });
12305
+ }, {
12306
+ threshold: 0
12307
+ }));
12308
+ }
12297
12309
  if (import_constants.isClient) if (rAF) {
12298
12310
  layoutOnAnimationFrame = function() {
12299
12311
  var now = Date.now(), timeSinceLastFrame = now - lastFrameAt;
12300
- if (lastFrameAt = now, frameCount < runEveryXFrames) {
12301
- frameCount++, rAF(layoutOnAnimationFrame);
12312
+ if (lastFrameAt = now, frameCount++, frameCount % RUN_EVERY_X_FRAMES === 0) {
12313
+ frameCount = 0, rAF(layoutOnAnimationFrame);
12302
12314
  return;
12303
12315
  }
12304
- if (frameCount = 0, strategy !== "off") {
12316
+ if (strategy !== "off") {
12305
12317
  var hasRecentSyncWork = timeSinceLastFrame > expectedFrameTime * numDroppedFramesUntilPause;
12306
12318
  hasRecentSyncWork || Nodes.forEach(function(node) {
12307
12319
  updateLayoutIfChanged(node, lastFrameAt);
12308
12320
  });
12309
12321
  }
12310
12322
  rAF(layoutOnAnimationFrame);
12311
- }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, lastFrameAt = Date.now();
12323
+ }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, supportsCheckVisibility = "checkVisibility" in document.body, lastFrameAt = Date.now();
12312
12324
  async function updateLayoutIfChanged(node, frameId) {
12313
- var onLayout = LayoutHandlers.get(node);
12314
- if (typeof onLayout == "function") {
12315
- var parentNode = node.parentElement;
12316
- if (parentNode) {
12317
- var nodeRect, parentRect;
12318
- if (strategy === "async") {
12319
- var [nr, pr] = await Promise.all([
12320
- getBoundingClientRectAsync(node),
12321
- getBoundingClientRectAsync(parentNode)
12322
- ]);
12323
- if (nr === !1 || pr === !1 || frameId !== lastFrameAt) return;
12324
- nodeRect = nr, parentRect = pr;
12325
- } else nodeRect = node.getBoundingClientRect(), parentRect = parentNode.getBoundingClientRect();
12326
- var cachedRect = NodeRectCache.get(node), cachedParentRect = NodeRectCache.get(parentNode);
12327
- if (!cachedRect || // has changed one rect
12328
- // @ts-expect-error DOMRectReadOnly can go into object
12329
- !(0, import_is_equal_shallow.isEqualShallow)(cachedRect, nodeRect) && // @ts-expect-error DOMRectReadOnly can go into object
12330
- (!cachedParentRect || !(0, import_is_equal_shallow.isEqualShallow)(cachedParentRect, parentRect))) {
12331
- NodeRectCache.set(node, nodeRect), ParentRectCache.set(parentNode, parentRect);
12332
- var event = getElementLayoutEvent(nodeRect, parentRect);
12333
- avoidUpdates ? queuedUpdates.set(node, function() {
12334
- return onLayout(event);
12335
- }) : onLayout(event);
12325
+ if (!(supportsCheckVisibility && !node.checkVisibility()) && IntersectionState.get(node) !== !1) {
12326
+ var onLayout = LayoutHandlers.get(node);
12327
+ if (typeof onLayout == "function") {
12328
+ var parentNode = node.parentElement;
12329
+ if (parentNode) {
12330
+ var nodeRect, parentRect;
12331
+ if (strategy === "async") {
12332
+ var [nr, pr] = await Promise.all([
12333
+ getBoundingClientRectAsync(node),
12334
+ getBoundingClientRectAsync(parentNode)
12335
+ ]);
12336
+ if (nr === !1 || pr === !1 || frameId !== lastFrameAt) return;
12337
+ nodeRect = nr, parentRect = pr;
12338
+ } else nodeRect = node.getBoundingClientRect(), parentRect = parentNode.getBoundingClientRect();
12339
+ var cachedRect = NodeRectCache.get(node), cachedParentRect = NodeRectCache.get(parentNode);
12340
+ if (!cachedRect || // has changed one rect
12341
+ // @ts-expect-error DOMRectReadOnly can go into object
12342
+ !(0, import_is_equal_shallow.isEqualShallow)(cachedRect, nodeRect) && // @ts-expect-error DOMRectReadOnly can go into object
12343
+ (!cachedParentRect || !(0, import_is_equal_shallow.isEqualShallow)(cachedParentRect, parentRect))) {
12344
+ NodeRectCache.set(node, nodeRect), ParentRectCache.set(parentNode, parentRect);
12345
+ var event = getElementLayoutEvent(nodeRect, parentRect);
12346
+ avoidUpdates ? queuedUpdates.set(node, function() {
12347
+ return onLayout(event);
12348
+ }) : onLayout(event);
12349
+ }
12336
12350
  }
12337
12351
  }
12338
12352
  }
12339
12353
  }
12340
- rAF(layoutOnAnimationFrame), frameCount = 0, runEveryXFrames = 6;
12354
+ rAF(layoutOnAnimationFrame), frameCount = 0, RUN_EVERY_X_FRAMES = 4;
12341
12355
  } else process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly");
12342
- var layoutOnAnimationFrame, layoutOnAnimationFrame2, lastFrameAt, frameCount, runEveryXFrames, getElementLayoutEvent = function(nodeRect, parentRect) {
12356
+ var layoutOnAnimationFrame, layoutOnAnimationFrame2, supportsCheckVisibility, lastFrameAt, frameCount, RUN_EVERY_X_FRAMES, getElementLayoutEvent = function(nodeRect, parentRect) {
12343
12357
  return {
12344
12358
  nativeEvent: {
12345
12359
  layout: getRelativeDimensions(nodeRect, parentRect),
@@ -12404,10 +12418,10 @@ var require_index_native12 = __commonJS({
12404
12418
  if (onLayout) {
12405
12419
  var node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;
12406
12420
  if (node2) {
12407
- LayoutHandlers.set(node2, onLayout), Nodes.add(node2);
12421
+ LayoutHandlers.set(node2, onLayout), Nodes.add(node2), startGlobalIntersectionObserver(), globalIntersectionObserver && (globalIntersectionObserver.observe(node2), IntersectionState.set(node2, !0));
12408
12422
  var parentNode = node2.parentNode;
12409
12423
  return parentNode && onLayout(getElementLayoutEvent(node2.getBoundingClientRect(), parentNode.getBoundingClientRect())), function() {
12410
- Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2), LastChangeTime.delete(node2);
12424
+ Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2), LastChangeTime.delete(node2), IntersectionState.delete(node2), globalIntersectionObserver && globalIntersectionObserver.unobserve(node2);
12411
12425
  };
12412
12426
  }
12413
12427
  }
@@ -12421,14 +12435,13 @@ var require_index_native12 = __commonJS({
12421
12435
  }
12422
12436
  var getBoundingClientRectAsync = function(node) {
12423
12437
  return new Promise(function(res) {
12424
- if (!(!node || node.nodeType !== 1)) {
12425
- var io = new IntersectionObserver(function(entries) {
12426
- return entries[0].isIntersecting ? (io.disconnect(), res(entries[0].boundingClientRect)) : res(!1);
12427
- }, {
12428
- threshold: 0
12429
- });
12430
- io.observe(node);
12431
- }
12438
+ if (!node || node.nodeType !== 1) return res(!1);
12439
+ var io = new IntersectionObserver(function(entries) {
12440
+ return io.disconnect(), res(entries[0].boundingClientRect);
12441
+ }, {
12442
+ threshold: 0
12443
+ });
12444
+ io.observe(node);
12432
12445
  });
12433
12446
  }, getBoundingClientRect = function(node) {
12434
12447
  var _node_getBoundingClientRect;