@tamagui/use-element-layout 3.0.0-beta.807.1 → 3.0.0-beta.831.1

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.
@@ -32,7 +32,6 @@ __export(index_exports, {
32
32
  measureLayout: () => measureLayout,
33
33
  measureNode: () => measureNode,
34
34
  registerLayoutNode: () => registerLayoutNode,
35
- setOnLayoutStrategy: () => setOnLayoutStrategy,
36
35
  useElementLayout: () => useElementLayout
37
36
  });
38
37
  module.exports = __toCommonJS(index_exports);
@@ -66,10 +65,6 @@ const LayoutMeasurementController = ({ disable, children }) => {
66
65
  let strategy = "async";
67
66
  let resumeLayoutLoop;
68
67
  let measureOnNextFrame;
69
- function setOnLayoutStrategy(state) {
70
- strategy = state;
71
- resumeLayoutLoop?.();
72
- }
73
68
  const NodeRectCache = /* @__PURE__ */ new WeakMap();
74
69
  let avoidUpdates = true;
75
70
  const queuedUpdates = /* @__PURE__ */ new Map();
@@ -34,7 +34,6 @@ __export(index_exports, {
34
34
  measureLayout: () => measureLayout,
35
35
  measureNode: () => measureNode,
36
36
  registerLayoutNode: () => registerLayoutNode,
37
- setOnLayoutStrategy: () => setOnLayoutStrategy,
38
37
  useElementLayout: () => useElementLayout
39
38
  });
40
39
  module.exports = __toCommonJS(index_exports);
@@ -75,10 +74,6 @@ var LayoutMeasurementController = function(param) {
75
74
  var strategy = "async";
76
75
  var resumeLayoutLoop;
77
76
  var measureOnNextFrame;
78
- function setOnLayoutStrategy(state) {
79
- strategy = state;
80
- resumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();
81
- }
82
77
  var NodeRectCache = /* @__PURE__ */ new WeakMap();
83
78
  var avoidUpdates = true;
84
79
  var queuedUpdates = /* @__PURE__ */ new Map();
@@ -34,7 +34,6 @@ __export(index_exports, {
34
34
  measureLayout: () => measureLayout,
35
35
  measureNode: () => measureNode,
36
36
  registerLayoutNode: () => registerLayoutNode,
37
- setOnLayoutStrategy: () => setOnLayoutStrategy,
38
37
  useElementLayout: () => useElementLayout
39
38
  });
40
39
  module.exports = __toCommonJS(index_exports);
@@ -75,10 +74,6 @@ var LayoutMeasurementController = function(param) {
75
74
  var strategy = "async";
76
75
  var resumeLayoutLoop;
77
76
  var measureOnNextFrame;
78
- function setOnLayoutStrategy(state) {
79
- strategy = state;
80
- resumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();
81
- }
82
77
  var NodeRectCache = /* @__PURE__ */ new WeakMap();
83
78
  var avoidUpdates = true;
84
79
  var queuedUpdates = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n\tLayoutMeasurementController: () => LayoutMeasurementController,\n\tcreateMeasure: () => createMeasure,\n\tcreateMeasureInWindow: () => createMeasureInWindow,\n\tcreateMeasureLayout: () => createMeasureLayout,\n\tenable: () => enable,\n\tgetBoundingClientRectAsync: () => getBoundingClientRectAsync,\n\tgetElementLayoutEvent: () => getElementLayoutEvent,\n\tmeasure: () => measure,\n\tmeasureInWindow: () => measureInWindow,\n\tmeasureLayout: () => measureLayout,\n\tmeasureNode: () => measureNode,\n\tregisterLayoutNode: () => registerLayoutNode,\n\tsetOnLayoutStrategy: () => setOnLayoutStrategy,\n\tuseElementLayout: () => useElementLayout\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_react = require(\"react\");\nfunction _instanceof(left, right) {\n\tif (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);\n\telse return left instanceof right;\n}\nvar LayoutHandlers = /* @__PURE__ */ new WeakMap();\nvar LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nvar Nodes = /* @__PURE__ */ new Set();\nvar usePretransformDimensions = function() {\n\treturn globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\n};\nvar _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nvar DisableLayoutContextValues = {};\nvar DisableLayoutContextKey = /* @__PURE__ */ (0, import_react.createContext)(\"\");\nvar ENABLE = false;\nvar LayoutMeasurementController = function(param) {\n\tvar { disable, children } = param;\n\tvar id = (0, import_react.useId)();\n\t(0, import_constants.useIsomorphicLayoutEffect)(function() {\n\t\tvar wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame === null || measureOnNextFrame === void 0 || measureOnNextFrame();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nvar strategy = \"async\";\nvar resumeLayoutLoop;\nvar measureOnNextFrame;\nfunction setOnLayoutStrategy(state) {\n\tstrategy = state;\n\tresumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();\n}\nvar NodeRectCache = /* @__PURE__ */ new WeakMap();\nvar avoidUpdates = true;\nvar queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach(function(cb) {\n\t\t\t\treturn cb();\n\t\t\t});\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver2 = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver(function(entries) {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (var i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame2 = function() {\n\t\tif (frameScheduled || strategy === \"off\" || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tvar BoundingRects = /* @__PURE__ */ new WeakMap();\n\tvar rectFetchObserver = null;\n\tvar rectFetchResolve = null;\n\tvar rectFetchStartTime = 0;\n\tvar lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tvar parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tvar nodeRect;\n\t\tvar parentRect;\n\t\tif (strategy === \"async\") {\n\t\t\tnodeRect = BoundingRects.get(node);\n\t\t\tparentRect = BoundingRects.get(parentNode);\n\t\t\tif (!nodeRect || !parentRect) return;\n\t\t} else {\n\t\t\tnodeRect = node.getBoundingClientRect();\n\t\t\tparentRect = parentNode.getBoundingClientRect();\n\t\t}\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tvar rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tvar userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tvar BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tvar MAX_SKIP_FRAMES = 20;\n\tvar skipFrames = BASE_SKIP_FRAMES;\n\tvar frameCount = 0;\n\tvar frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame2();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\tif (strategy !== \"off\") {\n\t\t\tvar activeNodes = [];\n\t\t\tvar parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\t\t\ttry {\n\t\t\t\tfor (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\t\t\tvar node = _step.value;\n\t\t\t\t\tvar parentElement = node.parentElement;\n\t\t\t\t\tif (!_instanceof(parentElement, HTMLElement)) {\n\t\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvar disableKey = LayoutDisableKey.get(node);\n\t\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\t\tactiveNodes.push(node);\n\t\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t_didIteratorError = true;\n\t\t\t\t_iteratorError = err;\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t\t\t} finally {\n\t\t\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tvar io = ensureRectFetchObserver2();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (var i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tvar _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator1 = parentsToObserve[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n\t\t\t\t\t\tvar parent = _step1.value;\n\t\t\t\t\t\tio.observe(parent);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError1 = true;\n\t\t\t\t\t_iteratorError1 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError1) throw _iteratorError1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait new Promise(function(res) {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (var i1 = 0; i1 < activeNodes.length; i1++) io.unobserve(activeNodes[i1]);\n\t\t\t\tvar _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator2 = parentsToObserve[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n\t\t\t\t\t\tvar parent1 = _step2.value;\n\t\t\t\t\t\tio.unobserve(parent1);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError2 = true;\n\t\t\t\t\t_iteratorError2 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion2 && _iterator2.return != null) _iterator2.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError2) throw _iteratorError2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (var i2 = 0; i2 < activeNodes.length; i2++) updateLayoutIfChanged(activeNodes[i2]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame2();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame2;\n\tmeasureOnNextFrame = function() {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame2();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame2);\n\tscheduleLayoutFrame2();\n}\nvar getElementLayoutEvent = function(nodeRect, parentRect, node) {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nvar getPreTransformDimensions = function(node) {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nvar getRelativeDimensions = function(a, b, aNode) {\n\tvar { left, top } = a;\n\tvar x = left - b.left;\n\tvar y = top - b.top;\n\tvar { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar cachedRect = NodeRectCache.get(node);\n\tvar cachedParentRect = NodeRectCache.get(parentNode);\n\tvar nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tvar parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tvar event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, function() {\n\t\treturn onLayout(event);\n\t});\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn function() {\n\t\treturn cleanupNode(node);\n\t};\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nvar PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tvar nodeRect = node.getBoundingClientRect();\n\tvar parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tvar _ref_current;\n\tvar disableKey = (0, import_react.useContext)(DisableLayoutContextKey);\n\tvar node = ensureWebElement((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\t(0, import_constants.useIsomorphicLayoutEffect)(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar nextNode = ensureWebElement((_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host);\n\t\tvar prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\t(0, import_constants.useIsomorphicLayoutEffect)(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn function() {\n\t\t\tcleanupNode(node2);\n\t\t\tvar swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn _instanceof(x, HTMLElement) ? x : void 0;\n}\nvar getBoundingClientRectAsync = function(node) {\n\treturn new Promise(function(res) {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tvar io = new IntersectionObserver(function(entries) {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nvar measureNode = async function(node, relativeTo) {\n\tvar relativeNode = relativeTo || (node === null || node === void 0 ? void 0 : node.parentElement);\n\tif (_instanceof(relativeNode, HTMLElement)) {\n\t\tvar [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nvar measure = async function(node, callback) {\n\tvar out = await measureNode(node, _instanceof(node.parentNode, HTMLElement) ? node.parentNode : null);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn function(callback) {\n\t\treturn measure(node, callback);\n\t};\n}\nvar measureInWindow = async function(node, callback) {\n\tvar out = await measureNode(node, null);\n\tif (out) callback === null || callback === void 0 || callback(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nvar createMeasureInWindow = function(node) {\n\treturn function(callback) {\n\t\treturn measureInWindow(node, callback);\n\t};\n};\nvar measureLayout = async function(node, relativeNode, callback) {\n\tvar out = await measureNode(node, relativeNode);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn function(relativeTo, callback) {\n\t\treturn measureLayout(node, relativeTo, callback);\n\t};\n}\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC/B,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KAAK,IAAI;EACT,YAAY;CACb,CAAC;AACF;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC7C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EACnE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GAAG,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI,KAAK;GAC9G,WAAW,KAAK;GAChB,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAC3D,CAAC;CACF;CACA,OAAO;AACR;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe;CACvB,mCAAmC;CACnC,qBAAqB;CACrB,6BAA6B;CAC7B,2BAA2B;CAC3B,cAAc;CACd,kCAAkC;CAClC,6BAA6B;CAC7B,eAAe;CACf,uBAAuB;CACvB,qBAAqB;CACrB,mBAAmB;CACnB,0BAA0B;CAC1B,2BAA2B;CAC3B,wBAAwB;AACzB,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,qBAAqB,QAAQ,mBAAmB;AACpD,IAAI,mBAAmB,QAAQ,oBAAoB;AACnD,IAAI,eAAe,QAAQ,OAAO;AAClC,S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ACA,SAAS,cAAc,MAAM;CAC5B,OAAO,SAAS,UAAU;EACzB,OAAO,QAAQ,MAAM,QAAQ;CAC9B;AACD;AACA,IAAI,kBAAkB,eAAe,MAAM,UAAU;CACpD,IAAI,MAAM,MAAM,YAAY,MAAM,IAAI;CACtC,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,IAAI,MAAM;CACzG,OAAO;AACR;AACA,IAAI,wBAAwB,SAAS,MAAM;CAC1C,OAAO,SAAS,UAAU;EACzB,OAAO,gBAAgB,MAAM,QAAQ;CACtC;AACD;AACA,IAAI,gBAAgB,eAAe,MAAM,cAAc,UAAU;CAChE,IAAI,MAAM,MAAM,YAAY,MAAM,YAAY;CAC9C,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CACvH,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,OAAO,SAAS,YAAY,UAAU;EACrC,OAAO,cAAc,MAAM,YAAY,QAAQ;CAChD;AACD"}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n\tLayoutMeasurementController: () => LayoutMeasurementController,\n\tcreateMeasure: () => createMeasure,\n\tcreateMeasureInWindow: () => createMeasureInWindow,\n\tcreateMeasureLayout: () => createMeasureLayout,\n\tenable: () => enable,\n\tgetBoundingClientRectAsync: () => getBoundingClientRectAsync,\n\tgetElementLayoutEvent: () => getElementLayoutEvent,\n\tmeasure: () => measure,\n\tmeasureInWindow: () => measureInWindow,\n\tmeasureLayout: () => measureLayout,\n\tmeasureNode: () => measureNode,\n\tregisterLayoutNode: () => registerLayoutNode,\n\tuseElementLayout: () => useElementLayout\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_react = require(\"react\");\nfunction _instanceof(left, right) {\n\tif (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);\n\telse return left instanceof right;\n}\nvar LayoutHandlers = /* @__PURE__ */ new WeakMap();\nvar LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nvar Nodes = /* @__PURE__ */ new Set();\nvar usePretransformDimensions = function() {\n\treturn globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\n};\nvar _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nvar DisableLayoutContextValues = {};\nvar DisableLayoutContextKey = /* @__PURE__ */ (0, import_react.createContext)(\"\");\nvar ENABLE = false;\nvar LayoutMeasurementController = function(param) {\n\tvar { disable, children } = param;\n\tvar id = (0, import_react.useId)();\n\t(0, import_constants.useIsomorphicLayoutEffect)(function() {\n\t\tvar wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame === null || measureOnNextFrame === void 0 || measureOnNextFrame();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nvar strategy = \"async\";\nvar resumeLayoutLoop;\nvar measureOnNextFrame;\nvar NodeRectCache = /* @__PURE__ */ new WeakMap();\nvar avoidUpdates = true;\nvar queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach(function(cb) {\n\t\t\t\treturn cb();\n\t\t\t});\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver2 = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver(function(entries) {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (var i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame2 = function() {\n\t\tif (frameScheduled || strategy === \"off\" || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tvar BoundingRects = /* @__PURE__ */ new WeakMap();\n\tvar rectFetchObserver = null;\n\tvar rectFetchResolve = null;\n\tvar rectFetchStartTime = 0;\n\tvar lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tvar parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tvar nodeRect;\n\t\tvar parentRect;\n\t\tif (strategy === \"async\") {\n\t\t\tnodeRect = BoundingRects.get(node);\n\t\t\tparentRect = BoundingRects.get(parentNode);\n\t\t\tif (!nodeRect || !parentRect) return;\n\t\t} else {\n\t\t\tnodeRect = node.getBoundingClientRect();\n\t\t\tparentRect = parentNode.getBoundingClientRect();\n\t\t}\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tvar rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tvar userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tvar BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tvar MAX_SKIP_FRAMES = 20;\n\tvar skipFrames = BASE_SKIP_FRAMES;\n\tvar frameCount = 0;\n\tvar frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame2();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\tif (strategy !== \"off\") {\n\t\t\tvar activeNodes = [];\n\t\t\tvar parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\t\t\ttry {\n\t\t\t\tfor (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\t\t\tvar node = _step.value;\n\t\t\t\t\tvar parentElement = node.parentElement;\n\t\t\t\t\tif (!_instanceof(parentElement, HTMLElement)) {\n\t\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvar disableKey = LayoutDisableKey.get(node);\n\t\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\t\tactiveNodes.push(node);\n\t\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t_didIteratorError = true;\n\t\t\t\t_iteratorError = err;\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t\t\t} finally {\n\t\t\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tvar io = ensureRectFetchObserver2();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (var i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tvar _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator1 = parentsToObserve[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n\t\t\t\t\t\tvar parent = _step1.value;\n\t\t\t\t\t\tio.observe(parent);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError1 = true;\n\t\t\t\t\t_iteratorError1 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError1) throw _iteratorError1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait new Promise(function(res) {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (var i1 = 0; i1 < activeNodes.length; i1++) io.unobserve(activeNodes[i1]);\n\t\t\t\tvar _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator2 = parentsToObserve[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n\t\t\t\t\t\tvar parent1 = _step2.value;\n\t\t\t\t\t\tio.unobserve(parent1);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError2 = true;\n\t\t\t\t\t_iteratorError2 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion2 && _iterator2.return != null) _iterator2.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError2) throw _iteratorError2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (var i2 = 0; i2 < activeNodes.length; i2++) updateLayoutIfChanged(activeNodes[i2]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame2();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame2;\n\tmeasureOnNextFrame = function() {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame2();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame2);\n\tscheduleLayoutFrame2();\n}\nvar getElementLayoutEvent = function(nodeRect, parentRect, node) {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nvar getPreTransformDimensions = function(node) {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nvar getRelativeDimensions = function(a, b, aNode) {\n\tvar { left, top } = a;\n\tvar x = left - b.left;\n\tvar y = top - b.top;\n\tvar { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar cachedRect = NodeRectCache.get(node);\n\tvar cachedParentRect = NodeRectCache.get(parentNode);\n\tvar nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tvar parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tvar event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, function() {\n\t\treturn onLayout(event);\n\t});\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn function() {\n\t\treturn cleanupNode(node);\n\t};\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nvar PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tvar nodeRect = node.getBoundingClientRect();\n\tvar parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tvar _ref_current;\n\tvar disableKey = (0, import_react.useContext)(DisableLayoutContextKey);\n\tvar node = ensureWebElement((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\t(0, import_constants.useIsomorphicLayoutEffect)(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar nextNode = ensureWebElement((_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host);\n\t\tvar prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\t(0, import_constants.useIsomorphicLayoutEffect)(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn function() {\n\t\t\tcleanupNode(node2);\n\t\t\tvar swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn _instanceof(x, HTMLElement) ? x : void 0;\n}\nvar getBoundingClientRectAsync = function(node) {\n\treturn new Promise(function(res) {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tvar io = new IntersectionObserver(function(entries) {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nvar measureNode = async function(node, relativeTo) {\n\tvar relativeNode = relativeTo || (node === null || node === void 0 ? void 0 : node.parentElement);\n\tif (_instanceof(relativeNode, HTMLElement)) {\n\t\tvar [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nvar measure = async function(node, callback) {\n\tvar out = await measureNode(node, _instanceof(node.parentNode, HTMLElement) ? node.parentNode : null);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn function(callback) {\n\t\treturn measure(node, callback);\n\t};\n}\nvar measureInWindow = async function(node, callback) {\n\tvar out = await measureNode(node, null);\n\tif (out) callback === null || callback === void 0 || callback(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nvar createMeasureInWindow = function(node) {\n\treturn function(callback) {\n\t\treturn measureInWindow(node, callback);\n\t};\n};\nvar measureLayout = async function(node, relativeNode, callback) {\n\tvar out = await measureNode(node, relativeNode);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn function(relativeTo, callback) {\n\t\treturn measureLayout(node, relativeTo, callback);\n\t};\n}\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC/B,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KAAK,IAAI;EACT,YAAY;CACb,CAAC;AACF;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC7C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EACnE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GAAG,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI,KAAK;GAC9G,WAAW,KAAK;GAChB,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAC3D,CAAC;CACF;CACA,OAAO;AACR;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe;CACvB,mCAAmC;CACnC,qBAAqB;CACrB,6BAA6B;CAC7B,2BAA2B;CAC3B,cAAc;CACd,kCAAkC;CAClC,6BAA6B;CAC7B,eAAe;CACf,uBAAuB;CACvB,qBAA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AK,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CACvH,OAAO;AACR;AACA,SAAS,cAAc,MAAM;CAC5B,OAAO,SAAS,UAAU;EACzB,OAAO,QAAQ,MAAM,QAAQ;CAC9B;AACD;AACA,IAAI,kBAAkB,eAAe,MAAM,UAAU;CACpD,IAAI,MAAM,MAAM,YAAY,MAAM,IAAI;CACtC,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,IAAI,MAAM;CACzG,OAAO;AACR;AACA,IAAI,wBAAwB,SAAS,MAAM;CAC1C,OAAO,SAAS,UAAU;EACzB,OAAO,gBAAgB,MAAM,QAAQ;CACtC;AACD;AACA,IAAI,gBAAgB,eAAe,MAAM,cAAc,UAAU;CAChE,IAAI,MAAM,MAAM,YAAY,MAAM,YAAY;CAC9C,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CACvH,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,OAAO,SAAS,YAAY,UAAU;EACrC,OAAO,cAAc,MAAM,YAAY,QAAQ;CAChD;AACD"}
package/dist/esm/index.js CHANGED
@@ -26,13 +26,8 @@ const LayoutMeasurementController = ({ disable, children }) => {
26
26
  children
27
27
  });
28
28
  };
29
- let strategy = "async";
30
29
  let resumeLayoutLoop;
31
30
  let measureOnNextFrame;
32
- function setOnLayoutStrategy(state) {
33
- strategy = state;
34
- resumeLayoutLoop?.();
35
- }
36
31
  const NodeRectCache = /* @__PURE__ */ new WeakMap();
37
32
  let avoidUpdates = true;
38
33
  const queuedUpdates = /* @__PURE__ */ new Map();
@@ -62,7 +57,7 @@ if (ENABLE) {
62
57
  }, { threshold: 0 });
