@tamagui/core 1.126.13-1747874018127 → 1.126.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.126.13-1747874018127",
3
+ "version": "1.126.14",
4
4
  "source": "src/index.tsx",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -35,14 +35,14 @@
35
35
  "native-test.d.ts"
36
36
  ],
37
37
  "dependencies": {
38
- "@tamagui/react-native-media-driver": "1.126.13-1747874018127",
39
- "@tamagui/react-native-use-pressable": "1.126.13-1747874018127",
40
- "@tamagui/react-native-use-responder-events": "1.126.13-1747874018127",
41
- "@tamagui/use-event": "1.126.13-1747874018127",
42
- "@tamagui/web": "1.126.13-1747874018127"
38
+ "@tamagui/react-native-media-driver": "1.126.14",
39
+ "@tamagui/react-native-use-pressable": "1.126.14",
40
+ "@tamagui/react-native-use-responder-events": "1.126.14",
41
+ "@tamagui/use-event": "1.126.14",
42
+ "@tamagui/web": "1.126.14"
43
43
  },
44
44
  "devDependencies": {
45
- "@tamagui/build": "1.126.13-1747874018127",
45
+ "@tamagui/build": "1.126.14",
46
46
  "@testing-library/react": "^16.1.0",
47
47
  "csstype": "^3.0.10",
48
48
  "typescript": "^5.8.2",
@@ -29,54 +29,64 @@ export type LayoutEvent = {
29
29
  const NodeRectCache = new WeakMap<HTMLElement, DOMRect>()
30
30
  const ParentRectCache = new WeakMap<HTMLElement, DOMRect>()
31
31
 
32
- if (isClient && typeof requestAnimationFrame === 'function') {
33
- // prevent thrashing during first hydration (somewhat, streaming gets trickier)
34
- let avoidUpdates = true
35
- const queuedUpdates = new Map<HTMLElement, Function>()
36
-
37
- ___onDidFinishClientRender(() => {
38
- avoidUpdates = false
39
- if (queuedUpdates) {
40
- queuedUpdates.forEach((cb) => cb())
41
- queuedUpdates.clear()
42
- }
43
- })
44
-
45
- function updateLayoutIfChanged(node: HTMLElement) {
46
- const nodeRect = node.getBoundingClientRect()
47
- const parentNode = node.parentElement
48
- const parentRect = parentNode?.getBoundingClientRect()
49
-
50
- const onLayout = LayoutHandlers.get(node)
51
- if (typeof onLayout !== 'function') return
52
-
53
- const cachedRect = NodeRectCache.get(node)
54
- const cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null
55
-
56
- if (
57
- !cachedRect ||
58
- // has changed one rect
59
- (!isEqualShallow(cachedRect, nodeRect) &&
60
- (!cachedParentRect || !isEqualShallow(cachedParentRect, parentRect)))
61
- ) {
62
- NodeRectCache.set(node, nodeRect)
63
- if (parentRect && parentNode) {
64
- ParentRectCache.set(parentNode, parentRect)
32
+ const rAF = typeof window !== 'undefined' ? window.requestAnimationFrame : undefined
33
+
34
+ if (isClient) {
35
+ if (rAF) {
36
+ // prevent thrashing during first hydration (somewhat, streaming gets trickier)
37
+ let avoidUpdates = true
38
+ const queuedUpdates = new Map<HTMLElement, Function>()
39
+
40
+ ___onDidFinishClientRender(() => {
41
+ avoidUpdates = false
42
+ if (queuedUpdates) {
43
+ queuedUpdates.forEach((cb) => cb())
44
+ queuedUpdates.clear()
65
45
  }
66
- const event = getElementLayoutEvent(node)
67
- if (avoidUpdates) {
68
- queuedUpdates.set(node, () => onLayout(event))
69
- } else {
70
- onLayout(event)
46
+ })
47
+
48
+ function updateLayoutIfChanged(node: HTMLElement) {
49
+ const nodeRect = node.getBoundingClientRect()
50
+ const parentNode = node.parentElement
51
+ const parentRect = parentNode?.getBoundingClientRect()
52
+
53
+ const onLayout = LayoutHandlers.get(node)
54
+ if (typeof onLayout !== 'function') return
55
+
56
+ const cachedRect = NodeRectCache.get(node)
57
+ const cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null
58
+
59
+ if (
60
+ !cachedRect ||
61
+ // has changed one rect
62
+ (!isEqualShallow(cachedRect, nodeRect) &&
63
+ (!cachedParentRect || !isEqualShallow(cachedParentRect, parentRect)))
64
+ ) {
65
+ NodeRectCache.set(node, nodeRect)
66
+ if (parentRect && parentNode) {
67
+ ParentRectCache.set(parentNode, parentRect)
68
+ }
69
+ const event = getElementLayoutEvent(node)
70
+ if (avoidUpdates) {
71
+ queuedUpdates.set(node, () => onLayout(event))
72
+ } else {
73
+ onLayout(event)
74
+ }
71
75
  }
72
76
  }
73
- }
74
77
 
75
- // note that getBoundingClientRect() does not thrash layout if its after an animation frame
76
- requestAnimationFrame(layoutOnAnimationFrame)
77
- function layoutOnAnimationFrame() {
78
- Nodes.forEach(updateLayoutIfChanged)
79
- requestAnimationFrame(layoutOnAnimationFrame)
78
+ // note that getBoundingClientRect() does not thrash layout if its after an animation frame
79
+ rAF!(layoutOnAnimationFrame)
80
+ function layoutOnAnimationFrame() {
81
+ Nodes.forEach(updateLayoutIfChanged)
82
+ rAF!(layoutOnAnimationFrame)
83
+ }
84
+ } else {
85
+ if (process.env.NODE_ENV === 'development') {
86
+ console.warn(
87
+ `No requestAnimationFrame - please polyfill for onLayout to work correctly`
88
+ )
89
+ }
80
90
  }
81
91
  }
82
92
 
@@ -1 +1 @@
1
- {"version":3,"file":"useElementLayout.d.ts","sourceRoot":"","sources":["../../src/hooks/useElementLayout.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,wBAAwB,EAE9B,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKtC,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE;QACX,MAAM,EAAE,WAAW,CAAA;QACnB,MAAM,EAAE,GAAG,CAAA;KACZ,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;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