@tamagui/animations-css 3.0.0-beta.669.1 → 3.0.0-beta.728.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.
@@ -1 +1 @@
1
- {"version":3,"file":"createAnimations.js","names":["hasNormalizedAnimation"],"sources":["esm/createAnimations.js"],"sourcesContent":["import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n getEffectiveAnimation\n} from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web\";\nimport React from \"react\";\nimport {\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle\n} from \"./animated-number\";\nconst hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise((resolve) => {\n const check = () => {\n const animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map((a) => a.finished)).then(() => resolve(true)).catch(() => {\n const remaining = node.getAnimations();\n if (remaining.some((a) => a.playState === \"running\" || a.pending)) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nconst DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/;\nfunction applyDurationOverride(animation, durationMs) {\n const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced;\n}\nconst CSS_TRANSFORM_PROPERTIES = {\n transform: [\"translate\", \"scale\", \"rotate\", \"transform\"],\n x: [\"translate\"],\n y: [\"translate\"],\n scale: [\"scale\"],\n scaleX: [\"scale\"],\n scaleY: [\"scale\"],\n rotate: [\"rotate\"],\n rotateX: [\"transform\"],\n rotateY: [\"transform\"],\n rotateZ: [\"transform\"],\n skewX: [\"transform\"],\n skewY: [\"transform\"]\n};\nconst getCSSProperties = (key) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key];\n};\nconst hyphenatedPropertyCache = {};\nconst emptyProperties = [];\nfunction hyphenateProperty(property) {\n if (property.startsWith(\"--\")) return property;\n return hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n );\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!keys?.size) return emptyProperties;\n const properties = /* @__PURE__ */ new Set();\n for (const key of keys) {\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property));\n }\n }\n return [...properties].sort();\n}\nfunction readComputedProperties(node, properties) {\n const computed = getComputedStyle(node);\n const values = {};\n for (const property of properties) {\n const value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (const property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n for (const property of properties) {\n node.style.removeProperty(property);\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition\n }) => {\n const isHydrating = componentState.unmounted === true;\n const isEntering = !!componentState.unmounted;\n const isExiting = presence?.[0] === false;\n const sendExitComplete = presence?.[1];\n const onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n const emit = (phase, cause, finished) => {\n onTransitionRef.current?.(\n phase === \"end\" ? { phase, cause, finished } : { phase, cause }\n );\n };\n const wasEnteringRef = React.useRef(isEntering);\n const justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(() => {\n wasEnteringRef.current = isEntering;\n });\n const exitCycleIdRef = React.useRef(0);\n const exitCompletedRef = React.useRef(false);\n const wasExitingRef = React.useRef(false);\n const sendExitCompleteRef = React.useRef(sendExitComplete);\n const lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n );\n const exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n const enterCycleIdRef = React.useRef(0);\n const enterStartedRef = React.useRef(false);\n const updateCycleIdRef = React.useRef(0);\n const updateInFlightRef = React.useRef(false);\n const prevUpdateSigRef = React.useRef(null);\n const exitStartedRef = React.useRef(false);\n const justStartedExiting = isExiting && !wasExitingRef.current;\n const justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(() => {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return;\n const host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n const node = host;\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature]);\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition;\n const normalized = normalizeTransition(effectiveTransition);\n const animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState);\n const defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;\n const animatedProperties = getAnimatedProperties(normalized);\n const hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;\n const hasPerPropertyConfigs = animatedProperties.length > 0;\n let keys;\n if (props.animateOnly) {\n keys = props.animateOnly;\n } else if (hasPerPropertyConfigs && !hasDefault) {\n keys = animatedProperties;\n } else if (hasPerPropertyConfigs && hasDefault) {\n keys = [\"all\", ...animatedProperties];\n } else {\n keys = [\"all\"];\n }\n let transition;\n const getTransition = () => {\n if (transition !== void 0) return transition;\n const delay = normalized.delay ? ` ${normalized.delay}ms` : \"\";\n const duration = normalized.config?.duration;\n transition = keys.flatMap((key) => {\n const propertyAnimation = normalized.properties[key];\n let animation = defaultAnimation;\n if (typeof propertyAnimation === \"string\") {\n animation = animations[propertyAnimation];\n } else if (propertyAnimation?.type) {\n animation = animations[propertyAnimation.type];\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration);\n }\n return animation ? getCSSProperties(key).map(\n (property) => `${property} ${animation}${delay}`\n ) : [];\n }).join(\", \");\n return transition;\n };\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n const node = host;\n const cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n sendExitCompleteRef.current?.();\n };\n if (keys.length === 0) {\n completeExit();\n return;\n }\n let rafId;\n let disposed = false;\n const mountedStyle = lastMountedStyleRef.current;\n const canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n let exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished);\n });\n return () => {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [isExiting, exitCSSPropertiesSignature]);\n const styleSignature = onTransition ? (() => {\n const { transition: _t, ...rest } = style;\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n const node = host;\n const cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n const node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n const cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [styleSignature, isEntering, justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [justStartedExiting, justStoppedExiting]);\n if (isHydrating) {\n return null;\n }\n if (!hasNormalizedAnimation(normalized)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting\n });\n }\n return { style, className: isEntering ? \"t_unmounted\" : \"\" };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;;;;;;AAgBA,MAAM,SAAS,OAAO,0BAA0B;AAChD,SAAS,kBAAkB,MAAM;CAC/B,IAAI,OAAO,KAAK,kBAAkB,YAAY;EAC5C,OAAO,QAAQ,QAAQ,IAAI;CAC7B;CACA,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,cAAc;GAClB,MAAM,aAAa,KAAK,cAAc;GACtC,IAAI,WAAW,WAAW,GAAG;IAC3B,QAAQ,IAAI;IACZ;GACF;GACA,QAAQ,IAAI,WAAW,KAAK,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,QAAQ,IAAI,CAAC,EAAE,YAAY;IACnF,MAAM,YAAY,KAAK,cAAc;IACrC,IAAI,UAAU,MAAM,MAAM,EAAE,cAAc,aAAa,EAAE,OAAO,GAAG;KACjE,MAAM;KACN;IACF;IACA,QAAQ,KAAK;GACf,CAAC;EACH;EACA,IAAI,QAAQ;GACV,sBAAsB,KAAK;EAC7B,OAAO;GACL,MAAM;EACR;CACF,CAAC;AACH;AACA,MAAM,iBAAiB;AACvB,SAAS,sBAAsB,WAAW,YAAY;CACpD,MAAM,WAAW,UAAU,QAAQ,gBAAgB,GAAG,WAAW,GAAG;CACpE,OAAO,aAAa,YAAY,GAAG,WAAW,KAAK,cAAc;AACnE;AACA,MAAM,2BAA2B;CAC/B,WAAW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AiB,SAAS;IACjD,iBAAiB,UAAU;IAC3B,MAAM,OAAO;IACb,IAAI,kBAAkB,SAAS;KAC7B,KAAK,OAAO,UAAU,KAAK;IAC7B;IACA,kBAAkB,UAAU;IAC5B,MAAM,UAAU,EAAE,iBAAiB;IACnC,KAAK,SAAS,QAAQ;IACtB,KAAK,kBAAkB,IAAI,EAAE,MAAM,aAAa;KAC9C,IAAI,YAAY,iBAAiB,SAAS;KAC1C,kBAAkB,UAAU;KAC5B,KAAK,OAAO,UAAU,QAAQ;IAChC,CAAC;GACH,GAAG;IAAC;IAAgB;IAAY;IAAsB;GAAS,CAAC;GAChE,gCAAgC;IAC9B,IAAI,sBAAsB,gBAAgB,SAAS;KACjD,gBAAgB;KAChB,gBAAgB,UAAU;KAC1B,KAAK,OAAO,SAAS,KAAK;IAC5B;IACA,IAAI,sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CAAC,oBAAoB,kBAAkB,CAAC;GAC3C,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,CAACA,aAAuB,UAAU,GAAG;IACvC,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,YAAY,mBAAmB,MAAM,SAAS;GACtD;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IAAE;IAAO,WAAW,aAAa,gBAAgB;GAAG;EAC7D;CACF;AACF"}
1
+ {"version":3,"file":"createAnimations.js","names":["hasNormalizedAnimation"],"sources":["esm/createAnimations.js"],"sourcesContent":["import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n getEffectiveAnimation\n} from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web\";\nimport React from \"react\";\nconst hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise((resolve) => {\n const check = () => {\n const animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map((a) => a.finished)).then(() => resolve(true)).catch(() => {\n const remaining = node.getAnimations();\n if (remaining.some((a) => a.playState === \"running\" || a.pending)) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nconst DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/;\nfunction applyDurationOverride(animation, durationMs) {\n const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced;\n}\nconst CSS_TRANSFORM_PROPERTIES = {\n transform: [\"translate\", \"scale\", \"rotate\", \"transform\"],\n x: [\"translate\"],\n y: [\"translate\"],\n scale: [\"scale\"],\n scaleX: [\"scale\"],\n scaleY: [\"scale\"],\n rotate: [\"rotate\"],\n rotateX: [\"transform\"],\n rotateY: [\"transform\"],\n rotateZ: [\"transform\"],\n skewX: [\"transform\"],\n skewY: [\"transform\"]\n};\nconst getCSSProperties = (key) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key];\n};\nconst hyphenatedPropertyCache = {};\nconst emptyProperties = [];\nfunction hyphenateProperty(property) {\n if (property.startsWith(\"--\")) return property;\n return hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n );\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!keys?.size) return emptyProperties;\n const properties = /* @__PURE__ */ new Set();\n for (const key of keys) {\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property));\n }\n }\n return [...properties].sort();\n}\nfunction readComputedProperties(node, properties) {\n const computed = getComputedStyle(node);\n const values = {};\n for (const property of properties) {\n const value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (const property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n for (const property of properties) {\n node.style.removeProperty(property);\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition\n }) => {\n const isHydrating = componentState.unmounted === true;\n const isEntering = !!componentState.unmounted;\n const isExiting = presence?.[0] === false;\n const sendExitComplete = presence?.[1];\n const onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n const emit = (phase, cause, finished) => {\n onTransitionRef.current?.(\n phase === \"end\" ? { phase, cause, finished } : { phase, cause }\n );\n };\n const wasEnteringRef = React.useRef(isEntering);\n const justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(() => {\n wasEnteringRef.current = isEntering;\n });\n const exitCycleIdRef = React.useRef(0);\n const exitCompletedRef = React.useRef(false);\n const wasExitingRef = React.useRef(false);\n const sendExitCompleteRef = React.useRef(sendExitComplete);\n const lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n );\n const exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n const enterCycleIdRef = React.useRef(0);\n const enterStartedRef = React.useRef(false);\n const updateCycleIdRef = React.useRef(0);\n const updateInFlightRef = React.useRef(false);\n const prevUpdateSigRef = React.useRef(null);\n const exitStartedRef = React.useRef(false);\n const justStartedExiting = isExiting && !wasExitingRef.current;\n const justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(() => {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return;\n const host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n const node = host;\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature]);\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition;\n const normalized = normalizeTransition(effectiveTransition);\n const animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState);\n const defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;\n const animatedProperties = getAnimatedProperties(normalized);\n const hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;\n const hasPerPropertyConfigs = animatedProperties.length > 0;\n let keys;\n if (props.animateOnly) {\n keys = props.animateOnly;\n } else if (hasPerPropertyConfigs && !hasDefault) {\n keys = animatedProperties;\n } else if (hasPerPropertyConfigs && hasDefault) {\n keys = [\"all\", ...animatedProperties];\n } else {\n keys = [\"all\"];\n }\n let transition;\n const getTransition = () => {\n if (transition !== void 0) return transition;\n const delay = normalized.delay ? ` ${normalized.delay}ms` : \"\";\n const duration = normalized.config?.duration;\n transition = keys.flatMap((key) => {\n const propertyAnimation = normalized.properties[key];\n let animation = defaultAnimation;\n if (typeof propertyAnimation === \"string\") {\n animation = animations[propertyAnimation];\n } else if (propertyAnimation?.type) {\n animation = animations[propertyAnimation.type];\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration);\n }\n return animation ? getCSSProperties(key).map(\n (property) => `${property} ${animation}${delay}`\n ) : [];\n }).join(\", \");\n return transition;\n };\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n const node = host;\n const cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n sendExitCompleteRef.current?.();\n };\n if (keys.length === 0) {\n completeExit();\n return;\n }\n let rafId;\n let disposed = false;\n const mountedStyle = lastMountedStyleRef.current;\n const canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n let exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished);\n });\n return () => {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [isExiting, exitCSSPropertiesSignature]);\n const styleSignature = onTransition ? (() => {\n const { transition: _t, ...rest } = style;\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n const node = host;\n const cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n const node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n const cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [styleSignature, isEntering, justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [justStartedExiting, justStoppedExiting]);\n if (isHydrating) {\n return null;\n }\n if (!hasNormalizedAnimation(normalized)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting\n });\n }\n return { style, className: isEntering ? \"t_unmounted\" : \"\" };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;;;;;AAUA,MAAM,SAAS,OAAO,0BAA0B;AAChD,SAAS,kBA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gB,SAAS;KACjD,gBAAgB;KAChB,gBAAgB,UAAU;KAC1B,KAAK,OAAO,SAAS,KAAK;IAC5B;IACA,IAAI,sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CAAC,oBAAoB,kBAAkB,CAAC;GAC3C,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,CAACA,aAAuB,UAAU,GAAG;IACvC,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,YAAY,mBAAmB,MAAM,SAAS;GACtD;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IAAE;IAAO,WAAW,aAAa,gBAAgB;GAAG;EAC7D;CACF;AACF"}
@@ -3,7 +3,6 @@ import { useIsomorphicLayoutEffect } from "@tamagui/constants";
3
3
  import { ResetPresence, usePresence } from "@tamagui/use-presence";
4
4
  import { transformsToString } from "@tamagui/web";
5
5
  import React from "react";
6
- import { useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle, useAnimatedNumbersStyle } from "./animated-number.native.js";
7
6
 
8
7
  var hasRAF = typeof requestAnimationFrame !== "undefined";
9
8
  function waitForAnimations(node) {
@@ -179,10 +178,6 @@ function createAnimations(animations) {
179
178
  ResetPresence,
180
179
  inputStyle: "css",
181
180
  outputStyle: "css",
182
- useAnimatedNumber,
183
- useAnimatedNumberReaction,
184
- useAnimatedNumberStyle,
185
- useAnimatedNumbersStyle,
186
181
  useAnimations: function(param) {
187
182
  var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;
188
183
  var _styleState_programLifecycleStyleKeys;
@@ -1 +1 @@
1
- {"version":3,"file":"createAnimations.native.js","names":["hasNormalizedAnimation"],"sources":["esm/createAnimations.native.js"],"sourcesContent":["import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation, getEffectiveAnimation } from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web\";\nimport React from \"react\";\nimport { useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle, useAnimatedNumbersStyle } from \"./animated-number\";\nvar hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise(function(resolve) {\n var check = function() {\n var animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map(function(a) {\n return a.finished;\n })).then(function() {\n return resolve(true);\n }).catch(function() {\n var remaining = node.getAnimations();\n if (remaining.some(function(a) {\n return a.playState === \"running\" || a.pending;\n })) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nvar DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/;\nfunction applyDurationOverride(animation, durationMs) {\n var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced;\n}\nvar CSS_TRANSFORM_PROPERTIES = {\n transform: [\n \"translate\",\n \"scale\",\n \"rotate\",\n \"transform\"\n ],\n x: [\n \"translate\"\n ],\n y: [\n \"translate\"\n ],\n scale: [\n \"scale\"\n ],\n scaleX: [\n \"scale\"\n ],\n scaleY: [\n \"scale\"\n ],\n rotate: [\n \"rotate\"\n ],\n rotateX: [\n \"transform\"\n ],\n rotateY: [\n \"transform\"\n ],\n rotateZ: [\n \"transform\"\n ],\n skewX: [\n \"transform\"\n ],\n skewY: [\n \"transform\"\n ]\n};\nvar getCSSProperties = function(key) {\n return CSS_TRANSFORM_PROPERTIES[key] || [\n key\n ];\n};\nvar hyphenatedPropertyCache = {};\nvar emptyProperties = [];\nfunction hyphenateProperty(property) {\n var _hyphenatedPropertyCache, _property;\n if (property.startsWith(\"--\")) return property;\n return (_hyphenatedPropertyCache = hyphenatedPropertyCache)[_property = property] || (_hyphenatedPropertyCache[_property] = property.replace(/[A-Z]/g, function(letter) {\n return `-${letter.toLowerCase()}`;\n }));\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!(keys === null || keys === void 0 ? void 0 : keys.size)) return emptyProperties;\n var properties = /* @__PURE__ */ new Set();\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var property = _step1.value;\n properties.add(hyphenateProperty(property));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return [\n ...properties\n ].sort();\n}\nfunction readComputedProperties(node, properties) {\n var computed = getComputedStyle(node);\n var values = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n var value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (var property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n node.style.removeProperty(property);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n // @ts-ignore - styleState is added by createComponent\n useAnimations: function(param) {\n var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;\n var _styleState_programLifecycleStyleKeys;\n var isHydrating = componentState.unmounted === true;\n var isEntering = !!componentState.unmounted;\n var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;\n var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];\n var onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n var emit = function(phase, cause, finished) {\n var _onTransitionRef_current;\n (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === \"end\" ? {\n phase,\n cause,\n finished\n } : {\n phase,\n cause\n });\n };\n var wasEnteringRef = React.useRef(isEntering);\n var justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(function() {\n wasEnteringRef.current = isEntering;\n });\n var exitCycleIdRef = React.useRef(0);\n var exitCompletedRef = React.useRef(false);\n var wasExitingRef = React.useRef(false);\n var sendExitCompleteRef = React.useRef(sendExitComplete);\n var lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n var exitCSSProperties = getLifecycleCSSProperties(styleState === null || styleState === void 0 ? void 0 : (_styleState_programLifecycleStyleKeys = styleState.programLifecycleStyleKeys) === null || _styleState_programLifecycleStyleKeys === void 0 ? void 0 : _styleState_programLifecycleStyleKeys.exit);\n var exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n var enterCycleIdRef = React.useRef(0);\n var enterStartedRef = React.useRef(false);\n var updateCycleIdRef = React.useRef(0);\n var updateInFlightRef = React.useRef(false);\n var prevUpdateSigRef = React.useRef(null);\n var exitStartedRef = React.useRef(false);\n var justStartedExiting = isExiting && !wasExitingRef.current;\n var justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(function() {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(function() {\n if (isExiting) return;\n var host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n var node = host;\n var capture = function() {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [\n isExiting,\n justFinishedEntering,\n exitCSSPropertiesSignature\n ]);\n var _styleState_effectiveTransition;\n var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;\n var normalized = normalizeTransition(effectiveTransition);\n var animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n var effectiveAnimationKey = getEffectiveAnimation(normalized, animationState);\n var defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;\n var animatedProperties = getAnimatedProperties(normalized);\n var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;\n var hasPerPropertyConfigs = animatedProperties.length > 0;\n var keys;\n if (props.animateOnly) {\n keys = props.animateOnly;\n } else if (hasPerPropertyConfigs && !hasDefault) {\n keys = animatedProperties;\n } else if (hasPerPropertyConfigs && hasDefault) {\n keys = [\n \"all\",\n ...animatedProperties\n ];\n } else {\n keys = [\n \"all\"\n ];\n }\n var transition;\n var getTransition = function() {\n var _normalized_config;\n if (transition !== void 0) return transition;\n var delay = normalized.delay ? ` ${normalized.delay}ms` : \"\";\n var duration = (_normalized_config = normalized.config) === null || _normalized_config === void 0 ? void 0 : _normalized_config.duration;\n transition = keys.flatMap(function(key) {\n var propertyAnimation = normalized.properties[key];\n var animation = defaultAnimation;\n if (typeof propertyAnimation === \"string\") {\n animation = animations[propertyAnimation];\n } else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {\n animation = animations[propertyAnimation.type];\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration);\n }\n return animation ? getCSSProperties(key).map(function(property) {\n return `${property} ${animation}${delay}`;\n }) : [];\n }).join(\", \");\n return transition;\n };\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n var node = host;\n var cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n var completeExit = function() {\n var finished = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;\n var _sendExitCompleteRef_current;\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n (_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);\n };\n if (keys.length === 0) {\n completeExit();\n return;\n }\n var rafId;\n var disposed = false;\n var mountedStyle = lastMountedStyleRef.current;\n var canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n var exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(function() {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then(function(finished) {\n if (!disposed) completeExit(finished);\n });\n return function() {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [\n isExiting,\n exitCSSPropertiesSignature\n ]);\n var styleSignature = onTransition ? (function() {\n var { transition: _t, ...rest } = style;\n var _styleState_classNames;\n return `${JSON.stringify((_styleState_classNames = styleState === null || styleState === void 0 ? void 0 : styleState.classNames) !== null && _styleState_classNames !== void 0 ? _styleState_classNames : null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n var node = host;\n var cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n var node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n var cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [\n styleSignature,\n isEntering,\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [\n justStartedExiting,\n justStoppedExiting\n ]);\n if (isHydrating) {\n return null;\n }\n if (!hasNormalizedAnimation(normalized)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting\n });\n }\n return {\n style,\n className: isEntering ? \"t_unmounted\" : \"\"\n };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;;;;;;AAMA,IAAI,SAAS,OAAO,0BAA0B;AAC9C,SAAS,kBAAkB,MAAM;CAC/B,IAAI,OAAO,KAAK,kBAAkB,YAAY;EAC5C,OAAO,QAA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C5B;IACA,IAAI,sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CACD,oBACA,kBACF,CAAC;GACD,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,CAACA,aAAuB,UAAU,GAAG;IACvC,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,YAAY,mBAAmB,MAAM,SAAS;GACtD;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IACL;IACA,WAAW,aAAa,gBAAgB;GAC1C;EACF;CACF;AACF"}
1
+ {"version":3,"file":"createAnimations.native.js","names":["hasNormalizedAnimation"],"sources":["esm/createAnimations.native.js"],"sourcesContent":["import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation, getEffectiveAnimation } from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web\";\nimport React from \"react\";\nvar hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise(function(resolve) {\n var check = function() {\n var animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map(function(a) {\n return a.finished;\n })).then(function() {\n return resolve(true);\n }).catch(function() {\n var remaining = node.getAnimations();\n if (remaining.some(function(a) {\n return a.playState === \"running\" || a.pending;\n })) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nvar DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/;\nfunction applyDurationOverride(animation, durationMs) {\n var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced;\n}\nvar CSS_TRANSFORM_PROPERTIES = {\n transform: [\n \"translate\",\n \"scale\",\n \"rotate\",\n \"transform\"\n ],\n x: [\n \"translate\"\n ],\n y: [\n \"translate\"\n ],\n scale: [\n \"scale\"\n ],\n scaleX: [\n \"scale\"\n ],\n scaleY: [\n \"scale\"\n ],\n rotate: [\n \"rotate\"\n ],\n rotateX: [\n \"transform\"\n ],\n rotateY: [\n \"transform\"\n ],\n rotateZ: [\n \"transform\"\n ],\n skewX: [\n \"transform\"\n ],\n skewY: [\n \"transform\"\n ]\n};\nvar getCSSProperties = function(key) {\n return CSS_TRANSFORM_PROPERTIES[key] || [\n key\n ];\n};\nvar hyphenatedPropertyCache = {};\nvar emptyProperties = [];\nfunction hyphenateProperty(property) {\n var _hyphenatedPropertyCache, _property;\n if (property.startsWith(\"--\")) return property;\n return (_hyphenatedPropertyCache = hyphenatedPropertyCache)[_property = property] || (_hyphenatedPropertyCache[_property] = property.replace(/[A-Z]/g, function(letter) {\n return `-${letter.toLowerCase()}`;\n }));\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!(keys === null || keys === void 0 ? void 0 : keys.size)) return emptyProperties;\n var properties = /* @__PURE__ */ new Set();\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var property = _step1.value;\n properties.add(hyphenateProperty(property));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return [\n ...properties\n ].sort();\n}\nfunction readComputedProperties(node, properties) {\n var computed = getComputedStyle(node);\n var values = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n var value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (var property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n node.style.removeProperty(property);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: function(param) {\n var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;\n var _styleState_programLifecycleStyleKeys;\n var isHydrating = componentState.unmounted === true;\n var isEntering = !!componentState.unmounted;\n var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;\n var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];\n var onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n var emit = function(phase, cause, finished) {\n var _onTransitionRef_current;\n (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === \"end\" ? {\n phase,\n cause,\n finished\n } : {\n phase,\n cause\n });\n };\n var wasEnteringRef = React.useRef(isEntering);\n var justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(function() {\n wasEnteringRef.current = isEntering;\n });\n var exitCycleIdRef = React.useRef(0);\n var exitCompletedRef = React.useRef(false);\n var wasExitingRef = React.useRef(false);\n var sendExitCompleteRef = React.useRef(sendExitComplete);\n var lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n var exitCSSProperties = getLifecycleCSSProperties(styleState === null || styleState === void 0 ? void 0 : (_styleState_programLifecycleStyleKeys = styleState.programLifecycleStyleKeys) === null || _styleState_programLifecycleStyleKeys === void 0 ? void 0 : _styleState_programLifecycleStyleKeys.exit);\n var exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n var enterCycleIdRef = React.useRef(0);\n var enterStartedRef = React.useRef(false);\n var updateCycleIdRef = React.useRef(0);\n var updateInFlightRef = React.useRef(false);\n var prevUpdateSigRef = React.useRef(null);\n var exitStartedRef = React.useRef(false);\n var justStartedExiting = isExiting && !wasExitingRef.current;\n var justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(function() {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(function() {\n if (isExiting) return;\n var host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n var node = host;\n var capture = function() {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [\n isExiting,\n justFinishedEntering,\n exitCSSPropertiesSignature\n ]);\n var _styleState_effectiveTransition;\n var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;\n var normalized = normalizeTransition(effectiveTransition);\n var animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n var effectiveAnimationKey = getEffectiveAnimation(normalized, animationState);\n var defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;\n var animatedProperties = getAnimatedProperties(normalized);\n var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;\n var hasPerPropertyConfigs = animatedProperties.length > 0;\n var keys;\n if (props.animateOnly) {\n keys = props.animateOnly;\n } else if (hasPerPropertyConfigs && !hasDefault) {\n keys = animatedProperties;\n } else if (hasPerPropertyConfigs && hasDefault) {\n keys = [\n \"all\",\n ...animatedProperties\n ];\n } else {\n keys = [\n \"all\"\n ];\n }\n var transition;\n var getTransition = function() {\n var _normalized_config;\n if (transition !== void 0) return transition;\n var delay = normalized.delay ? ` ${normalized.delay}ms` : \"\";\n var duration = (_normalized_config = normalized.config) === null || _normalized_config === void 0 ? void 0 : _normalized_config.duration;\n transition = keys.flatMap(function(key) {\n var propertyAnimation = normalized.properties[key];\n var animation = defaultAnimation;\n if (typeof propertyAnimation === \"string\") {\n animation = animations[propertyAnimation];\n } else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {\n animation = animations[propertyAnimation.type];\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration);\n }\n return animation ? getCSSProperties(key).map(function(property) {\n return `${property} ${animation}${delay}`;\n }) : [];\n }).join(\", \");\n return transition;\n };\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n var node = host;\n var cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n var completeExit = function() {\n var finished = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;\n var _sendExitCompleteRef_current;\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n (_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);\n };\n if (keys.length === 0) {\n completeExit();\n return;\n }\n var rafId;\n var disposed = false;\n var mountedStyle = lastMountedStyleRef.current;\n var canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n var exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(function() {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then(function(finished) {\n if (!disposed) completeExit(finished);\n });\n return function() {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [\n isExiting,\n exitCSSPropertiesSignature\n ]);\n var styleSignature = onTransition ? (function() {\n var { transition: _t, ...rest } = style;\n var _styleState_classNames;\n return `${JSON.stringify((_styleState_classNames = styleState === null || styleState === void 0 ? void 0 : styleState.classNames) !== null && _styleState_classNames !== void 0 ? _styleState_classNames : null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n var node = host;\n var cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n var node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n var cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [\n styleSignature,\n isEntering,\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [\n justStartedExiting,\n justStoppedExiting\n ]);\n if (isHydrating) {\n return null;\n }\n if (!hasNormalizedAnimation(normalized)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting\n });\n }\n return {\n style,\n className: isEntering ? \"t_unmounted\" : \"\"\n };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;;;;;AAKA,IAAI,SAAS,OAAO,0BAA0B;AAC9C,SAAS,kBAAkB,MAAM;CAC/B,IAAI,OAAO,KAAK,kBAAkB,YAAY;EAC5C,OAAO,QAAQ,QAAQ,IAAI;CAC7B;CACA,OAAO,IAAI,QAAQ,SAAS,SAAS;EACnC,IAAI,QAAQ,WAAW;GACrB,IAAI,aAAa,KAAK,cAAc;GACpC,IAAI,WAAW,WAAW,GAAG;IAC3B,QAAQ,IAAI;IACZ;GACF;GACA,QAAQ,IAAI,WAAW,IAAI,SAAS,GAAG;IACrC,OAAO,EAAE;GACX,CAAC,CAAC,CAAC,CAAC,KAAK,WAAW;IAClB,OAAO,QAAQ,IAAI;GACrB,CAAC,CAAC,CAAC,MAAM,WAAW;IAClB,IAAI,YAAY,KAAK,cAAc;IACnC,IAAI,UAAU,KAAK,SAAS,GAAG;KAC7B,OAAO,EAAE,cAAc,aAAa,EAAE;IACxC,CAAC,GAAG;KACF,MAAM;KACN;IACF;IACA,QAAQ,KAAK;GACf,CAAC;EACH;EACA,IAAI,QAAQ;GACV,sBAAsB,KAAK;EAC7B,OAAO;GACL,MAAM;EACR;CACF,CAAC;AACH;AACA,IAAI,iBAAiB;AACrB,SAAS,sBAAsB,WAAW,YAAY;CACpD,IAAI,WAAW,UAAU,QAAQ,gBAAgB,GAAG,WAAW,GAAG;CAClE,OAAO,aAAa,YAAY,GAAG,WAAW,KAAK,cAAc;AACnE;AACA,IAAI,2BAA2B;CAC7B,WAAW;EACT;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B;IACF;IACA,IAAI,mBAAmB,iBAAiB,SAAS;IACjD,iBAAiB,UAAU;IAC3B,IAAI,OAAO;IACX,IAAI,kBAAkB,SAAS;KAC7B,KAAK,OAAO,UAAU,KAAK;IAC7B;IACA,kBAAkB,UAAU;IAC5B,IAAI,UAAU,EAAE,iBAAiB;IACjC,KAAK,SAAS,QAAQ;IACtB,KAAK,kBAAkB,IAAI,CAAC,CAAC,KAAK,SAAS,UAAU;KACnD,IAAI,YAAY,iBAAiB,SAAS;KAC1C,kBAAkB,UAAU;KAC5B,KAAK,OAAO,UAAU,QAAQ;IAChC,CAAC;GACH,GAAG;IACD;IACA;IACA;IACA;GACF,CAAC;GACD,0BAA0B,WAAW;IACnC,IAAI,sBAAsB,gBAAgB,SAAS;KACjD,gBAAgB;KAChB,gBAAgB,UAAU;KAC1B,KAAK,OAAO,SAAS,KAAK;IAC5B;IACA,IAAI,sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CACD,oBACA,kBACF,CAAC;GACD,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,CAACA,aAAuB,UAAU,GAAG;IACvC,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,YAAY,mBAAmB,MAAM,SAAS;GACtD;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IACL;IACA,WAAW,aAAa,gBAAgB;GAC1C;EACF;CACF;AACF"}
@@ -0,0 +1,17 @@
1
+ import { useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle, useAnimatedNumbersStyle } from "./animated-number.mjs";
2
+ import { createAnimations as createAnimations$1 } from "./createAnimations.mjs";
3
+
4
+ export * from "./animated-number.mjs"
5
+
6
+ function createAnimations(animations) {
7
+ return {
8
+ ...createAnimations$1(animations),
9
+ useAnimatedNumber,
10
+ useAnimatedNumberReaction,
11
+ useAnimatedNumberStyle,
12
+ useAnimatedNumbersStyle
13
+ };
14
+ }
15
+
16
+ export { createAnimations };
17
+ //# sourceMappingURL=extras.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extras.js","names":["createCoreAnimations"],"sources":["esm/extras.js"],"sourcesContent":["import {\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle\n} from \"./animated-number\";\nimport { createAnimations as createCoreAnimations } from \"./createAnimations\";\nexport * from \"./animated-number\";\nfunction createAnimations(animations) {\n return {\n ...createCoreAnimations(animations),\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=extras.js.map\n"],"mappings":";;;;;;AAQA,SAAS,iBAAiB,YAAY;CACpC,OAAO;EACL,GAAGA,mBAAqB,UAAU;EAClC;EACA;EACA;EACA;CACF;AACF"}
@@ -0,0 +1,17 @@
1
+ import { useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle, useAnimatedNumbersStyle } from "./animated-number.native.js";
2
+ import { createAnimations as createAnimations$1 } from "./createAnimations.native.js";
3
+
4
+ export * from "./animated-number.native.js"
5
+
6
+ function createAnimations(animations) {
7
+ return {
8
+ ...createAnimations$1(animations),
9
+ useAnimatedNumber,
10
+ useAnimatedNumberReaction,
11
+ useAnimatedNumberStyle,
12
+ useAnimatedNumbersStyle
13
+ };
14
+ }
15
+
16
+ export { createAnimations };
17
+ //# sourceMappingURL=extras.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extras.native.js","names":["createCoreAnimations"],"sources":["esm/extras.native.js"],"sourcesContent":["import { useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle, useAnimatedNumbersStyle } from \"./animated-number\";\nimport { createAnimations as createCoreAnimations } from \"./createAnimations\";\nexport * from \"./animated-number\";\nfunction createAnimations(animations) {\n return {\n ...createCoreAnimations(animations),\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=extras.js.map\n"],"mappings":";;;;;;AAGA,SAAS,iBAAiB,YAAY;CACpC,OAAO;EACL,GAAGA,mBAAqB,UAAU;EAClC;EACA;EACA;EACA;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animations-css",
3
- "version": "3.0.0-beta.669.1",
3
+ "version": "3.0.0-beta.728.1",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "license": "MIT",
6
6
  "source": "src/index.ts",
@@ -33,6 +33,15 @@
33
33
  "import": "./dist/esm/animated-number.mjs",
34
34
  "require": "./dist/cjs/animated-number.cjs",
35
35
  "default": "./dist/esm/animated-number.mjs"
36
+ },
37
+ "./extras": {
38
+ "types": "./types/extras.d.ts",
39
+ "react-native": "./dist/esm/extras.native.js",
40
+ "browser": "./dist/esm/extras.mjs",
41
+ "module": "./dist/esm/extras.mjs",
42
+ "import": "./dist/esm/extras.mjs",
43
+ "require": "./dist/cjs/extras.cjs",
44
+ "default": "./dist/esm/extras.mjs"
36
45
  }
37
46
  },
38
47
  "publishConfig": {
@@ -45,16 +54,16 @@
45
54
  "clean:build": "tamagui-build clean:build"
46
55
  },
47
56
  "dependencies": {
48
- "@tamagui/animation-helpers": "3.0.0-beta.669.1",
49
- "@tamagui/constants": "3.0.0-beta.669.1",
50
- "@tamagui/cubic-bezier-animator": "3.0.0-beta.669.1",
51
- "@tamagui/use-presence": "3.0.0-beta.669.1",
52
- "@tamagui/web": "3.0.0-beta.669.1"
57
+ "@tamagui/animation-helpers": "3.0.0-beta.728.1",
58
+ "@tamagui/constants": "3.0.0-beta.728.1",
59
+ "@tamagui/cubic-bezier-animator": "3.0.0-beta.728.1",
60
+ "@tamagui/use-presence": "3.0.0-beta.728.1",
61
+ "@tamagui/web": "3.0.0-beta.728.1"
53
62
  },
54
63
  "devDependencies": {
55
- "@tamagui/build": "3.0.0-beta.669.1",
56
- "react": ">=19",
57
- "react-dom": "*"
64
+ "@tamagui/build": "3.0.0-beta.728.1",
65
+ "react": "19.2.3",
66
+ "react-dom": "19.2.3"
58
67
  },
59
68
  "peerDependencies": {
60
69
  "react": ">=19",
@@ -15,8 +15,8 @@ import { unstable_batchedUpdates } from 'react-dom'
15
15
  * this module must reach the config, the provider and the component runtime
16
16
  * through nothing but types. It owns the CSS driver's rAF timing and spring
17
17
  * engine, cancellation, completion callbacks, listener notification and the
18
- * linked-style render. `createAnimations` uses these same functions, so there is
19
- * one implementation rather than two.
18
+ * linked-style render. The `/extras` factory composes these functions onto the
19
+ * core transition driver.
20
20
  */
21
21
 
22
22
  // rAF-driven animated number is browser-only. read (don't call) at module scope
@@ -10,13 +10,6 @@ import type { AnimationDriver } from '@tamagui/web'
10
10
  import { transformsToString } from '@tamagui/web'
11
11
  import React from 'react'
12
12
 
13
- import {
14
- useAnimatedNumber,
15
- useAnimatedNumberReaction,
16
- useAnimatedNumberStyle,
17
- useAnimatedNumbersStyle,
18
- } from './animated-number'
19
-
20
13
  // rAF-driven animated number is browser-only. read (don't call) at module scope
21
14
  // so ssr never touches requestAnimationFrame.
22
15
  const hasRAF = typeof requestAnimationFrame !== 'undefined'
@@ -145,11 +138,6 @@ export function createAnimations<A extends object>(animations: A): AnimationDriv
145
138
  inputStyle: 'css',
146
139
  outputStyle: 'css',
147
140
 
148
- useAnimatedNumber,
149
- useAnimatedNumberReaction,
150
- useAnimatedNumberStyle,
151
- useAnimatedNumbersStyle,
152
-
153
141
  // @ts-ignore - styleState is added by createComponent
154
142
  useAnimations: ({
155
143
  props,
package/src/extras.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { AnimationDriverWithAnimatedNumbers } from '@tamagui/web'
2
+
3
+ import {
4
+ useAnimatedNumber,
5
+ useAnimatedNumberReaction,
6
+ useAnimatedNumberStyle,
7
+ useAnimatedNumbersStyle,
8
+ } from './animated-number'
9
+ import { createAnimations as createCoreAnimations } from './createAnimations'
10
+
11
+ export * from './animated-number'
12
+
13
+ export function createAnimations<A extends object>(
14
+ animations: A
15
+ ): AnimationDriverWithAnimatedNumbers<A> {
16
+ return {
17
+ ...createCoreAnimations(animations),
18
+ useAnimatedNumber,
19
+ useAnimatedNumberReaction,
20
+ useAnimatedNumberStyle,
21
+ useAnimatedNumbersStyle,
22
+ }
23
+ }
@@ -6,6 +6,6 @@
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "import type {\n AnimatedNumberStrategy,\n UniversalAnimatedNumber,\n UseAnimatedNumberReaction,\n UseAnimatedNumberStyle,\n UseAnimatedNumbersStyle,\n} from '@tamagui/web'\nimport React from 'react'\nimport { unstable_batchedUpdates } from 'react-dom'\n\n/**\n * The optional animated-number leaf.\n *\n * Zero-runtime mode rewrites the four public animated-number imports here, so\n * this module must reach the config, the provider and the component runtime\n * through nothing but types. It owns the CSS driver's rAF timing and spring\n * engine, cancellation, completion callbacks, listener notification and the\n * linked-style render. `createAnimations` uses these same functions, so there is\n * one implementation rather than two.\n */\n\n// rAF-driven animated number is browser-only. read (don't call) at module scope\n// so ssr never touches requestAnimationFrame.\nconst hasRAF = typeof requestAnimationFrame !== 'undefined'\n\ntype CSSAnimatedNumberInstance = {\n current: number\n target: number\n listeners: Set<(value: number) => void>\n styleHost: object | null\n raf: number | null\n finish: (() => void) | null\n renderTarget: () => void\n cancel: () => void\n}\n\ntype CSSAnimatedNumber = UniversalAnimatedNumber<CSSAnimatedNumberInstance>\n\nfunction notifyAnimatedNumber(instance: CSSAnimatedNumberInstance, value: number) {\n instance.current = value\n if (instance.listeners.size === 0) return\n unstable_batchedUpdates(() => {\n for (const listener of instance.listeners) listener(value)\n })\n}\n\nfunction useAnimatedNumberStyles(\n values: CSSAnimatedNumber[],\n getStyle: (...current: number[]) => any\n) {\n const token = React.useRef<object>(null)\n token.current ||= {}\n const [, renderLinkedValue] = React.useReducer((value) => value + 1, 0)\n const instances = values.map((value) => value.getInstance())\n for (const instance of instances) {\n if (!instance.styleHost) instance.styleHost = token.current\n }\n\n React.useEffect(() => {\n const listener = () => renderLinkedValue()\n for (const instance of instances) {\n if (instance.styleHost !== token.current) instance.listeners.add(listener)\n }\n return () => {\n for (const instance of instances) {\n instance.listeners.delete(listener)\n if (instance.styleHost === token.current) instance.styleHost = null\n }\n }\n }, instances)\n\n return getStyle(\n ...instances.map((instance) =>\n instance.styleHost === token.current ? instance.target : instance.current\n )\n )\n}\n\nexport function useAnimatedNumber(initial: number): CSSAnimatedNumber {\n const [, renderTarget] = React.useReducer((value) => value + 1, 0)\n const instanceRef = React.useRef<CSSAnimatedNumberInstance>(null)\n\n if (!instanceRef.current) {\n instanceRef.current = {\n current: initial,\n target: initial,\n listeners: new Set(),\n styleHost: null,\n raf: null,\n finish: null,\n renderTarget,\n cancel() {\n if (this.raf !== null) cancelAnimationFrame(this.raf)\n this.raf = null\n this.finish = null\n },\n }\n }\n\n const instance = instanceRef.current\n instance.renderTarget = renderTarget\n React.useEffect(() => () => instance.cancel(), [instance])\n\n return React.useMemo(\n () => ({\n getInstance() {\n return instance\n },\n getValue() {\n return instance.current\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n instance.cancel()\n const from = instance.current\n instance.target = next\n if (instance.styleHost) instance.renderTarget()\n\n if (\n !hasRAF ||\n config.type === 'direct' ||\n (config.type === 'timing' && config.duration === 0) ||\n from === next\n ) {\n notifyAnimatedNumber(instance, next)\n onFinish?.()\n return\n }\n\n // css transitions interpolate the host. js only ticks when a\n // reaction, linked style, or completion callback needs live values.\n if (instance.listeners.size === 0 && !onFinish) {\n instance.current = next\n return\n }\n\n instance.finish = onFinish ?? null\n const settle = () => {\n instance.raf = null\n notifyAnimatedNumber(instance, next)\n const finish = instance.finish\n instance.finish = null\n finish?.()\n }\n\n if (config.type === 'timing') {\n const startedAt = performance.now()\n const tick = () => {\n const progress = Math.min(\n 1,\n (performance.now() - startedAt) / config.duration\n )\n if (progress === 1) {\n settle()\n return\n }\n notifyAnimatedNumber(instance, from + (next - from) * progress)\n instance.raf = requestAnimationFrame(tick)\n }\n instance.raf = requestAnimationFrame(tick)\n return\n }\n\n const {\n stiffness = 300,\n damping = 35,\n mass = 1,\n overshootClamping,\n restSpeedThreshold: restSpeed = 0.001,\n restDisplacementThreshold: restDisplacement = 0.001,\n } = config as Extract<AnimatedNumberStrategy, { type: 'spring' }>\n const displacement = from - next\n const decayRate = damping / (2 * mass)\n const naturalFrequency = Math.sqrt(stiffness / mass)\n const startedAt = performance.now()\n\n const tick = () => {\n const elapsed = (performance.now() - startedAt) / 1000\n let value: number\n let velocity: number\n if (decayRate < naturalFrequency) {\n const dampedFrequency = Math.sqrt(naturalFrequency ** 2 - decayRate ** 2)\n const b = (decayRate * displacement) / dampedFrequency\n const decay = Math.exp(-decayRate * elapsed)\n const cos = Math.cos(dampedFrequency * elapsed)\n const sin = Math.sin(dampedFrequency * elapsed)\n value = next + decay * (displacement * cos + b * sin)\n velocity =\n decay *\n ((-decayRate * displacement + b * dampedFrequency) * cos +\n (-decayRate * b - displacement * dampedFrequency) * sin)\n } else if (decayRate === naturalFrequency) {\n const b = decayRate * displacement\n const decay = Math.exp(-decayRate * elapsed)\n value = next + (displacement + b * elapsed) * decay\n velocity = (b - decayRate * (displacement + b * elapsed)) * decay\n } else {\n const frequency = Math.sqrt(decayRate ** 2 - naturalFrequency ** 2)\n const slowRoot = -decayRate + frequency\n const fastRoot = -decayRate - frequency\n const slowCoefficient = (-fastRoot * displacement) / (slowRoot - fastRoot)\n const fastCoefficient = displacement - slowCoefficient\n value =\n next +\n slowCoefficient * Math.exp(slowRoot * elapsed) +\n fastCoefficient * Math.exp(fastRoot * elapsed)\n velocity =\n slowCoefficient * slowRoot * Math.exp(slowRoot * elapsed) +\n fastCoefficient * fastRoot * Math.exp(fastRoot * elapsed)\n }\n\n if (\n overshootClamping &&\n ((from < next && value > next) || (from > next && value < next))\n ) {\n value = next\n velocity = 0\n }\n\n if (\n Math.abs(velocity) <= restSpeed &&\n Math.abs(next - value) <= restDisplacement\n ) {\n settle()\n return\n }\n\n notifyAnimatedNumber(instance, value)\n instance.raf = requestAnimationFrame(tick)\n }\n instance.raf = requestAnimationFrame(tick)\n },\n stop() {\n instance.cancel()\n },\n }),\n [instance]\n )\n}\n\nexport const useAnimatedNumberReaction: UseAnimatedNumberReaction = (\n { value },\n onValue\n) => {\n const onValueRef = React.useRef(onValue)\n onValueRef.current = onValue\n React.useEffect(() => {\n const instance = value.getInstance() as CSSAnimatedNumberInstance\n const listener = (current: number) => onValueRef.current(current)\n instance.listeners.add(listener)\n return () => {\n instance.listeners.delete(listener)\n }\n }, [value])\n}\n\nexport const useAnimatedNumberStyle: UseAnimatedNumberStyle = (val, getStyle) =>\n useAnimatedNumberStyles([val as CSSAnimatedNumber], getStyle)\n\nexport const useAnimatedNumbersStyle: UseAnimatedNumbersStyle = (vals, getStyle) =>\n useAnimatedNumberStyles(vals as CSSAnimatedNumber[], getStyle)\n\nexport type { CSSAnimatedNumber, CSSAnimatedNumberInstance }\n"
9
+ "import type {\n AnimatedNumberStrategy,\n UniversalAnimatedNumber,\n UseAnimatedNumberReaction,\n UseAnimatedNumberStyle,\n UseAnimatedNumbersStyle,\n} from '@tamagui/web'\nimport React from 'react'\nimport { unstable_batchedUpdates } from 'react-dom'\n\n/**\n * The optional animated-number leaf.\n *\n * Zero-runtime mode rewrites the four public animated-number imports here, so\n * this module must reach the config, the provider and the component runtime\n * through nothing but types. It owns the CSS driver's rAF timing and spring\n * engine, cancellation, completion callbacks, listener notification and the\n * linked-style render. The `/extras` factory composes these functions onto the\n * core transition driver.\n */\n\n// rAF-driven animated number is browser-only. read (don't call) at module scope\n// so ssr never touches requestAnimationFrame.\nconst hasRAF = typeof requestAnimationFrame !== 'undefined'\n\ntype CSSAnimatedNumberInstance = {\n current: number\n target: number\n listeners: Set<(value: number) => void>\n styleHost: object | null\n raf: number | null\n finish: (() => void) | null\n renderTarget: () => void\n cancel: () => void\n}\n\ntype CSSAnimatedNumber = UniversalAnimatedNumber<CSSAnimatedNumberInstance>\n\nfunction notifyAnimatedNumber(instance: CSSAnimatedNumberInstance, value: number) {\n instance.current = value\n if (instance.listeners.size === 0) return\n unstable_batchedUpdates(() => {\n for (const listener of instance.listeners) listener(value)\n })\n}\n\nfunction useAnimatedNumberStyles(\n values: CSSAnimatedNumber[],\n getStyle: (...current: number[]) => any\n) {\n const token = React.useRef<object>(null)\n token.current ||= {}\n const [, renderLinkedValue] = React.useReducer((value) => value + 1, 0)\n const instances = values.map((value) => value.getInstance())\n for (const instance of instances) {\n if (!instance.styleHost) instance.styleHost = token.current\n }\n\n React.useEffect(() => {\n const listener = () => renderLinkedValue()\n for (const instance of instances) {\n if (instance.styleHost !== token.current) instance.listeners.add(listener)\n }\n return () => {\n for (const instance of instances) {\n instance.listeners.delete(listener)\n if (instance.styleHost === token.current) instance.styleHost = null\n }\n }\n }, instances)\n\n return getStyle(\n ...instances.map((instance) =>\n instance.styleHost === token.current ? instance.target : instance.current\n )\n )\n}\n\nexport function useAnimatedNumber(initial: number): CSSAnimatedNumber {\n const [, renderTarget] = React.useReducer((value) => value + 1, 0)\n const instanceRef = React.useRef<CSSAnimatedNumberInstance>(null)\n\n if (!instanceRef.current) {\n instanceRef.current = {\n current: initial,\n target: initial,\n listeners: new Set(),\n styleHost: null,\n raf: null,\n finish: null,\n renderTarget,\n cancel() {\n if (this.raf !== null) cancelAnimationFrame(this.raf)\n this.raf = null\n this.finish = null\n },\n }\n }\n\n const instance = instanceRef.current\n instance.renderTarget = renderTarget\n React.useEffect(() => () => instance.cancel(), [instance])\n\n return React.useMemo(\n () => ({\n getInstance() {\n return instance\n },\n getValue() {\n return instance.current\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n instance.cancel()\n const from = instance.current\n instance.target = next\n if (instance.styleHost) instance.renderTarget()\n\n if (\n !hasRAF ||\n config.type === 'direct' ||\n (config.type === 'timing' && config.duration === 0) ||\n from === next\n ) {\n notifyAnimatedNumber(instance, next)\n onFinish?.()\n return\n }\n\n // css transitions interpolate the host. js only ticks when a\n // reaction, linked style, or completion callback needs live values.\n if (instance.listeners.size === 0 && !onFinish) {\n instance.current = next\n return\n }\n\n instance.finish = onFinish ?? null\n const settle = () => {\n instance.raf = null\n notifyAnimatedNumber(instance, next)\n const finish = instance.finish\n instance.finish = null\n finish?.()\n }\n\n if (config.type === 'timing') {\n const startedAt = performance.now()\n const tick = () => {\n const progress = Math.min(\n 1,\n (performance.now() - startedAt) / config.duration\n )\n if (progress === 1) {\n settle()\n return\n }\n notifyAnimatedNumber(instance, from + (next - from) * progress)\n instance.raf = requestAnimationFrame(tick)\n }\n instance.raf = requestAnimationFrame(tick)\n return\n }\n\n const {\n stiffness = 300,\n damping = 35,\n mass = 1,\n overshootClamping,\n restSpeedThreshold: restSpeed = 0.001,\n restDisplacementThreshold: restDisplacement = 0.001,\n } = config as Extract<AnimatedNumberStrategy, { type: 'spring' }>\n const displacement = from - next\n const decayRate = damping / (2 * mass)\n const naturalFrequency = Math.sqrt(stiffness / mass)\n const startedAt = performance.now()\n\n const tick = () => {\n const elapsed = (performance.now() - startedAt) / 1000\n let value: number\n let velocity: number\n if (decayRate < naturalFrequency) {\n const dampedFrequency = Math.sqrt(naturalFrequency ** 2 - decayRate ** 2)\n const b = (decayRate * displacement) / dampedFrequency\n const decay = Math.exp(-decayRate * elapsed)\n const cos = Math.cos(dampedFrequency * elapsed)\n const sin = Math.sin(dampedFrequency * elapsed)\n value = next + decay * (displacement * cos + b * sin)\n velocity =\n decay *\n ((-decayRate * displacement + b * dampedFrequency) * cos +\n (-decayRate * b - displacement * dampedFrequency) * sin)\n } else if (decayRate === naturalFrequency) {\n const b = decayRate * displacement\n const decay = Math.exp(-decayRate * elapsed)\n value = next + (displacement + b * elapsed) * decay\n velocity = (b - decayRate * (displacement + b * elapsed)) * decay\n } else {\n const frequency = Math.sqrt(decayRate ** 2 - naturalFrequency ** 2)\n const slowRoot = -decayRate + frequency\n const fastRoot = -decayRate - frequency\n const slowCoefficient = (-fastRoot * displacement) / (slowRoot - fastRoot)\n const fastCoefficient = displacement - slowCoefficient\n value =\n next +\n slowCoefficient * Math.exp(slowRoot * elapsed) +\n fastCoefficient * Math.exp(fastRoot * elapsed)\n velocity =\n slowCoefficient * slowRoot * Math.exp(slowRoot * elapsed) +\n fastCoefficient * fastRoot * Math.exp(fastRoot * elapsed)\n }\n\n if (\n overshootClamping &&\n ((from < next && value > next) || (from > next && value < next))\n ) {\n value = next\n velocity = 0\n }\n\n if (\n Math.abs(velocity) <= restSpeed &&\n Math.abs(next - value) <= restDisplacement\n ) {\n settle()\n return\n }\n\n notifyAnimatedNumber(instance, value)\n instance.raf = requestAnimationFrame(tick)\n }\n instance.raf = requestAnimationFrame(tick)\n },\n stop() {\n instance.cancel()\n },\n }),\n [instance]\n )\n}\n\nexport const useAnimatedNumberReaction: UseAnimatedNumberReaction = (\n { value },\n onValue\n) => {\n const onValueRef = React.useRef(onValue)\n onValueRef.current = onValue\n React.useEffect(() => {\n const instance = value.getInstance() as CSSAnimatedNumberInstance\n const listener = (current: number) => onValueRef.current(current)\n instance.listeners.add(listener)\n return () => {\n instance.listeners.delete(listener)\n }\n }, [value])\n}\n\nexport const useAnimatedNumberStyle: UseAnimatedNumberStyle = (val, getStyle) =>\n useAnimatedNumberStyles([val as CSSAnimatedNumber], getStyle)\n\nexport const useAnimatedNumbersStyle: UseAnimatedNumbersStyle = (vals, getStyle) =>\n useAnimatedNumberStyles(vals as CSSAnimatedNumber[], getStyle)\n\nexport type { CSSAnimatedNumber, CSSAnimatedNumberInstance }\n"
10
10
  ]
11
11
  }
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AAQA,cAAc,uBAAuB;AAmIrC,OAAO,iBAAS,iBAAiB,kBAAkB,YAAY,IAAI,gBAAgB",
2
+ "mappings": "AAQA,cAAc,uBAAuB;AA4HrC,OAAO,iBAAS,iBAAiB,kBAAkB,YAAY,IAAI,gBAAgB",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/createAnimations.tsx"
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n getEffectiveAnimation,\n} from '@tamagui/animation-helpers'\nimport { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { ResetPresence, usePresence } from '@tamagui/use-presence'\nimport type { AnimationDriver } from '@tamagui/web'\nimport { transformsToString } from '@tamagui/web'\nimport React from 'react'\n\nimport {\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n} from './animated-number'\n\n// rAF-driven animated number is browser-only. read (don't call) at module scope\n// so ssr never touches requestAnimationFrame.\nconst hasRAF = typeof requestAnimationFrame !== 'undefined'\n\n// resolve once all WAAPI animations on `node` finish. mirrors base-ui's\n// useAnimationsFinished: resolves immediately when the browser exposes no\n// animations (zero-animation elements), and re-checks after an aborted\n// animation in case a property it depended on changed mid-flight and started a\n// new one. falls back to immediate resolve when getAnimations is unavailable\n// (ssr / older webviews). resolves `false` when animations were canceled with\n// nothing left running (interruption).\nfunction waitForAnimations(node: HTMLElement): Promise<boolean> {\n if (typeof node.getAnimations !== 'function') {\n return Promise.resolve(true)\n }\n return new Promise<boolean>((resolve) => {\n const check = () => {\n const animations = node.getAnimations()\n if (animations.length === 0) {\n resolve(true)\n return\n }\n Promise.all(animations.map((a) => a.finished))\n .then(() => resolve(true))\n .catch(() => {\n const remaining = node.getAnimations()\n if (remaining.some((a) => a.playState === 'running' || a.pending)) {\n check()\n return\n }\n resolve(false)\n })\n }\n // css transitions register as pending until the next style recalc, so give\n // the browser one frame to start them before we read getAnimations.\n if (hasRAF) {\n requestAnimationFrame(check)\n } else {\n check()\n }\n })\n}\n\nconst DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/\n\n/**\n * Apply duration override to a CSS animation string\n * Replaces the existing duration with the override value\n */\nfunction applyDurationOverride(animation: string, durationMs: number): string {\n const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`)\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced\n}\n\nconst CSS_TRANSFORM_PROPERTIES: Record<string, string[]> = {\n transform: ['translate', 'scale', 'rotate', 'transform'],\n x: ['translate'],\n y: ['translate'],\n scale: ['scale'],\n scaleX: ['scale'],\n scaleY: ['scale'],\n rotate: ['rotate'],\n rotateX: ['transform'],\n rotateY: ['transform'],\n rotateZ: ['transform'],\n skewX: ['transform'],\n skewY: ['transform'],\n}\n\nconst getCSSProperties = (key: string) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key]\n}\n\nconst hyphenatedPropertyCache: Record<string, string> = {}\nconst emptyProperties: string[] = []\n\nfunction hyphenateProperty(property: string): string {\n if (property.startsWith('--')) return property\n return (hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n ))\n}\n\nfunction getLifecycleCSSProperties(keys: Set<string> | undefined): string[] {\n if (!keys?.size) return emptyProperties\n const properties = new Set<string>()\n for (const key of keys) {\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property))\n }\n }\n return [...properties].sort()\n}\n\nfunction readComputedProperties(\n node: HTMLElement,\n properties: readonly string[]\n): Record<string, string> {\n const computed = getComputedStyle(node)\n const values: Record<string, string> = {}\n for (const property of properties) {\n const value = computed.getPropertyValue(property)\n if (value) values[property] = value\n }\n return values\n}\n\nfunction applyCSSProperties(node: HTMLElement, values: Record<string, string>): void {\n for (const property in values) {\n node.style.setProperty(property, values[property])\n }\n}\n\nfunction clearCSSProperties(node: HTMLElement, properties: readonly string[]): void {\n for (const property of properties) {\n node.style.removeProperty(property)\n }\n}\n\nexport function createAnimations<A extends object>(animations: A): AnimationDriver<A> {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: 'css',\n outputStyle: 'css',\n\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition,\n }: any) => {\n const isHydrating = componentState.unmounted === true\n const isEntering = !!componentState.unmounted\n const isExiting = presence?.[0] === false\n const sendExitComplete = presence?.[1]\n const onTransitionRef = React.useRef(onTransition)\n onTransitionRef.current = onTransition\n const emit = (\n phase: 'start' | 'end',\n cause: 'enter' | 'exit' | 'update',\n finished?: boolean\n ) => {\n onTransitionRef.current?.(\n phase === 'end' ? { phase, cause, finished } : { phase, cause }\n )\n }\n\n // Track if we just finished entering (transition from entering to not entering)\n // This is needed because the CSS transition happens on the render AFTER t_unmounted is removed\n const wasEnteringRef = React.useRef(isEntering)\n const justFinishedEntering = wasEnteringRef.current && !isEntering\n React.useEffect(() => {\n wasEnteringRef.current = isEntering\n })\n\n // exit cycle guards to prevent stale/duplicate completion\n const exitCycleIdRef = React.useRef(0)\n const exitCompletedRef = React.useRef(false)\n const wasExitingRef = React.useRef(false)\n const sendExitCompleteRef = React.useRef(sendExitComplete)\n const lastMountedStyleRef = React.useRef<Record<string, string>>({})\n sendExitCompleteRef.current = sendExitComplete\n\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n )\n const exitCSSPropertiesSignature = exitCSSProperties.join('\\0')\n\n // onTransition lifecycle bookkeeping (independent from presence completion)\n const enterCycleIdRef = React.useRef(0)\n const enterStartedRef = React.useRef(false)\n const updateCycleIdRef = React.useRef(0)\n const updateInFlightRef = React.useRef(false)\n const prevUpdateSigRef = React.useRef<string | null>(null)\n const exitStartedRef = React.useRef(false)\n\n // detect transition into/out of exiting state\n const justStartedExiting = isExiting && !wasExitingRef.current\n const justStoppedExiting = !isExiting && wasExitingRef.current\n\n // start new exit cycle only on transition INTO exiting\n if (justStartedExiting) {\n exitCycleIdRef.current++\n exitCompletedRef.current = false\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++\n }\n\n // track previous exiting state\n React.useEffect(() => {\n wasExitingRef.current = isExiting\n })\n\n // Snapshot the actual mounted CSS values for every property with an exit\n // clause. Most program values live in generated classes rather than the\n // inline `style` object, so computed style is the only complete source.\n // The snapshot becomes the reset point for normal and interrupted exits.\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return\n const host = stateRef.current.host\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {}\n return\n }\n const node = host as HTMLElement\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties)\n }\n\n // The first mounted layout effect can run while an enter clause is still\n // active. Capture again after that concrete transition settles so a later\n // exit restarts from the mounted value, not the enter value.\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture)\n } else {\n capture()\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature])\n\n // use effectiveTransition computed by createComponent (single source of truth)\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition\n\n // Normalize the transition prop to a consistent format\n const normalized = normalizeTransition(effectiveTransition)\n\n // Determine animation state and get effective animation\n // Use 'enter' if we're entering OR if we just finished entering (transition is happening)\n const animationState = isExiting\n ? 'exit'\n : isEntering || justFinishedEntering\n ? 'enter'\n : 'default'\n const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState)\n const defaultAnimation = effectiveAnimationKey\n ? animations[effectiveAnimationKey]\n : null\n const animatedProperties = getAnimatedProperties(normalized)\n\n // Determine which properties to animate\n // - animateOnly prop is an exclusive filter (only animate those properties)\n // - per-property configs WITHOUT a default = only animate those specific properties\n // - per-property configs WITH a default = per-property overrides + default for rest\n const hasDefault =\n normalized.default !== null ||\n normalized.enter !== null ||\n normalized.exit !== null\n const hasPerPropertyConfigs = animatedProperties.length > 0\n\n let keys: string[]\n if (props.animateOnly) {\n // animateOnly is explicit filter\n keys = props.animateOnly\n } else if (hasPerPropertyConfigs && !hasDefault) {\n // object format without default: { opacity: '200ms' } = only animate opacity\n keys = animatedProperties\n } else if (hasPerPropertyConfigs && hasDefault) {\n // array format or object with default: 'all' first, then per-property overrides\n // CSS transition specificity: later declarations override earlier ones for the same property\n keys = ['all', ...animatedProperties]\n } else {\n // simple string format: 'quick' = animate all\n keys = ['all']\n }\n\n let transition: string | undefined\n const getTransition = () => {\n if (transition !== undefined) return transition\n const delay = normalized.delay ? ` ${normalized.delay}ms` : ''\n const duration = normalized.config?.duration\n transition = keys\n .flatMap((key) => {\n const propertyAnimation = normalized.properties[key]\n let animation = defaultAnimation\n if (typeof propertyAnimation === 'string') {\n animation = animations[propertyAnimation]\n } else if (propertyAnimation?.type) {\n animation = animations[propertyAnimation.type]\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration)\n }\n return animation\n ? getCSSProperties(key).map(\n (property) => `${property} ${animation}${delay}`\n )\n : []\n })\n .join(', ')\n return transition\n }\n\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!sendExitComplete || !isExiting || !host) return\n const node = host as HTMLElement\n\n // capture current cycle id for this effect\n const cycleId = exitCycleIdRef.current\n\n // emit exit start once per cycle\n if (!exitStartedRef.current) {\n exitStartedRef.current = true\n emit('start', 'exit')\n }\n\n // helper to complete exit with guards. the exit 'end' event fires\n // immediately before presence safeToRemove so users can observe exit\n // completion without reaching into presence internals.\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return\n if (exitCompletedRef.current) return\n exitCompletedRef.current = true\n if (exitStartedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', finished)\n }\n sendExitCompleteRef.current?.()\n }\n\n // if no properties to animate (animateOnly=[]), complete immediately\n if (keys.length === 0) {\n completeExit()\n return\n }\n\n // React can apply the exit class in the same render batch as the\n // transition. Restart from the last mounted computed values so normal\n // and interrupted exits both produce a concrete browser transition.\n let rafId: number | undefined\n let disposed = false\n\n const mountedStyle = lastMountedStyleRef.current\n const canRestart =\n exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0\n let exitTarget: Record<string, string> | undefined\n if (canRestart) {\n node.style.transition = 'none'\n // With transitions disabled, the exit classes expose their final\n // targets immediately. Capture those, then restore the mounted values.\n exitTarget = readComputedProperties(node, exitCSSProperties)\n applyCSSProperties(node, mountedStyle)\n void node.offsetHeight\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return\n node.style.transition = getTransition()\n void node.offsetHeight\n applyCSSProperties(node, exitTarget!)\n })\n }\n\n // wait for the browser's concrete animations. this covers `all`,\n // transform aliases, delays, and concurrent WAAPI animations without\n // guessing property names or maintaining a duration timer.\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished)\n })\n\n return () => {\n disposed = true\n if (rafId !== undefined) cancelAnimationFrame(rafId)\n clearCSSProperties(node, exitCSSProperties)\n // restore transition: the exit handling sets node.style.transition='none'\n // directly on the DOM (bypassing React). if exit is interrupted (e.g. same-key\n // re-entry in AnimatePresence), React won't re-apply its managed transition\n // value because it hasn't changed in the virtual DOM. clearing the inline\n // override lets React's value take effect again.\n node.style.transition = ''\n }\n }, [isExiting, exitCSSPropertiesSignature])\n\n // signature of the animatable style, so the update effect can detect\n // in-place style changes. the css driver applies most style values as\n // atomic classNames (not inline style), so the signature must include the\n // className map. only computed when a listener is attached.\n const styleSignature = onTransition\n ? (() => {\n const { transition: _t, ...rest } = style\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`\n })()\n : ''\n\n // enter lifecycle: emit start when the enter transition kicks off, end\n // once every animation on the node finishes (getAnimations-based, resolves\n // immediately for zero-animation elements). the promise outlives benign\n // re-renders because it keys off the cycle id, not the effect lifetime.\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return\n }\n const node = host as HTMLElement\n const cycleId = ++enterCycleIdRef.current\n enterStartedRef.current = true\n emit('start', 'enter')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return\n enterStartedRef.current = false\n emit('end', 'enter', finished)\n })\n }, [justFinishedEntering, isExiting])\n\n // update lifecycle: a style change while mounted (not entering or exiting).\n // a new update that supersedes an in-flight one emits end(finished:false).\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (\n !onTransitionRef.current ||\n isEntering ||\n justFinishedEntering ||\n isExiting ||\n !host\n ) {\n // keep the signature current so leaving enter/exit isn't seen as an update\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (styleSignature === prevUpdateSigRef.current) return\n prevUpdateSigRef.current = styleSignature\n\n const node = host as HTMLElement\n if (updateInFlightRef.current) {\n emit('end', 'update', false)\n }\n updateInFlightRef.current = true\n const cycleId = ++updateCycleIdRef.current\n emit('start', 'update')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return\n updateInFlightRef.current = false\n emit('end', 'update', finished)\n })\n }, [styleSignature, isEntering, justFinishedEntering, isExiting])\n\n // interruption: emit a finished:false end for an enter canceled by an exit,\n // or an exit canceled by a re-enter (before its own completion fired).\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++\n enterStartedRef.current = false\n emit('end', 'enter', false)\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', false)\n }\n }, [justStartedExiting, justStoppedExiting])\n\n // tamagui doesnt even use animation output during hydration\n if (isHydrating) {\n return null\n }\n\n // Check if we have any animation to apply\n if (!hasNormalizedAnimation(normalized)) {\n return null\n }\n\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform)\n }\n\n style.transition = getTransition()\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.info('CSS animation', {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting,\n })\n }\n\n return { style, className: isEntering ? 't_unmounted' : '' }\n },\n }\n}\n"
9
+ "import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n getEffectiveAnimation,\n} from '@tamagui/animation-helpers'\nimport { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { ResetPresence, usePresence } from '@tamagui/use-presence'\nimport type { AnimationDriver } from '@tamagui/web'\nimport { transformsToString } from '@tamagui/web'\nimport React from 'react'\n\n// rAF-driven animated number is browser-only. read (don't call) at module scope\n// so ssr never touches requestAnimationFrame.\nconst hasRAF = typeof requestAnimationFrame !== 'undefined'\n\n// resolve once all WAAPI animations on `node` finish. mirrors base-ui's\n// useAnimationsFinished: resolves immediately when the browser exposes no\n// animations (zero-animation elements), and re-checks after an aborted\n// animation in case a property it depended on changed mid-flight and started a\n// new one. falls back to immediate resolve when getAnimations is unavailable\n// (ssr / older webviews). resolves `false` when animations were canceled with\n// nothing left running (interruption).\nfunction waitForAnimations(node: HTMLElement): Promise<boolean> {\n if (typeof node.getAnimations !== 'function') {\n return Promise.resolve(true)\n }\n return new Promise<boolean>((resolve) => {\n const check = () => {\n const animations = node.getAnimations()\n if (animations.length === 0) {\n resolve(true)\n return\n }\n Promise.all(animations.map((a) => a.finished))\n .then(() => resolve(true))\n .catch(() => {\n const remaining = node.getAnimations()\n if (remaining.some((a) => a.playState === 'running' || a.pending)) {\n check()\n return\n }\n resolve(false)\n })\n }\n // css transitions register as pending until the next style recalc, so give\n // the browser one frame to start them before we read getAnimations.\n if (hasRAF) {\n requestAnimationFrame(check)\n } else {\n check()\n }\n })\n}\n\nconst DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/\n\n/**\n * Apply duration override to a CSS animation string\n * Replaces the existing duration with the override value\n */\nfunction applyDurationOverride(animation: string, durationMs: number): string {\n const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`)\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced\n}\n\nconst CSS_TRANSFORM_PROPERTIES: Record<string, string[]> = {\n transform: ['translate', 'scale', 'rotate', 'transform'],\n x: ['translate'],\n y: ['translate'],\n scale: ['scale'],\n scaleX: ['scale'],\n scaleY: ['scale'],\n rotate: ['rotate'],\n rotateX: ['transform'],\n rotateY: ['transform'],\n rotateZ: ['transform'],\n skewX: ['transform'],\n skewY: ['transform'],\n}\n\nconst getCSSProperties = (key: string) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key]\n}\n\nconst hyphenatedPropertyCache: Record<string, string> = {}\nconst emptyProperties: string[] = []\n\nfunction hyphenateProperty(property: string): string {\n if (property.startsWith('--')) return property\n return (hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n ))\n}\n\nfunction getLifecycleCSSProperties(keys: Set<string> | undefined): string[] {\n if (!keys?.size) return emptyProperties\n const properties = new Set<string>()\n for (const key of keys) {\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property))\n }\n }\n return [...properties].sort()\n}\n\nfunction readComputedProperties(\n node: HTMLElement,\n properties: readonly string[]\n): Record<string, string> {\n const computed = getComputedStyle(node)\n const values: Record<string, string> = {}\n for (const property of properties) {\n const value = computed.getPropertyValue(property)\n if (value) values[property] = value\n }\n return values\n}\n\nfunction applyCSSProperties(node: HTMLElement, values: Record<string, string>): void {\n for (const property in values) {\n node.style.setProperty(property, values[property])\n }\n}\n\nfunction clearCSSProperties(node: HTMLElement, properties: readonly string[]): void {\n for (const property of properties) {\n node.style.removeProperty(property)\n }\n}\n\nexport function createAnimations<A extends object>(animations: A): AnimationDriver<A> {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: 'css',\n outputStyle: 'css',\n\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition,\n }: any) => {\n const isHydrating = componentState.unmounted === true\n const isEntering = !!componentState.unmounted\n const isExiting = presence?.[0] === false\n const sendExitComplete = presence?.[1]\n const onTransitionRef = React.useRef(onTransition)\n onTransitionRef.current = onTransition\n const emit = (\n phase: 'start' | 'end',\n cause: 'enter' | 'exit' | 'update',\n finished?: boolean\n ) => {\n onTransitionRef.current?.(\n phase === 'end' ? { phase, cause, finished } : { phase, cause }\n )\n }\n\n // Track if we just finished entering (transition from entering to not entering)\n // This is needed because the CSS transition happens on the render AFTER t_unmounted is removed\n const wasEnteringRef = React.useRef(isEntering)\n const justFinishedEntering = wasEnteringRef.current && !isEntering\n React.useEffect(() => {\n wasEnteringRef.current = isEntering\n })\n\n // exit cycle guards to prevent stale/duplicate completion\n const exitCycleIdRef = React.useRef(0)\n const exitCompletedRef = React.useRef(false)\n const wasExitingRef = React.useRef(false)\n const sendExitCompleteRef = React.useRef(sendExitComplete)\n const lastMountedStyleRef = React.useRef<Record<string, string>>({})\n sendExitCompleteRef.current = sendExitComplete\n\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n )\n const exitCSSPropertiesSignature = exitCSSProperties.join('\\0')\n\n // onTransition lifecycle bookkeeping (independent from presence completion)\n const enterCycleIdRef = React.useRef(0)\n const enterStartedRef = React.useRef(false)\n const updateCycleIdRef = React.useRef(0)\n const updateInFlightRef = React.useRef(false)\n const prevUpdateSigRef = React.useRef<string | null>(null)\n const exitStartedRef = React.useRef(false)\n\n // detect transition into/out of exiting state\n const justStartedExiting = isExiting && !wasExitingRef.current\n const justStoppedExiting = !isExiting && wasExitingRef.current\n\n // start new exit cycle only on transition INTO exiting\n if (justStartedExiting) {\n exitCycleIdRef.current++\n exitCompletedRef.current = false\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++\n }\n\n // track previous exiting state\n React.useEffect(() => {\n wasExitingRef.current = isExiting\n })\n\n // Snapshot the actual mounted CSS values for every property with an exit\n // clause. Most program values live in generated classes rather than the\n // inline `style` object, so computed style is the only complete source.\n // The snapshot becomes the reset point for normal and interrupted exits.\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return\n const host = stateRef.current.host\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {}\n return\n }\n const node = host as HTMLElement\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties)\n }\n\n // The first mounted layout effect can run while an enter clause is still\n // active. Capture again after that concrete transition settles so a later\n // exit restarts from the mounted value, not the enter value.\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture)\n } else {\n capture()\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature])\n\n // use effectiveTransition computed by createComponent (single source of truth)\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition\n\n // Normalize the transition prop to a consistent format\n const normalized = normalizeTransition(effectiveTransition)\n\n // Determine animation state and get effective animation\n // Use 'enter' if we're entering OR if we just finished entering (transition is happening)\n const animationState = isExiting\n ? 'exit'\n : isEntering || justFinishedEntering\n ? 'enter'\n : 'default'\n const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState)\n const defaultAnimation = effectiveAnimationKey\n ? animations[effectiveAnimationKey]\n : null\n const animatedProperties = getAnimatedProperties(normalized)\n\n // Determine which properties to animate\n // - animateOnly prop is an exclusive filter (only animate those properties)\n // - per-property configs WITHOUT a default = only animate those specific properties\n // - per-property configs WITH a default = per-property overrides + default for rest\n const hasDefault =\n normalized.default !== null ||\n normalized.enter !== null ||\n normalized.exit !== null\n const hasPerPropertyConfigs = animatedProperties.length > 0\n\n let keys: string[]\n if (props.animateOnly) {\n // animateOnly is explicit filter\n keys = props.animateOnly\n } else if (hasPerPropertyConfigs && !hasDefault) {\n // object format without default: { opacity: '200ms' } = only animate opacity\n keys = animatedProperties\n } else if (hasPerPropertyConfigs && hasDefault) {\n // array format or object with default: 'all' first, then per-property overrides\n // CSS transition specificity: later declarations override earlier ones for the same property\n keys = ['all', ...animatedProperties]\n } else {\n // simple string format: 'quick' = animate all\n keys = ['all']\n }\n\n let transition: string | undefined\n const getTransition = () => {\n if (transition !== undefined) return transition\n const delay = normalized.delay ? ` ${normalized.delay}ms` : ''\n const duration = normalized.config?.duration\n transition = keys\n .flatMap((key) => {\n const propertyAnimation = normalized.properties[key]\n let animation = defaultAnimation\n if (typeof propertyAnimation === 'string') {\n animation = animations[propertyAnimation]\n } else if (propertyAnimation?.type) {\n animation = animations[propertyAnimation.type]\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration)\n }\n return animation\n ? getCSSProperties(key).map(\n (property) => `${property} ${animation}${delay}`\n )\n : []\n })\n .join(', ')\n return transition\n }\n\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!sendExitComplete || !isExiting || !host) return\n const node = host as HTMLElement\n\n // capture current cycle id for this effect\n const cycleId = exitCycleIdRef.current\n\n // emit exit start once per cycle\n if (!exitStartedRef.current) {\n exitStartedRef.current = true\n emit('start', 'exit')\n }\n\n // helper to complete exit with guards. the exit 'end' event fires\n // immediately before presence safeToRemove so users can observe exit\n // completion without reaching into presence internals.\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return\n if (exitCompletedRef.current) return\n exitCompletedRef.current = true\n if (exitStartedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', finished)\n }\n sendExitCompleteRef.current?.()\n }\n\n // if no properties to animate (animateOnly=[]), complete immediately\n if (keys.length === 0) {\n completeExit()\n return\n }\n\n // React can apply the exit class in the same render batch as the\n // transition. Restart from the last mounted computed values so normal\n // and interrupted exits both produce a concrete browser transition.\n let rafId: number | undefined\n let disposed = false\n\n const mountedStyle = lastMountedStyleRef.current\n const canRestart =\n exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0\n let exitTarget: Record<string, string> | undefined\n if (canRestart) {\n node.style.transition = 'none'\n // With transitions disabled, the exit classes expose their final\n // targets immediately. Capture those, then restore the mounted values.\n exitTarget = readComputedProperties(node, exitCSSProperties)\n applyCSSProperties(node, mountedStyle)\n void node.offsetHeight\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return\n node.style.transition = getTransition()\n void node.offsetHeight\n applyCSSProperties(node, exitTarget!)\n })\n }\n\n // wait for the browser's concrete animations. this covers `all`,\n // transform aliases, delays, and concurrent WAAPI animations without\n // guessing property names or maintaining a duration timer.\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished)\n })\n\n return () => {\n disposed = true\n if (rafId !== undefined) cancelAnimationFrame(rafId)\n clearCSSProperties(node, exitCSSProperties)\n // restore transition: the exit handling sets node.style.transition='none'\n // directly on the DOM (bypassing React). if exit is interrupted (e.g. same-key\n // re-entry in AnimatePresence), React won't re-apply its managed transition\n // value because it hasn't changed in the virtual DOM. clearing the inline\n // override lets React's value take effect again.\n node.style.transition = ''\n }\n }, [isExiting, exitCSSPropertiesSignature])\n\n // signature of the animatable style, so the update effect can detect\n // in-place style changes. the css driver applies most style values as\n // atomic classNames (not inline style), so the signature must include the\n // className map. only computed when a listener is attached.\n const styleSignature = onTransition\n ? (() => {\n const { transition: _t, ...rest } = style\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`\n })()\n : ''\n\n // enter lifecycle: emit start when the enter transition kicks off, end\n // once every animation on the node finishes (getAnimations-based, resolves\n // immediately for zero-animation elements). the promise outlives benign\n // re-renders because it keys off the cycle id, not the effect lifetime.\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return\n }\n const node = host as HTMLElement\n const cycleId = ++enterCycleIdRef.current\n enterStartedRef.current = true\n emit('start', 'enter')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return\n enterStartedRef.current = false\n emit('end', 'enter', finished)\n })\n }, [justFinishedEntering, isExiting])\n\n // update lifecycle: a style change while mounted (not entering or exiting).\n // a new update that supersedes an in-flight one emits end(finished:false).\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (\n !onTransitionRef.current ||\n isEntering ||\n justFinishedEntering ||\n isExiting ||\n !host\n ) {\n // keep the signature current so leaving enter/exit isn't seen as an update\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (styleSignature === prevUpdateSigRef.current) return\n prevUpdateSigRef.current = styleSignature\n\n const node = host as HTMLElement\n if (updateInFlightRef.current) {\n emit('end', 'update', false)\n }\n updateInFlightRef.current = true\n const cycleId = ++updateCycleIdRef.current\n emit('start', 'update')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return\n updateInFlightRef.current = false\n emit('end', 'update', finished)\n })\n }, [styleSignature, isEntering, justFinishedEntering, isExiting])\n\n // interruption: emit a finished:false end for an enter canceled by an exit,\n // or an exit canceled by a re-enter (before its own completion fired).\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++\n enterStartedRef.current = false\n emit('end', 'enter', false)\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', false)\n }\n }, [justStartedExiting, justStoppedExiting])\n\n // tamagui doesnt even use animation output during hydration\n if (isHydrating) {\n return null\n }\n\n // Check if we have any animation to apply\n if (!hasNormalizedAnimation(normalized)) {\n return null\n }\n\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform)\n }\n\n style.transition = getTransition()\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.info('CSS animation', {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting,\n })\n }\n\n return { style, className: isEntering ? 't_unmounted' : '' }\n },\n }\n}\n"
10
10
  ]
11
11
  }
@@ -0,0 +1,5 @@
1
+ import type { AnimationDriverWithAnimatedNumbers } from "@tamagui/web";
2
+ export * from "./animated-number";
3
+ export declare function createAnimations<A extends object>(animations: A): AnimationDriverWithAnimatedNumbers<A>;
4
+
5
+ //# sourceMappingURL=extras.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAAA,cAAc,0CAA0C;AAUxD,cAAc;AAEd,OAAO,iBAAS,iBAAiB,kBAC/B,YAAY,IACX,mCAAmC",
3
+ "names": [],
4
+ "sources": [
5
+ "src/extras.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import type { AnimationDriverWithAnimatedNumbers } from '@tamagui/web'\n\nimport {\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n} from './animated-number'\nimport { createAnimations as createCoreAnimations } from './createAnimations'\n\nexport * from './animated-number'\n\nexport function createAnimations<A extends object>(\n animations: A\n): AnimationDriverWithAnimatedNumbers<A> {\n return {\n ...createCoreAnimations(animations),\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n }\n}\n"
10
+ ]
11
+ }