63
58
  return rectFetchObserver;
64
59
  }, scheduleLayoutFrame = function() {
65
- if (frameScheduled || strategy === "off" || Nodes.size === 0 || document.hidden) return;
60
+ if (frameScheduled || Nodes.size === 0 || document.hidden) return;
66
61
  frameScheduled = true;
67
62
  rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);
68
63
  };
@@ -77,14 +72,9 @@ if (ENABLE) {
77
72
  if (!parentNode) return;
78
73
  let nodeRect;
79
74
  let parentRect;
80
- if (strategy === "async") {
81
- nodeRect = BoundingRects.get(node);
82
- parentRect = BoundingRects.get(parentNode);
83
- if (!nodeRect || !parentRect) return;
84
- } else {
85
- nodeRect = node.getBoundingClientRect();
86
- parentRect = parentNode.getBoundingClientRect();
87
- }
75
+ nodeRect = BoundingRects.get(node);
76
+ parentRect = BoundingRects.get(parentNode);
77
+ if (!nodeRect || !parentRect) return;
88
78
  emitLayoutIfChanged(node, parentNode, nodeRect, parentRect);
89
79
  }
90
80
  const rAF = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : void 0;
@@ -101,7 +91,7 @@ if (ENABLE) {
101
91
  return;
102
92
  }
103
93
  if (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;
104
- if (strategy !== "off") {
94
+ {
105
95
  const activeNodes = [];
106
96
  const parentsToObserve = /* @__PURE__ */ new Set();
107
97
  for (const node of Nodes) {
@@ -309,5 +299,5 @@ function createMeasureLayout(node) {
309
299
  return (relativeTo, callback) => measureLayout(node, relativeTo, callback);
310
300
  }
311
301
 
312
- export { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, setOnLayoutStrategy, useElementLayout };
302
+ export { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, useElementLayout };
313
303
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useId } from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst LayoutHandlers = /* @__PURE__ */ new WeakMap();\nconst LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nconst Nodes = /* @__PURE__ */ new Set();\nconst usePretransformDimensions = () => globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\nlet _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nconst DisableLayoutContextValues = {};\nconst DisableLayoutContextKey = createContext(\"\");\nconst ENABLE = typeof IntersectionObserver !== \"undefined\";\nconst LayoutMeasurementController = ({ disable, children }) => {\n\tconst id = useId();\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconst wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame?.();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ jsx(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nlet strategy = \"async\";\nlet resumeLayoutLoop;\nlet measureOnNextFrame;\nfunction setOnLayoutStrategy(state) {\n\tstrategy = state;\n\tresumeLayoutLoop?.();\n}\nconst NodeRectCache = /* @__PURE__ */ new WeakMap();\nlet avoidUpdates = true;\nconst queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach((cb) => cb());\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver((entries) => {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (let i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame = function() {\n\t\tif (frameScheduled || strategy === \"off\" || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tconst BoundingRects = /* @__PURE__ */ new WeakMap();\n\tlet rectFetchObserver = null;\n\tlet rectFetchResolve = null;\n\tlet rectFetchStartTime = 0;\n\tlet lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tconst parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tlet nodeRect;\n\t\tlet parentRect;\n\t\tif (strategy === \"async\") {\n\t\t\tnodeRect = BoundingRects.get(node);\n\t\t\tparentRect = BoundingRects.get(parentNode);\n\t\t\tif (!nodeRect || !parentRect) return;\n\t\t} else {\n\t\t\tnodeRect = node.getBoundingClientRect();\n\t\t\tparentRect = parentNode.getBoundingClientRect();\n\t\t}\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tconst rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tconst userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tconst BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tconst MAX_SKIP_FRAMES = 20;\n\tlet skipFrames = BASE_SKIP_FRAMES;\n\tlet frameCount = 0;\n\tlet frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\tif (strategy !== \"off\") {\n\t\t\tconst activeNodes = [];\n\t\t\tconst parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tfor (const node of Nodes) {\n\t\t\t\tconst parentElement = node.parentElement;\n\t\t\t\tif (!(parentElement instanceof HTMLElement)) {\n\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst disableKey = LayoutDisableKey.get(node);\n\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\tactiveNodes.push(node);\n\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tconst io = ensureRectFetchObserver();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.observe(parent);\n\t\t\t\tawait new Promise((res) => {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.unobserve(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.unobserve(parent);\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) updateLayoutIfChanged(activeNodes[i]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame;\n\tmeasureOnNextFrame = () => {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame);\n\tscheduleLayoutFrame();\n}\nconst getElementLayoutEvent = (nodeRect, parentRect, node) => {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nconst getPreTransformDimensions = (node) => {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nconst getRelativeDimensions = (a, b, aNode) => {\n\tconst { left, top } = a;\n\tconst x = left - b.left;\n\tconst y = top - b.top;\n\tconst { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst cachedRect = NodeRectCache.get(node);\n\tconst cachedParentRect = NodeRectCache.get(parentNode);\n\tconst nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tconst parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tconst event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, () => onLayout(event));\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop?.();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn () => cleanupNode(node);\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nconst PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tconst nodeRect = node.getBoundingClientRect();\n\tconst parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tconst disableKey = useContext(DisableLayoutContextKey);\n\tconst node = ensureWebElement(ref.current?.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst nextNode = ensureWebElement(ref.current?.host);\n\t\tconst prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst node2 = ref.current?.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn () => {\n\t\t\tcleanupNode(node2);\n\t\t\tconst swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn x instanceof HTMLElement ? x : void 0;\n}\nconst getBoundingClientRectAsync = (node) => {\n\treturn new Promise((res) => {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tconst io = new IntersectionObserver((entries) => {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nconst measureNode = async (node, relativeTo) => {\n\tconst relativeNode = relativeTo || node?.parentElement;\n\tif (relativeNode instanceof HTMLElement) {\n\t\tconst [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nconst measure = async (node, callback) => {\n\tconst out = await measureNode(node, node.parentNode instanceof HTMLElement ? node.parentNode : null);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn (callback) => measure(node, callback);\n}\nconst measureInWindow = async (node, callback) => {\n\tconst out = await measureNode(node, null);\n\tif (out) callback?.(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nconst createMeasureInWindow = (node) => {\n\treturn (callback) => measureInWindow(node, callback);\n};\nconst measureLayout = async (node, relativeNode, callback) => {\n\tconst out = await measureNode(node, relativeNode);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn (relativeTo, callback) => measureLayout(node, relativeTo, callback);\n}\n\nexport { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, setOnLayoutStrategy, useElementLayout };"],"mappings":";;;;;AAIA,MAAM,iCAAiC,IAAI,QAAQ;AACnD,MAAM,mCAAmC,IAAI,QAAQ;AACrD,MAAM,wBAAwB,IAAI,IAAI;AACtC,MAAM,kCAAkC,WAAW,oCAAoC,QAAQ,QAAQ,IAAI,kCAAkC;AAC7I,IAAI;AACJ,SAAS,gBAAgB;CACxB,IAAI,iBAAiB,KAAK,GAAG,eAAe,OAAO,WAAW,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,mBAAmB;CAChJ,OAAO;AACR;AACA,MAAM,6BAA6B,CAAC;AACpC,MAAM,0BAA0B,cAAc,EAAE;AAChD,MAAM,SAAS,OAAO,yBAAyB;AAC/C,MAAM,+BAA+B,EAAE,SAAS,eAAe;CAC9D,MAAM,KAAK,MAAM;CACjB,gCAAgC;EAC/B,MAAM,cAAc,2BAA2B,QAAQ;EACvD,2BAA2B,MAAM;EACjC,IAAI,eAAe,CAAC,SAAS,qBAAqB;CACnD,GAAG,CAAC,SAAS,EAAE,CAAC;CAChB,OAAuB,oBAAI,wBAAwB,UAAU;EAC5D,OA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O;AACR;AACA,MAAM,yBAAyB,SAAS;CACvC,QAAQ,aAAa,gBAAgB,MAAM,QAAQ;AACpD;AACA,MAAM,gBAAgB,OAAO,MAAM,cAAc,aAAa;CAC7D,MAAM,MAAM,MAAM,YAAY,MAAM,YAAY;CAChD,IAAI,KAAK,WAAW,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CAC7E,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,QAAQ,YAAY,aAAa,cAAc,MAAM,YAAY,QAAQ;AAC1E"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useId } from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst LayoutHandlers = /* @__PURE__ */ new WeakMap();\nconst LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nconst Nodes = /* @__PURE__ */ new Set();\nconst usePretransformDimensions = () => globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\nlet _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nconst DisableLayoutContextValues = {};\nconst DisableLayoutContextKey = createContext(\"\");\nconst ENABLE = typeof IntersectionObserver !== \"undefined\";\nconst LayoutMeasurementController = ({ disable, children }) => {\n\tconst id = useId();\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconst wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame?.();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ jsx(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nlet resumeLayoutLoop;\nlet measureOnNextFrame;\nconst NodeRectCache = /* @__PURE__ */ new WeakMap();\nlet avoidUpdates = true;\nconst queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach((cb) => cb());\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver((entries) => {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (let i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame = function() {\n\t\tif (frameScheduled || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tconst BoundingRects = /* @__PURE__ */ new WeakMap();\n\tlet rectFetchObserver = null;\n\tlet rectFetchResolve = null;\n\tlet rectFetchStartTime = 0;\n\tlet lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tconst parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tlet nodeRect;\n\t\tlet parentRect;\n\t\tnodeRect = BoundingRects.get(node);\n\t\tparentRect = BoundingRects.get(parentNode);\n\t\tif (!nodeRect || !parentRect) return;\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tconst rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tconst userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tconst BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tconst MAX_SKIP_FRAMES = 20;\n\tlet skipFrames = BASE_SKIP_FRAMES;\n\tlet frameCount = 0;\n\tlet frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\t{\n\t\t\tconst activeNodes = [];\n\t\t\tconst parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tfor (const node of Nodes) {\n\t\t\t\tconst parentElement = node.parentElement;\n\t\t\t\tif (!(parentElement instanceof HTMLElement)) {\n\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst disableKey = LayoutDisableKey.get(node);\n\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\tactiveNodes.push(node);\n\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tconst io = ensureRectFetchObserver();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.observe(parent);\n\t\t\t\tawait new Promise((res) => {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.unobserve(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.unobserve(parent);\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) updateLayoutIfChanged(activeNodes[i]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame;\n\tmeasureOnNextFrame = () => {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame);\n\tscheduleLayoutFrame();\n}\nconst getElementLayoutEvent = (nodeRect, parentRect, node) => {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nconst getPreTransformDimensions = (node) => {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nconst getRelativeDimensions = (a, b, aNode) => {\n\tconst { left, top } = a;\n\tconst x = left - b.left;\n\tconst y = top - b.top;\n\tconst { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst cachedRect = NodeRectCache.get(node);\n\tconst cachedParentRect = NodeRectCache.get(parentNode);\n\tconst nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tconst parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tconst event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, () => onLayout(event));\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop?.();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn () => cleanupNode(node);\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nconst PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tconst nodeRect = node.getBoundingClientRect();\n\tconst parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tconst disableKey = useContext(DisableLayoutContextKey);\n\tconst node = ensureWebElement(ref.current?.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst nextNode = ensureWebElement(ref.current?.host);\n\t\tconst prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst node2 = ref.current?.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn () => {\n\t\t\tcleanupNode(node2);\n\t\t\tconst swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn x instanceof HTMLElement ? x : void 0;\n}\nconst getBoundingClientRectAsync = (node) => {\n\treturn new Promise((res) => {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tconst io = new IntersectionObserver((entries) => {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nconst measureNode = async (node, relativeTo) => {\n\tconst relativeNode = relativeTo || node?.parentElement;\n\tif (relativeNode instanceof HTMLElement) {\n\t\tconst [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nconst measure = async (node, callback) => {\n\tconst out = await measureNode(node, node.parentNode instanceof HTMLElement ? node.parentNode : null);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn (callback) => measure(node, callback);\n}\nconst measureInWindow = async (node, callback) => {\n\tconst out = await measureNode(node, null);\n\tif (out) callback?.(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nconst createMeasureInWindow = (node) => {\n\treturn (callback) => measureInWindow(node, callback);\n};\nconst measureLayout = async (node, relativeNode, callback) => {\n\tconst out = await measureNode(node, relativeNode);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn (relativeTo, callback) => measureLayout(node, relativeTo, callback);\n}\n\nexport { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, useElementLayout };"],"mappings":";;;;;AAIA,MAAM,iCAAiC,IAAI,QAAQ;AACnD,MAAM,mCAAmC,IAAI,QAAQ;AACrD,MAAM,wBAAwB,IAAI,IAAI;AACtC,MAAM,kCAAkC,WAAW,oCAAoC,QAAQ,QAAQ,IAAI,kCAAkC;AAC7I,IAAI;AACJ,SAAS,gBAAgB;CACxB,IAAI,iBAAiB,KAAK,GAAG,eAAe,OAAO,WAAW,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,mBAAmB;CAChJ,OAAO;AACR;AACA,MAAM,6BAA6B,CAAC;AACpC,MAAM,0BAA0B,cAAc,EAAE;AAChD,MAAM,SAAS,OAAO,yBAAyB;AAC/C,MAAM,+BAA+B,EAAE,SAAS,eAAe;CAC9D,MAAM,KAAK,MAAM;CACjB,gCAAgC;EAC/B,MAAM,cAAc,2BAA2B,QAA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AAgB,MAAM,QAAQ;AACpD;AACA,MAAM,gBAAgB,OAAO,MAAM,cAAc,aAAa;CAC7D,MAAM,MAAM,MAAM,YAAY,MAAM,YAAY;CAChD,IAAI,KAAK,WAAW,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CAC7E,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,QAAQ,YAAY,aAAa,cAAc,MAAM,YAAY,QAAQ;AAC1E"}
@@ -26,13 +26,8 @@ const LayoutMeasurementController = ({ disable, children }) => {
26
26
  children
27
27
  });
