@tamagui/core 2.3.3 → 2.4.0-1783099846627

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.
@@ -634,7 +634,6 @@ var getMediaKey = function(key) {
634
634
  if (match) return match[1];
635
635
  return false;
636
636
  };
637
- var initState;
638
637
  var mediaKeysOrdered;
639
638
  var getMediaKeyImportance = function(key) {
640
639
  return mediaKeysOrdered.indexOf(key) + 100;
@@ -647,12 +646,13 @@ var configureMedia = function(config) {
647
646
  if (!media) return;
648
647
  mediaVersion++;
649
648
  resetMediaStyleCache();
649
+ resetMediaTouchTracker();
650
650
  for (var key in media) {
651
651
  getMedia()[key] = (mediaQueryDefaultActive === null || mediaQueryDefaultActive === void 0 ? void 0 : mediaQueryDefaultActive[key]) || false;
652
652
  mediaKeys.add(`$${key}`);
653
653
  }
654
654
  Object.assign(mediaQueryConfig, media);
655
- initState = _objectSpread2({}, getMedia());
655
+ _objectSpread2({}, getMedia());
656
656
  mediaKeysOrdered = Object.keys(media);
657
657
  setupMediaListeners();
658
658
  };
@@ -696,6 +696,45 @@ function updateMediaListeners() {
696
696
  });
697
697
  }
698
698
  var States = /* @__PURE__ */ new WeakMap();
