@tamagui/core 1.126.13-1747671613486 → 1.126.13-1747874018127

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.
@@ -70,9 +70,9 @@ var require_index_native = __commonJS({
70
70
  }
71
71
  });
72
72
  module2.exports = __toCommonJS2(index_exports2);
73
- var cache2 = /* @__PURE__ */ new Map(), cacheSize = 0, simpleHash = function(strIn) {
73
+ var cache = /* @__PURE__ */ new Map(), cacheSize = 0, simpleHash = function(strIn) {
74
74
  var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;
75
- if (cache2.has(strIn)) return cache2.get(strIn);
75
+ if (cache.has(strIn)) return cache.get(strIn);
76
76
  var str = strIn;
77
77
  str[0] === "v" && str.startsWith("var(") && (str = str.slice(6, str.length - 1));
78
78
  for (var hash = 0, valids = "", added = 0, len = str.length, i = 0; i < len; i++) {
@@ -90,7 +90,7 @@ var require_index_native = __commonJS({
90
90
  hash = hashChar(hash, str[i]);
91
91
  }
92
92
  var res = valids + (hash ? Math.abs(hash) : "");
93
- return cacheSize > 1e4 && (cache2.clear(), cacheSize = 0), cache2.set(strIn, res), cacheSize++, res;
93
+ return cacheSize > 1e4 && (cache.clear(), cacheSize = 0), cache.set(strIn, res), cacheSize++, res;
94
94
  }, hashChar = function(hash, c) {
95
95
  return Math.imul(31, hash) + c.charCodeAt(0) | 0;
96
96
  };
@@ -403,7 +403,7 @@ var require_constants_native = __commonJS({
403
403
  return isChrome;
404
404
  },
405
405
  isClient: function() {
406
- return isClient;
406
+ return isClient2;
407
407
  },
408
408
  isIos: function() {
409
409
  return isIos;
@@ -428,7 +428,7 @@ var require_constants_native = __commonJS({
428
428
  }
429
429
  });
430
430
  module2.exports = __toCommonJS2(constants_native_exports);
431
- var import_react3 = require("react"), import_react_native = require("react-native"), isWeb = !1, isWindowDefined = !1, isServer = !1, isClient = !1, useIsomorphicLayoutEffect2 = import_react3.useLayoutEffect, isChrome = !1, isWebTouchable = !1, isTouchable = !0, isAndroid = import_react_native.Platform.OS === "android" || process.env.TEST_NATIVE_PLATFORM === "android", isIos = import_react_native.Platform.OS === "ios" || process.env.TEST_NATIVE_PLATFORM === "ios", platforms = {
431
+ var import_react3 = require("react"), import_react_native = require("react-native"), isWeb = !1, isWindowDefined = !1, isServer = !1, isClient2 = !1, useIsomorphicLayoutEffect2 = import_react3.useLayoutEffect, isChrome = !1, isWebTouchable = !1, isTouchable = !0, isAndroid = import_react_native.Platform.OS === "android" || process.env.TEST_NATIVE_PLATFORM === "android", isIos = import_react_native.Platform.OS === "ios" || process.env.TEST_NATIVE_PLATFORM === "ios", platforms = {
432
432
  ios: "ios",
433
433
  android: "android"
434
434
  }, currentPlatform = platforms[import_react_native.Platform.OS] || "native";
@@ -1916,15 +1916,15 @@ var require_useMedia_native = __commonJS({
1916
1916
  return `-${m.toLowerCase()}`;
1917
1917
  }).toLowerCase();
1918
1918
  }
1919
- var cache2 = /* @__PURE__ */ new WeakMap(), cachedMediaKeyToQuery = {};
1919
+ var cache = /* @__PURE__ */ new WeakMap(), cachedMediaKeyToQuery = {};
1920
1920
  function mediaObjectToString2(query, key) {
1921
1921
  if (typeof query == "string") return query;
1922
- if (cache2.has(query)) return cache2.get(query);
1922
+ if (cache.has(query)) return cache.get(query);
1923
1923
  var res = Object.entries(query).map(function(param) {
1924
1924
  var [feature, value] = param;
1925
1925
  return feature = camelToHyphen(feature), typeof value == "string" ? `(${feature}: ${value})` : (typeof value == "number" && /[height|width]$/.test(feature) && (value = `${value}px`), `(${feature}: ${value})`);
1926
1926
  }).join(" and ");
1927
- return key && (cachedMediaKeyToQuery[key] = res), cache2.set(query, res), res;
1927
+ return key && (cachedMediaKeyToQuery[key] = res), cache.set(query, res), res;
1928
1928
  }
1929
1929
  function mediaKeyToQuery(key) {
1930
1930
  return cachedMediaKeyToQuery[key] || mediaObjectToString2(mediaQueryConfig2[key], key);
@@ -2228,15 +2228,15 @@ var require_objectIdentityKey_native = __commonJS({
2228
2228
  k += key;
2229
2229
  var arg = obj[key], type = typeof arg;
2230
2230
  if (!arg || type !== "object" && type !== "function") k += type + arg;
2231
- else if (cache2.has(arg)) k += cache2.get(arg);
2231
+ else if (cache.has(arg)) k += cache.get(arg);
2232
2232
  else {
2233
2233
  var v = Math.random();
2234
- cache2.set(arg, v), k += v;
2234
+ cache.set(arg, v), k += v;
2235
2235
  }
2236
2236
  }
2237
2237
  return k;
2238
2238
  }
2239
- var cache2 = /* @__PURE__ */ new WeakMap();
2239
+ var cache = /* @__PURE__ */ new WeakMap();
2240
2240
  }
2241
2241
  });
2242
2242
 
@@ -4261,8 +4261,8 @@ var require_getVariantExtras_native = __commonJS({
4261
4261
  }
4262
4262
  });
4263
4263
  module2.exports = __toCommonJS2(getVariantExtras_exports);
4264
- var import_createVariable = require_createVariable_native(), cache2 = /* @__PURE__ */ new WeakMap(), getVariantExtras = function(styleState) {
4265
- if (cache2.has(styleState)) return cache2.get(styleState);
4264
+ var import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), getVariantExtras = function(styleState) {
4265
+ if (cache.has(styleState)) return cache.get(styleState);
4266
4266
  var { props, conf, context, theme } = styleState, fonts = conf.fontsParsed;
4267
4267
  context != null && context.language && (fonts = getFontsForLanguage(conf.fontsParsed, context.language));
4268
4268
  var next = {
@@ -4277,7 +4277,7 @@ var require_getVariantExtras_native = __commonJS({
4277
4277
  },
4278
4278
  props
4279
4279
  };
4280
- return cache2.set(styleState, next), next;
4280
+ return cache.set(styleState, next), next;
4281
4281
  }, fontLanguageCache = /* @__PURE__ */ new WeakMap();
4282
4282
  function getFontsForLanguage(fonts, language) {
4283
4283
  if (fontLanguageCache.has(language)) return fontLanguageCache.get(language);
@@ -5636,7 +5636,7 @@ var require_createShallowSetState_native = __commonJS({
5636
5636
  return createShallowSetState;
5637
5637
  },
5638
5638
  isEqualShallow: function() {
5639
- return isEqualShallow;
5639
+ return isEqualShallow2;
5640
5640
  },
5641
5641
  mergeIfNotShallowEqual: function() {
5642
5642
  return mergeIfNotShallowEqual;
@@ -5667,12 +5667,12 @@ var require_createShallowSetState_native = __commonJS({
5667
5667
  for (var key in next) onlyAllow.includes(key) && (allowed[key] = next[key]);
5668
5668
  next = allowed;
5669
5669
  }
5670
- return !prev || !next || isEqualShallow(prev, next) ? prev || next : {
5670
+ return !prev || !next || isEqualShallow2(prev, next) ? prev || next : {
5671
5671
  ...prev,
5672
5672
  ...next
5673
5673
  };
5674
5674
  }
5675
- function isEqualShallow(prev, next) {
5675
+ function isEqualShallow2(prev, next) {
5676
5676
  for (var key in next) if (prev[key] !== next[key]) return !1;
5677
5677
  return !0;
5678
5678
  }
@@ -6094,11 +6094,11 @@ var require_getThemeProxied_native = __commonJS({
6094
6094
  }
6095
6095
  });
6096
6096
  module2.exports = __toCommonJS2(getThemeProxied_exports);
6097
- var import_constants2 = require_index_native2(), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_doesRootSchemeMatchSystem = require_doesRootSchemeMatchSystem_native(), import_getDynamicVal = require_getDynamicVal_native(), cache2 = /* @__PURE__ */ new Map(), curKeys, curProps, curState, emptyObject = {};
6097
+ var import_constants2 = require_index_native2(), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_doesRootSchemeMatchSystem = require_doesRootSchemeMatchSystem_native(), import_getDynamicVal = require_getDynamicVal_native(), cache = /* @__PURE__ */ new Map(), curKeys, curProps, curState, emptyObject = {};
6098
6098
  function getThemeProxied(_props, _state, _keys) {
6099
6099
  if (!(_state != null && _state.theme)) return emptyObject;
6100
- if (curKeys = _keys, curProps = _props, curState = _state, cache2.has(curState.theme)) {
6101
- var proxied = cache2.get(curState.theme);
6100
+ if (curKeys = _keys, curProps = _props, curState = _state, cache.has(curState.theme)) {
6101
+ var proxied = cache.get(curState.theme);
6102
6102
  return proxied;
6103
6103
  }
6104
6104
  var config = (0, import_config.getConfig)();
@@ -6137,7 +6137,7 @@ var require_getThemeProxied_native = __commonJS({
6137
6137
  ]
6138
6138
  ];
6139
6139
  }));
6140
- return cache2.set(_state.theme, proxied1), proxied1;
6140
+ return cache.set(_state.theme, proxied1), proxied1;
6141
6141
  }
6142
6142
  }
6143
6143
  });
@@ -7604,9 +7604,9 @@ var require_createVariables_native = __commonJS({
7604
7604
  }
7605
7605
  });