28
28
  };
29
- let strategy = "async";
30
29
  let resumeLayoutLoop;
31
30
  let measureOnNextFrame;
32
- function setOnLayoutStrategy(state) {
33
- strategy = state;
34
- resumeLayoutLoop?.();
35
- }
36
31
  const NodeRectCache = /* @__PURE__ */ new WeakMap();
37
32
  let avoidUpdates = true;
38
33
  const queuedUpdates = /* @__PURE__ */ new Map();
@@ -62,7 +57,7 @@ if (ENABLE) {
62
57
  }, { threshold: 0 });
63
58
  return rectFetchObserver;
64
59
  }, scheduleLayoutFrame = function() {
65
- if (frameScheduled || strategy === "off" || Nodes.size === 0 || document.hidden) return;
60
+ if (frameScheduled || Nodes.size === 0 || document.hidden) return;
66
61
  frameScheduled = true;
67
62
  rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);
68
63
  };
@@ -77,14 +72,9 @@ if (ENABLE) {
77
72
  if (!parentNode) return;
78
73
  let nodeRect;
79
74
  let parentRect;
80
- if (strategy === "async") {
81
- nodeRect = BoundingRects.get(node);
82
- parentRect = BoundingRects.get(parentNode);
83
- if (!nodeRect || !parentRect) return;
84
- } else {
85
- nodeRect = node.getBoundingClientRect();
86
- parentRect = parentNode.getBoundingClientRect();
87
- }
75
+ nodeRect = BoundingRects.get(node);
76
+ parentRect = BoundingRects.get(parentNode);
77
+ if (!nodeRect || !parentRect) return;
88
78
  emitLayoutIfChanged(node, parentNode, nodeRect, parentRect);
89
79
  }
90
80
  const rAF = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : void 0;
@@ -101,7 +91,7 @@ if (ENABLE) {
101
91
  return;
102
92
  }
