@hanzogui/use-element-layout 8.3.1 → 8.3.2

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.
@@ -1 +1 @@
1
- {"version":3,"names":["useIsomorphicLayoutEffect","createContext","useContext","useId","jsx","LayoutHandlers","WeakMap","LayoutDisableKey","Nodes","Set","IntersectionState","usePretransformDimensions","globalThis","__GUI_ONLAYOUT_PRETRANSFORM","process","env","GUI_ONLAYOUT_PRETRANSFORM","_debugLayout","isDebugLayout","window","URLSearchParams","location","search","has","DisableLayoutContextValues","DisableLayoutContextKey","ENABLE","IntersectionObserver","LayoutMeasurementController","disable","children","id","Provider","value","globalIntersectionObserver","strategy","setOnLayoutStrategy","state","NodeRectCache","avoidUpdates","queuedUpdates","Map","enable","forEach","cb","clear","startGlobalObservers","entries","i","length","entry","node","target","get","isIntersecting","set","threshold","rectsEqual","a","b","x","y","width","height","ensureRectFetchObserver","rectFetchObserver","lastCallbackDelay","Math","round","performance","now","rectFetchStartTime","BoundingRects","boundingClientRect","NODE_ENV","console","warn","rectFetchResolve","updateLayoutIfChanged","parentNode","parentElement","nodeRect","parentRect","getBoundingClientRect","emitLayoutIfChanged","rAF","requestAnimationFrame","userSkipVal","GUI_LAYOUT_FRAME_SKIP","BASE_SKIP_FRAMES","MAX_SKIP_FRAMES","skipFrames","frameCount","layoutOnAnimationFrame","setTimeout","Number","MAX_SAFE_INTEGER","visibleNodes","parentsToObserve","HTMLElement","cleanupNode","disableKey","push","add","io","observe","parent","Promise","res","unobserve","min","max","getElementLayoutEvent","nativeEvent","layout","getRelativeDimensions","timeStamp","Date","getPreTransformDimensions","offsetWidth","offsetHeight","aNode","left","top","pageX","pageY","onLayout","cachedRect","cachedParentRect","nodeChanged","parentChanged","event","log","tag","tagName","className","slice","first","observeLayoutNode","delete","registerLayoutNode","onChange","PrevHostNode","emitLayoutSync","useElementLayout","ref","ensureWebElement","current","host","nextNode","prevNode","node2","totalNodes","size","swappedNode","getBoundingClientRectAsync","nodeType","disconnect","measureNode","relativeTo","relativeNode","nodeDim","relativeNodeDim","all","measure","callback","out","createMeasure","measureInWindow","createMeasureInWindow","measureLayout","createMeasureLayout"],"sources":["index.mjs"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@hanzogui/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 IntersectionState = /* @__PURE__ */ new WeakMap();\nconst usePretransformDimensions = () => globalThis.__GUI_ONLAYOUT_PRETRANSFORM === true || process.env.GUI_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\tDisableLayoutContextValues[id] = disable;\n\t}, [disable, id]);\n\treturn /* @__PURE__ */ jsx(DisableLayoutContextKey.Provider, {\n\t\tvalue: id,\n\t\tchildren\n\t});\n};\nlet globalIntersectionObserver = null;\nlet strategy = \"async\";\nfunction setOnLayoutStrategy(state) {\n\tstrategy = state;\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 startGlobalObservers() {\n\tif (!ENABLE || globalIntersectionObserver) return;\n\tglobalIntersectionObserver = new IntersectionObserver((entries) => {\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst entry = entries[i];\n\t\t\tconst node = entry.target;\n\t\t\tif (IntersectionState.get(node) !== entry.isIntersecting) IntersectionState.set(node, entry.isIntersecting);\n\t\t}\n\t}, { threshold: 0 });\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};\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.GUI_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\tasync function layoutOnAnimationFrame() {\n\t\tif (frameCount++ % skipFrames !== 0) {\n\t\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\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 visibleNodes = [];\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\tif (IntersectionState.get(node) === false) continue;\n\t\t\t\tvisibleNodes.push(node);\n\t\t\t\tparentsToObserve.add(parentElement);\n\t\t\t}\n\t\t\tif (visibleNodes.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 < visibleNodes.length; i++) io.observe(visibleNodes[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 < visibleNodes.length; i++) io.unobserve(visibleNodes[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 < visibleNodes.length; i++) updateLayoutIfChanged(visibleNodes[i]);\n\t\t\t}\n\t\t}\n\t\trAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);\n\t}\n\tlayoutOnAnimationFrame();\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\tstartGlobalObservers();\n\tif (globalIntersectionObserver) {\n\t\tglobalIntersectionObserver.observe(node);\n\t\tIntersectionState.set(node, true);\n\t}\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\tIntersectionState.delete(node);\n\tif (globalIntersectionObserver) globalIntersectionObserver.unobserve(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":"AAAA,SAASA,yBAAyB,QAAQ,qBAAqB;AAC/D,SAASC,aAAa,EAAEC,UAAU,EAAEC,KAAK,QAAQ,OAAO;AACxD,SAASC,GAAG,QAAQ,mBAAmB;AAEvC,MAAMC,cAAc,GAAG,eAAgB,IAAIC,OAAO,CAAC,CAAC;AACpD,MAAMC,gBAAgB,GAAG,eAAgB,IAAID,OAAO,CAAC,CAAC;AACtD,MAAME,KAAK,GAAG,eAAgB,IAAIC,GAAG,CAAC,CAAC;AACvC,MAAMC,iBAAiB,GAAG,eAAgB,IAAIJ,OAAO,CAAC,CAAC;AACvD,MAAMK,yBAAyB,GAAGA,CAAA,KAAMC,UAAU,CAACC,2BAA2B,KAAK,IAAI,IAAIC,OAAO,CAACC,GAAG,CAACC,yBAAyB,KAAK,GAAG;AACxI,IAAIC,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D,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,IAAiB,EACgD,EAAE;IACnE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACtD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,IAAiB,EACjB,YAAyB,EACzB,QAAmB,EACU,EAAE;IAC/B,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;IACjD,IAAI,GAAG,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;IACvE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAiB;IAEjB,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;AAC5E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/use-element-layout",
3
- "version": "8.3.1",
3
+ "version": "8.3.2",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "files": [
6
6
  "src",
@@ -9,39 +9,44 @@
9
9
  ],