7606
7606
  module2.exports = __toCommonJS2(createVariables_exports);
7607
- var import_helpers2 = require_index_native3(), import_createVariable = require_createVariable_native(), cache2 = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
7607
+ var import_helpers2 = require_index_native3(), import_createVariable = require_createVariable_native(), cache = /* @__PURE__ */ new WeakMap(), createVariables = function(tokens) {
7608
7608
  var parentPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", isFont = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
7609
- if (cache2.has(tokens)) return tokens;
7609
+ if (cache.has(tokens)) return tokens;
7610
7610
  var res = {}, i = 0;
7611
7611
  for (var keyIn in tokens) {
7612
7612
  i++;
@@ -7627,7 +7627,7 @@ var require_createVariables_native = __commonJS({
7627
7627
  });
7628
7628
  res[key] = finalValue;
7629
7629
  }
7630
- return cache2.set(res, !0), res;
7630
+ return cache.set(res, !0), res;
7631
7631
  };
7632
7632
  }
7633
7633
  });
@@ -10448,9 +10448,9 @@ var require_createMedia_native = __commonJS({
10448
10448
  }
10449
10449
  });
10450
10450
  module2.exports = __toCommonJS2(createMedia_exports);
10451
- var import_web2 = require_index_native8(), import_matchMedia = require_matchMedia_native2();
10451
+ var import_web3 = require_index_native8(), import_matchMedia = require_matchMedia_native2();
10452
10452
  function createMedia2(media) {
10453
- return (0, import_web2.setupMatchMedia)(import_matchMedia.matchMedia), media;
10453
+ return (0, import_web3.setupMatchMedia)(import_matchMedia.matchMedia), media;
10454
10454
  }
