@tamagui/core 2.3.3 → 2.4.0-1783110557100

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
@@ -3426,6 +3588,29 @@ var propMapper = function(key, value, styleState, disabled, map) {
3426
3588
  }
3427
3589
  var { conf, styleProps, staticConfig } = styleState;
3428
3590
  var { variants } = staticConfig;
3591
+ if (value === "unset") {
3592
+ var expandedKey = !styleProps.disableExpandShorthands && conf.shorthands[key] || key;
3593
+ var expanded = styleProps.noExpand ? null : expandStyle(expandedKey, value, conf.settings.styleCompat || "web");
3594
+ if (styleState.style) if (expanded) {
3595
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
3596
+ try {
3597
+ for (var _iterator = expanded[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3598
+ var [nkey] = _step.value;
3599
+ delete styleState.style[nkey];
3600
+ }
3601
+ } catch (err) {
3602
+ _didIteratorError = true;
3603
+ _iteratorError = err;
3604
+ } finally {
3605
+ try {
3606
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
3607
+ } finally {
3608
+ if (_didIteratorError) throw _iteratorError;
3609
+ }
3610
+ }
3611
+ } else delete styleState.style[expandedKey];
3612
+ return;
3613
+ }
3429
3614
  if (!styleProps.noExpand) {
3430
3615
  if (variants && key in variants) {
3431
3616
  var variantValue = resolveVariants(key, value, styleProps, styleState, "");
@@ -3455,20 +3640,20 @@ var propMapper = function(key, value, styleState, disabled, map) {
3455
3640
  var parsed = parseNativeStyle(key, value);
3456
3641
  if (parsed) {
3457
3642
  if (key === "textShadow" && Array.isArray(parsed) && Array.isArray(parsed[0])) {
3458
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
3643
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
3459
3644
  try {
3460
- for (var _iterator = parsed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3461
- var [nkey, nvalue] = _step.value;
3462
- map(nkey, nvalue, originalValue);
3645
+ for (var _iterator1 = parsed[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
3646
+ var [nkey1, nvalue] = _step1.value;
3647
+ map(nkey1, nvalue, originalValue);
3463
3648
  }
3464
3649
  } catch (err) {
3465
- _didIteratorError = true;
3466
- _iteratorError = err;
3650
+ _didIteratorError1 = true;
3651
+ _iteratorError1 = err;
3467
3652
  } finally {
3468
3653
  try {
3469
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
3654
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();
3470
3655
  } finally {
3471
- if (_didIteratorError) throw _iteratorError;
3656
+ if (_didIteratorError1) throw _iteratorError1;
3472
3657
  }
3473
3658
  }
3474
3659
  return;
@@ -3479,12 +3664,12 @@ var propMapper = function(key, value, styleState, disabled, map) {
3479
3664
  if (value != null) {
3480
3665
  var fontToken = getLastFontFamilyToken();
3481
3666
  if (key === "fontFamily" && fontToken) styleState.fontFamily = fontToken;
3482
- var expanded = styleProps.noExpand ? null : expandStyle(key, value, conf.settings.styleCompat || "web");
3483
- if (expanded) {
3484
- var max = expanded.length;
3667
+ var expanded1 = styleProps.noExpand ? null : expandStyle(key, value, conf.settings.styleCompat || "web");
3668
+ if (expanded1) {
3669
+ var max = expanded1.length;
3485
3670
  for (var i = 0; i < max; i++) {
3486
- var [nkey1, nvalue1, noriginalValue] = expanded[i];
3487
- map(nkey1, nvalue1, noriginalValue !== null && noriginalValue !== void 0 ? noriginalValue : originalValue);
3671
+ var [nkey2, nvalue1, noriginalValue] = expanded1[i];
3672
+ map(nkey2, nvalue1, noriginalValue !== null && noriginalValue !== void 0 ? noriginalValue : originalValue);
3488
3673
  }
3489
3674
  } else map(key, value, originalValue);
3490
3675
  }
@@ -3709,6 +3894,11 @@ function normalizeGroupKey(key, groupContext) {
3709
3894
  function isValidStyleKey(key, validStyles, accept) {
3710
3895
  return key in validStyles ? true : accept && key in accept;
3711
3896
  }
3897
+ function shouldSkipNativeHoverProp(key, isMedia) {
3898
+ if (key === "hoverStyle") return true;
3899
+ if (isMedia === "group") return getGroupPropParts(key.slice(1)).pseudo === "hover";
3900
+ return false;
3901
+ }
3712
3902
  var getSplitStyles = function(props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, componentContext, groupContext, elementType, startedUnhydrated, debug, animationDriver) {
3713
3903
  var _loop = function(keyOg2) {
3714
3904
  var keyInit = keyOg2;
@@ -3717,6 +3907,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3717
3907
  viewProps[keyInit] = valInit;
3718
3908
  return "continue";
3719
3909
  }
3910
+ if (keyInit[0] === "d" && keyInit.startsWith("data-")) return "continue";
3720
3911
  if (keyInit === "jestAnimatedStyle") return "continue";
3721
3912
  if (accept) {
3722
3913
  var accepted = accept[keyInit];
@@ -3759,6 +3950,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3759
3950
  var isMediaOrPseudo = Boolean(isMedia || isPseudo);
3760
3951
  if (isMediaOrPseudo && isMedia === "group") keyInit = normalizeGroupKey(keyInit, groupContext);
3761
3952
  var isStyleProp = isValidStyleKeyInit || isMediaOrPseudo || isVariant && !noExpand;
3953
+ if (shouldSkipNativeHoverProp(keyInit, isMedia)) return "continue";
3762
3954
  if (isStyleProp && (asChild === "except-style" || asChild === "except-style-web")) return "continue";
3763
3955
  var shouldPassProp = !isStyleProp && isHOC || isHOC && parentVariants && keyInit in parentVariants || (inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(keyInit));
3764
3956
  var parentVariant = parentVariants === null || parentVariants === void 0 ? void 0 : parentVariants[keyInit];
@@ -3796,6 +3988,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3796
3988
  isMediaOrPseudo = Boolean(isMedia || isPseudo);
3797
3989
  isVariant = variants && key5 in variants;
3798
3990
  if (isMedia === "group") key5 = normalizeGroupKey(key5, groupContext);
3991
+ if (shouldSkipNativeHoverProp(key5, isMedia)) return;
3799
3992
  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
3993
  var _props_key;
3801
3994
  viewProps[key5] = (_props_key = props[key5]) !== null && _props_key !== void 0 ? _props_key : val2;
@@ -3960,6 +4153,7 @@ var getSplitStyles = function(props, staticConfig, theme, themeName, componentSt
3960
4153
  var groupState = groupContext === null || groupContext === void 0 ? void 0 : (_groupContext_groupName = groupContext[groupName]) === null || _groupContext_groupName === void 0 ? void 0 : _groupContext_groupName.state;
3961
4154
  var groupPseudoKey = groupInfo.pseudo;
3962
4155
  var groupMediaKey = groupInfo.media;
4156
+ if (groupPseudoKey === "hover") return;
3963
4157
  if (!groupState) {
3964
4158
  pseudoGroups || (pseudoGroups = /* @__PURE__ */ new Set());
3965
4159
  return;
@@ -4380,13 +4574,17 @@ function mergeRenderElementProps(elementProps, viewProps, children) {
4380
4574
  function usePointerEvents(props, viewProps) {
4381
4575
  var { onPointerDown, onPointerUp, onPointerMove, onPointerCancel, onPointerEnter, onPointerLeave } = props;
4382
4576
  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);
4577
+ var ref = (0, react.useRef)(null);
4578
+ if (!ref.current) ref.current = {
4579
+ isInside: false,
4580
+ layout: {
4581
+ width: 0,
4582
+ height: 0
4583
+ },
4584
+ isCaptured: false
4585
+ };
4389
4586
  if (!hasPointerEvents) return;
4587
+ var bag = ref.current;
4390
4588
  var createNormalizedEvent = function(e) {
4391
4589
  var touch = e.nativeEvent;
4392
4590
  var _touch_identifier;
@@ -4402,10 +4600,10 @@ function usePointerEvents(props, viewProps) {
4402
4600
  nativeEvent: touch,
4403
4601
  target: {
4404
4602
  setPointerCapture: function(_pointerId) {
4405
- isCapturedRef.current = true;
4603
+ bag.isCaptured = true;
4406
4604
  },
4407
4605
  releasePointerCapture: function(_pointerId) {
4408
- isCapturedRef.current = false;
4606
+ bag.isCaptured = false;
4409
4607
  }
4410
4608
  }
4411
4609
  });
@@ -4414,46 +4612,46 @@ function usePointerEvents(props, viewProps) {
4414
4612
  onPointerDown(createNormalizedEvent(e));
4415
4613
  });
4416
4614
  if (onPointerUp) viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
4417
- isCapturedRef.current = false;
4615
+ bag.isCaptured = false;
4418
4616
  onPointerUp(createNormalizedEvent(e));
4419
4617
  });
4420
4618
  if (onPointerMove) viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
4421
4619
  var { locationX, locationY } = e.nativeEvent;
4422
- var { width, height } = layoutRef.current;
4620
+ var { width, height } = bag.layout;
4423
4621
  var isInBounds = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
4424
- if (isCapturedRef.current || isInBounds) onPointerMove(createNormalizedEvent(e));
4622
+ if (bag.isCaptured || isInBounds) onPointerMove(createNormalizedEvent(e));
4425
4623
  });
4426
4624
  if (onPointerCancel) viewProps.onTouchCancel = composeEventHandlers(viewProps.onTouchCancel, function(e) {
4427
- isCapturedRef.current = false;
4625
+ bag.isCaptured = false;
4428
4626
  onPointerCancel(createNormalizedEvent(e));
4429
4627
  });
4430
4628
  if (onPointerEnter || onPointerLeave || onPointerMove) viewProps.onLayout = composeEventHandlers(viewProps.onLayout, function(e) {
4431
- layoutRef.current = {
4629
+ bag.layout = {
4432
4630
  width: e.nativeEvent.layout.width,
4433
4631
  height: e.nativeEvent.layout.height
4434
4632
  };
4435
4633
  });
4436
4634
  if (onPointerEnter) viewProps.onTouchStart = composeEventHandlers(viewProps.onTouchStart, function(e) {
4437
4635
  var { locationX, locationY } = e.nativeEvent;
4438
- var { width, height } = layoutRef.current;
4636
+ var { width, height } = bag.layout;
4439
4637
  if (locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height) {
4440
- isInsideRef.current = true;
4638
+ bag.isInside = true;
4441
4639
  onPointerEnter(createNormalizedEvent(e));
4442
4640
  }
4443
4641
  });
4444
4642
  if (onPointerLeave) {
4445
4643
  viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
4446
4644
  var { locationX, locationY } = e.nativeEvent;
4447
- var { width, height } = layoutRef.current;
4645
+ var { width, height } = bag.layout;
4448
4646
  var isInside = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
4449
- if (isInsideRef.current && !isInside) {
4450
- isInsideRef.current = false;
4647
+ if (bag.isInside && !isInside) {
4648
+ bag.isInside = false;
4451
4649
  onPointerLeave(createNormalizedEvent(e));
4452
4650
  }
4453
4651
  });
4454
4652
  viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
4455
- if (isInsideRef.current) {
4456
- isInsideRef.current = false;
4653
+ if (bag.isInside) {
4654
+ bag.isInside = false;
4457
4655
  onPointerLeave(createNormalizedEvent(e));
4458
4656
  }
4459
4657
  });
@@ -4604,7 +4802,7 @@ var Theme = /* @__PURE__ */ (0, react.forwardRef)(function Theme2(props, ref) {
4604
4802
  if (props.disable) return props.children;
4605
4803
  var { passThrough } = props;
4606
4804
  var isRoot = !!props["_isRoot"];
4607
- var [_, themeState] = useThemeWithState(props, isRoot);
4805
+ var [_, themeState] = useThemeWithState(props, isRoot, true);
4608
4806
  var finalChildren = props["disable-child-theme"] ? react.Children.map(props.children, function(child) {
4609
4807
  return passThrough || !/* @__PURE__ */ (0, react.isValidElement)(child) ? child : /* @__PURE__ */ (0, react.cloneElement)(child, { ["data-disable-theme"]: true });
4610
4808
  }) : props.children;
@@ -4769,7 +4967,15 @@ var useComponentState = function(props, animationDriver, staticConfig, config) {
4769
4967
  });
4770
4968
  }
4771
4969
  var groupName = props.group;
4772
- var setStateShallow = useCreateShallowSetState(setState, props.debug);
4970
+ if (!stateRef.current.baseSetStateShallow) {
4971
+ var r = stateRef.current;
4972
+ r.baseSetStateShallow = function(stateOrGetState) {
4973
+ setState(function(prev) {
4974
+ return mergeIfNotShallowEqual(prev, typeof stateOrGetState === "function" ? stateOrGetState(prev) : stateOrGetState);
4975
+ });
4976
+ };
4977
+ }
4978
+ var setStateShallow = stateRef.current.baseSetStateShallow;
4773
4979
  if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
4774
4980
  var { enterVariant, exitVariant, enterExitVariant, custom } = presenceState;
4775
4981
  if (isObj(custom)) Object.assign(props, custom);
@@ -4930,10 +5136,11 @@ function createComponent(staticConfig) {
4930
5136
  BaseView = baseViews.View;
4931
5137
  }
4932
5138
  }
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;
5139
+ var testRenderCount = propsIn["data-test-renders"];
5140
+ if (testRenderCount && (typeof testRenderCount === "undefined" ? "undefined" : _type_of$1(testRenderCount)) === "object" && !Object.isFrozen(testRenderCount)) {
5141
+ var _testRenderCount_current;
5142
+ testRenderCount.current = (_testRenderCount_current = testRenderCount.current) !== null && _testRenderCount_current !== void 0 ? _testRenderCount_current : 0;
5143
+ testRenderCount.current += 1;
4937
5144
  }
4938
5145
  var { context, isReactNative } = staticConfig;
4939
5146
  var debugProp = propsIn["debug"];
@@ -4941,7 +5148,7 @@ function createComponent(staticConfig) {
4941
5148
  var overriddenContextProps = null;
4942
5149
  var componentContext = react.default.useContext(ComponentContext);
4943
5150
  var hasTextAncestor = false;
4944
- var isInsideNativeMenu = react.default.useContext(NativeMenuContext);
5151
+ var isInsideNativeMenu = isAndroid ? react.default.useContext(NativeMenuContext) : false;
4945
5152
  var props = propsIn;
4946
5153
  var componentName = props.componentName || staticConfig.componentName;
4947
5154
  var [nextProps, overrides] = mergeComponentProps(getDefaultProps(staticConfig, props.componentName), styledContextValue, propsIn);
@@ -5375,7 +5582,8 @@ function createComponent(staticConfig) {
5375
5582
  var propsInWithHref = propsIn;
5376
5583
  var _props_testID, _ref, _ref1, _ref2, _ref3;
5377
5584
  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));
5585
+ var hasRealPressEvents = !!(onPress || onPressIn || onPressOut || onLongPress);
5586
+ var pressGesture = useEvents(events, viewProps, stateRef, staticConfig, isHOC, isInsideNativeMenu, pressDebugName, hasRealPressEvents);
5379
5587
  if (asChild) {
5380
5588
  elementType = Slot;
5381
5589
  Object.assign(viewProps, {
@@ -5400,7 +5608,7 @@ function createComponent(staticConfig) {
5400
5608
  content = /* @__PURE__ */ react.default.createElement(elementType, viewProps, content || children);
5401
5609
  }
5402
5610
  }
5403
- content = wrapWithGestureDetector(content, pressGesture, stateRef, isHOC, !isHOC && Component && typeof Component !== "string");
5611
+ content = wrapWithGestureDetector(content, pressGesture, stateRef, isHOC, !isHOC && Component && typeof Component !== "string", hasRealPressEvents);
5404
5612
  var ResetPresence = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.ResetPresence;
5405
5613
  var needsReset = Boolean(!asChild && splitStyles && !isHOC && ResetPresence && willBeAnimated && (hasEnterStyle || presenceState));
5406
5614
  var hasEverReset = stateRef.current.hasEverResetPresence;
@@ -6973,8 +7181,7 @@ if (ENABLE) {
6973
7181
  }
6974
7182
  function _updateLayoutIfChanged() {
6975
7183
  _updateLayoutIfChanged = _asyncToGenerator(function* (node) {
6976
- var onLayout = LayoutHandlers.get(node);
6977
- if (typeof onLayout !== "function") return;
7184
+ if (typeof LayoutHandlers.get(node) !== "function") return;
6978
7185
  var parentNode = node.parentElement;
6979
7186
  if (!parentNode) return;
6980
7187
  var nodeRect;
@@ -6987,19 +7194,7 @@ if (ENABLE) {
6987
7194
  nodeRect = node.getBoundingClientRect();
6988
7195
  parentRect = parentNode.getBoundingClientRect();
6989
7196
  }
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
- }
7197
+ emitLayoutIfChanged(node, parentNode, nodeRect, parentRect);
7003
7198
  });
7004
7199
  return _updateLayoutIfChanged.apply(this, arguments);
7005
7200
  }
@@ -7130,15 +7325,35 @@ var getRelativeDimensions = function(a, b, aNode) {
7130
7325
  pageY: a.top
7131
7326
  };
7132
7327
  };
7133
- function registerLayoutNode(node, onChange, disableKey) {
7328
+ function emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {
7329
+ var onLayout = LayoutHandlers.get(node);
7330
+ if (typeof onLayout !== "function") return;
7331
+ var cachedRect = NodeRectCache.get(node);
7332
+ var cachedParentRect = NodeRectCache.get(parentNode);
7333
+ var nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);
7334
+ var parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);
7335
+ if (!nodeChanged && !parentChanged) return;
7336
+ NodeRectCache.set(node, nodeRect);
7337
+ NodeRectCache.set(parentNode, parentRect);
7338
+ var event = getElementLayoutEvent(nodeRect, parentRect, node);
7339
+ if (avoidUpdates) queuedUpdates.set(node, function() {
7340
+ return onLayout(event);
7341
+ });
7342
+ else onLayout(event);
7343
+ }
7344
+ function observeLayoutNode(node, disableKey) {
7134
7345
  Nodes.add(node);
7135
- LayoutHandlers.set(node, onChange);
7136
7346
  if (disableKey) LayoutDisableKey.set(node, disableKey);
7347
+ else LayoutDisableKey.delete(node);
7137
7348
  startGlobalObservers();
7138
7349
  if (globalIntersectionObserver) {
7139
7350
  globalIntersectionObserver.observe(node);
7140
7351
  IntersectionState.set(node, true);
7141
7352
  }
7353
+ }
7354
+ function registerLayoutNode(node, onChange, disableKey) {
7355
+ LayoutHandlers.set(node, onChange);
7356
+ observeLayoutNode(node, disableKey);
7142
7357
  return function() {
7143
7358
  return cleanupNode(node);
7144
7359
  };
@@ -7343,6 +7558,7 @@ exports.rgba = rgba;
7343
7558
  exports.setConfig = setConfig;
7344
7559
  exports.setDidGetVariableValue = setDidGetVariableValue;
7345
7560
  exports.setIdentifierValue = setIdentifierValue;
7561
+ exports.setMediaState = setMediaState;
7346
7562
  exports.setNonce = setNonce;
7347
7563
  exports.setOnLayoutStrategy = setOnLayoutStrategy;
7348
7564
  exports.setRef = setRef;
@@ -7368,6 +7584,7 @@ exports.tokenCategories = tokenCategories;
7368
7584
  exports.transformsToString = transformsToString;
7369
7585
  exports.updateConfig = updateConfig;
7370
7586
  exports.updateFont = updateFont;
7587
+ exports.updateMediaListeners = updateMediaListeners;
7371
7588
  exports.useClientValue = useClientValue;
7372
7589
  exports.useComposedRefs = useComposedRefs;
7373
7590
  exports.useConfiguration = useConfiguration;