10
10
  "type": "module",
11
11
  "sideEffects": false,
12
- "main": "dist/cjs",
13
- "module": "dist/esm",
12
+ "main": "./dist/cjs/index.js",
13
+ "module": "./dist/esm/index.js",
14
14
  "types": "./types/index.d.ts",
15
15
  "exports": {
16
16
  "./package.json": "./package.json",
17
17
  ".": {
18
18
  "types": "./types/index.d.ts",
19
- "react-native": "./dist/esm/index.native.js",
20
- "browser": "./dist/esm/index.mjs",
21
- "module": "./dist/esm/index.mjs",
22
- "import": "./dist/esm/index.mjs",
23
- "require": "./dist/cjs/index.cjs",
24
- "default": "./dist/esm/index.mjs"
19
+ "react-native": "./dist/esm/index.js",
20
+ "browser": "./dist/esm/index.js",
21
+ "module": "./dist/esm/index.js",
22
+ "import": "./dist/esm/index.js",
23
+ "require": "./dist/cjs/index.js",
24
+ "default": "./dist/esm/index.js"
25
25
  }
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
30
  "scripts": {
31
- "build": "hanzogui-build",
31
+ "build": "hanzogui-build --skip-native",
32
32
  "watch": "hanzogui-build --watch",
33
33
  "clean": "hanzogui-build clean",
34
34
  "clean:build": "hanzogui-build clean:build"
35
35
  },
36
36
  "dependencies": {
37
- "@hanzogui/constants": "8.3.1",
38
- "@hanzogui/is-equal-shallow": "8.3.1"
37
+ "@hanzogui/constants": "8.3.2",
38
+ "@hanzogui/is-equal-shallow": "8.3.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@hanzogui/build": "8.3.1",
42
- "react": ">=19"
41
+ "@hanzogui/build": "8.3.2",
42
+ "react": "19.2.8"
43
43
  },
44
44
  "peerDependencies": {
45
- "react": ">=19"
45
+ "react": ">=19.2.8"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/hanzoai/gui.git",
50
+ "directory": "pkgs/core/use-element-layout"
46
51
  }
47
52
  }