10455
10455
  }
10456
10456
  });
@@ -11503,10 +11503,11 @@ __export(index_exports, {
11503
11503
  Stack: () => Stack,
11504
11504
  Text: () => Text,
11505
11505
  View: () => View,
11506
- createTamagui: () => createTamagui
11506
+ createTamagui: () => createTamagui,
11507
+ getElementLayoutEvent: () => getElementLayoutEvent
11507
11508
  });
11508
11509
  module.exports = __toCommonJS(index_exports);
11509
- var import_react_native_media_driver = __toESM(require_index_native9()), import_react_native_use_responder_events = __toESM(require_index_native10()), import_web = __toESM(require_index_native8()), import_react2 = __toESM(require("react"));
11510
+ var import_react_native_media_driver = __toESM(require_index_native9()), import_react_native_use_responder_events = __toESM(require_index_native10()), import_web2 = __toESM(require_index_native8()), import_react2 = __toESM(require("react"));
11510
11511
 
11511
11512
  // src/createOptimizedView.native.tsx
11512
11513
  var import_react = __toESM(require("react"));
@@ -11722,77 +11723,58 @@ var getRect = function(node) {
11722
11723
  };
11723
11724
 
11724
11725
  // src/hooks/useElementLayout.tsx
11725
- var import_constants = __toESM(require_index_native2());
11726
- function _type_of(obj) {
11727
- "@swc/helpers - typeof";
11728
- return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
11729
- }
11730
- var LayoutHandlers = /* @__PURE__ */ new WeakMap(), resizeListeners = /* @__PURE__ */ new Set(), resizeObserver = null;
11731
- typeof window < "u" && "ResizeObserver" in window && (resizeObserver = new ResizeObserver(function(entries) {
11732
- var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
11733
- try {
11734
- for (var _loop = function() {
11735
- var { target } = _step.value, onLayout = LayoutHandlers.get(target);
11736
- if (typeof onLayout != "function") return {
11737
- v: void 0
11738
- };
11739
- measureElement(target).then(function(event) {
11740
- onLayout(event);
11741
- });
11742
- }, _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
11743
- var _ret = _loop();
11744
- if (_type_of(_ret) === "object") return _ret.v;
11745
- }
11746
- } catch (err) {
11747
- _didIteratorError = !0, _iteratorError = err;
11748
- } finally {
11749
- try {
11750
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
11751
- } finally {
11752
- if (_didIteratorError)
11753
- throw _iteratorError;
11754
- }
11755
- }
11756
- }), typeof window.addEventListener == "function" && window.addEventListener("resize", function() {
11757
- clearTimeout(tm), tm = setTimeout(function() {
11758
- resizeListeners.forEach(function(cb) {
11726
+ var import_constants = __toESM(require_index_native2()), import_web = __toESM(require_index_native8()), LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set(), NodeRectCache = /* @__PURE__ */ new WeakMap(), ParentRectCache = /* @__PURE__ */ new WeakMap();
11727
+ if (import_constants.isClient && typeof requestAnimationFrame == "function") {
11728
+ let updateLayoutIfChanged = function(node) {
11729
+ var nodeRect = node.getBoundingClientRect(), parentNode = node.parentElement, parentRect = parentNode == null ? void 0 : parentNode.getBoundingClientRect(), onLayout = LayoutHandlers.get(node);
11730
+ if (typeof onLayout == "function") {
11731
+ var cachedRect = NodeRectCache.get(node), cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
11732
+ if (!cachedRect || // has changed one rect
11733
+ !(0, import_web.isEqualShallow)(cachedRect, nodeRect) && (!cachedParentRect || !(0, import_web.isEqualShallow)(cachedParentRect, parentRect))) {
11734
+ NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect);
11735
+ var event = getElementLayoutEvent(node);
11736
+ avoidUpdates ? queuedUpdates.set(node, function() {
11737
+ return onLayout(event);
11738
+ }) : onLayout(event);
11739
+ }
11740
+ }
11741
+ }, layoutOnAnimationFrame = function() {
11742
+ Nodes.forEach(updateLayoutIfChanged), requestAnimationFrame(layoutOnAnimationFrame);
11743
+ };
11744
+ updateLayoutIfChanged2 = updateLayoutIfChanged, layoutOnAnimationFrame2 = layoutOnAnimationFrame, avoidUpdates = !0, queuedUpdates = /* @__PURE__ */ new Map(), (0, import_web.___onDidFinishClientRender)(function() {
11745
+ avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(function(cb) {
11759
11746
  return cb();
11760
- });
11761
- }, 4);
11762
- }));
11763
- var tm, measureElement = async function(target) {
11764
- return new Promise(function(res) {
11765
- measureLayout(target, null, function(x, y, width, height, left, top) {
11766
- res({
11767
- nativeEvent: {
11768
- layout: {
11769
- x,
11770
- y,
11771
- width,
11772
- height,
11773
- left,
11774
- top
11775
- },
11776
- target
11747
+ }), queuedUpdates.clear());
11748
+ }), requestAnimationFrame(layoutOnAnimationFrame);
11749
+ }
11750
+ var avoidUpdates, queuedUpdates, updateLayoutIfChanged2, layoutOnAnimationFrame2, getElementLayoutEvent = function(target) {
11751
+ var res = null;
11752
+ if (measureLayout(target, null, function(x, y, width, height, left, top) {
11753
+ res = {
11754
+ nativeEvent: {
11755
+ layout: {
11756
+ x,
11757
+ y,
11758
+ width,
11759
+ height,
11760
+ left,
11761
+ top
11777
11762
  },
11778
- timeStamp: Date.now()
11779
- });
11780
- });
11781
- });
11782
- }, cache = /* @__PURE__ */ new WeakMap(), measureLayout = function(node, relativeTo, callback) {
11783
- var relativeNode = relativeTo || (node == null ? void 0 : node.parentNode);
11763
+ target
11764
+ },
11765
+ timeStamp: Date.now()
11766
+ };
11767
+ }), !res)
11768
+ throw new Error("\u203C\uFE0F");
11769
+ return res;
11770
+ }, measureLayout = function(node, relativeTo, callback) {
11771
+ var relativeNode = relativeTo || (node == null ? void 0 : node.parentElement);
11784
11772
  if (relativeNode instanceof HTMLElement) {
11785
- var now = Date.now();
11786
- cache.set(node, now), Promise.all([
11787
- getBoundingClientRectAsync(node),
11788
- getBoundingClientRectAsync(relativeNode)
11789
- ]).then(function(param) {
11790
- var [nodeDim, relativeNodeDim] = param;
11791
- if (relativeNodeDim && nodeDim && cache.get(node) === now) {
11792
- var { x, y, width, height, left, top } = getRelativeDimensions(nodeDim, relativeNodeDim);
11793
- callback(x, y, width, height, left, top);
11794
- }
11795
- });
11773
+ var nodeDim = node.getBoundingClientRect(), relativeNodeDim = relativeNode.getBoundingClientRect();
11774
+ if (relativeNodeDim && nodeDim) {
11775
+ var { x, y, width, height, left, top } = getRelativeDimensions(nodeDim, relativeNodeDim);
11776
+ callback(x, y, width, height, left, top);
11777
+ }
11796
11778
  }
11797
11779
  }, getRelativeDimensions = function(a, b) {
11798
11780
  var { height, left, top, width } = a, x = left - b.left, y = top - b.top;
@@ -11804,19 +11786,6 @@ var tm, measureElement = async function(target) {
11804
11786
  left,
11805
11787
  top
11806
11788
  };
11807
- }, getBoundingClientRectAsync = function(element) {
11808
- return new Promise(function(resolve) {
11809
- function fallbackToSync() {
11810
- resolve(getBoundingClientRect(element));
11811
- }
11812
- var tm = setTimeout(fallbackToSync, 10), observer = new IntersectionObserver(function(entries, ob) {
11813
- var _entries_;
11814
- clearTimeout(tm), ob.disconnect(), resolve((_entries_ = entries[0]) === null || _entries_ === void 0 ? void 0 : _entries_.boundingClientRect);
11815
- }, {
11816
- threshold: 1e-4
11817
- });
11818
- observer.observe(element);
11819
- });
11820
11789
  };