103
93
  if (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;
104
- if (strategy !== "off") {
94
+ {
105
95
  const activeNodes = [];
106
96
  const parentsToObserve = /* @__PURE__ */ new Set();
107
97
  for (const node of Nodes) {
@@ -309,5 +299,5 @@ function createMeasureLayout(node) {
309
299
  return (relativeTo, callback) => measureLayout(node, relativeTo, callback);
310
300
  }
311
301
 
312
- export { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, setOnLayoutStrategy, useElementLayout };
302
+ export { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, useElementLayout };
313
303
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useId } from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst LayoutHandlers = /* @__PURE__ */ new WeakMap();\nconst LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nconst Nodes = /* @__PURE__ */ new Set();\nconst usePretransformDimensions = () => globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\nlet _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nconst DisableLayoutContextValues = {};\nconst DisableLayoutContextKey = createContext(\"\");\nconst ENABLE = typeof IntersectionObserver !== \"undefined\";\nconst LayoutMeasurementController = ({ disable, children }) => {\n\tconst id = useId();\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconst wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame?.();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ jsx(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nlet strategy = \"async\";\nlet resumeLayoutLoop;\nlet measureOnNextFrame;\nfunction setOnLayoutStrategy(state) {\n\tstrategy = state;\n\tresumeLayoutLoop?.();\n}\nconst NodeRectCache = /* @__PURE__ */ new WeakMap();\nlet avoidUpdates = true;\nconst queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach((cb) => cb());\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver((entries) => {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (let i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame = function() {\n\t\tif (frameScheduled || strategy === \"off\" || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tconst BoundingRects = /* @__PURE__ */ new WeakMap();\n\tlet rectFetchObserver = null;\n\tlet rectFetchResolve = null;\n\tlet rectFetchStartTime = 0;\n\tlet lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tconst parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tlet nodeRect;\n\t\tlet parentRect;\n\t\tif (strategy === \"async\") {\n\t\t\tnodeRect = BoundingRects.get(node);\n\t\t\tparentRect = BoundingRects.get(parentNode);\n\t\t\tif (!nodeRect || !parentRect) return;\n\t\t} else {\n\t\t\tnodeRect = node.getBoundingClientRect();\n\t\t\tparentRect = parentNode.getBoundingClientRect();\n\t\t}\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tconst rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tconst userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tconst BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tconst MAX_SKIP_FRAMES = 20;\n\tlet skipFrames = BASE_SKIP_FRAMES;\n\tlet frameCount = 0;\n\tlet frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\tif (strategy !== \"off\") {\n\t\t\tconst activeNodes = [];\n\t\t\tconst parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tfor (const node of Nodes) {\n\t\t\t\tconst parentElement = node.parentElement;\n\t\t\t\tif (!(parentElement instanceof HTMLElement)) {\n\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst disableKey = LayoutDisableKey.get(node);\n\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\tactiveNodes.push(node);\n\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tconst io = ensureRectFetchObserver();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.observe(parent);\n\t\t\t\tawait new Promise((res) => {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.unobserve(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.unobserve(parent);\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) updateLayoutIfChanged(activeNodes[i]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame;\n\tmeasureOnNextFrame = () => {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame);\n\tscheduleLayoutFrame();\n}\nconst getElementLayoutEvent = (nodeRect, parentRect, node) => {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nconst getPreTransformDimensions = (node) => {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nconst getRelativeDimensions = (a, b, aNode) => {\n\tconst { left, top } = a;\n\tconst x = left - b.left;\n\tconst y = top - b.top;\n\tconst { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst cachedRect = NodeRectCache.get(node);\n\tconst cachedParentRect = NodeRectCache.get(parentNode);\n\tconst nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tconst parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tconst event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, () => onLayout(event));\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop?.();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn () => cleanupNode(node);\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nconst PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tconst nodeRect = node.getBoundingClientRect();\n\tconst parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tconst disableKey = useContext(DisableLayoutContextKey);\n\tconst node = ensureWebElement(ref.current?.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst nextNode = ensureWebElement(ref.current?.host);\n\t\tconst prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst node2 = ref.current?.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn () => {\n\t\t\tcleanupNode(node2);\n\t\t\tconst swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn x instanceof HTMLElement ? x : void 0;\n}\nconst getBoundingClientRectAsync = (node) => {\n\treturn new Promise((res) => {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tconst io = new IntersectionObserver((entries) => {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nconst measureNode = async (node, relativeTo) => {\n\tconst relativeNode = relativeTo || node?.parentElement;\n\tif (relativeNode instanceof HTMLElement) {\n\t\tconst [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nconst measure = async (node, callback) => {\n\tconst out = await measureNode(node, node.parentNode instanceof HTMLElement ? node.parentNode : null);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn (callback) => measure(node, callback);\n}\nconst measureInWindow = async (node, callback) => {\n\tconst out = await measureNode(node, null);\n\tif (out) callback?.(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nconst createMeasureInWindow = (node) => {\n\treturn (callback) => measureInWindow(node, callback);\n};\nconst measureLayout = async (node, relativeNode, callback) => {\n\tconst out = await measureNode(node, relativeNode);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn (relativeTo, callback) => measureLayout(node, relativeTo, callback);\n}\n\nexport { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, setOnLayoutStrategy, useElementLayout };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Ae,cAAc,MAAM;CACzC,IAAI,wBAAwB,aAAa;EACxC,MAAM,CAAC,SAAS,mBAAmB,MAAM,QAAQ,IAAI,CAAC,2BAA2B,IAAI,GAAG,2BAA2B,YAAY,CAAC,CAAC;EACjI,IAAI,mBAAmB,SAAS,OAAO,sBAAsB,SAAS,iBAAiB,IAAI;CAC5F;CACA,OAAO;AACR;AACA,MAAM,UAAU,OAAO,MAAM,aAAa;CACzC,MAAM,MAAM,MAAM,YAAY,MAAM,KAAK,sBAAsB,cAAc,KAAK,aAAa,IAAI;CACnG,IAAI,KAAK,WAAW,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CAC7E,OAAO;AACR;AACA,SAAS,cAAc,MAAM;CAC5B,QAAQ,aAAa,QAAQ,MAAM,QAAQ;AAC5C;AACA,MAAM,kBAAkB,OAAO,MAAM,aAAa;CACjD,MAAM,MAAM,MAAM,YAAY,MAAM,IAAI;CACxC,IAAI,KAAK,WAAW,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,IAAI,MAAM;CAC/D,OAAO;AACR;AACA,MAAM,yBAAyB,SAAS;CACvC,QAAQ,aAAa,gBAAgB,MAAM,QAAQ;AACpD;AACA,MAAM,gBAAgB,OAAO,MAAM,cAAc,aAAa;CAC7D,MAAM,MAAM,MAAM,YAAY,MAAM,YAAY;CAChD,IAAI,KAAK,WAAW,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CAC7E,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,QAAQ,YAAY,aAAa,cAAc,MAAM,YAAY,QAAQ;AAC1E"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useId } from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst LayoutHandlers = /* @__PURE__ */ new WeakMap();\nconst LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nconst Nodes = /* @__PURE__ */ new Set();\nconst usePretransformDimensions = () => globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\nlet _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nconst DisableLayoutContextValues = {};\nconst DisableLayoutContextKey = createContext(\"\");\nconst ENABLE = typeof IntersectionObserver !== \"undefined\";\nconst LayoutMeasurementController = ({ disable, children }) => {\n\tconst id = useId();\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconst wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame?.();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ jsx(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nlet resumeLayoutLoop;\nlet measureOnNextFrame;\nconst NodeRectCache = /* @__PURE__ */ new WeakMap();\nlet avoidUpdates = true;\nconst queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach((cb) => cb());\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver((entries) => {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (let i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame = function() {\n\t\tif (frameScheduled || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tconst BoundingRects = /* @__PURE__ */ new WeakMap();\n\tlet rectFetchObserver = null;\n\tlet rectFetchResolve = null;\n\tlet rectFetchStartTime = 0;\n\tlet lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tconst parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tlet nodeRect;\n\t\tlet parentRect;\n\t\tnodeRect = BoundingRects.get(node);\n\t\tparentRect = BoundingRects.get(parentNode);\n\t\tif (!nodeRect || !parentRect) return;\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tconst rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tconst userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tconst BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tconst MAX_SKIP_FRAMES = 20;\n\tlet skipFrames = BASE_SKIP_FRAMES;\n\tlet frameCount = 0;\n\tlet frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\t{\n\t\t\tconst activeNodes = [];\n\t\t\tconst parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tfor (const node of Nodes) {\n\t\t\t\tconst parentElement = node.parentElement;\n\t\t\t\tif (!(parentElement instanceof HTMLElement)) {\n\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst disableKey = LayoutDisableKey.get(node);\n\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\tactiveNodes.push(node);\n\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tconst io = ensureRectFetchObserver();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.observe(parent);\n\t\t\t\tawait new Promise((res) => {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) io.unobserve(activeNodes[i]);\n\t\t\t\tfor (const parent of parentsToObserve) io.unobserve(parent);\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (let i = 0; i < activeNodes.length; i++) updateLayoutIfChanged(activeNodes[i]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame;\n\tmeasureOnNextFrame = () => {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame);\n\tscheduleLayoutFrame();\n}\nconst getElementLayoutEvent = (nodeRect, parentRect, node) => {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nconst getPreTransformDimensions = (node) => {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nconst getRelativeDimensions = (a, b, aNode) => {\n\tconst { left, top } = a;\n\tconst x = left - b.left;\n\tconst y = top - b.top;\n\tconst { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst cachedRect = NodeRectCache.get(node);\n\tconst cachedParentRect = NodeRectCache.get(parentNode);\n\tconst nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tconst parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tconst event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, () => onLayout(event));\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop?.();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn () => cleanupNode(node);\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nconst PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tconst onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tconst parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tconst nodeRect = node.getBoundingClientRect();\n\tconst parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tconst disableKey = useContext(DisableLayoutContextKey);\n\tconst node = ensureWebElement(ref.current?.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst nextNode = ensureWebElement(ref.current?.host);\n\t\tconst prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!onLayout) return;\n\t\tconst node2 = ref.current?.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn () => {\n\t\t\tcleanupNode(node2);\n\t\t\tconst swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn x instanceof HTMLElement ? x : void 0;\n}\nconst getBoundingClientRectAsync = (node) => {\n\treturn new Promise((res) => {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tconst io = new IntersectionObserver((entries) => {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nconst measureNode = async (node, relativeTo) => {\n\tconst relativeNode = relativeTo || node?.parentElement;\n\tif (relativeNode instanceof HTMLElement) {\n\t\tconst [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nconst measure = async (node, callback) => {\n\tconst out = await measureNode(node, node.parentNode instanceof HTMLElement ? node.parentNode : null);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn (callback) => measure(node, callback);\n}\nconst measureInWindow = async (node, callback) => {\n\tconst out = await measureNode(node, null);\n\tif (out) callback?.(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nconst createMeasureInWindow = (node) => {\n\treturn (callback) => measureInWindow(node, callback);\n};\nconst measureLayout = async (node, relativeNode, callback) => {\n\tconst out = await measureNode(node, relativeNode);\n\tif (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn (relativeTo, callback) => measureLayout(node, relativeTo, callback);\n}\n\nexport { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, useElementLayout };"],"mappings":";;;;;AAIA,MAAM,iCAAiC,IAAI,QAAQ;AACnD,MAAM,mCAAmC,IAAI,QAAQ;AACrD,MAAM,wBAAwB,IAAI,IAAI;AACtC,MAAM,kCAAkC,WAAW,oCAAoC,QAAQ,QAAQ,IAAI,kCAAkC;AAC7I,IAAI;AACJ,SAAS,gBAAgB;CACxB,IAAI,iBAAiB,KAAK,GAAG,eAAe,OAAO,WAAW,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,mBAAmB;CAChJ,OAAO;AACR;AACA,MAAM,6BAA6B,CAAC;AACpC,MAAM,0BAA0B,cAAc,EAAE;AAChD,MAAM,SAAS,OAAO,yBAAyB;AAC/C,MAAM,+BAA+B,EAAE,SAAS,eAAe;CAC9D,MAAM,KAAK,MAAM;CACjB,gCAAgC;EAC/B,MAAM,cAAc,2BAA2B,QAAQ;EACvD,2BAA2B,MAAM;EACjC,IAAI,eAAe,CAAC,SAAS,qBAAqB;CACnD,GAAG,CAAC,SAAS,EAAE,CAAC;CAChB,OAAuB,oBAAI,wBAAwB,UAAU;EAC5D,OAAO;EACP;CACD,CAAC;AACF;AACA,IAAI;AACJ,IAAI;AACJ,MAAM,gCAAgC,IAAI,QAAQ;AAClD,IAAI,eAAe;AACnB,MAAM,gCAAgC,IAAI,IAAI;AAC9C,SAAS,SAAS;CACjB,IAAI,cAAc;EACjB,eAAe;EACf,IAAI,eAAe;GAClB,cAAc,SAAS,OAAO,GAAG,CAAC;GAClC,cAAc,MAAM;EACrB;CACD;AACD;AACA,SAAS,WAAW,GAAG,GAAG;CACzB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE;A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CAAC,SAAS,mBAAmB,MAAM,QAAQ,IAAI,CAAC,2BAA2B,IAAI,GAAG,2BAA2B,YAAY,CAAC,CAAC;EACjI,IAAI,mBAAmB,SAAS,OAAO,sBAAsB,SAAS,iBAAiB,IAAI;CAC5F;CACA,OAAO;AACR;AACA,MAAM,UAAU,OAAO,MAAM,aAAa;CACzC,MAAM,MAAM,MAAM,YAAY,MAAM,KAAK,sBAAsB,cAAc,KAAK,aAAa,IAAI;CACnG,IAAI,KAAK,WAAW,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CAC7E,OAAO;AACR;AACA,SAAS,cAAc,MAAM;CAC5B,QAAQ,aAAa,QAAQ,MAAM,QAAQ;AAC5C;AACA,MAAM,kBAAkB,OAAO,MAAM,aAAa;CACjD,MAAM,MAAM,MAAM,YAAY,MAAM,IAAI;CACxC,IAAI,KAAK,WAAW,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,IAAI,MAAM;CAC/D,OAAO;AACR;AACA,MAAM,yBAAyB,SAAS;CACvC,QAAQ,aAAa,gBAAgB,MAAM,QAAQ;AACpD;AACA,MAAM,gBAAgB,OAAO,MAAM,cAAc,aAAa;CAC7D,MAAM,MAAM,MAAM,YAAY,MAAM,YAAY;CAChD,IAAI,KAAK,WAAW,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CAC7E,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,QAAQ,YAAY,aAAa,cAAc,MAAM,YAAY,QAAQ;AAC1E"}
@@ -36,10 +36,6 @@ var LayoutMeasurementController = function(param) {
36
36
  var strategy = "async";
37
37
  var resumeLayoutLoop;
38
38
  var measureOnNextFrame;
39
- function setOnLayoutStrategy(state) {
40
- strategy = state;
41
- resumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();
42
- }
43
39
  var NodeRectCache = /* @__PURE__ */ new WeakMap();
44
40
  var avoidUpdates = true;
45
41
  var queuedUpdates = /* @__PURE__ */ new Map();
@@ -374,5 +370,5 @@ function createMeasureLayout(node) {
374
370
  };
375
371
  }
376
372
 
377
- export { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, setOnLayoutStrategy, useElementLayout };
373
+ export { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, useElementLayout };
378
374
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { jsx } from \"react/jsx-runtime\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useId } from \"react\";\n\nfunction _instanceof(left, right) {\n\tif (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);\n\telse return left instanceof right;\n}\nvar LayoutHandlers = /* @__PURE__ */ new WeakMap();\nvar LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nvar Nodes = /* @__PURE__ */ new Set();\nvar usePretransformDimensions = function() {\n\treturn globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\n};\nvar _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nvar DisableLayoutContextValues = {};\nvar DisableLayoutContextKey = /* @__PURE__ */ createContext(\"\");\nvar ENABLE = false;\nvar LayoutMeasurementController = function(param) {\n\tvar { disable, children } = param;\n\tvar id = useId();\n\tuseIsomorphicLayoutEffect(function() {\n\t\tvar wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame === null || measureOnNextFrame === void 0 || measureOnNextFrame();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ jsx(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nvar strategy = \"async\";\nvar resumeLayoutLoop;\nvar measureOnNextFrame;\nfunction setOnLayoutStrategy(state) {\n\tstrategy = state;\n\tresumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();\n}\nvar NodeRectCache = /* @__PURE__ */ new WeakMap();\nvar avoidUpdates = true;\nvar queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach(function(cb) {\n\t\t\t\treturn cb();\n\t\t\t});\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver2 = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver(function(entries) {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (var i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame2 = function() {\n\t\tif (frameScheduled || strategy === \"off\" || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tvar BoundingRects = /* @__PURE__ */ new WeakMap();\n\tvar rectFetchObserver = null;\n\tvar rectFetchResolve = null;\n\tvar rectFetchStartTime = 0;\n\tvar lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tvar parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tvar nodeRect;\n\t\tvar parentRect;\n\t\tif (strategy === \"async\") {\n\t\t\tnodeRect = BoundingRects.get(node);\n\t\t\tparentRect = BoundingRects.get(parentNode);\n\t\t\tif (!nodeRect || !parentRect) return;\n\t\t} else {\n\t\t\tnodeRect = node.getBoundingClientRect();\n\t\t\tparentRect = parentNode.getBoundingClientRect();\n\t\t}\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tvar rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tvar userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tvar BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tvar MAX_SKIP_FRAMES = 20;\n\tvar skipFrames = BASE_SKIP_FRAMES;\n\tvar frameCount = 0;\n\tvar frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame2();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\tif (strategy !== \"off\") {\n\t\t\tvar activeNodes = [];\n\t\t\tvar parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\t\t\ttry {\n\t\t\t\tfor (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\t\t\tvar node = _step.value;\n\t\t\t\t\tvar parentElement = node.parentElement;\n\t\t\t\t\tif (!_instanceof(parentElement, HTMLElement)) {\n\t\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvar disableKey = LayoutDisableKey.get(node);\n\t\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\t\tactiveNodes.push(node);\n\t\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t_didIteratorError = true;\n\t\t\t\t_iteratorError = err;\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t\t\t} finally {\n\t\t\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tvar io = ensureRectFetchObserver2();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (var i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tvar _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator1 = parentsToObserve[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n\t\t\t\t\t\tvar parent = _step1.value;\n\t\t\t\t\t\tio.observe(parent);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError1 = true;\n\t\t\t\t\t_iteratorError1 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError1) throw _iteratorError1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait new Promise(function(res) {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (var i1 = 0; i1 < activeNodes.length; i1++) io.unobserve(activeNodes[i1]);\n\t\t\t\tvar _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator2 = parentsToObserve[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n\t\t\t\t\t\tvar parent1 = _step2.value;\n\t\t\t\t\t\tio.unobserve(parent1);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError2 = true;\n\t\t\t\t\t_iteratorError2 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion2 && _iterator2.return != null) _iterator2.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError2) throw _iteratorError2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (var i2 = 0; i2 < activeNodes.length; i2++) updateLayoutIfChanged(activeNodes[i2]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame2();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame2;\n\tmeasureOnNextFrame = function() {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame2();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame2);\n\tscheduleLayoutFrame2();\n}\nvar getElementLayoutEvent = function(nodeRect, parentRect, node) {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nvar getPreTransformDimensions = function(node) {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nvar getRelativeDimensions = function(a, b, aNode) {\n\tvar { left, top } = a;\n\tvar x = left - b.left;\n\tvar y = top - b.top;\n\tvar { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar cachedRect = NodeRectCache.get(node);\n\tvar cachedParentRect = NodeRectCache.get(parentNode);\n\tvar nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tvar parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tvar event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, function() {\n\t\treturn onLayout(event);\n\t});\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn function() {\n\t\treturn cleanupNode(node);\n\t};\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nvar PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tvar nodeRect = node.getBoundingClientRect();\n\tvar parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tvar _ref_current;\n\tvar disableKey = useContext(DisableLayoutContextKey);\n\tvar node = ensureWebElement((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\tuseIsomorphicLayoutEffect(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar nextNode = ensureWebElement((_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host);\n\t\tvar prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\tuseIsomorphicLayoutEffect(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn function() {\n\t\t\tcleanupNode(node2);\n\t\t\tvar swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn _instanceof(x, HTMLElement) ? x : void 0;\n}\nvar getBoundingClientRectAsync = function(node) {\n\treturn new Promise(function(res) {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tvar io = new IntersectionObserver(function(entries) {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nvar measureNode = async function(node, relativeTo) {\n\tvar relativeNode = relativeTo || (node === null || node === void 0 ? void 0 : node.parentElement);\n\tif (_instanceof(relativeNode, HTMLElement)) {\n\t\tvar [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nvar measure = async function(node, callback) {\n\tvar out = await measureNode(node, _instanceof(node.parentNode, HTMLElement) ? node.parentNode : null);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn function(callback) {\n\t\treturn measure(node, callback);\n\t};\n}\nvar measureInWindow = async function(node, callback) {\n\tvar out = await measureNode(node, null);\n\tif (out) callback === null || callback === void 0 || callback(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nvar createMeasureInWindow = function(node) {\n\treturn function(callback) {\n\t\treturn measureInWindow(node, callback);\n\t};\n};\nvar measureLayout = async function(node, relativeNode, callback) {\n\tvar out = await measureNode(node, relativeNode);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn function(relativeTo, callback) {\n\t\treturn measureLayout(node, relativeTo, callback);\n\t};\n}\n\nexport { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, setOnLayoutStrategy, useElementLayout };"],"mappings":";;;;;AAIA,SAAS,YAAY,MAAM,OAAO;CACjC,IAAI,SAAS,QAAQ,OAAO,WAAW,eAAe,MAAM,OAAO,cAAc,OAAO,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,IAAI;MACnH,OAAO,gBAAgB;AAC7B;AACA,IAAI,iCAAiC,IAAI,QAAQ;AACjD,IAAI,mCAAmC,IAAI,QAAQ;AACnD,IAAI,wBAAwB,IAAI,IAAI;AACpC,IAAI,4BAA4B,WAAW;CAC1C,OAAO,WAAW,oCAAoC,QAAQ,QAAQ,IAAI,kCAAkC;AAC7G;AACA,IAAI;AACJ,SAAS,gBAAgB;CACxB,IAAI,iBAAiB,KAAK,GAAG,eAAe,OAAO,WAAW,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM,CAAC,CAAC,IAAI,mBAAmB;CAChJ,OAAO;AACR;AACA,IAAI,6BAA6B,CAAC;AAClC,IAAI,0BAA0C,8BAAc,EAAE;AAC9D,IAAI,SAAS;AACb,IAAI,8BAA8B,SAAS,OAAO;CACjD,IAAI,EAAE,SAAS,aAAa;CAC5B,IA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,2BAA2B,IAAI,GAAG,2BAA2B,YAAY,CAAC,CAAC;EAC/H,IAAI,mBAAmB,SAAS,OAAO,sBAAsB,SAAS,iBAAiB,IAAI;CAC5F;CACA,OAAO;AACR;AACA,IAAI,UAAU,eAAe,MAAM,UAAU;CAC5C,IAAI,MAAM,MAAM,YAAY,MAAM,YAAY,KAAK,YAAY,WAAW,IAAI,KAAK,aAAa,IAAI;CACpG,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CACvH,OAAO;AACR;AACA,SAAS,cAAc,MAAM;CAC5B,OAAO,SAAS,UAAU;EACzB,OAAO,QAAQ,MAAM,QAAQ;CAC9B;AACD;AACA,IAAI,kBAAkB,eAAe,MAAM,UAAU;CACpD,IAAI,MAAM,MAAM,YAAY,MAAM,IAAI;CACtC,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,IAAI,MAAM;CACzG,OAAO;AACR;AACA,IAAI,wBAAwB,SAAS,MAAM;CAC1C,OAAO,SAAS,UAAU;EACzB,OAAO,gBAAgB,MAAM,QAAQ;CACtC;AACD;AACA,IAAI,gBAAgB,eAAe,MAAM,cAAc,UAAU;CAChE,IAAI,MAAM,MAAM,YAAY,MAAM,YAAY;CAC9C,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CACvH,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,OAAO,SAAS,YAAY,UAAU;EACrC,OAAO,cAAc,MAAM,YAAY,QAAQ;CAChD;AACD"}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { jsx } from \"react/jsx-runtime\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createContext, useContext, useId } from \"react\";\n\nfunction _instanceof(left, right) {\n\tif (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);\n\telse return left instanceof right;\n}\nvar LayoutHandlers = /* @__PURE__ */ new WeakMap();\nvar LayoutDisableKey = /* @__PURE__ */ new WeakMap();\nvar Nodes = /* @__PURE__ */ new Set();\nvar usePretransformDimensions = function() {\n\treturn globalThis.__TAMAGUI_ONLAYOUT_PRETRANSFORM === true || process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === \"1\";\n};\nvar _debugLayout;\nfunction isDebugLayout() {\n\tif (_debugLayout === void 0) _debugLayout = typeof window !== \"undefined\" && new URLSearchParams(window.location.search).has(\"__tamaDebugLayout\");\n\treturn _debugLayout;\n}\nvar DisableLayoutContextValues = {};\nvar DisableLayoutContextKey = /* @__PURE__ */ createContext(\"\");\nvar ENABLE = false;\nvar LayoutMeasurementController = function(param) {\n\tvar { disable, children } = param;\n\tvar id = useId();\n\tuseIsomorphicLayoutEffect(function() {\n\t\tvar wasDisabled = DisableLayoutContextValues[id] === true;\n\t\tDisableLayoutContextValues[id] = disable;\n\t\tif (wasDisabled && !disable) measureOnNextFrame === null || measureOnNextFrame === void 0 || measureOnNextFrame();\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ jsx(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nvar strategy = \"async\";\nvar resumeLayoutLoop;\nvar measureOnNextFrame;\nvar NodeRectCache = /* @__PURE__ */ new WeakMap();\nvar avoidUpdates = true;\nvar queuedUpdates = /* @__PURE__ */ new Map();\nfunction enable() {\n\tif (avoidUpdates) {\n\t\tavoidUpdates = false;\n\t\tif (queuedUpdates) {\n\t\t\tqueuedUpdates.forEach(function(cb) {\n\t\t\t\treturn cb();\n\t\t\t});\n\t\t\tqueuedUpdates.clear();\n\t\t}\n\t}\n}\nfunction rectsEqual(a, b) {\n\treturn a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\nif (ENABLE) {\n\tlet ensureRectFetchObserver2 = function() {\n\t\tif (rectFetchObserver) return rectFetchObserver;\n\t\trectFetchObserver = new IntersectionObserver(function(entries) {\n\t\t\tlastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);\n\t\t\tfor (var i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);\n\t\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout() && lastCallbackDelay > 50) console.warn(\"[onLayout-io-delay]\", lastCallbackDelay + \"ms\", entries.length, \"entries\");\n\t\t\tif (rectFetchResolve) {\n\t\t\t\trectFetchResolve(true);\n\t\t\t\trectFetchResolve = null;\n\t\t\t}\n\t\t}, { threshold: 0 });\n\t\treturn rectFetchObserver;\n\t}, scheduleLayoutFrame2 = function() {\n\t\tif (frameScheduled || strategy === \"off\" || Nodes.size === 0 || document.hidden) return;\n\t\tframeScheduled = true;\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t};\n\tvar BoundingRects = /* @__PURE__ */ new WeakMap();\n\tvar rectFetchObserver = null;\n\tvar rectFetchResolve = null;\n\tvar rectFetchStartTime = 0;\n\tvar lastCallbackDelay = 0;\n\tasync function updateLayoutIfChanged(node) {\n\t\tif (typeof LayoutHandlers.get(node) !== \"function\") return;\n\t\tvar parentNode = node.parentElement;\n\t\tif (!parentNode) return;\n\t\tvar nodeRect;\n\t\tvar parentRect;\n\t\tif (strategy === \"async\") {\n\t\t\tnodeRect = BoundingRects.get(node);\n\t\t\tparentRect = BoundingRects.get(parentNode);\n\t\t\tif (!nodeRect || !parentRect) return;\n\t\t} else {\n\t\t\tnodeRect = node.getBoundingClientRect();\n\t\t\tparentRect = parentNode.getBoundingClientRect();\n\t\t}\n\t\temitLayoutIfChanged(node, parentNode, nodeRect, parentRect);\n\t}\n\tvar rAF = typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : void 0;\n\tvar userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP;\n\tvar BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;\n\tvar MAX_SKIP_FRAMES = 20;\n\tvar skipFrames = BASE_SKIP_FRAMES;\n\tvar frameCount = 0;\n\tvar frameScheduled = false;\n\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\tframeScheduled = false;\n\t\t\tscheduleLayoutFrame2();\n\t\t\treturn;\n\t\t}\n\t\tif (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;\n\t\tif (strategy !== \"off\") {\n\t\t\tvar activeNodes = [];\n\t\t\tvar parentsToObserve = /* @__PURE__ */ new Set();\n\t\t\tvar _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n\t\t\ttry {\n\t\t\t\tfor (var _iterator = Nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\t\t\tvar node = _step.value;\n\t\t\t\t\tvar parentElement = node.parentElement;\n\t\t\t\t\tif (!_instanceof(parentElement, HTMLElement)) {\n\t\t\t\t\t\tcleanupNode(node);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvar disableKey = LayoutDisableKey.get(node);\n\t\t\t\t\tif (disableKey && DisableLayoutContextValues[disableKey] === true) continue;\n\t\t\t\t\tactiveNodes.push(node);\n\t\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t_didIteratorError = true;\n\t\t\t\t_iteratorError = err;\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();\n\t\t\t\t} finally {\n\t\t\t\t\tif (_didIteratorError) throw _iteratorError;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (activeNodes.length > 0) {\n\t\t\t\tvar io = ensureRectFetchObserver2();\n\t\t\t\trectFetchStartTime = performance.now();\n\t\t\t\tfor (var i = 0; i < activeNodes.length; i++) io.observe(activeNodes[i]);\n\t\t\t\tvar _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator1 = parentsToObserve[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n\t\t\t\t\t\tvar parent = _step1.value;\n\t\t\t\t\t\tio.observe(parent);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError1 = true;\n\t\t\t\t\t_iteratorError1 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError1) throw _iteratorError1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait new Promise(function(res) {\n\t\t\t\t\trectFetchResolve = res;\n\t\t\t\t});\n\t\t\t\tfor (var i1 = 0; i1 < activeNodes.length; i1++) io.unobserve(activeNodes[i1]);\n\t\t\t\tvar _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n\t\t\t\ttry {\n\t\t\t\t\tfor (var _iterator2 = parentsToObserve[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n\t\t\t\t\t\tvar parent1 = _step2.value;\n\t\t\t\t\t\tio.unobserve(parent1);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\t_didIteratorError2 = true;\n\t\t\t\t\t_iteratorError2 = err;\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!_iteratorNormalCompletion2 && _iterator2.return != null) _iterator2.return();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (_didIteratorError2) throw _iteratorError2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);\n\t\t\t\telse if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);\n\t\t\t\tfor (var i2 = 0; i2 < activeNodes.length; i2++) updateLayoutIfChanged(activeNodes[i2]);\n\t\t\t}\n\t\t}\n\t\tframeScheduled = false;\n\t\tscheduleLayoutFrame2();\n\t}\n\tresumeLayoutLoop = scheduleLayoutFrame2;\n\tmeasureOnNextFrame = function() {\n\t\tframeCount = 0;\n\t\tscheduleLayoutFrame2();\n\t};\n\tdocument.addEventListener(\"visibilitychange\", scheduleLayoutFrame2);\n\tscheduleLayoutFrame2();\n}\nvar getElementLayoutEvent = function(nodeRect, parentRect, node) {\n\treturn {\n\t\tnativeEvent: {\n\t\t\tlayout: getRelativeDimensions(nodeRect, parentRect, node),\n\t\t\ttarget: nodeRect\n\t\t},\n\t\ttimeStamp: Date.now()\n\t};\n};\nvar getPreTransformDimensions = function(node) {\n\treturn {\n\t\twidth: node.offsetWidth,\n\t\theight: node.offsetHeight\n\t};\n};\nvar getRelativeDimensions = function(a, b, aNode) {\n\tvar { left, top } = a;\n\tvar x = left - b.left;\n\tvar y = top - b.top;\n\tvar { width, height } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {\n\t\twidth: a.width,\n\t\theight: a.height\n\t};\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight,\n\t\tpageX: a.left,\n\t\tpageY: a.top\n\t};\n};\nfunction emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar cachedRect = NodeRectCache.get(node);\n\tvar cachedParentRect = NodeRectCache.get(parentNode);\n\tvar nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);\n\tvar parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);\n\tif (!nodeChanged && !parentChanged) return;\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tvar event = getElementLayoutEvent(nodeRect, parentRect, node);\n\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] change\", {\n\t\ttag: node.tagName,\n\t\tid: node.id || void 0,\n\t\tclassName: (node.className || \"\").slice(0, 60) || void 0,\n\t\tlayout: event.nativeEvent.layout,\n\t\tfirst: !cachedRect\n\t});\n\tif (avoidUpdates) queuedUpdates.set(node, function() {\n\t\treturn onLayout(event);\n\t});\n\telse onLayout(event);\n}\nfunction observeLayoutNode(node, disableKey) {\n\tNodes.add(node);\n\tif (disableKey) LayoutDisableKey.set(node, disableKey);\n\telse LayoutDisableKey.delete(node);\n\tresumeLayoutLoop === null || resumeLayoutLoop === void 0 || resumeLayoutLoop();\n}\nfunction registerLayoutNode(node, onChange, disableKey) {\n\tLayoutHandlers.set(node, onChange);\n\tobserveLayoutNode(node, disableKey);\n\treturn function() {\n\t\treturn cleanupNode(node);\n\t};\n}\nfunction cleanupNode(node) {\n\tNodes.delete(node);\n\tLayoutHandlers.delete(node);\n\tLayoutDisableKey.delete(node);\n\tNodeRectCache.delete(node);\n}\nvar PrevHostNode = /* @__PURE__ */ new WeakMap();\nfunction emitLayoutSync(node) {\n\tvar onLayout = LayoutHandlers.get(node);\n\tif (typeof onLayout !== \"function\") return;\n\tvar parentNode = node.parentElement;\n\tif (!parentNode) return;\n\tvar nodeRect = node.getBoundingClientRect();\n\tvar parentRect = parentNode.getBoundingClientRect();\n\tNodeRectCache.set(node, nodeRect);\n\tNodeRectCache.set(parentNode, parentRect);\n\tonLayout(getElementLayoutEvent(nodeRect, parentRect, node));\n}\nfunction useElementLayout(ref, onLayout) {\n\tvar _ref_current;\n\tvar disableKey = useContext(DisableLayoutContextKey);\n\tvar node = ensureWebElement((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.host);\n\tif (node && onLayout) {\n\t\tLayoutHandlers.set(node, onLayout);\n\t\tLayoutDisableKey.set(node, disableKey);\n\t}\n\tuseIsomorphicLayoutEffect(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar nextNode = ensureWebElement((_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host);\n\t\tvar prevNode = PrevHostNode.get(ref);\n\t\tif (nextNode === prevNode) return;\n\t\tif (prevNode) cleanupNode(prevNode);\n\t\tPrevHostNode.set(ref, nextNode);\n\t\tif (!nextNode) return;\n\t\tLayoutHandlers.set(nextNode, onLayout);\n\t\tobserveLayoutNode(nextNode, disableKey);\n\t\temitLayoutSync(nextNode);\n\t});\n\tuseIsomorphicLayoutEffect(function() {\n\t\tvar _ref_current2;\n\t\tif (!onLayout) return;\n\t\tvar node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;\n\t\tif (!node2) return;\n\t\tLayoutHandlers.set(node2, onLayout);\n\t\tobserveLayoutNode(node2, disableKey);\n\t\tif (process.env.NODE_ENV === \"development\" && isDebugLayout()) console.log(\"[useElementLayout] register\", {\n\t\t\ttag: node2.tagName,\n\t\t\tid: node2.id || void 0,\n\t\t\tclassName: (node2.className || \"\").slice(0, 60) || void 0,\n\t\t\ttotalNodes: Nodes.size\n\t\t});\n\t\treturn function() {\n\t\t\tcleanupNode(node2);\n\t\t\tvar swappedNode = PrevHostNode.get(ref);\n\t\t\tif (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);\n\t\t\tPrevHostNode.delete(ref);\n\t\t};\n\t}, [ref, !!onLayout]);\n}\nfunction ensureWebElement(x) {\n\tif (typeof HTMLElement === \"undefined\") return;\n\treturn _instanceof(x, HTMLElement) ? x : void 0;\n}\nvar getBoundingClientRectAsync = function(node) {\n\treturn new Promise(function(res) {\n\t\tif (!node || node.nodeType !== 1) return res(false);\n\t\tvar io = new IntersectionObserver(function(entries) {\n\t\t\tio.disconnect();\n\t\t\treturn res(entries[0].boundingClientRect);\n\t\t}, { threshold: 0 });\n\t\tio.observe(node);\n\t});\n};\nvar measureNode = async function(node, relativeTo) {\n\tvar relativeNode = relativeTo || (node === null || node === void 0 ? void 0 : node.parentElement);\n\tif (_instanceof(relativeNode, HTMLElement)) {\n\t\tvar [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);\n\t\tif (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);\n\t}\n\treturn null;\n};\nvar measure = async function(node, callback) {\n\tvar out = await measureNode(node, _instanceof(node.parentNode, HTMLElement) ? node.parentNode : null);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasure(node) {\n\treturn function(callback) {\n\t\treturn measure(node, callback);\n\t};\n}\nvar measureInWindow = async function(node, callback) {\n\tvar out = await measureNode(node, null);\n\tif (out) callback === null || callback === void 0 || callback(out.pageX, out.pageY, out.width, out.height);\n\treturn out;\n};\nvar createMeasureInWindow = function(node) {\n\treturn function(callback) {\n\t\treturn measureInWindow(node, callback);\n\t};\n};\nvar measureLayout = async function(node, relativeNode, callback) {\n\tvar out = await measureNode(node, relativeNode);\n\tif (out) callback === null || callback === void 0 || callback(out.x, out.y, out.width, out.height, out.pageX, out.pageY);\n\treturn out;\n};\nfunction createMeasureLayout(node) {\n\treturn function(relativeTo, callback) {\n\t\treturn measureLayout(node, relativeTo, callback);\n\t};\n}\n\nexport { LayoutMeasurementController, createMeasure, createMeasureInWindow, createMeasureLayout, enable, getBoundingClientRectAsync, getElementLayoutEvent, measure, measureInWindow, measureLayout, measureNode, registerLayoutNode, useElementLayout };"],"mappings":";;;;;AAIA,SAAS,YAAY,MAAM,OAAO;CACjC,IAAI,SAAS,QAAQ,OAAO,WAAW,eAAe,MAAM,OA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AAS,UAAU;EACzB,OAAO,gBAAgB,MAAM,QAAQ;CACtC;AACD;AACA,IAAI,gBAAgB,eAAe,MAAM,cAAc,UAAU;CAChE,IAAI,MAAM,MAAM,YAAY,MAAM,YAAY;CAC9C,IAAI,KAAK,aAAa,QAAQ,aAAa,KAAK,KAAK,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,KAAK;CACvH,OAAO;AACR;AACA,SAAS,oBAAoB,MAAM;CAClC,OAAO,SAAS,YAAY,UAAU;EACrC,OAAO,cAAc,MAAM,YAAY,QAAQ;CAChD;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/use-element-layout",
3
- "version": "3.0.0-beta.807.1",
3
+ "version": "3.0.0-beta.831.1",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "files": [
6
6
  "src",
@@ -34,11 +34,11 @@
34
34
  "clean:build": "tamagui-build clean:build"
35
35
  },