699
+ var touchTrackerProto = null;
700
+ var refSlot = /* @__PURE__ */ Symbol("mediaRefSlot");
701
+ function buildTouchTrackerProto() {
702
+ var proto = {};
703
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
704
+ try {
705
+ var _loop = function() {
706
+ var fullKey = _step.value;
707
+ var key = fullKey[0] === "$" ? fullKey.slice(1) : fullKey;
708
+ proto[key] = {
709
+ enumerable: true,
710
+ configurable: true,
711
+ get() {
712
+ var slot = this[refSlot];
713
+ if (!disableMediaTouch) slot.keys.add(key);
714
+ return slot.proxyTarget[key];
715
+ }
716
+ };
717
+ };
718
+ for (var _iterator = mediaKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
719
+ } catch (err) {
720
+ _didIteratorError = true;
721
+ _iteratorError = err;
722
+ } finally {
723
+ try {
724
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
725
+ } finally {
726
+ if (_didIteratorError) throw _iteratorError;
727
+ }
728
+ }
729
+ return Object.create(null, proto);
730
+ }
731
+ function getTouchTrackerProto() {
732
+ if (!touchTrackerProto) touchTrackerProto = buildTouchTrackerProto();
733
+ return touchTrackerProto;
734
+ }
735
+ function resetMediaTouchTracker() {
736
+ touchTrackerProto = null;
737
+ }
699
738
  function setMediaShouldUpdate(ref, enabled, keys) {
700
739
  var cur = States.get(ref);
701
740
  if (!cur || cur.enabled !== enabled || keys) States.set(ref, _objectSpread2(_objectSpread2({}, cur), {}, {
@@ -711,56 +750,102 @@ function subscribe(subscriber) {
711
750
  }
712
751
  function useMedia(componentContext, debug) {
713
752
  "use no memo";
714
- var componentState = componentContext ? States.get(componentContext) : null;
715
753
  var internalRef = (0, react.useRef)(null);
716
- if (!internalRef.current) internalRef.current = {
717
- keys: /* @__PURE__ */ new Set(),
718
- lastState: getMedia()
719
- };
720
- if (internalRef.current.pendingState) {
721
- internalRef.current.lastState = internalRef.current.pendingState;
722
- internalRef.current.pendingState = void 0;
723
- }
724
- var { keys } = internalRef.current;
725
- if (keys.size) keys.clear();
726
- var state = (0, react.useSyncExternalStore)(subscribe, function() {
727
- var curKeys = (componentState === null || componentState === void 0 ? void 0 : componentState.keys) || keys;
728
- var { lastState, pendingState } = internalRef.current;
729
- if (!curKeys.size) return lastState;
730
- var ms = getMedia();
731
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
732
- try {
733
- for (var _iterator = curKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
734
- var key = _step.value;
735
- if (ms[key] !== (pendingState || lastState)[key]) {
736
- if (componentContext === null || componentContext === void 0 ? void 0 : componentContext.mediaEmit) {
737
- componentContext.mediaEmit(ms);
738
- internalRef.current.pendingState = ms;
739
- return lastState;
754
+ if (!internalRef.current) {
755
+ var initial = getMedia();
756
+ var r = {
757
+ keys: /* @__PURE__ */ new Set(),
758
+ lastState: initial,
759
+ renderVersion: 0,
760
+ proxyTarget: initial,
761
+ proxy: void 0,
762
+ getSnapshot: void 0,
763
+ componentContext,
764
+ debug
765
+ };
766
+ var tracker = Object.create(getTouchTrackerProto());
767
+ tracker[refSlot] = {
768
+ proxyTarget: initial,
769
+ keys: r.keys
770
+ };
771
+ r.proxy = tracker;
772
+ r.getSnapshot = function() {
773
+ var _States_get;
774
+ var curKeys = r.componentContext ? ((_States_get = States.get(r.componentContext)) === null || _States_get === void 0 ? void 0 : _States_get.keys) || r.keys : r.keys;
775
+ var { lastState, pendingState } = r;
776
+ if (!curKeys.size) return lastState;
777
+ var ms = getMedia();
778
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
779
+ try {
780
+ for (var _iterator = curKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
781
+ var key = _step.value;
782
+ if (ms[key] !== (pendingState || lastState)[key]) {
783
+ var _r_componentContext;
784
+ if ((_r_componentContext = r.componentContext) === null || _r_componentContext === void 0 ? void 0 : _r_componentContext.mediaEmit) {
785
+ r.componentContext.mediaEmit(ms);
786
+ r.pendingState = ms;
787
+ return lastState;
788
+ }
789
+ r.lastState = ms;
790
+ return ms;
740
791
  }
741
- internalRef.current.lastState = ms;
742
- return ms;
743
792
  }
744
- }
745
- } catch (err) {
746
- _didIteratorError = true;
747
- _iteratorError = err;
748
- } finally {
749
- try {
750
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
793
+ } catch (err) {
794
+ _didIteratorError = true;
795
+ _iteratorError = err;
751
796
  } finally {
752
- if (_didIteratorError) throw _iteratorError;
797
+ try {
798
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
799
+ } finally {
800
+ if (_didIteratorError) throw _iteratorError;
801
+ }
753
802
  }
803
+ return lastState;
804
+ };
805
+ internalRef.current = r;
806
+ } else {
807
+ internalRef.current.componentContext = componentContext;
808
+ internalRef.current.debug = debug;
809
+ }
810
+ var ref = internalRef.current;
811
+ ref.renderVersion++;
812
+ if (ref.pendingState) {
813
+ ref.lastState = ref.pendingState;
814
+ ref.pendingState = void 0;
815
+ }
816
+ if (ref.keys.size) ref.keys.clear();
817
+ var [, forceUpdate] = (0, react.useReducer)(incReducer$1, 0);
818
+ var state = ref.getSnapshot();
819
+ ref.proxyTarget = state;
820
+ ref.proxy[refSlot].proxyTarget = state;
821
+ (0, react.useEffect)(function() {
822
+ var _States_get;
823
+ var renderVersion = ref.renderVersion;
824
+ if (!ref.componentContext || !!((_States_get = States.get(ref.componentContext)) === null || _States_get === void 0 ? void 0 : _States_get.enabled)) {
825
+ if (!ref.unsubscribe) ref.unsubscribe = subscribe(function() {
826
+ var next = ref.getSnapshot();
827
+ if (next !== ref.proxyTarget) {
828
+ ref.proxyTarget = next;
829
+ ref.proxy[refSlot].proxyTarget = next;
830
+ forceUpdate();
831
+ }
832
+ });
833
+ } else if (ref.unsubscribe) {
834
+ ref.unsubscribe();
835
+ ref.unsubscribe = void 0;
754
836
  }
755
- return lastState;
756
- }, getServerSnapshot);
757
- return new Proxy(state, { get(_, key) {
758
- if (!disableMediaTouch && typeof key === "string") keys.add(key);
759
- return Reflect.get(state, key);
760
- } });
837
+ return function() {
838
+ if (ref.renderVersion === renderVersion) {
839
+ var _ref_unsubscribe;
840
+ (_ref_unsubscribe = ref.unsubscribe) === null || _ref_unsubscribe === void 0 || _ref_unsubscribe.call(ref);
841
+ ref.unsubscribe = void 0;
842
+ }
843
+ };
844
+ });
845
+ return ref.proxy;
761
846
  }
762
- var getServerSnapshot = function() {
763
- return initState;
847
+ var incReducer$1 = function(c) {
848
+ return c + 1;
764
849
  };
765
850
  var disableMediaTouch = false;
766
851
  function _disableMediaTouch(val) {
@@ -1400,9 +1485,12 @@ var getRootThemeState = function() {
1400
1485
  var getThemeBaseName = function(name) {
1401
1486
  return name.replace(/^(light|dark)_/, "");
1402
1487
  };
1488
+ var incReducer = function(c) {
1489
+ return c + 1;
1490
+ };
1403
1491
  var useThemeState = function(props) {
1404
1492
  "use no memo";
1405
- var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0;
1493
+ var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0, cascadeOnChange = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
1406
1494
  var { disable } = props;
1407
1495
  var parentId = (0, react.useContext)(ThemeStateContext);
1408
1496
  if (!parentId && !isRoot) throw new Error(MISSING_THEME_MESSAGE);
@@ -1412,53 +1500,69 @@ var useThemeState = function(props) {
1412
1500
  theme: getConfig().themes.light
1413
1501
  };
1414
1502
  var id = (0, react.useId)();
1415
- var subscribe = (0, react.useCallback)(function(cb) {
1416
- listenersByParent[parentId] = listenersByParent[parentId] || /* @__PURE__ */ new Set();
1417
- listenersByParent[parentId].add(id);
1418
- allListeners.set(id, function() {
1419
- PendingUpdate.set(id, shouldForce ? "force" : true);
1420
- cb();
1421
- });
1422
- return function() {
1423
- allListeners.delete(id);
1424
- listenersByParent[parentId].delete(id);
1425
- localStates.delete(id);
1426
- states.delete(id);
1427
- PendingUpdate.delete(id);
1428
- };
1429
- }, [id, parentId]);
1430
1503
  var propsKey = getPropsKey(props);
1431
- var getSnapshot = function() {
1432
- var _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;
1433
- var local = localStates.get(id);
1434
- var parentState = states.get(parentId);
1435
- if (local && !PendingUpdate.has(id)) {
1436
- if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
1437
- }
1438
- var isSchemeOnlyChange = supportsDynamicColorIOS && getSetting("fastSchemeChange") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);
1439
- var _keys_current_size;
1440
- var keysSize = (_keys_current_size = keys === null || keys === void 0 ? void 0 : (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) !== null && _keys_current_size !== void 0 ? _keys_current_size : 0;
1441
- var _schemeKeys_current_size;
1442
- var allKeysSchemeOptimized = ((_schemeKeys_current_size = schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) !== null && _schemeKeys_current_size !== void 0 ? _schemeKeys_current_size : 0) === keysSize && keysSize > 0;
1443
- var canSkipForSchemeChange = isSchemeOnlyChange && allKeysSchemeOptimized;
1444
- var needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);
1445
- var [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
1446
- PendingUpdate.delete(id);
1447
- if (!local || rerender) {
1448
- local = _objectSpread2({}, next);
1449
- localStates.set(id, local);
1450
- }
1451
- if (next !== local) {
1452
- Object.assign(local, next);
1453
- local.id = id;
1454
- }
1455
- local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
1456
- local._propsKey = propsKey;
1457
- states.set(id, next);
1458
- return local;
1504
+ var ref = (0, react.useRef)(null);
1505
+ if (!ref.current) ref.current = {
1506
+ id,
1507
+ parentId,
1508
+ props,
1509
+ propsKey,
1510
+ isRoot,
1511
+ keys,
1512
+ schemeKeys,
1513
+ renderVersion: 0
1459
1514
  };
1460
- var state = (0, react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
1461
- useIsomorphicLayoutEffect(function() {
1515
+ else {
1516
+ ref.current.props = props;
1517
+ ref.current.propsKey = propsKey;
1518
+ ref.current.isRoot = isRoot;
1519
+ ref.current.keys = keys;
1520
+ ref.current.schemeKeys = schemeKeys;
1521
+ ref.current.parentId = parentId;
1522
+ }
1523
+ ref.current.renderVersion++;
1524
+ var [, forceUpdate] = (0, react.useReducer)(incReducer, 0);
1525
+ var state = getSnapshotImpl(ref.current);
1526
+ ref.current.lastSnap = state;
1527
+ (0, react.useEffect)(function() {
1528
+ var r = ref.current;
1529
+ var renderVersion = r.renderVersion;
1530
+ if (r.unsubscribe && r.subscribedParentId !== r.parentId) cleanupThemeSubscription(r);
1531
+ if (shouldSubscribeToTheme(r, cascadeOnChange)) {
1532
+ if (!r.unsubscribe) {
1533
+ var pid = r.parentId;
1534
+ var sid = r.id;
1535
+ var cb = function() {
1536
+ var next = getSnapshotImpl(r);
1537
+ if (next !== r.lastSnap) {
1538
+ r.lastSnap = next;
1539
+ forceUpdate();
1540
+ }
1541
+ };
1542
+ listenersByParent[pid] = listenersByParent[pid] || /* @__PURE__ */ new Set();
1543
+ listenersByParent[pid].add(sid);
1544
+ allListeners.set(sid, function() {
1545
+ PendingUpdate.set(sid, shouldForce ? "force" : true);
1546
+ cb();
1547
+ });
1548
+ r.subscribedParentId = pid;
1549
+ r.unsubscribe = function() {
1550
+ var _listenersByParent_pid;
1551
+ allListeners.delete(sid);
1552
+ (_listenersByParent_pid = listenersByParent[pid]) === null || _listenersByParent_pid === void 0 || _listenersByParent_pid.delete(sid);
1553
+ localStates.delete(sid);
1554
+ states.delete(sid);
1555
+ PendingUpdate.delete(sid);
1556
+ r.unsubscribe = void 0;
1557
+ r.subscribedParentId = void 0;
1558
+ };
1559
+ }
1560
+ } else if (r.unsubscribe) cleanupThemeSubscription(r);
1561
+ return function() {
1562
+ if (r.renderVersion === renderVersion) cleanupThemeState(r);
1563
+ };
1564
+ });
1565
+ if (cascadeOnChange) useIsomorphicLayoutEffect(function() {
1462
1566
  if (!HasRenderedOnce.get(keys)) {
1463
1567
  HasRenderedOnce.set(keys, true);
1464
1568
  return;
@@ -1473,6 +1577,52 @@ var useThemeState = function(props) {
1473
1577
  }, [keys, propsKey]);
1474
1578
  return state;
1475
1579
  };
1580
+ var shouldSubscribeToTheme = function(r, cascadeOnChange) {
1581
+ var _r_keys_current, _r_props_needsUpdate, _r_props;
1582
+ return r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || !!((_r_keys_current = r.keys.current) === null || _r_keys_current === void 0 ? void 0 : _r_keys_current.size) || !!((_r_props_needsUpdate = (_r_props = r.props).needsUpdate) === null || _r_props_needsUpdate === void 0 ? void 0 : _r_props_needsUpdate.call(_r_props));
1583
+ };
1584
+ function cleanupThemeSubscription(r) {
1585
+ var _r_unsubscribe;
1586
+ (_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);
1587
+ }
1588
+ function cleanupThemeState(r) {
1589
+ if (r.unsubscribe) cleanupThemeSubscription(r);
1590
+ else {
1591
+ localStates.delete(r.id);
1592
+ states.delete(r.id);
1593
+ PendingUpdate.delete(r.id);
1594
+ }
1595
+ }
1596
+ var getSnapshotImpl = function(r) {
1597
+ var _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;
1598
+ var { id, parentId, props, propsKey, isRoot, keys, schemeKeys } = r;
1599
+ var local = localStates.get(id);
1600
+ var parentState = states.get(parentId);
1601
+ if (local && !PendingUpdate.has(id)) {
1602
+ if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
1603
+ }
1604
+ var isSchemeOnlyChange = supportsDynamicColorIOS && getSetting("fastSchemeChange") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);
1605
+ var _keys_current_size;
1606
+ var keysSize = (_keys_current_size = keys === null || keys === void 0 ? void 0 : (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) !== null && _keys_current_size !== void 0 ? _keys_current_size : 0;
1607
+ var _schemeKeys_current_size;
1608
+ var allKeysSchemeOptimized = ((_schemeKeys_current_size = schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) !== null && _schemeKeys_current_size !== void 0 ? _schemeKeys_current_size : 0) === keysSize && keysSize > 0;
1609
+ var canSkipForSchemeChange = isSchemeOnlyChange && allKeysSchemeOptimized;
1610
+ var needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);
1611
+ var [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
1612
+ PendingUpdate.delete(id);
1613
+ if (!local || rerender) {
1614
+ local = _objectSpread2({}, next);
1615
+ localStates.set(id, local);
1616
+ }
1617
+ if (next !== local) {
1618
+ Object.assign(local, next);
1619
+ local.id = id;
1620
+ }
1621
+ local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
1622
+ local._propsKey = propsKey;
1623
+ states.set(id, next);
1624
+ return local;
1625
+ };
1476
1626
  var getNextState = function(lastState, props, propsKey) {
1477
1627
  var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, 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;
1478
1628
  var { debug } = props;
@@ -1487,9 +1637,13 @@ var getNextState = function(lastState, props, propsKey) {
1487
1637
  return [shouldRerender, _objectSpread2(_objectSpread2({}, parentState), {}, { isNew: false })];
1488
1638
  }
1489
1639
  if (!name) {
1490
- var next = lastState !== null && lastState !== void 0 ? lastState : parentState;
1491
- if (!next) throw new Error(MISSING_THEME_MESSAGE);
1492
- if (shouldRerender) return [true, _objectSpread2({}, parentState || lastState)];
1640
+ var _ref, _ref1;
1641
+ var next = (_ref1 = (_ref = lastState !== null && lastState !== void 0 ? lastState : parentState) !== null && _ref !== void 0 ? _ref : rootThemeState) !== null && _ref1 !== void 0 ? _ref1 : {
1642
+ id,
1643
+ name: "light",
1644
+ theme: getConfig().themes.light
1645
+ };
1646
+ if (shouldRerender) return [true, _objectSpread2({}, parentState || lastState || next)];
1493
1647
  return [false, next];
1494
1648
  }
1495
1649
  var scheme = getScheme(name);
@@ -1769,10 +1923,14 @@ var useTheme = function() {
1769
1923
  };
1770
1924
  var useThemeWithState = function(props) {
1771
1925
  "use no memo";
1772
- var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1773
- var keys = (0, react.useRef)(null);
1774
- var schemeKeys = (0, react.useRef)(null);
1775
- var themeState = useThemeState(props, isRoot, keys, schemeKeys);
1926
+ var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, forThemeView = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
1927
+ var bag = (0, react.useRef)(null);
1928
+ if (!bag.current) bag.current = {
1929
+ keys: { current: null },
1930
+ schemeKeys: { current: null }
1931
+ };
1932
+ var { keys, schemeKeys } = bag.current;
1933
+ var themeState = useThemeState(props, isRoot, keys, schemeKeys, forThemeView);
1776
1934
  return [props.passThrough ? {} : getThemeProxied(props, themeState, keys, schemeKeys), themeState];
1777
1935
  };
1778
1936
  //#endregion
@@ -1841,6 +1999,8 @@ function createGlobalState(key, defaultValue) {
1841
1999
  }
1842
2000
  //#endregion
1843
2001
  //#region ../native/dist/esm/gestureState.native.js
2002
+ var _globalThis;
2003
+ var _PRESS_STATE_KEY;
1844
2004
  var state = createGlobalState(`gesture`, {
1845
2005
  enabled: false,
1846
2006
  Gesture: null,
@@ -1873,13 +2033,15 @@ function canChangeGestureHandlerEnabled(nextEnabled, source) {
1873
2033
  var pressGestureDebugId = 0;
1874
2034
  var PRESS_MOVE_CANCEL_DISTANCE = 12;
1875
2035
  var PRESS_MOVE_CANCEL_DISTANCE_SQ = PRESS_MOVE_CANCEL_DISTANCE * PRESS_MOVE_CANCEL_DISTANCE;
2036
+ var PRESS_STATE_KEY = "__tamagui_press_state__";
1876
2037
  function getEventPointerId(e) {
1877
2038
  var _e_pointer, _e_event, _e_event_pointer, _e_event1, _e_nativeEvent, _e_nativeEvent1, _e_event_nativeEvent, _e_event2, _e_event_nativeEvent1, _e_event3;
1878
2039
  var _e_pointerId, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
1879
2040
  var pointerId = (_ref6 = (_ref5 = (_ref4 = (_ref3 = (_ref2 = (_ref1 = (_ref = (_e_pointerId = e === null || e === void 0 ? void 0 : e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : e === null || e === void 0 ? void 0 : (_e_pointer = e.pointer) === null || _e_pointer === void 0 ? void 0 : _e_pointer.id) !== null && _ref !== void 0 ? _ref : e === null || e === void 0 ? void 0 : (_e_event = e.event) === null || _e_event === void 0 ? void 0 : _e_event.pointerId) !== null && _ref1 !== void 0 ? _ref1 : e === null || e === void 0 ? void 0 : (_e_event1 = e.event) === null || _e_event1 === void 0 ? void 0 : (_e_event_pointer = _e_event1.pointer) === null || _e_event_pointer === void 0 ? void 0 : _e_event_pointer.id) !== null && _ref2 !== void 0 ? _ref2 : e === null || e === void 0 ? void 0 : (_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.pointerId) !== null && _ref3 !== void 0 ? _ref3 : e === null || e === void 0 ? void 0 : (_e_nativeEvent1 = e.nativeEvent) === null || _e_nativeEvent1 === void 0 ? void 0 : _e_nativeEvent1.id) !== null && _ref4 !== void 0 ? _ref4 : e === null || e === void 0 ? void 0 : (_e_event2 = e.event) === null || _e_event2 === void 0 ? void 0 : (_e_event_nativeEvent = _e_event2.nativeEvent) === null || _e_event_nativeEvent === void 0 ? void 0 : _e_event_nativeEvent.pointerId) !== null && _ref5 !== void 0 ? _ref5 : e === null || e === void 0 ? void 0 : (_e_event3 = e.event) === null || _e_event3 === void 0 ? void 0 : (_e_event_nativeEvent1 = _e_event3.nativeEvent) === null || _e_event_nativeEvent1 === void 0 ? void 0 : _e_event_nativeEvent1.id) !== null && _ref6 !== void 0 ? _ref6 : null;
1880
2041
  return pointerId == null || Number.isNaN(pointerId) ? null : Number(pointerId);
1881
2042
  }
1882
- var pressState = {
2043
+ var _$1;
2044
+ var pressState = (_$1 = (_globalThis = globalThis)[_PRESS_STATE_KEY = PRESS_STATE_KEY]) !== null && _$1 !== void 0 ? _$1 : _globalThis[_PRESS_STATE_KEY] = {
1883
2045
  owner: null,
1884
2046
  ownerId: null,
1885
2047
  ownerSource: null,
@@ -1896,6 +2058,10 @@ function resetPressOwner() {
1896
2058
  function resetStaleOwner(now, debugName) {
1897
2059
  if (now - pressState.timestamp > 2e3) resetPressOwner();
1898
2060
  }
2061
+ function hasExternalPressOwnership() {
2062
+ resetStaleOwner(Date.now());
2063
+ return pressState.ownerSource === "external";
2064
+ }
1899
2065
  function getGestureHandler() {
1900
2066
  return {
1901
2067
  get isEnabled() {
@@ -2056,7 +2222,8 @@ function useMainThreadPressEvents(events, viewProps) {
2056
2222
  pressInTimer: null,
2057
2223
  pressOutTimer: null,
2058
2224
  longPressTimer: null,
2059
- activateTime: 0
2225
+ activateTime: 0,
2226
+ blockedByExternalOwnership: false
2060
2227
  };
2061
2228
  if (!enabled || !events) return;
2062
2229
  var _events_delayPressIn;
@@ -2100,11 +2267,18 @@ function useMainThreadPressEvents(events, viewProps) {
2100
2267
  var userTerminationRequest = viewProps.onResponderTerminationRequest;
2101
2268
  var userMove = viewProps.onResponderMove;
2102
2269
  viewProps.onStartShouldSetResponder = function(e) {
2103
- return Boolean(userStartShouldSet === null || userStartShouldSet === void 0 ? void 0 : userStartShouldSet(e)) || !events.disabled;
2270
+ if (userStartShouldSet === null || userStartShouldSet === void 0 ? void 0 : userStartShouldSet(e)) return true;
2271
+ return !events.disabled && !hasExternalPressOwnership();
2104
2272
  };
2105
2273
  viewProps.onResponderGrant = function(e) {
2106
- userGrant === null || userGrant === void 0 || userGrant(e);
2107
2274
  cleanup();
2275
+ if (hasExternalPressOwnership()) {
2276
+ ref.current.state = "idle";
2277
+ ref.current.blockedByExternalOwnership = true;
2278
+ return;
2279
+ }
2280
+ userGrant === null || userGrant === void 0 || userGrant(e);
2281
+ ref.current.blockedByExternalOwnership = false;
2108
2282
  ref.current.state = "pressing";
2109
2283
  if (delayPressIn > 0) ref.current.pressInTimer = setTimeout(function() {
2110
2284
  return activate(e);
@@ -2119,6 +2293,12 @@ function useMainThreadPressEvents(events, viewProps) {
2119
2293
  }, delayLongPress + delayPressIn);
2120
2294
  };
2121
2295
  viewProps.onResponderRelease = function(e) {
2296
+ if (ref.current.blockedByExternalOwnership || hasExternalPressOwnership()) {
2297
+ cleanup();
2298
+ ref.current.blockedByExternalOwnership = false;
2299
+ ref.current.state = "idle";
2300
+ return;
2301
+ }
2122
2302
  userRelease === null || userRelease === void 0 || userRelease(e);
2123
2303
  var wasLongPressed = ref.current.state === "longPressed";
2124
2304
  cleanup();
@@ -2129,12 +2309,14 @@ function useMainThreadPressEvents(events, viewProps) {
2129
2309
  }
2130
2310
  deactivate(e);
2131
2311
  ref.current.state = "idle";
2312
+ ref.current.blockedByExternalOwnership = false;
2132
2313
  };
2133
2314
  viewProps.onResponderTerminate = function(e) {
2134
2315
  userTerminate === null || userTerminate === void 0 || userTerminate(e);
2135
2316
  cleanup();
2136
2317
  if (ref.current.state === "active" || ref.current.state === "longPressed") deactivate(e);
2137
2318
  ref.current.state = "idle";
2319
+ ref.current.blockedByExternalOwnership = false;
2138
2320
  };
2139
2321
  viewProps.onResponderTerminationRequest = function(e) {
2140
2322
  if (userTerminationRequest) return userTerminationRequest(e);
@@ -2207,7 +2389,7 @@ function useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNat
2207
2389
  if (isUsingRNGH) {
2208
2390
  var callbacksRef = (0, react.useRef)(isUsingRNGH ? {} : null);
2209
2391
  var gestureRef = (0, react.useRef)(null);
2210
- useMainThreadPressEvents(events, viewProps, getIsAndroid() && !(hasRealPressEvents || stateRef.current.hasRealPressEvents) && Boolean(hasPressEvents), debugName);
2392
+ useMainThreadPressEvents(events, viewProps, !isInsideNativeMenu && Boolean(hasRealPressEvents || getIsAndroid() && hasPressEvents), debugName);
2211
2393
  if (everEnabled) {
2212
2394
  callbacksRef.current = hasPressEvents ? {
2213
2395
  onPressIn: events.onPressIn,
@@ -2215,6 +2397,10 @@ function useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNat
2215
2397
  onPress: events.onPress,
2216
2398
  onLongPress: events.onLongPress
2217
2399
  } : {};
2400
+ if (hasRealPressEvents && !isInsideNativeMenu) {
2401
+ gestureRef.current = null;
2402
+ return null;
2403
+ }
2218
2404
  if (!gestureRef.current) {
2219
2405
  var { Gesture } = gh.state;
2220
2406
  if (isInsideNativeMenu) gestureRef.current = Gesture.Manual().runOnJS(true).manualActivation(true).onTouchesDown(function() {
@@ -2228,27 +2414,6 @@ function useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNat
2228
2414
  var _callbacksRef_current_onPressOut, _callbacksRef_current;
2229
2415
  (_callbacksRef_current_onPressOut = (_callbacksRef_current = callbacksRef.current).onPressOut) === null || _callbacksRef_current_onPressOut === void 0 || _callbacksRef_current_onPressOut.call(_callbacksRef_current, {});
2230
2416
  });
2231
- else if (hasRealPressEvents || stateRef.current.hasRealPressEvents) gestureRef.current = gh.createPressGesture({
2232
- debugName,
2233
- onPressIn: function(e) {
2234
- var _callbacksRef_current_onPressIn, _callbacksRef_current;
2235
- return (_callbacksRef_current_onPressIn = (_callbacksRef_current = callbacksRef.current).onPressIn) === null || _callbacksRef_current_onPressIn === void 0 ? void 0 : _callbacksRef_current_onPressIn.call(_callbacksRef_current, e);
2236
- },
2237
- onPressOut: function(e) {
2238
- var _callbacksRef_current_onPressOut, _callbacksRef_current;
2239
- return (_callbacksRef_current_onPressOut = (_callbacksRef_current = callbacksRef.current).onPressOut) === null || _callbacksRef_current_onPressOut === void 0 ? void 0 : _callbacksRef_current_onPressOut.call(_callbacksRef_current, e);
2240
- },
2241
- onPress: function(e) {
2242
- var _callbacksRef_current_onPress, _callbacksRef_current;
2243
- return (_callbacksRef_current_onPress = (_callbacksRef_current = callbacksRef.current).onPress) === null || _callbacksRef_current_onPress === void 0 ? void 0 : _callbacksRef_current_onPress.call(_callbacksRef_current, e);
2244
- },
2245
- onLongPress: function(e) {
2246
- var _callbacksRef_current_onLongPress, _callbacksRef_current;
2247
- return (_callbacksRef_current_onLongPress = (_callbacksRef_current = callbacksRef.current).onLongPress) === null || _callbacksRef_current_onLongPress === void 0 ? void 0 : _callbacksRef_current_onLongPress.call(_callbacksRef_current, e);
2248
- },
2249
- delayLongPress: events === null || events === void 0 ? void 0 : events.delayLongPress,
2250
- hitSlop: viewProps.hitSlop
2251
- });
2252
2417
  else if (!getIsAndroid()) gestureRef.current = Gesture.Manual().runOnJS(true).manualActivation(true).onTouchesDown(function(e) {
2253
2418
  var _callbacksRef_current_onPressIn, _callbacksRef_current;
2254
2419
  return (_callbacksRef_current_onPressIn = (_callbacksRef_current = callbacksRef.current).onPressIn) === null || _callbacksRef_current_onPressIn === void 0 ? void 0 : _callbacksRef_current_onPressIn.call(_callbacksRef_current, e);
@@ -2268,23 +2433,20 @@ function useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNat
2268
2433
  useMainThreadPressEvents(events, viewProps, hasPressEvents, debugName);
2269
2434
  return null;
2270
2435
  }
2271
- function wrapWithGestureDetector(content, gesture, stateRef, isHOC, isCompositeComponent) {
2436
+ function wrapWithGestureDetector(content, gesture, _stateRef, isHOC, isCompositeComponent, hasRealPressEvents) {
2272
2437
  if (isHOC || isCompositeComponent) return content;
2273
- var { GestureDetector, Gesture } = getGestureHandler().state;
2274
- var shouldWrap = getIsAndroid() ? stateRef.current.hasRealPressEvents : stateRef.current.hasHadEvents;
2275
- if (!GestureDetector || !shouldWrap) return content;
2276
- var gestureToUse = gesture || (Gesture === null || Gesture === void 0 ? void 0 : Gesture.Manual());
2277
- if (!gestureToUse) return content;
2278
- if (!stateRef.current.hasRealPressEvents) return react.default.createElement(GestureDetector, { gesture: gestureToUse }, content);
2438
+ var { GestureDetector } = getGestureHandler().state;
2439
+ if (!GestureDetector || !gesture) return content;
2440
+ if (!hasRealPressEvents) return react.default.createElement(GestureDetector, { gesture }, content);
2279
2441
  if (isFabric) {
2280
2442
  var claimed = react.default.cloneElement(content, { onStartShouldSetResponder: responderClaim });
2281
- return react.default.createElement(GestureDetector, { gesture: gestureToUse }, claimed);
2443
+ return react.default.createElement(GestureDetector, { gesture }, claimed);
2282
2444
  }
2283
2445
  return react.default.createElement(react_native.View, {
2284
2446
  collapsable: false,
2285
2447
  style: responderWrapperStyle,
2286
2448
  onStartShouldSetResponder: responderClaim
2287
- }, react.default.createElement(GestureDetector, { gesture: gestureToUse }, content));
2449
+ }, react.default.createElement(GestureDetector, { gesture }, content));
2288
2450
  }
2289
2451
  //#endregion
2290
2452
  //#region ../web/dist/esm/helpers/getDefaultProps.native.js
@@ -3709,6 +3871,11 @@ function normalizeGroupKey(key, groupContext) {
3709
3871
  function isValidStyleKey(key, validStyles, accept) {
3710
3872
  return key in validStyles ? true : accept && key in accept;
3711
3873
  }
3874
+ function shouldSkipNativeHoverProp(key, isMedia) {
3875
+ if (key === "hoverStyle") return true;
3876
+ if (isMedia === "group") return getGroupPropParts(key.slice(1)).pseudo === "hover";
3877
+ return false;
3878
+ }
3712
3879
  var getSplitStyles = function(props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, componentContext, groupContext, elementType, startedUnhydrated, debug, animationDriver) {
3713
3880
  var _loop = function(keyOg2) {
3714
3881
  var keyInit = keyOg2;
@@ -3717,6 +3884,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3717
3884
  viewProps[keyInit] = valInit;
3718
3885
  return "continue";
3719
3886
  }
3887
+ if (keyInit[0] === "d" && keyInit.startsWith("data-")) return "continue";
3720
3888
  if (keyInit === "jestAnimatedStyle") return "continue";
3721
3889
  if (accept) {
3722
3890
  var accepted = accept[keyInit];
@@ -3759,6 +3927,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3759
3927
  var isMediaOrPseudo = Boolean(isMedia || isPseudo);
3760
3928
  if (isMediaOrPseudo && isMedia === "group") keyInit = normalizeGroupKey(keyInit, groupContext);
3761
3929
  var isStyleProp = isValidStyleKeyInit || isMediaOrPseudo || isVariant && !noExpand;
3930
+ if (shouldSkipNativeHoverProp(keyInit, isMedia)) return "continue";
3762
3931
  if (isStyleProp && (asChild === "except-style" || asChild === "except-style-web")) return "continue";
3763
3932
  var shouldPassProp = !isStyleProp && isHOC || isHOC && parentVariants && keyInit in parentVariants || (inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(keyInit));
3764
3933
  var parentVariant = parentVariants === null || parentVariants === void 0 ? void 0 : parentVariants[keyInit];
@@ -3796,6 +3965,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3796
3965
  isMediaOrPseudo = Boolean(isMedia || isPseudo);
3797
3966
  isVariant = variants && key5 in variants;
3798
3967
  if (isMedia === "group") key5 = normalizeGroupKey(key5, groupContext);
3968
+ if (shouldSkipNativeHoverProp(key5, isMedia)) return;
3799
3969
  if ((inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(key5)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened === null || inlineWhenUnflattened === void 0 ? void 0 : inlineWhenUnflattened.has(key5))) {
3800
3970
  var _props_key;
3801
3971
  viewProps[key5] = (_props_key = props[key5]) !== null && _props_key !== void 0 ? _props_key : val2;
@@ -3960,6 +4130,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3960
4130
  var groupState = groupContext === null || groupContext === void 0 ? void 0 : (_groupContext_groupName = groupContext[groupName]) === null || _groupContext_groupName === void 0 ? void 0 : _groupContext_groupName.state;
3961
4131
  var groupPseudoKey = groupInfo.pseudo;
3962
4132
  var groupMediaKey = groupInfo.media;
4133
+ if (groupPseudoKey === "hover") return;
3963
4134
  if (!groupState) {
3964
4135
  pseudoGroups || (pseudoGroups = /* @__PURE__ */ new Set());
3965
4136
  return;
@@ -4380,13 +4551,17 @@ function mergeRenderElementProps(elementProps, viewProps, children) {
4380
4551
  function usePointerEvents(props, viewProps) {
4381
4552
  var { onPointerDown, onPointerUp, onPointerMove, onPointerCancel, onPointerEnter, onPointerLeave } = props;
4382
4553
  var hasPointerEvents = onPointerDown || onPointerUp || onPointerMove || onPointerCancel || onPointerEnter || onPointerLeave;
4383
- var isInsideRef = (0, react.useRef)(false);
4384
- var layoutRef = (0, react.useRef)({
4385
- width: 0,
4386
- height: 0
4387
- });
4388
- var isCapturedRef = (0, react.useRef)(false);
4554
+ var ref = (0, react.useRef)(null);
4555
+ if (!ref.current) ref.current = {
4556
+ isInside: false,
4557
+ layout: {
4558
+ width: 0,
4559
+ height: 0
4560
+ },
4561
+ isCaptured: false
4562
+ };
4389
4563
  if (!hasPointerEvents) return;
4564
+ var bag = ref.current;
4390
4565
  var createNormalizedEvent = function(e) {
4391
4566
  var touch = e.nativeEvent;
4392
4567
  var _touch_identifier;
@@ -4402,10 +4577,10 @@ function usePointerEvents(props, viewProps) {
4402
4577
  nativeEvent: touch,
4403
4578
  target: {
4404
4579
  setPointerCapture: function(_pointerId) {
4405
- isCapturedRef.current = true;
4580
+ bag.isCaptured = true;
4406
4581
  },
4407
4582
  releasePointerCapture: function(_pointerId) {
4408
- isCapturedRef.current = false;
4583
+ bag.isCaptured = false;
4409
4584
  }
4410
4585
  }
4411
4586
  });
@@ -4414,46 +4589,46 @@ function usePointerEvents(props, viewProps) {
4414
4589
  onPointerDown(createNormalizedEvent(e));
4415
4590
  });
4416
4591
  if (onPointerUp) viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
4417
- isCapturedRef.current = false;
4592
+ bag.isCaptured = false;
4418
4593
  onPointerUp(createNormalizedEvent(e));
4419
4594
  });
4420
4595
  if (onPointerMove) viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
4421
4596
  var { locationX, locationY } = e.nativeEvent;
4422
- var { width, height } = layoutRef.current;
4597
+ var { width, height } = bag.layout;
4423
4598
  var isInBounds = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
4424
- if (isCapturedRef.current || isInBounds) onPointerMove(createNormalizedEvent(e));
4599
+ if (bag.isCaptured || isInBounds) onPointerMove(createNormalizedEvent(e));
4425
4600
  });
4426
4601
  if (onPointerCancel) viewProps.onTouchCancel = composeEventHandlers(viewProps.onTouchCancel, function(e) {
4427
- isCapturedRef.current = false;
4602
+ bag.isCaptured = false;
4428
4603
  onPointerCancel(createNormalizedEvent(e));
4429
4604
  });
4430
4605
  if (onPointerEnter || onPointerLeave || onPointerMove) viewProps.onLayout = composeEventHandlers(viewProps.onLayout, function(e) {
4431
- layoutRef.current = {
4606
+ bag.layout = {
4432
4607
  width: e.nativeEvent.layout.width,
4433
4608
  height: e.nativeEvent.layout.height
4434
4609
  };
4435
4610
  });
4436
4611
  if (onPointerEnter) viewProps.onTouchStart = composeEventHandlers(viewProps.onTouchStart, function(e) {
4437
4612
  var { locationX, locationY } = e.nativeEvent;
4438
- var { width, height } = layoutRef.current;
4613
+ var { width, height } = bag.layout;
4439
4614
  if (locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height) {
4440
- isInsideRef.current = true;
4615
+ bag.isInside = true;
4441
4616
  onPointerEnter(createNormalizedEvent(e));
4442
4617
  }
4443
4618
  });
4444
4619
  if (onPointerLeave) {
4445
4620
  viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
4446
4621
  var { locationX, locationY } = e.nativeEvent;
4447
- var { width, height } = layoutRef.current;
4622
+ var { width, height } = bag.layout;
4448
4623
  var isInside = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
4449
- if (isInsideRef.current && !isInside) {
4450
- isInsideRef.current = false;
4624
+ if (bag.isInside && !isInside) {
4625
+ bag.isInside = false;
4451
4626
  onPointerLeave(createNormalizedEvent(e));
4452
4627
  }
4453
4628
  });
4454
4629
  viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
4455
- if (isInsideRef.current) {
4456
- isInsideRef.current = false;
4630
+ if (bag.isInside) {
4631
+ bag.isInside = false;
4457
4632
  onPointerLeave(createNormalizedEvent(e));
4458
4633
  }
4459
4634
  });
@@ -4604,7 +4779,7 @@ var Theme = /* @__PURE__ */ (0, react.forwardRef)(function Theme2(props, ref) {
4604
4779
  if (props.disable) return props.children;
4605
4780
  var { passThrough } = props;
4606
4781
  var isRoot = !!props["_isRoot"];
4607
- var [_, themeState] = useThemeWithState(props, isRoot);
4782
+ var [_, themeState] = useThemeWithState(props, isRoot, true);
4608
4783
  var finalChildren = props["disable-child-theme"] ? react.Children.map(props.children, function(child) {
4609
4784
  return passThrough || !/* @__PURE__ */ (0, react.isValidElement)(child) ? child : /* @__PURE__ */ (0, react.cloneElement)(child, { ["data-disable-theme"]: true });
4610
4785
  }) : props.children;
@@ -4769,7 +4944,15 @@ var useComponentState = function(props, animationDriver, staticConfig, config) {
4769
4944
  });
4770
4945
  }
4771
4946
  var groupName = props.group;
4772
- var setStateShallow = useCreateShallowSetState(setState, props.debug);
4947
+ if (!stateRef.current.baseSetStateShallow) {
4948
+ var r = stateRef.current;
4949
+ r.baseSetStateShallow = function(stateOrGetState) {
4950
+ setState(function(prev) {
4951
+ return mergeIfNotShallowEqual(prev, typeof stateOrGetState === "function" ? stateOrGetState(prev) : stateOrGetState);
4952
+ });
4953
+ };
4954
+ }
4955
+ var setStateShallow = stateRef.current.baseSetStateShallow;
4773
4956
  if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
4774
4957
  var { enterVariant, exitVariant, enterExitVariant, custom } = presenceState;
4775
4958
  if (isObj(custom)) Object.assign(props, custom);
@@ -4930,10 +5113,11 @@ function createComponent(staticConfig) {
4930
5113
  BaseView = baseViews.View;
4931
5114
  }
4932
5115
  }
4933
- if (propsIn["data-test-renders"]) {
4934
- var _propsIn_datatestrenders_current;
4935
- propsIn["data-test-renders"]["current"] = (_propsIn_datatestrenders_current = propsIn["data-test-renders"]["current"]) !== null && _propsIn_datatestrenders_current !== void 0 ? _propsIn_datatestrenders_current : 0;
4936
- propsIn["data-test-renders"]["current"] += 1;
5116
+ var testRenderCount = propsIn["data-test-renders"];
5117
+ if (testRenderCount && (typeof testRenderCount === "undefined" ? "undefined" : _type_of$1(testRenderCount)) === "object" && !Object.isFrozen(testRenderCount)) {
5118
+ var _testRenderCount_current;
5119
+ testRenderCount.current = (_testRenderCount_current = testRenderCount.current) !== null && _testRenderCount_current !== void 0 ? _testRenderCount_current : 0;
5120
+ testRenderCount.current += 1;
4937
5121
  }
4938
5122
  var { context, isReactNative } = staticConfig;
4939
5123
  var debugProp = propsIn["debug"];
@@ -4941,7 +5125,7 @@ function createComponent(staticConfig) {
4941
5125
  var overriddenContextProps = null;
4942
5126
  var componentContext = react.default.useContext(ComponentContext);
4943
5127
  var hasTextAncestor = false;
4944
- var isInsideNativeMenu = react.default.useContext(NativeMenuContext);
5128
+ var isInsideNativeMenu = isAndroid ? react.default.useContext(NativeMenuContext) : false;
4945
5129
  var props = propsIn;
4946
5130
  var componentName = props.componentName || staticConfig.componentName;
4947
5131
  var [nextProps, overrides] = mergeComponentProps(getDefaultProps(staticConfig, props.componentName), styledContextValue, propsIn);
@@ -5375,7 +5559,8 @@ function createComponent(staticConfig) {
5375
5559
  var propsInWithHref = propsIn;
5376
5560
  var _props_testID, _ref, _ref1, _ref2, _ref3;
5377
5561
  var pressDebugName = [componentName, (_ref3 = (_ref2 = (_ref1 = (_ref = (_props_testID = props.testID) !== null && _props_testID !== void 0 ? _props_testID : propsIn.testID) !== null && _ref !== void 0 ? _ref : props.accessibilityLabel) !== null && _ref1 !== void 0 ? _ref1 : propsIn.accessibilityLabel) !== null && _ref2 !== void 0 ? _ref2 : typeof propsWithHref.href === "string" ? propsWithHref.href : null) !== null && _ref3 !== void 0 ? _ref3 : typeof propsInWithHref.href === "string" ? propsInWithHref.href : null].filter(Boolean).join(":") || null;
5378
- var pressGesture = useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNativeMenu, pressDebugName, !!(onPress || onPressIn || onPressOut || onLongPress));
5562
+ var hasRealPressEvents = !!(onPress || onPressIn || onPressOut || onLongPress);
5563
+ var pressGesture = useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNativeMenu, pressDebugName, hasRealPressEvents);
5379
5564
  if (asChild) {
5380
5565
  elementType = Slot;
5381
5566
  Object.assign(viewProps, {
@@ -5400,7 +5585,7 @@ function createComponent(staticConfig) {
5400
5585
  content = /* @__PURE__ */ react.default.createElement(elementType, viewProps, content || children);
5401
5586
  }
5402
5587
  }
5403
- content = wrapWithGestureDetector(content, pressGesture, stateRef, isHOC, !isHOC && Component && typeof Component !== "string");
5588
+ content = wrapWithGestureDetector(content, pressGesture, stateRef, isHOC, !isHOC && Component && typeof Component !== "string", hasRealPressEvents);
5404
5589
  var ResetPresence = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.ResetPresence;
5405
5590
  var needsReset = Boolean(!asChild && splitStyles && !isHOC && ResetPresence && willBeAnimated && (hasEnterStyle || presenceState));
5406
5591
  var hasEverReset = stateRef.current.hasEverResetPresence;
@@ -6973,8 +7158,7 @@ if (ENABLE) {
6973
7158
  }
6974
7159
  function _updateLayoutIfChanged() {
6975
7160
  _updateLayoutIfChanged = _asyncToGenerator(function* (node) {
6976
- var onLayout = LayoutHandlers.get(node);
6977
- if (typeof onLayout !== "function") return;
7161
+ if (typeof LayoutHandlers.get(node) !== "function") return;
6978
7162
  var parentNode = node.parentElement;
6979
7163
  if (!parentNode) return;
6980
7164
  var nodeRect;
@@ -6987,19 +7171,7 @@ if (ENABLE) {
6987
7171
  nodeRect = node.getBoundingClientRect();
6988
7172
  parentRect = parentNode.getBoundingClientRect();
6989
7173
  }
6990
- var cachedRect = NodeRectCache.get(node);
6991
- var cachedParentRect = NodeRectCache.get(parentNode);
6992
- var nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);
6993
- var parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);
6994
- if (nodeChanged || parentChanged) {
6995
- NodeRectCache.set(node, nodeRect);
6996
- NodeRectCache.set(parentNode, parentRect);
6997
- var event = getElementLayoutEvent(nodeRect, parentRect, node);
6998
- if (avoidUpdates) queuedUpdates.set(node, function() {
6999
- return onLayout(event);
7000
- });
7001
- else onLayout(event);
7002
- }
7174
+ emitLayoutIfChanged(node, parentNode, nodeRect, parentRect);
7003
7175
  });
7004
7176
  return _updateLayoutIfChanged.apply(this, arguments);
7005
7177
  }
@@ -7130,15 +7302,35 @@ var getRelativeDimensions = function(a, b, aNode) {
7130
7302
  pageY: a.top
7131
7303
  };
7132
7304
  };
7133
- function registerLayoutNode(node, onChange, disableKey) {
7305
+ function emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {
7306
+ var onLayout = LayoutHandlers.get(node);
7307
+ if (typeof onLayout !== "function") return;
7308
+ var cachedRect = NodeRectCache.get(node);
7309
+ var cachedParentRect = NodeRectCache.get(parentNode);
7310
+ var nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);
7311
+ var parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);
7312
+ if (!nodeChanged && !parentChanged) return;
7313
+ NodeRectCache.set(node, nodeRect);
7314
+ NodeRectCache.set(parentNode, parentRect);
7315
+ var event = getElementLayoutEvent(nodeRect, parentRect, node);
7316
+ if (avoidUpdates) queuedUpdates.set(node, function() {
7317
+ return onLayout(event);
7318
+ });
7319
+ else onLayout(event);
7320
+ }
7321
+ function observeLayoutNode(node, disableKey) {
7134
7322
  Nodes.add(node);
7135
- LayoutHandlers.set(node, onChange);
7136
7323
  if (disableKey) LayoutDisableKey.set(node, disableKey);
7324
+ else LayoutDisableKey.delete(node);
7137
7325
  startGlobalObservers();
7138
7326
  if (globalIntersectionObserver) {
7139
7327
  globalIntersectionObserver.observe(node);
7140
7328
  IntersectionState.set(node, true);
7141
7329
  }
7330
+ }
7331
+ function registerLayoutNode(node, onChange, disableKey) {
7332
+ LayoutHandlers.set(node, onChange);
7333
+ observeLayoutNode(node, disableKey);
7142
7334
  return function() {
7143
7335
  return cleanupNode(node);
7144
7336
  };
@@ -7343,6 +7535,7 @@ exports.rgba = rgba;
7343
7535
  exports.setConfig = setConfig;
7344
7536
  exports.setDidGetVariableValue = setDidGetVariableValue;
7345
7537
  exports.setIdentifierValue = setIdentifierValue;
7538
+ exports.setMediaState = setMediaState;
7346
7539
  exports.setNonce = setNonce;
7347
7540
  exports.setOnLayoutStrategy = setOnLayoutStrategy;
7348
7541
  exports.setRef = setRef;
@@ -7368,6 +7561,7 @@ exports.tokenCategories = tokenCategories;
7368
7561
  exports.transformsToString = transformsToString;
7369
7562
  exports.updateConfig = updateConfig;
7370
7563
  exports.updateFont = updateFont;
7564
+ exports.updateMediaListeners = updateMediaListeners;
7371
7565
  exports.useClientValue = useClientValue;
7372
7566
  exports.useComposedRefs = useComposedRefs;
7373
7567
  exports.useConfiguration = useConfiguration;