package/types/index.d.ts CHANGED
@@ -1,27 +1,27 @@
1
- import { type ReactNode, type RefObject } from "react";
2
- export declare const LayoutMeasurementController: ({ disable, children }: {
3
- disable: boolean;
4
- children: ReactNode;
1
+ import { type ReactNode, type RefObject } from 'react';
2
+ export declare const LayoutMeasurementController: ({ disable, children, }: {
3
+ disable: boolean;
4
+ children: ReactNode;
5
5
  }) => ReactNode;
6
6
  type GuiComponentStatePartial = {
7
- host?: any;
7
+ host?: any;
8
8
  };
9
- type LayoutMeasurementStrategy = "off" | "sync" | "async";
9
+ type LayoutMeasurementStrategy = 'off' | 'sync' | 'async';
10
10
  export declare function setOnLayoutStrategy(state: LayoutMeasurementStrategy): void;
11
11
  export type LayoutValue = {
12
- x: number;
13
- y: number;
14
- width: number;
15
- height: number;
16
- pageX: number;
17
- pageY: number;
12
+ x: number;
13
+ y: number;
14
+ width: number;
15
+ height: number;
16
+ pageX: number;
17
+ pageY: number;
18
18
  };
19
19
  export type LayoutEvent = {
20
- nativeEvent: {
21
- layout: LayoutValue;
22
- target: any;
23
- };
24
- timeStamp: number;
20
+ nativeEvent: {
21
+ layout: LayoutValue;
22
+ target: any;
23
+ };
24
+ timeStamp: number;
25
25
  };
26
26
  export declare function enable(): void;
27
27
  export declare const getElementLayoutEvent: (nodeRect: DOMRectReadOnly, parentRect: DOMRectReadOnly, node?: HTMLElement) => LayoutEvent;
@@ -34,15 +34,14 @@ type MeasureCb = (x: number, y: number, width: number, height: number, pageX: nu
34
34
  export declare const measure: (node: HTMLElement, callback: MeasureCb) => Promise<LayoutValue | null>;
35
35
  export declare function createMeasure(node: HTMLElement): (callback: MeasureCb) => Promise<LayoutValue | null>;
36
36
  type WindowLayout = {
37
- pageX: number;
38
- pageY: number;
39
- width: number;
40
- height: number;
37
+ pageX: number;
38
+ pageY: number;
39
+ width: number;
40
+ height: number;
41
41
  };
42
42
  export declare const measureInWindow: (node: HTMLElement, callback: MeasureInWindowCb) => Promise<WindowLayout | null>;
43
43
  export declare const createMeasureInWindow: (node: HTMLElement) => ((callback: MeasureInWindowCb) => Promise<WindowLayout | null>);
44
44
  export declare const measureLayout: (node: HTMLElement, relativeNode: HTMLElement, callback: MeasureCb) => Promise<LayoutValue | null>;
45
45
  export declare function createMeasureLayout(node: HTMLElement): (relativeTo: HTMLElement, callback: MeasureCb) => Promise<LayoutValue | null>;
46
46
  export {};
47
-
48
47
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1 @@
1
- {
2
- "mappings": "AACA,cAAgD,gBAAgB,iBAAiB;AAmCjF,OAAO,cAAM,8BAA+B,EAC1C,SACA,YACC;CACD;CACA,UAAU;MACR;KAiBC,2BAA2B;CAC9B;;KAGG,4BAA4B,QAAQ,SAAS;AAIlD,OAAO,iBAAS,oBAAoB,OAAO;AAI3C,YAAY,cAAc;CACxB;CACA;CACA;CACA;CACA;CACA;;AAGF,YAAY,cAAc;CACxB,aAAa;EACX,QAAQ;EACR;;CAEF;;AASF,OAAO,iBAAS;AAqMhB,OAAO,cAAM,wBACX,UAAU,iBACV,YAAY,iBACZ,OAAO,gBACN;AAkGH,OAAO,iBAAS,mBACd,MAAM,aACN,sBACA;AAqCF,OAAO,iBAAS,iBACd,KAAK,UAAU,2BACf,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
- "names": [],
4
- "sources": [
5
- "src/index.tsx"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
9
- "import { useIsomorphicLayoutEffect } from '@hanzogui/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>()\nconst IntersectionState = new WeakMap<HTMLElement, boolean>()\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/hanzoai/gui/pull/2329\nconst usePretransformDimensions = () =>\n (globalThis as any).__GUI_ONLAYOUT_PRETRANSFORM === true ||\n process.env.GUI_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.GUI_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 DisableLayoutContextValues[id] = disable\n }, [disable, id])\n\n return (\n <DisableLayoutContextKey.Provider value={id}>\n {children}\n </DisableLayoutContextKey.Provider>\n )\n}\n\n// Single persistent IntersectionObserver for visibility tracking\nlet globalIntersectionObserver: IntersectionObserver | null = null\n\ntype GuiComponentStatePartial = {\n host?: any\n}\n\ntype LayoutMeasurementStrategy = 'off' | 'sync' | 'async'\n\nlet strategy: LayoutMeasurementStrategy = 'async'\n\nexport function setOnLayoutStrategy(state: LayoutMeasurementStrategy): void {\n strategy = state\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\nfunction startGlobalObservers() {\n if (!ENABLE || globalIntersectionObserver) return\n\n globalIntersectionObserver = new IntersectionObserver(\n (entries) => {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i]\n const node = entry.target as HTMLElement\n if (IntersectionState.get(node) !== entry.isIntersecting) {\n IntersectionState.set(node, entry.isIntersecting)\n }\n }\n },\n {\n threshold: 0,\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.GUI_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 async function layoutOnAnimationFrame() {\n // skip frames based on adaptive rate\n if (frameCount++ % skipFrames !== 0) {\n rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16)\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 visibleNodes: HTMLElement[] = []\n // optimization: deduplicate parent observations\n const parentsToObserve = new Set<HTMLElement>()\n\n // collect visible nodes and their unique parents\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 if (IntersectionState.get(node) === false) continue\n\n visibleNodes.push(node)\n parentsToObserve.add(parentElement)\n }\n\n if (visibleNodes.length > 0) {\n const io = ensureRectFetchObserver()\n rectFetchStartTime = performance.now()\n\n // observe all nodes\n for (let i = 0; i < visibleNodes.length; i++) {\n io.observe(visibleNodes[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 < visibleNodes.length; i++) {\n io.unobserve(visibleNodes[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 < visibleNodes.length; i++) {\n updateLayoutIfChanged(visibleNodes[i])\n }\n }\n }\n\n // schedule next frame\n rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16)\n }\n\n layoutOnAnimationFrame()\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/hanzoai/gui/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 startGlobalObservers()\n if (globalIntersectionObserver) {\n globalIntersectionObserver.observe(node)\n IntersectionState.set(node, true)\n }\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 IntersectionState.delete(node)\n if (globalIntersectionObserver) {\n globalIntersectionObserver.unobserve(node)\n }\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<GuiComponentStatePartial>,\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
- ]
11
- }
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAoC,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAmCxF,eAAO,MAAM,2BAA2B,2BAGrC;IACD,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,SAAS,CAAA;CACpB,KAAG,SAYH,CAAA;AAKD,KAAK,wBAAwB,GAAG;IAC9B,IAAI,CAAC,EAAE,GAAG,CAAA;CACX,CAAA;AAED,KAAK,yBAAyB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;AAIzD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI,CAE1E;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE;QACX,MAAM,EA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K,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAEtD;AAED,KAAK,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnF,eAAO,MAAM,eAAe,SACpB,WAAW,YACP,iBAAiB,KAC1B,OAAO,CAAC,YAAY,GAAG,IAAI,CAM7B,CAAA;AAED,eAAO,MAAM,qBAAqB,SAC1B,WAAW,KAChB,CAAC,CAAC,QAAQ,EAAE,iBAAiB,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAEhE,CAAA;AAED,eAAO,MAAM,aAAa,SAClB,WAAW,gBACH,WAAW,YACf,SAAS,KAClB,OAAO,CAAC,WAAW,GAAG,IAAI,CAM5B,CAAA;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAChB,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAE/E"}
@@ -1,362 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
- var index_exports = {};
24
- __export(index_exports, {
25
- LayoutMeasurementController: () => LayoutMeasurementController,
26
- createMeasure: () => createMeasure,
27
- createMeasureInWindow: () => createMeasureInWindow,
28
- createMeasureLayout: () => createMeasureLayout,
29
- enable: () => enable,
30
- getBoundingClientRectAsync: () => getBoundingClientRectAsync,
31
- getElementLayoutEvent: () => getElementLayoutEvent,
32
- measure: () => measure,
33
- measureInWindow: () => measureInWindow,
34
- measureLayout: () => measureLayout,
35
- measureNode: () => measureNode,
36
- registerLayoutNode: () => registerLayoutNode,
37
- setOnLayoutStrategy: () => setOnLayoutStrategy,
38
- useElementLayout: () => useElementLayout
39
- });
40
- module.exports = __toCommonJS(index_exports);
41
- var import_constants = require("@hanzogui/constants");
42
- var import_react = require("react");
43
- var import_jsx_runtime = require("react/jsx-runtime");
44
- const LayoutHandlers = /* @__PURE__ */new WeakMap();
45
- const LayoutDisableKey = /* @__PURE__ */new WeakMap();
46
- const Nodes = /* @__PURE__ */new Set();
47
- const IntersectionState = /* @__PURE__ */new WeakMap();
48
- const usePretransformDimensions = () => globalThis.__GUI_ONLAYOUT_PRETRANSFORM === true || process.env.GUI_ONLAYOUT_PRETRANSFORM === "1";
49
- let _debugLayout;
50
- function isDebugLayout() {
51
- if (_debugLayout === void 0) _debugLayout = typeof window !== "undefined" && new URLSearchParams(window.location.search).has("__tamaDebugLayout");
52
- return _debugLayout;
53
- }
54
- const DisableLayoutContextValues = {};
55
- const DisableLayoutContextKey = (0, import_react.createContext)("");
56
- const ENABLE = typeof IntersectionObserver !== "undefined";
57
- const LayoutMeasurementController = ({
58
- disable,
59
- children
60
- }) => {
61
- const id = (0, import_react.useId)();
62
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
63
- DisableLayoutContextValues[id] = disable;
64
- }, [disable, id]);
65
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DisableLayoutContextKey.Provider, {
66
- value: id,
67
- children
68
- });
69
- };
70
- let globalIntersectionObserver = null;
71
- let strategy = "async";
72
- function setOnLayoutStrategy(state) {
73
- strategy = state;
74
- }
75
- const NodeRectCache = /* @__PURE__ */new WeakMap();
76
- let avoidUpdates = true;
77
- const queuedUpdates = /* @__PURE__ */new Map();
78
- function enable() {
79
- if (avoidUpdates) {
80
- avoidUpdates = false;
81
- if (queuedUpdates) {
82
- queuedUpdates.forEach(cb => cb());
83
- queuedUpdates.clear();
84
- }
85
- }
86
- }
87
- function startGlobalObservers() {
88
- if (!ENABLE || globalIntersectionObserver) return;
89
- globalIntersectionObserver = new IntersectionObserver(entries => {
90
- for (let i = 0; i < entries.length; i++) {
91
- const entry = entries[i];
92
- const node = entry.target;
93
- if (IntersectionState.get(node) !== entry.isIntersecting) IntersectionState.set(node, entry.isIntersecting);
94
- }
95
- }, {
96
- threshold: 0
97
- });
98
- }
99
- function rectsEqual(a, b) {
100
- return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
101
- }
102
- if (ENABLE) {
103
- let ensureRectFetchObserver = function () {
104
- if (rectFetchObserver) return rectFetchObserver;
105
- rectFetchObserver = new IntersectionObserver(entries => {
106
- lastCallbackDelay = Math.round(performance.now() - rectFetchStartTime);
107
- for (let i = 0; i < entries.length; i++) BoundingRects.set(entries[i].target, entries[i].boundingClientRect);
108
- if (process.env.NODE_ENV === "development" && isDebugLayout() && lastCallbackDelay > 50) console.warn("[onLayout-io-delay]", lastCallbackDelay + "ms", entries.length, "entries");
109
- if (rectFetchResolve) {
110
- rectFetchResolve(true);
111
- rectFetchResolve = null;
112
- }
113
- }, {
114
- threshold: 0
115
- });
116
- return rectFetchObserver;
117
- };
118
- const BoundingRects = /* @__PURE__ */new WeakMap();
119
- let rectFetchObserver = null;
120
- let rectFetchResolve = null;
121
- let rectFetchStartTime = 0;
122
- let lastCallbackDelay = 0;
123
- async function updateLayoutIfChanged(node) {
124
- if (typeof LayoutHandlers.get(node) !== "function") return;
125
- const parentNode = node.parentElement;
126
- if (!parentNode) return;
127
- let nodeRect;
128
- let parentRect;
129
- if (strategy === "async") {
130
- nodeRect = BoundingRects.get(node);
131
- parentRect = BoundingRects.get(parentNode);
132
- if (!nodeRect || !parentRect) return;
133
- } else {
134
- nodeRect = node.getBoundingClientRect();
135
- parentRect = parentNode.getBoundingClientRect();
136
- }
137
- emitLayoutIfChanged(node, parentNode, nodeRect, parentRect);
138
- }
139
- const rAF = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : void 0;
140
- const userSkipVal = process.env.GUI_LAYOUT_FRAME_SKIP;
141
- const BASE_SKIP_FRAMES = userSkipVal ? +userSkipVal : 10;
142
- const MAX_SKIP_FRAMES = 20;
143
- let skipFrames = BASE_SKIP_FRAMES;
144
- let frameCount = 0;
145
- async function layoutOnAnimationFrame() {
146
- if (frameCount++ % skipFrames !== 0) {
147
- rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);
148
- return;
149
- }
150
- if (frameCount >= Number.MAX_SAFE_INTEGER) frameCount = 0;
151
- if (strategy !== "off") {
152
- const visibleNodes = [];
153
- const parentsToObserve = /* @__PURE__ */new Set();
154
- for (const node of Nodes) {
155
- const parentElement = node.parentElement;
156
- if (!(parentElement instanceof HTMLElement)) {
157
- cleanupNode(node);
158
- continue;
159
- }
160
- const disableKey = LayoutDisableKey.get(node);
161
- if (disableKey && DisableLayoutContextValues[disableKey] === true) continue;
162
- if (IntersectionState.get(node) === false) continue;
163
- visibleNodes.push(node);
164
- parentsToObserve.add(parentElement);
165
- }
166
- if (visibleNodes.length > 0) {
167
- const io = ensureRectFetchObserver();
168
- rectFetchStartTime = performance.now();
169
- for (let i = 0; i < visibleNodes.length; i++) io.observe(visibleNodes[i]);
170
- for (const parent of parentsToObserve) io.observe(parent);
171
- await new Promise(res => {
172
- rectFetchResolve = res;
173
- });
174
- for (let i = 0; i < visibleNodes.length; i++) io.unobserve(visibleNodes[i]);
175
- for (const parent of parentsToObserve) io.unobserve(parent);
176
- if (lastCallbackDelay > 50) skipFrames = Math.min(skipFrames + 2, MAX_SKIP_FRAMES);else if (lastCallbackDelay < 20) skipFrames = Math.max(skipFrames - 1, BASE_SKIP_FRAMES);
177
- for (let i = 0; i < visibleNodes.length; i++) updateLayoutIfChanged(visibleNodes[i]);
178
- }
179
- }
180
- rAF ? rAF(layoutOnAnimationFrame) : setTimeout(layoutOnAnimationFrame, 16);
181
- }
182
- layoutOnAnimationFrame();
183
- }
184
- const getElementLayoutEvent = (nodeRect, parentRect, node) => {
185
- return {
186
- nativeEvent: {
187
- layout: getRelativeDimensions(nodeRect, parentRect, node),
188
- target: nodeRect
189
- },
190
- timeStamp: Date.now()
191
- };
192
- };
193
- const getPreTransformDimensions = node => {
194
- return {
195
- width: node.offsetWidth,
196
- height: node.offsetHeight
197
- };
198
- };
199
- const getRelativeDimensions = (a, b, aNode) => {
200
- const {
201
- left,
202
- top
203
- } = a;
204
- const x = left - b.left;
205
- const y = top - b.top;
206
- const {
207
- width,
208
- height
209
- } = usePretransformDimensions() && aNode ? getPreTransformDimensions(aNode) : {
210
- width: a.width,
211
- height: a.height
212
- };
213
- return {
214
- x,
215
- y,
216
- width,
217
- height,
218
- pageX: a.left,
219
- pageY: a.top
220
- };
221
- };
222
- function emitLayoutIfChanged(node, parentNode, nodeRect, parentRect) {
223
- const onLayout = LayoutHandlers.get(node);
224
- if (typeof onLayout !== "function") return;
225
- const cachedRect = NodeRectCache.get(node);
226
- const cachedParentRect = NodeRectCache.get(parentNode);
227
- const nodeChanged = !cachedRect || !rectsEqual(cachedRect, nodeRect);
228
- const parentChanged = !cachedParentRect || !rectsEqual(cachedParentRect, parentRect);
229
- if (!nodeChanged && !parentChanged) return;
230
- NodeRectCache.set(node, nodeRect);
231
- NodeRectCache.set(parentNode, parentRect);
232
- const event = getElementLayoutEvent(nodeRect, parentRect, node);
233
- if (process.env.NODE_ENV === "development" && isDebugLayout()) console.log("[useElementLayout] change", {
234
- tag: node.tagName,
235
- id: node.id || void 0,
236
- className: (node.className || "").slice(0, 60) || void 0,
237
- layout: event.nativeEvent.layout,
238
- first: !cachedRect
239
- });
240
- if (avoidUpdates) queuedUpdates.set(node, () => onLayout(event));else onLayout(event);
241
- }
242
- function observeLayoutNode(node, disableKey) {
243
- Nodes.add(node);
244
- if (disableKey) LayoutDisableKey.set(node, disableKey);else LayoutDisableKey.delete(node);
245
- startGlobalObservers();
246
- if (globalIntersectionObserver) {
247
- globalIntersectionObserver.observe(node);
248
- IntersectionState.set(node, true);
249
- }
250
- }
251
- function registerLayoutNode(node, onChange, disableKey) {
252
- LayoutHandlers.set(node, onChange);
253
- observeLayoutNode(node, disableKey);
254
- return () => cleanupNode(node);
255
- }
256
- function cleanupNode(node) {
257
- Nodes.delete(node);
258
- LayoutHandlers.delete(node);
259
- LayoutDisableKey.delete(node);
260
- NodeRectCache.delete(node);
261
- IntersectionState.delete(node);
262
- if (globalIntersectionObserver) globalIntersectionObserver.unobserve(node);
263
- }
264
- const PrevHostNode = /* @__PURE__ */new WeakMap();
265
- function emitLayoutSync(node) {
266
- const onLayout = LayoutHandlers.get(node);
267
- if (typeof onLayout !== "function") return;
268
- const parentNode = node.parentElement;
269
- if (!parentNode) return;
270
- const nodeRect = node.getBoundingClientRect();
271
- const parentRect = parentNode.getBoundingClientRect();
272
- NodeRectCache.set(node, nodeRect);
273
- NodeRectCache.set(parentNode, parentRect);
274
- onLayout(getElementLayoutEvent(nodeRect, parentRect, node));
275
- }
276
- function useElementLayout(ref, onLayout) {
277
- const disableKey = (0, import_react.useContext)(DisableLayoutContextKey);
278
- const node = ensureWebElement(ref.current?.host);
279
- if (node && onLayout) {
280
- LayoutHandlers.set(node, onLayout);
281
- LayoutDisableKey.set(node, disableKey);
282
- }
283
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
284
- if (!onLayout) return;
285
- const nextNode = ensureWebElement(ref.current?.host);
286
- const prevNode = PrevHostNode.get(ref);
287
- if (nextNode === prevNode) return;
288
- if (prevNode) cleanupNode(prevNode);
289
- PrevHostNode.set(ref, nextNode);
290
- if (!nextNode) return;
291
- LayoutHandlers.set(nextNode, onLayout);
292
- observeLayoutNode(nextNode, disableKey);
293
- emitLayoutSync(nextNode);
294
- });
295
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
296
- if (!onLayout) return;
297
- const node2 = ref.current?.host;
298
- if (!node2) return;
299
- LayoutHandlers.set(node2, onLayout);
300
- observeLayoutNode(node2, disableKey);
301
- if (process.env.NODE_ENV === "development" && isDebugLayout()) console.log("[useElementLayout] register", {
302
- tag: node2.tagName,
303
- id: node2.id || void 0,
304
- className: (node2.className || "").slice(0, 60) || void 0,
305
- totalNodes: Nodes.size
306
- });
307
- return () => {
308
- cleanupNode(node2);
309
- const swappedNode = PrevHostNode.get(ref);
310
- if (swappedNode && swappedNode !== node2) cleanupNode(swappedNode);
311
- PrevHostNode.delete(ref);
312
- };
313
- }, [ref, !!onLayout]);
314
- }
315
- function ensureWebElement(x) {
316
- if (typeof HTMLElement === "undefined") return;
317
- return x instanceof HTMLElement ? x : void 0;
318
- }
319
- const getBoundingClientRectAsync = node => {
320
- return new Promise(res => {
321
- if (!node || node.nodeType !== 1) return res(false);
322
- const io = new IntersectionObserver(entries => {
323
- io.disconnect();
324
- return res(entries[0].boundingClientRect);
325
- }, {
326
- threshold: 0
327
- });
328
- io.observe(node);
329
- });
330
- };
331
- const measureNode = async (node, relativeTo) => {
332
- const relativeNode = relativeTo || node?.parentElement;
333
- if (relativeNode instanceof HTMLElement) {
334
- const [nodeDim, relativeNodeDim] = await Promise.all([getBoundingClientRectAsync(node), getBoundingClientRectAsync(relativeNode)]);
335
- if (relativeNodeDim && nodeDim) return getRelativeDimensions(nodeDim, relativeNodeDim, node);
336
- }
337
- return null;
338
- };
339
- const measure = async (node, callback) => {
340
- const out = await measureNode(node, node.parentNode instanceof HTMLElement ? node.parentNode : null);
341
- if (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);
342
- return out;
343
- };
344
- function createMeasure(node) {
345
- return callback => measure(node, callback);
346
- }
347
- const measureInWindow = async (node, callback) => {
348
- const out = await measureNode(node, null);
349
- if (out) callback?.(out.pageX, out.pageY, out.width, out.height);
350
- return out;
351
- };
352
- const createMeasureInWindow = node => {
353
- return callback => measureInWindow(node, callback);
354
- };
355
- const measureLayout = async (node, relativeNode, callback) => {
356
- const out = await measureNode(node, relativeNode);
357
- if (out) callback?.(out.x, out.y, out.width, out.height, out.pageX, out.pageY);
358
- return out;
359
- };
360
- function createMeasureLayout(node) {
361
- return (relativeTo, callback) => measureLayout(node, relativeTo, callback);
362
- }