36
36
  "dependencies": {
37
- "@tamagui/constants": "3.0.0-beta.807.1",
38
- "@tamagui/is-equal-shallow": "3.0.0-beta.807.1"
37
+ "@tamagui/constants": "3.0.0-beta.831.1",
38
+ "@tamagui/is-equal-shallow": "3.0.0-beta.831.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@tamagui/build": "3.0.0-beta.807.1",
41
+ "@tamagui/build": "3.0.0-beta.831.1",
42
42
  "react": "19.2.3"
43
43
  },
44
44
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -78,11 +78,6 @@ let resumeLayoutLoop: (() => void) | undefined
78
78
  // measurement (an opening sheet parked off-screen).
79
79
  let measureOnNextFrame: (() => void) | undefined
80
80
 
81
- export function setOnLayoutStrategy(state: LayoutMeasurementStrategy): void {
82
- strategy = state
83
- resumeLayoutLoop?.()
84
- }
85
-
86
81
  export type LayoutValue = {
87
82
  x: number
88
83
  y: number
package/types/index.d.ts CHANGED
@@ -6,8 +6,6 @@ export declare const LayoutMeasurementController: ({ disable, children }: {
6
6
  type TamaguiComponentStatePartial = {
7
7
  host?: any;
8
8
  };
9
- type LayoutMeasurementStrategy = "off" | "sync" | "async";
10
- export declare function setOnLayoutStrategy(state: LayoutMeasurementStrategy): void;
11
9
  export type LayoutValue = {
12
10
  x: number;
13
11
  y: number;
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AACA,cAAgD,gBAAgB,iBAAiB;AAkCjF,OAAO,cAAM,8BAA+B,EAC1C,SACA,YACC;CACD;CACA,UAAU;MACR;KAqBC,+BAA+B;CAClC;;KAGG,4BAA4B,QAAQ,SAAS;AAclD,OAAO,iBAAS,oBAAoB,OAAO;AAK3C,YAAY,cAAc;CACxB;CACA;CACA;CACA;CACA;CACA;;AAGF,YAAY,cAAc;CACxB,aAAa;EACX,QAAQ;EACR;;CAEF;;AASF,OAAO,iBAAS;AAuMhB,OAAO,cAAM,wBACX,UAAU,iBACV,YAAY,iBACZ,OAAO,gBACN;AA8FH,OAAO,iBAAS,mBACd,MAAM,aACN,sBACA;AAiCF,OAAO,iBAAS,iBACd,KAAK,UAAU,+BACf,aAAa,GAAG;AAgElB,OAAO,cAAM,6BACX,MAAM,uBACL,QAAQ,kBAAkB;AAiB7B,OAAO,cAAM,cACX,MAAM,aACN,aAAa,uBACZ,eAAe;KAcb,qBAAqB,WAAW,WAAW,eAAe;KAE1D,aACH,WACA,WACA,eACA,gBACA,eACA;AAGF,OAAO,cAAM,UACX,MAAM,aACN,UAAU,cACT,QAAQ;AAWX,OAAO,iBAAS,cACd,MAAM,eACJ,UAAU,cAAc,QAAQ;KAI/B,eAAe;CAAE;CAAe;CAAe;CAAe;;AAEnE,OAAO,cAAM,kBACX,MAAM,aACN,UAAU,sBACT,QAAQ;AAQX,OAAO,cAAM,wBACX,MAAM,kBACH,UAAU,sBAAsB,QAAQ;AAI7C,OAAO,cAAM,gBACX,MAAM,aACN,cAAc,aACd,UAAU,cACT,QAAQ;AAQX,OAAO,iBAAS,oBACd,MAAM,eACJ,YAAY,aAAa,UAAU,cAAc,QAAQ",
2
+ "mappings": "AACA,cAAgD,gBAAgB,iBAAiB;AAkCjF,OAAO,cAAM,8BAA+B,EAC1C,SACA,YACC;CACD;CACA,UAAU;MACR;KAqBC,+BAA+B;CAClC;;AAiBF,YAAY,cAAc;CACxB;CACA;CACA;CACA;CACA;CACA;;AAGF,YAAY,cAAc;CACxB,aAAa;EACX,QAAQ;EACR;;CAEF;;AASF,OAAO,iBAAS;AAuMhB,OAAO,cAAM,wBACX,UAAU,iBACV,YAAY,iBACZ,OAAO,gBACN;AA8FH,OAAO,iBAAS,mBACd,MAAM,aACN,sBACA;AAiCF,OAAO,iBAAS,iBACd,KAAK,UAAU,+BACf,aAAa,GAAG;AAgElB,OAAO,cAAM,6BACX,MAAM,uBACL,QAAQ,kBAAkB;AAiB7B,OAAO,cAAM,cACX,MAAM,aACN,aAAa,uBACZ,eAAe;KAcb,qBAAqB,WAAW,WAAW,eAAe;KAE1D,aACH,WACA,WACA,eACA,gBACA,eACA;AAGF,OAAO,cAAM,UACX,MAAM,aACN,UAAU,cACT,QAAQ;AAWX,OAAO,iBAAS,cACd,MAAM,eACJ,UAAU,cAAc,QAAQ;KAI/B,eAAe;CAAE;CAAe;CAAe;CAAe;;AAEnE,OAAO,cAAM,kBACX,MAAM,aACN,UAAU,sBACT,QAAQ;AAQX,OAAO,cAAM,wBACX,MAAM,kBACH,UAAU,sBAAsB,QAAQ;AAI7C,OAAO,cAAM,gBACX,MAAM,aACN,cAAc,aACd,UAAU,cACT,QAAQ;AAQX,OAAO,iBAAS,oBACd,MAAM,eACJ,YAAY,aAAa,UAAU,cAAc,QAAQ",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/index.tsx"
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { createContext, useContext, useId, type ReactNode, type RefObject } from 'react'\n\nconst LayoutHandlers = new WeakMap<HTMLElement, Function>()\nconst LayoutDisableKey = new WeakMap<HTMLElement, string>()\nconst Nodes = new Set<HTMLElement>()\n\n// feature flag to enable pre-transform dimension reporting (matches RN behavior)\n// can be set via env var at build time or runtime global for testing\n// see: https://github.com/tamagui/tamagui/pull/2329\nconst usePretransformDimensions = () =>\n (globalThis as any).__TAMAGUI_ONLAYOUT_PRETRANSFORM === true ||\n process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === '1'\n\nlet _debugLayout: boolean | undefined\n\nfunction isDebugLayout() {\n if (_debugLayout === undefined) {\n _debugLayout =\n typeof window !== 'undefined' &&\n new URLSearchParams(window.location.search).has('__tamaDebugLayout')\n }\n return _debugLayout\n}\n\n// separating to avoid all re-rendering\nconst DisableLayoutContextValues: Record<string, boolean> = {}\nconst DisableLayoutContextKey = createContext<string>('')\n\nconst ENABLE =\n process.env.TAMAGUI_TARGET === 'web' && typeof IntersectionObserver !== 'undefined'\n\n// internal testing - advanced helper to turn off layout measurement for extra performance\n// TODO document!\n// TODO could add frame skip control here\nexport const LayoutMeasurementController = ({\n disable,\n children,\n}: {\n disable: boolean\n children: ReactNode\n}): ReactNode => {\n const id = useId()\n\n useIsomorphicLayoutEffect(() => {\n const wasDisabled = DisableLayoutContextValues[id] === true\n DisableLayoutContextValues[id] = disable\n // a controller flipping to enabled (a sheet or popper opening) is often\n // waiting on a measurement to position itself, so don't make it sit out\n // the frame-skip window\n if (wasDisabled && !disable) {\n measureOnNextFrame?.()\n }\n }, [disable, id])\n\n return (\n <DisableLayoutContextKey.Provider value={id}>\n {children}\n </DisableLayoutContextKey.Provider>\n )\n}\n\ntype TamaguiComponentStatePartial = {\n host?: any\n}\n\ntype LayoutMeasurementStrategy = 'off' | 'sync' | 'async'\n\nlet strategy: LayoutMeasurementStrategy = 'async'\n\n// the measurement loop parks itself whenever it provably has nothing to do: no\n// registered nodes, a hidden document, or measurement turned off. these are the\n// only three ways work can reappear, so each one restarts it.\nlet resumeLayoutLoop: (() => void) | undefined\n\n// restarts the loop AND makes its next frame a measuring frame, skipping the\n// frame-skip backoff once. for consumers whose position depends on a pending\n// measurement (an opening sheet parked off-screen).\nlet measureOnNextFrame: (() => void) | undefined\n\nexport function setOnLayoutStrategy(state: LayoutMeasurementStrategy): void {\n strategy = state\n resumeLayoutLoop?.()\n}\n\nexport type LayoutValue = {\n x: number\n y: number\n width: number\n height: number\n pageX: number\n pageY: number\n}\n\nexport type LayoutEvent = {\n nativeEvent: {\n layout: LayoutValue\n target: any\n }\n timeStamp: number\n}\n\nconst NodeRectCache = new WeakMap<HTMLElement, DOMRectReadOnly>()\n\n// prevent thrashing during first hydration (somewhat, streaming gets trickier)\nlet avoidUpdates = true\nconst queuedUpdates = new Map<HTMLElement, Function>()\n\nexport function enable(): void {\n if (avoidUpdates) {\n avoidUpdates = false\n if (queuedUpdates) {\n queuedUpdates.forEach((cb) => cb())\n queuedUpdates.clear()\n }\n }\n}\n\n// optimization: inline rect comparison to avoid function call overhead on hot path\nfunction rectsEqual(a: DOMRectReadOnly, b: DOMRectReadOnly): boolean {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height\n}\n\nif (ENABLE) {\n const BoundingRects = new WeakMap<Element, DOMRectReadOnly>()\n\n // optimization: persistent IO for rect fetching, reused across cycles\n let rectFetchObserver: IntersectionObserver | null = null\n let rectFetchResolve: ((value: boolean) => void) | null = null\n let rectFetchStartTime = 0\n let lastCallbackDelay = 0\n\n function ensureRectFetchObserver() {\n if (rectFetchObserver) return rectFetchObserver\n\n rectFetchObserver = new IntersectionObserver(\n (entries) => {\n lastCallbackDelay = Math.round(performance.now() - rectFetchStartTime)\n\n // store all rects\n for (let i = 0; i < entries.length; i++) {\n BoundingRects.set(entries[i].target, entries[i].boundingClientRect)\n }\n\n if (\n process.env.NODE_ENV === 'development' &&\n isDebugLayout() &&\n lastCallbackDelay > 50\n ) {\n console.warn(\n '[onLayout-io-delay]',\n lastCallbackDelay + 'ms',\n entries.length,\n 'entries'\n )\n }\n\n if (rectFetchResolve) {\n rectFetchResolve(true)\n rectFetchResolve = null\n }\n },\n {\n threshold: 0,\n }\n )\n\n return rectFetchObserver\n }\n\n async function updateLayoutIfChanged(node: HTMLElement) {\n const onLayout = LayoutHandlers.get(node)\n if (typeof onLayout !== 'function') return\n\n const parentNode = node.parentElement\n if (!parentNode) return\n\n let nodeRect: DOMRectReadOnly | undefined\n let parentRect: DOMRectReadOnly | undefined\n\n // respect the strategy contract\n if (strategy === 'async') {\n nodeRect = BoundingRects.get(node)\n parentRect = BoundingRects.get(parentNode)\n\n if (!nodeRect || !parentRect) {\n return\n }\n } else {\n nodeRect = node.getBoundingClientRect()\n parentRect = parentNode.getBoundingClientRect()\n }\n\n emitLayoutIfChanged(node, parentNode, nodeRect, parentRect)\n }\n\n const rAF =\n typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame : undefined\n\n // adaptive frame skipping with backoff\n const userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP\n const BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10\n const MAX_SKIP_FRAMES = 20\n let skipFrames = BASE_SKIP_FRAMES\n let frameCount = 0\n\n // stays true across the await below so a node registering mid-cycle cannot\n // start a second concurrent loop\n let frameScheduled = false\n\n function scheduleLayoutFrame() {\n if (frameScheduled || strategy === 'off' || Nodes.size === 0 || document.hidden) {\n return\n }\n frameScheduled = true\n rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16)\n }\n\n async function layoutOnAnimationFrame() {\n // skip frames based on adaptive rate\n if (frameCount++ % skipFrames !== 0) {\n frameScheduled = false\n scheduleLayoutFrame()\n return\n }\n\n // reset frame count to avoid overflow\n if (frameCount >= Number.MAX_SAFE_INTEGER) {\n frameCount = 0\n }\n\n if (strategy !== 'off') {\n const activeNodes: HTMLElement[] = []\n // optimization: deduplicate parent observations\n const parentsToObserve = new Set<HTMLElement>()\n\n // collect non-disabled nodes and their unique parents. off-viewport\n // nodes stay in: a sheet or popper parks off-screen until its own\n // measurement arrives, so gating measurement on visibility deadlocks it\n // there, and RN fires onLayout for off-screen views anyway\n for (const node of Nodes) {\n const parentElement = node.parentElement\n if (!(parentElement instanceof HTMLElement)) {\n cleanupNode(node)\n continue\n }\n const disableKey = LayoutDisableKey.get(node)\n if (disableKey && DisableLayoutContextValues[disableKey] === true) continue\n activeNodes.push(node)\n parentsToObserve.add(parentElement)\n }\n\n if (activeNodes.length > 0) {\n const io = ensureRectFetchObserver()\n rectFetchStartTime = performance.now()\n\n // observe all nodes\n for (let i = 0; i < activeNodes.length; i++) {\n io.observe(activeNodes[i])\n }\n // optimization: observe unique parents only (not N times for N children)\n for (const parent of parentsToObserve) {\n io.observe(parent)\n }\n\n // wait for callback\n await new Promise<boolean>((res) => {\n rectFetchResolve = res\n })\n\n // unobserve all to reset for next cycle\n for (let i = 0; i < activeNodes.length; i++) {\n io.unobserve(activeNodes[i])\n }\n for (const parent of parentsToObserve) {\n io.unobserve(parent)\n }\n\n // adaptive backoff: if IO was slow, skip more frames next cycle\n if (lastCallbackDelay > 50) {\n skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES)\n } else if (lastCallbackDelay < 20) {\n // recover back to base rate when things are fast\n skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES)\n }\n\n // process updates\n for (let i = 0; i < activeNodes.length; i++) {\n updateLayoutIfChanged(activeNodes[i])\n }\n }\n }\n\n // schedule next frame\n frameScheduled = false\n scheduleLayoutFrame()\n }\n\n resumeLayoutLoop = scheduleLayoutFrame\n measureOnNextFrame = () => {\n frameCount = 0\n scheduleLayoutFrame()\n }\n document.addEventListener('visibilitychange', scheduleLayoutFrame)\n scheduleLayoutFrame()\n}\n\nexport const getElementLayoutEvent = (\n nodeRect: DOMRectReadOnly,\n parentRect: DOMRectReadOnly,\n node?: HTMLElement\n): LayoutEvent => {\n return {\n nativeEvent: {\n layout: getRelativeDimensions(nodeRect, parentRect, node),\n target: nodeRect,\n },\n timeStamp: Date.now(),\n }\n}\n\n/**\n * get pre-transform dimensions for a node.\n * uses offsetWidth/offsetHeight which report CSS layout dimensions\n * unaffected by transforms - this matches React Native's onLayout behavior.\n *\n * see: https://github.com/tamagui/tamagui/pull/2329\n */\nconst getPreTransformDimensions = (\n node: HTMLElement\n): { width: number; height: number } => {\n return {\n width: node.offsetWidth,\n height: node.offsetHeight,\n }\n}\n\nconst getRelativeDimensions = (\n a: DOMRectReadOnly,\n b: DOMRectReadOnly,\n aNode?: HTMLElement\n) => {\n const { left, top } = a\n const x = left - b.left\n const y = top - b.top\n\n // get pre-transform dimensions when flag is enabled and node is available\n const { width, height } =\n usePretransformDimensions() && aNode\n ? getPreTransformDimensions(aNode)\n : { width: a.width, height: a.height }\n\n return { x, y, width, height, pageX: a.left, pageY: a.top }\n}\n\nfunction emitLayoutIfChanged(\n node: HTMLElement,\n parentNode: HTMLElement,\n nodeRect: DOMRectReadOnly,\n parentRect: DOMRectReadOnly\n) {\n const onLayout = LayoutHandlers.get(node)\n if (typeof onLayout !== 'function') return\n\n const cachedRect = NodeRectCache.get(node)\n const cachedParentRect = NodeRectCache.get(parentNode)\n\n const nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect)\n const parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect)\n\n if (!nodeChanged && !parentChanged) return\n\n NodeRectCache.set(node, nodeRect)\n NodeRectCache.set(parentNode, parentRect)\n\n const event = getElementLayoutEvent(nodeRect, parentRect, node)\n\n if (process.env.NODE_ENV === 'development' && isDebugLayout()) {\n console.log('[useElementLayout] change', {\n tag: node.tagName,\n id: node.id || undefined,\n className: (node.className || '').slice(0, 60) || undefined,\n layout: event.nativeEvent.layout,\n first: !cachedRect,\n })\n }\n\n if (avoidUpdates) {\n queuedUpdates.set(node, () => onLayout(event))\n } else {\n onLayout(event)\n }\n}\n\nfunction observeLayoutNode(node: HTMLElement, disableKey?: string) {\n Nodes.add(node)\n if (disableKey) {\n LayoutDisableKey.set(node, disableKey)\n } else {\n LayoutDisableKey.delete(node)\n }\n resumeLayoutLoop?.()\n}\n\n// register an arbitrary DOM element into the measurement loop without React lifecycle\nexport function registerLayoutNode(\n node: HTMLElement,\n onChange: () => void,\n disableKey?: string\n): () => void {\n LayoutHandlers.set(node, onChange)\n observeLayoutNode(node, disableKey)\n return () => cleanupNode(node)\n}\n\nfunction cleanupNode(node: HTMLElement) {\n Nodes.delete(node)\n LayoutHandlers.delete(node)\n LayoutDisableKey.delete(node)\n NodeRectCache.delete(node)\n}\n\nconst PrevHostNode = new WeakMap<object, HTMLElement | undefined>()\n\n// spec: onLayout fires one synchronous initial event on mount and on host swap\n// (RN parity, and before-paint so consumers can position without flicker).\n// bypasses the avoidUpdates queue on purpose; seeds the rect cache so the\n// measurement loop doesn't re-emit an identical event a frame later.\nfunction emitLayoutSync(node: HTMLElement) {\n const onLayout = LayoutHandlers.get(node)\n if (typeof onLayout !== 'function') return\n const parentNode = node.parentElement\n if (!parentNode) return\n\n const nodeRect = node.getBoundingClientRect()\n const parentRect = parentNode.getBoundingClientRect()\n NodeRectCache.set(node, nodeRect)\n NodeRectCache.set(parentNode, parentRect)\n onLayout(getElementLayoutEvent(nodeRect, parentRect, node))\n}\n\nexport function useElementLayout(\n ref: RefObject<TamaguiComponentStatePartial>,\n onLayout?: ((e: LayoutEvent) => void) | null\n): void {\n const disableKey = useContext(DisableLayoutContextKey)\n\n // keep handlers up to date so polling always calls the latest callback\n const node = ensureWebElement(ref.current?.host)\n if (node && onLayout) {\n LayoutHandlers.set(node, onLayout)\n LayoutDisableKey.set(node, disableKey)\n }\n\n // detect mounts + host swaps after commit and fire the immediate sync layout event\n useIsomorphicLayoutEffect(() => {\n if (!onLayout) return\n const nextNode = ensureWebElement(ref.current?.host)\n const prevNode = PrevHostNode.get(ref)\n if (nextNode === prevNode) return\n\n if (prevNode) cleanupNode(prevNode)\n PrevHostNode.set(ref, nextNode)\n if (!nextNode) return\n\n LayoutHandlers.set(nextNode, onLayout)\n observeLayoutNode(nextNode, disableKey)\n emitLayoutSync(nextNode)\n })\n\n useIsomorphicLayoutEffect(() => {\n if (!onLayout) return\n const node = ref.current?.host\n if (!node) return\n\n LayoutHandlers.set(node, onLayout)\n observeLayoutNode(node, disableKey)\n\n if (process.env.NODE_ENV === 'development' && isDebugLayout()) {\n console.log('[useElementLayout] register', {\n tag: node.tagName,\n id: node.id || undefined,\n className: (node.className || '').slice(0, 60) || undefined,\n totalNodes: Nodes.size,\n })\n }\n\n return () => {\n cleanupNode(node)\n\n // also clean up any node from a mid-lifecycle host swap\n const swappedNode = PrevHostNode.get(ref)\n if (swappedNode && swappedNode !== node) {\n cleanupNode(swappedNode)\n }\n PrevHostNode.delete(ref)\n }\n }, [ref, !!onLayout])\n}\n\nfunction ensureWebElement<X>(x: X): HTMLElement | undefined {\n if (typeof HTMLElement === 'undefined') {\n return undefined\n }\n return x instanceof HTMLElement ? x : undefined\n}\n\nexport const getBoundingClientRectAsync = (\n node: HTMLElement | null\n): Promise<DOMRectReadOnly | false> => {\n return new Promise<DOMRectReadOnly | false>((res) => {\n if (!node || node.nodeType !== 1) return res(false)\n\n const io = new IntersectionObserver(\n (entries) => {\n io.disconnect()\n return res(entries[0].boundingClientRect)\n },\n {\n threshold: 0,\n }\n )\n io.observe(node)\n })\n}\n\nexport const measureNode = async (\n node: HTMLElement,\n relativeTo?: HTMLElement | null\n): Promise<null | LayoutValue> => {\n const relativeNode = relativeTo || node?.parentElement\n if (relativeNode instanceof HTMLElement) {\n const [nodeDim, relativeNodeDim] = await Promise.all([\n getBoundingClientRectAsync(node),\n getBoundingClientRectAsync(relativeNode),\n ])\n if (relativeNodeDim && nodeDim) {\n return getRelativeDimensions(nodeDim, relativeNodeDim, node)\n }\n }\n return null\n}\n\ntype MeasureInWindowCb = (x: number, y: number, width: number, height: number) => void\n\ntype MeasureCb = (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n) => void\n\nexport const measure = async (\n node: HTMLElement,\n callback: MeasureCb\n): Promise<LayoutValue | null> => {\n const out = await measureNode(\n node,\n node.parentNode instanceof HTMLElement ? node.parentNode : null\n )\n if (out) {\n callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY)\n }\n return out\n}\n\nexport function createMeasure(\n node: HTMLElement\n): (callback: MeasureCb) => Promise<LayoutValue | null> {\n return (callback) => measure(node, callback)\n}\n\ntype WindowLayout = { pageX: number; pageY: number; width: number; height: number }\n\nexport const measureInWindow = async (\n node: HTMLElement,\n callback: MeasureInWindowCb\n): Promise<WindowLayout | null> => {\n const out = await measureNode(node, null)\n if (out) {\n callback?.(out.pageX, out.pageY, out.width, out.height)\n }\n return out\n}\n\nexport const createMeasureInWindow = (\n node: HTMLElement\n): ((callback: MeasureInWindowCb) => Promise<WindowLayout | null>) => {\n return (callback) => measureInWindow(node, callback)\n}\n\nexport const measureLayout = async (\n node: HTMLElement,\n relativeNode: HTMLElement,\n callback: MeasureCb\n): Promise<LayoutValue | null> => {\n const out = await measureNode(node, relativeNode)\n if (out) {\n callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY)\n }\n return out\n}\n\nexport function createMeasureLayout(\n node: HTMLElement\n): (relativeTo: HTMLElement, callback: MeasureCb) => Promise<LayoutValue | null> {\n return (relativeTo, callback) => measureLayout(node, relativeTo, callback)\n}\n"
9
+ "import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { createContext, useContext, useId, type ReactNode, type RefObject } from 'react'\n\nconst LayoutHandlers = new WeakMap<HTMLElement, Function>()\nconst LayoutDisableKey = new WeakMap<HTMLElement, string>()\nconst Nodes = new Set<HTMLElement>()\n\n// feature flag to enable pre-transform dimension reporting (matches RN behavior)\n// can be set via env var at build time or runtime global for testing\n// see: https://github.com/tamagui/tamagui/pull/2329\nconst usePretransformDimensions = () =>\n (globalThis as any).__TAMAGUI_ONLAYOUT_PRETRANSFORM === true ||\n process.env.TAMAGUI_ONLAYOUT_PRETRANSFORM === '1'\n\nlet _debugLayout: boolean | undefined\n\nfunction isDebugLayout() {\n if (_debugLayout === undefined) {\n _debugLayout =\n typeof window !== 'undefined' &&\n new URLSearchParams(window.location.search).has('__tamaDebugLayout')\n }\n return _debugLayout\n}\n\n// separating to avoid all re-rendering\nconst DisableLayoutContextValues: Record<string, boolean> = {}\nconst DisableLayoutContextKey = createContext<string>('')\n\nconst ENABLE =\n process.env.TAMAGUI_TARGET === 'web' && typeof IntersectionObserver !== 'undefined'\n\n// internal testing - advanced helper to turn off layout measurement for extra performance\n// TODO document!\n// TODO could add frame skip control here\nexport const LayoutMeasurementController = ({\n disable,\n children,\n}: {\n disable: boolean\n children: ReactNode\n}): ReactNode => {\n const id = useId()\n\n useIsomorphicLayoutEffect(() => {\n const wasDisabled = DisableLayoutContextValues[id] === true\n DisableLayoutContextValues[id] = disable\n // a controller flipping to enabled (a sheet or popper opening) is often\n // waiting on a measurement to position itself, so don't make it sit out\n // the frame-skip window\n if (wasDisabled && !disable) {\n measureOnNextFrame?.()\n }\n }, [disable, id])\n\n return (\n <DisableLayoutContextKey.Provider value={id}>\n {children}\n </DisableLayoutContextKey.Provider>\n )\n}\n\ntype TamaguiComponentStatePartial = {\n host?: any\n}\n\ntype LayoutMeasurementStrategy = 'off' | 'sync' | 'async'\n\nlet strategy: LayoutMeasurementStrategy = 'async'\n\n// the measurement loop parks itself whenever it provably has nothing to do: no\n// registered nodes, a hidden document, or measurement turned off. these are the\n// only three ways work can reappear, so each one restarts it.\nlet resumeLayoutLoop: (() => void) | undefined\n\n// restarts the loop AND makes its next frame a measuring frame, skipping the\n// frame-skip backoff once. for consumers whose position depends on a pending\n// measurement (an opening sheet parked off-screen).\nlet measureOnNextFrame: (() => void) | undefined\n\nexport type LayoutValue = {\n x: number\n y: number\n width: number\n height: number\n pageX: number\n pageY: number\n}\n\nexport type LayoutEvent = {\n nativeEvent: {\n layout: LayoutValue\n target: any\n }\n timeStamp: number\n}\n\nconst NodeRectCache = new WeakMap<HTMLElement, DOMRectReadOnly>()\n\n// prevent thrashing during first hydration (somewhat, streaming gets trickier)\nlet avoidUpdates = true\nconst queuedUpdates = new Map<HTMLElement, Function>()\n\nexport function enable(): void {\n if (avoidUpdates) {\n avoidUpdates = false\n if (queuedUpdates) {\n queuedUpdates.forEach((cb) => cb())\n queuedUpdates.clear()\n }\n }\n}\n\n// optimization: inline rect comparison to avoid function call overhead on hot path\nfunction rectsEqual(a: DOMRectReadOnly, b: DOMRectReadOnly): boolean {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height\n}\n\nif (ENABLE) {\n const BoundingRects = new WeakMap<Element, DOMRectReadOnly>()\n\n // optimization: persistent IO for rect fetching, reused across cycles\n let rectFetchObserver: IntersectionObserver | null = null\n let rectFetchResolve: ((value: boolean) => void) | null = null\n let rectFetchStartTime = 0\n let lastCallbackDelay = 0\n\n function ensureRectFetchObserver() {\n if (rectFetchObserver) return rectFetchObserver\n\n rectFetchObserver = new IntersectionObserver(\n (entries) => {\n lastCallbackDelay = Math.round(performance.now() - rectFetchStartTime)\n\n // store all rects\n for (let i = 0; i < entries.length; i++) {\n BoundingRects.set(entries[i].target, entries[i].boundingClientRect)\n }\n\n if (\n process.env.NODE_ENV === 'development' &&\n isDebugLayout() &&\n lastCallbackDelay > 50\n ) {\n console.warn(\n '[onLayout-io-delay]',\n lastCallbackDelay + 'ms',\n entries.length,\n 'entries'\n )\n }\n\n if (rectFetchResolve) {\n rectFetchResolve(true)\n rectFetchResolve = null\n }\n },\n {\n threshold: 0,\n }\n )\n\n return rectFetchObserver\n }\n\n async function updateLayoutIfChanged(node: HTMLElement) {\n const onLayout = LayoutHandlers.get(node)\n if (typeof onLayout !== 'function') return\n\n const parentNode = node.parentElement\n if (!parentNode) return\n\n let nodeRect: DOMRectReadOnly | undefined\n let parentRect: DOMRectReadOnly | undefined\n\n // respect the strategy contract\n if (strategy === 'async') {\n nodeRect = BoundingRects.get(node)\n parentRect = BoundingRects.get(parentNode)\n\n if (!nodeRect || !parentRect) {\n return\n }\n } else {\n nodeRect = node.getBoundingClientRect()\n parentRect = parentNode.getBoundingClientRect()\n }\n\n emitLayoutIfChanged(node, parentNode, nodeRect, parentRect)\n }\n\n const rAF =\n typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame : undefined\n\n // adaptive frame skipping with backoff\n const userSkipVal = process.env.TAMAGUI_LAYOUT_FRAME_SKIP\n const BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10\n const MAX_SKIP_FRAMES = 20\n let skipFrames = BASE_SKIP_FRAMES\n let frameCount = 0\n\n // stays true across the await below so a node registering mid-cycle cannot\n // start a second concurrent loop\n let frameScheduled = false\n\n function scheduleLayoutFrame() {\n if (frameScheduled || strategy === 'off' || Nodes.size === 0 || document.hidden) {\n return\n }\n frameScheduled = true\n rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16)\n }\n\n async function layoutOnAnimationFrame() {\n // skip frames based on adaptive rate\n if (frameCount++ % skipFrames !== 0) {\n frameScheduled = false\n scheduleLayoutFrame()\n return\n }\n\n // reset frame count to avoid overflow\n if (frameCount >= Number.MAX_SAFE_INTEGER) {\n frameCount = 0\n }\n\n if (strategy !== 'off') {\n const activeNodes: HTMLElement[] = []\n // optimization: deduplicate parent observations\n const parentsToObserve = new Set<HTMLElement>()\n\n // collect non-disabled nodes and their unique parents. off-viewport\n // nodes stay in: a sheet or popper parks off-screen until its own\n // measurement arrives, so gating measurement on visibility deadlocks it\n // there, and RN fires onLayout for off-screen views anyway\n for (const node of Nodes) {\n const parentElement = node.parentElement\n if (!(parentElement instanceof HTMLElement)) {\n cleanupNode(node)\n continue\n }\n const disableKey = LayoutDisableKey.get(node)\n if (disableKey && DisableLayoutContextValues[disableKey] === true) continue\n activeNodes.push(node)\n parentsToObserve.add(parentElement)\n }\n\n if (activeNodes.length > 0) {\n const io = ensureRectFetchObserver()\n rectFetchStartTime = performance.now()\n\n // observe all nodes\n for (let i = 0; i < activeNodes.length; i++) {\n io.observe(activeNodes[i])\n }\n // optimization: observe unique parents only (not N times for N children)\n for (const parent of parentsToObserve) {\n io.observe(parent)\n }\n\n // wait for callback\n await new Promise<boolean>((res) => {\n rectFetchResolve = res\n })\n\n // unobserve all to reset for next cycle\n for (let i = 0; i < activeNodes.length; i++) {\n io.unobserve(activeNodes[i])\n }\n for (const parent of parentsToObserve) {\n io.unobserve(parent)\n }\n\n // adaptive backoff: if IO was slow, skip more frames next cycle\n if (lastCallbackDelay > 50) {\n skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES)\n } else if (lastCallbackDelay < 20) {\n // recover back to base rate when things are fast\n skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES)\n }\n\n // process updates\n for (let i = 0; i < activeNodes.length; i++) {\n updateLayoutIfChanged(activeNodes[i])\n }\n }\n }\n\n // schedule next frame\n frameScheduled = false\n scheduleLayoutFrame()\n }\n\n resumeLayoutLoop = scheduleLayoutFrame\n measureOnNextFrame = () => {\n frameCount = 0\n scheduleLayoutFrame()\n }\n document.addEventListener('visibilitychange', scheduleLayoutFrame)\n scheduleLayoutFrame()\n}\n\nexport const getElementLayoutEvent = (\n nodeRect: DOMRectReadOnly,\n parentRect: DOMRectReadOnly,\n node?: HTMLElement\n): LayoutEvent => {\n return {\n nativeEvent: {\n layout: getRelativeDimensions(nodeRect, parentRect, node),\n target: nodeRect,\n },\n timeStamp: Date.now(),\n }\n}\n\n/**\n * get pre-transform dimensions for a node.\n * uses offsetWidth/offsetHeight which report CSS layout dimensions\n * unaffected by transforms - this matches React Native's onLayout behavior.\n *\n * see: https://github.com/tamagui/tamagui/pull/2329\n */\nconst getPreTransformDimensions = (\n node: HTMLElement\n): { width: number; height: number } => {\n return {\n width: node.offsetWidth,\n height: node.offsetHeight,\n }\n}\n\nconst getRelativeDimensions = (\n a: DOMRectReadOnly,\n b: DOMRectReadOnly,\n aNode?: HTMLElement\n) => {\n const { left, top } = a\n const x = left - b.left\n const y = top - b.top\n\n // get pre-transform dimensions when flag is enabled and node is available\n const { width, height } =\n usePretransformDimensions() && aNode\n ? getPreTransformDimensions(aNode)\n : { width: a.width, height: a.height }\n\n return { x, y, width, height, pageX: a.left, pageY: a.top }\n}\n\nfunction emitLayoutIfChanged(\n node: HTMLElement,\n parentNode: HTMLElement,\n nodeRect: DOMRectReadOnly,\n parentRect: DOMRectReadOnly\n) {\n const onLayout = LayoutHandlers.get(node)\n if (typeof onLayout !== 'function') return\n\n const cachedRect = NodeRectCache.get(node)\n const cachedParentRect = NodeRectCache.get(parentNode)\n\n const nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect)\n const parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect)\n\n if (!nodeChanged && !parentChanged) return\n\n NodeRectCache.set(node, nodeRect)\n NodeRectCache.set(parentNode, parentRect)\n\n const event = getElementLayoutEvent(nodeRect, parentRect, node)\n\n if (process.env.NODE_ENV === 'development' && isDebugLayout()) {\n console.log('[useElementLayout] change', {\n tag: node.tagName,\n id: node.id || undefined,\n className: (node.className || '').slice(0, 60) || undefined,\n layout: event.nativeEvent.layout,\n first: !cachedRect,\n })\n }\n\n if (avoidUpdates) {\n queuedUpdates.set(node, () => onLayout(event))\n } else {\n onLayout(event)\n }\n}\n\nfunction observeLayoutNode(node: HTMLElement, disableKey?: string) {\n Nodes.add(node)\n if (disableKey) {\n LayoutDisableKey.set(node, disableKey)\n } else {\n LayoutDisableKey.delete(node)\n }\n resumeLayoutLoop?.()\n}\n\n// register an arbitrary DOM element into the measurement loop without React lifecycle\nexport function registerLayoutNode(\n node: HTMLElement,\n onChange: () => void,\n disableKey?: string\n): () => void {\n LayoutHandlers.set(node, onChange)\n observeLayoutNode(node, disableKey)\n return () => cleanupNode(node)\n}\n\nfunction cleanupNode(node: HTMLElement) {\n Nodes.delete(node)\n LayoutHandlers.delete(node)\n LayoutDisableKey.delete(node)\n NodeRectCache.delete(node)\n}\n\nconst PrevHostNode = new WeakMap<object, HTMLElement | undefined>()\n\n// spec: onLayout fires one synchronous initial event on mount and on host swap\n// (RN parity, and before-paint so consumers can position without flicker).\n// bypasses the avoidUpdates queue on purpose; seeds the rect cache so the\n// measurement loop doesn't re-emit an identical event a frame later.\nfunction emitLayoutSync(node: HTMLElement) {\n const onLayout = LayoutHandlers.get(node)\n if (typeof onLayout !== 'function') return\n const parentNode = node.parentElement\n if (!parentNode) return\n\n const nodeRect = node.getBoundingClientRect()\n const parentRect = parentNode.getBoundingClientRect()\n NodeRectCache.set(node, nodeRect)\n NodeRectCache.set(parentNode, parentRect)\n onLayout(getElementLayoutEvent(nodeRect, parentRect, node))\n}\n\nexport function useElementLayout(\n ref: RefObject<TamaguiComponentStatePartial>,\n onLayout?: ((e: LayoutEvent) => void) | null\n): void {\n const disableKey = useContext(DisableLayoutContextKey)\n\n // keep handlers up to date so polling always calls the latest callback\n const node = ensureWebElement(ref.current?.host)\n if (node && onLayout) {\n LayoutHandlers.set(node, onLayout)\n LayoutDisableKey.set(node, disableKey)\n }\n\n // detect mounts + host swaps after commit and fire the immediate sync layout event\n useIsomorphicLayoutEffect(() => {\n if (!onLayout) return\n const nextNode = ensureWebElement(ref.current?.host)\n const prevNode = PrevHostNode.get(ref)\n if (nextNode === prevNode) return\n\n if (prevNode) cleanupNode(prevNode)\n PrevHostNode.set(ref, nextNode)\n if (!nextNode) return\n\n LayoutHandlers.set(nextNode, onLayout)\n observeLayoutNode(nextNode, disableKey)\n emitLayoutSync(nextNode)\n })\n\n useIsomorphicLayoutEffect(() => {\n if (!onLayout) return\n const node = ref.current?.host\n if (!node) return\n\n LayoutHandlers.set(node, onLayout)\n observeLayoutNode(node, disableKey)\n\n if (process.env.NODE_ENV === 'development' && isDebugLayout()) {\n console.log('[useElementLayout] register', {\n tag: node.tagName,\n id: node.id || undefined,\n className: (node.className || '').slice(0, 60) || undefined,\n totalNodes: Nodes.size,\n })\n }\n\n return () => {\n cleanupNode(node)\n\n // also clean up any node from a mid-lifecycle host swap\n const swappedNode = PrevHostNode.get(ref)\n if (swappedNode && swappedNode !== node) {\n cleanupNode(swappedNode)\n }\n PrevHostNode.delete(ref)\n }\n }, [ref, !!onLayout])\n}\n\nfunction ensureWebElement<X>(x: X): HTMLElement | undefined {\n if (typeof HTMLElement === 'undefined') {\n return undefined\n }\n return x instanceof HTMLElement ? x : undefined\n}\n\nexport const getBoundingClientRectAsync = (\n node: HTMLElement | null\n): Promise<DOMRectReadOnly | false> => {\n return new Promise<DOMRectReadOnly | false>((res) => {\n if (!node || node.nodeType !== 1) return res(false)\n\n const io = new IntersectionObserver(\n (entries) => {\n io.disconnect()\n return res(entries[0].boundingClientRect)\n },\n {\n threshold: 0,\n }\n )\n io.observe(node)\n })\n}\n\nexport const measureNode = async (\n node: HTMLElement,\n relativeTo?: HTMLElement | null\n): Promise<null | LayoutValue> => {\n const relativeNode = relativeTo || node?.parentElement\n if (relativeNode instanceof HTMLElement) {\n const [nodeDim, relativeNodeDim] = await Promise.all([\n getBoundingClientRectAsync(node),\n getBoundingClientRectAsync(relativeNode),\n ])\n if (relativeNodeDim && nodeDim) {\n return getRelativeDimensions(nodeDim, relativeNodeDim, node)\n }\n }\n return null\n}\n\ntype MeasureInWindowCb = (x: number, y: number, width: number, height: number) => void\n\ntype MeasureCb = (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n) => void\n\nexport const measure = async (\n node: HTMLElement,\n callback: MeasureCb\n): Promise<LayoutValue | null> => {\n const out = await measureNode(\n node,\n node.parentNode instanceof HTMLElement ? node.parentNode : null\n )\n if (out) {\n callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY)\n }\n return out\n}\n\nexport function createMeasure(\n node: HTMLElement\n): (callback: MeasureCb) => Promise<LayoutValue | null> {\n return (callback) => measure(node, callback)\n}\n\ntype WindowLayout = { pageX: number; pageY: number; width: number; height: number }\n\nexport const measureInWindow = async (\n node: HTMLElement,\n callback: MeasureInWindowCb\n): Promise<WindowLayout | null> => {\n const out = await measureNode(node, null)\n if (out) {\n callback?.(out.pageX, out.pageY, out.width, out.height)\n }\n return out\n}\n\nexport const createMeasureInWindow = (\n node: HTMLElement\n): ((callback: MeasureInWindowCb) => Promise<WindowLayout | null>) => {\n return (callback) => measureInWindow(node, callback)\n}\n\nexport const measureLayout = async (\n node: HTMLElement,\n relativeNode: HTMLElement,\n callback: MeasureCb\n): Promise<LayoutValue | null> => {\n const out = await measureNode(node, relativeNode)\n if (out) {\n callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY)\n }\n return out\n}\n\nexport function createMeasureLayout(\n node: HTMLElement\n): (relativeTo: HTMLElement, callback: MeasureCb) => Promise<LayoutValue | null> {\n return (relativeTo, callback) => measureLayout(node, relativeTo, callback)\n}\n"
10
10
  ]
11
11
  }