11821
11790
 
11822
11791
  // src/vendor/Pressability.native.tsx
@@ -11863,9 +11832,9 @@ function addNativeValidStyles() {
11863
11832
  __reExport(index_exports, __toESM(require_index_native8()), module.exports);
11864
11833
  addNativeValidStyles();
11865
11834
  var createTamagui = function(conf) {
11866
- return conf.media && (conf.media = (0, import_react_native_media_driver.createMedia)(conf.media)), (0, import_web.createTamagui)(conf);
11835
+ return conf.media && (conf.media = (0, import_react_native_media_driver.createMedia)(conf.media)), (0, import_web2.createTamagui)(conf);
11867
11836
  }, baseViews = getBaseViews();
11868
- (0, import_web.setupHooks)({
11837
+ (0, import_web2.setupHooks)({
11869
11838
  getBaseViews,
11870
11839
  setElementProps: function(node) {
11871
11840
  if (node && !node.measure) {
@@ -11897,7 +11866,7 @@ var createTamagui = function(conf) {
11897
11866
  onPressIn,
11898
11867
  onPressOut: onPressOut || onPress
11899
11868
  };
11900
- onPressOut && onPress && (inputEvents.onPressOut = (0, import_web.composeEventHandlers)(onPress, onPressOut)), Object.assign(viewProps, inputEvents);
11869
+ onPressOut && onPress && (inputEvents.onPressOut = (0, import_web2.composeEventHandlers)(onPress, onPressOut)), Object.assign(viewProps, inputEvents);
11901
11870
  }
11902
11871
  } else {
11903
11872
  events && viewProps.hitSlop && (events.hitSlop = viewProps.hitSlop);
@@ -11905,7 +11874,7 @@ var createTamagui = function(conf) {
11905
11874
  if (events && events.onPress)
11906
11875
  for (var key in pressability) {
11907
11876
  var og = viewProps[key], val = pressability[key];
11908
- viewProps[key] = og && !dontComposePressabilityKeys[key] ? (0, import_web.composeEventHandlers)(og, val) : val;
11877
+ viewProps[key] = og && !dontComposePressabilityKeys[key] ? (0, import_web2.composeEventHandlers)(og, val) : val;
11909
11878
  }
11910
11879
  }
11911
11880
  },
@@ -11914,12 +11883,13 @@ var createTamagui = function(conf) {
11914
11883
  });
11915
11884
  var dontComposePressabilityKeys = {
11916
11885
  onClick: !0
11917
- }, View = import_web.View, Stack = import_web.Stack, Text = import_web.Text;
11886
+ }, View = import_web2.View, Stack = import_web2.Stack, Text = import_web2.Text;
11918
11887
  // Annotate the CommonJS export names for ESM import in node:
11919
11888
  0 && (module.exports = {
11920
11889
  Stack,
11921
11890
  Text,
11922
11891
  View,
11923
- createTamagui
11892
+ createTamagui,
11893
+ getElementLayoutEvent
11924
11894
  });
11925
11895
  //# sourceMappingURL=test.js.map