@tamagui/animations-moti 2.0.0-rc.9 → 2.0.0

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.
Files changed (38) hide show
  1. package/dist/cjs/createAnimations.cjs +224 -172
  2. package/dist/cjs/createAnimations.native.js +227 -189
  3. package/dist/cjs/createAnimations.native.js.map +1 -1
  4. package/dist/cjs/index.cjs +7 -5
  5. package/dist/cjs/index.native.js +7 -5
  6. package/dist/cjs/index.native.js.map +1 -1
  7. package/dist/cjs/polyfill.cjs +6 -2
  8. package/dist/cjs/polyfill.native.js +6 -2
  9. package/dist/cjs/polyfill.native.js.map +1 -1
  10. package/dist/esm/createAnimations.mjs +194 -144
  11. package/dist/esm/createAnimations.mjs.map +1 -1
  12. package/dist/esm/createAnimations.native.js +197 -161
  13. package/dist/esm/createAnimations.native.js.map +1 -1
  14. package/dist/esm/index.js +1 -2
  15. package/dist/esm/index.js.map +1 -6
  16. package/dist/esm/index.mjs +0 -1
  17. package/dist/esm/index.mjs.map +1 -1
  18. package/dist/esm/index.native.js +0 -1
  19. package/dist/esm/index.native.js.map +1 -1
  20. package/dist/esm/polyfill.mjs +6 -2
  21. package/dist/esm/polyfill.mjs.map +1 -1
  22. package/dist/esm/polyfill.native.js +6 -2
  23. package/dist/esm/polyfill.native.js.map +1 -1
  24. package/package.json +9 -9
  25. package/src/createAnimations.tsx +2 -2
  26. package/types/createAnimations.d.ts.map +3 -3
  27. package/types/index.d.ts.map +2 -2
  28. package/types/polyfill.d.ts.map +2 -2
  29. package/dist/cjs/createAnimations.js +0 -220
  30. package/dist/cjs/createAnimations.js.map +0 -6
  31. package/dist/cjs/index.js +0 -16
  32. package/dist/cjs/index.js.map +0 -6
  33. package/dist/cjs/polyfill.js +0 -3
  34. package/dist/cjs/polyfill.js.map +0 -6
  35. package/dist/esm/createAnimations.js +0 -218
  36. package/dist/esm/createAnimations.js.map +0 -6
  37. package/dist/esm/polyfill.js +0 -3
  38. package/dist/esm/polyfill.js.map +0 -6
@@ -95,7 +95,7 @@ function createTamaguiAnimatedComponent(defaultTag = 'div') {
95
95
  return <Element {...transformedProps} ref={composedRefs} />
96
96
  })
97
97
  )
98
- Component['acceptTagProp'] = true
98
+ Component['acceptRenderProp'] = true
99
99
  return Component
100
100
  }
101
101
 
@@ -145,12 +145,12 @@ export function createAnimations<A extends Record<string, TransitionConfig>>(
145
145
  animations: A
146
146
  ): AnimationDriver<A> {
147
147
  return {
148
+ needsCustomComponent: true,
148
149
  View: isWeb ? AnimatedView : Animated.View,
149
150
  Text: isWeb ? AnimatedText : Animated.Text,
150
151
  // View: Animated.View,
151
152
  // Text: Animated.Text,
152
153
  isReactNative: true,
153
- supportsCSS: false,
154
154
  inputStyle: 'value',
155
155
  outputStyle: 'inline',
156
156
  animations,
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/createAnimations.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
- "// @ts-nocheck - deprecated package, moti dependency intentionally not included\nimport { PresenceContext, ResetPresence, usePresence } from '@tamagui/use-presence'\n// we need core for hooks.usePropsTransform\nimport {\n getSplitStyles,\n hooks,\n isWeb,\n Text,\n useComposedRefs,\n useThemeWithState,\n View,\n type AnimationDriver,\n type UniversalAnimatedNumber,\n} from '@tamagui/core'\n\n// Helper to resolve dynamic theme values like {dynamic: {dark: \"value\", light: undefined}}\nconst resolveDynamicValue = (value: any, isDark: boolean): any => {\n if (value && typeof value === 'object' && 'dynamic' in value) {\n const dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light\n return dynamicValue\n }\n return value\n}\nimport type { TransitionConfig } from 'moti'\nimport { useMotify } from 'moti/author'\nimport type { CSSProperties } from 'react'\nimport React, { forwardRef, useMemo, useRef } from 'react'\nimport type { TextStyle } from 'react-native'\nimport type { SharedValue } from 'react-native-reanimated'\nimport Animated_, {\n cancelAnimation,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated'\n\n// fix for building with type module\n// see https://github.com/evanw/esbuild/issues/2480#issuecomment-1833104754\nconst safeESModule = <T,>(a: T | { default: T }): T => {\n const b = a as any\n const out = b.__esModule || b[Symbol.toStringTag] === 'Module' ? b.default : b\n // add metro support\n return out || a\n}\n\nconst Animated = safeESModule(Animated_)\n\ntype ReanimatedAnimatedNumber = SharedValue<number>\n\n// this is our own custom reanimated animated component so we can allow data- attributes, className etc\n// this should ultimately be merged with react-native-web-lite\n\nfunction createTamaguiAnimatedComponent(defaultTag = 'div') {\n const isText = defaultTag === 'span'\n\n const Component = Animated.createAnimatedComponent(\n forwardRef((propsIn: any, ref) => {\n const { forwardedRef, animation, render = defaultTag, ...propsRest } = propsIn\n const hostRef = useRef(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, hostRef)\n const stateRef = useRef<any>(null)\n if (!stateRef.current) {\n stateRef.current = {\n get host() {\n return hostRef.current\n },\n }\n }\n\n const [_, state] = useThemeWithState({})\n\n // get styles but only inline style\n const result = getSplitStyles(\n propsRest,\n isText ? Text.staticConfig : View.staticConfig,\n state?.theme,\n state?.name,\n {\n unmounted: false,\n } as any,\n {\n isAnimated: false,\n noClass: true,\n }\n )\n\n const props = result?.viewProps || {}\n const Element = render\n const transformedProps = hooks.usePropsTransform?.(render, props, stateRef, false)\n\n return <Element {...transformedProps} ref={composedRefs} />\n })\n )\n Component['acceptTagProp'] = true\n return Component\n}\n\nconst AnimatedView = createTamaguiAnimatedComponent('div')\nconst AnimatedText = createTamaguiAnimatedComponent('span')\n\n// const AnimatedView = styled(View, {\n// disableClassName: true,\n// })\n\n// const AnimatedText = styled(Text, {\n// disableClassName: true,\n// })\n\nconst onlyAnimateKeys: { [key in keyof TextStyle | keyof CSSProperties]?: boolean } = {\n transform: true,\n opacity: true,\n height: true,\n width: true,\n backgroundColor: true,\n borderColor: true,\n borderLeftColor: true,\n borderRightColor: true,\n borderTopColor: true,\n borderBottomColor: true,\n borderRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderLeftWidth: true,\n borderRightWidth: true,\n borderTopWidth: true,\n borderBottomWidth: true,\n color: true,\n left: true,\n right: true,\n top: true,\n bottom: true,\n fontSize: true,\n fontWeight: true,\n lineHeight: true,\n letterSpacing: true,\n}\n\nexport function createAnimations<A extends Record<string, TransitionConfig>>(\n animations: A\n): AnimationDriver<A> {\n return {\n View: isWeb ? AnimatedView : Animated.View,\n Text: isWeb ? AnimatedText : Animated.Text,\n // View: Animated.View,\n // Text: Animated.Text,\n isReactNative: true,\n supportsCSS: false,\n inputStyle: 'value',\n outputStyle: 'inline',\n animations,\n usePresence,\n ResetPresence,\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<ReanimatedAnimatedNumber> {\n const sharedValue = useSharedValue(initial)\n\n return React.useMemo(\n () => ({\n getInstance() {\n 'worklet'\n return sharedValue\n },\n getValue() {\n 'worklet'\n return sharedValue.value\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n 'worklet'\n if (config.type === 'direct') {\n sharedValue.value = next\n onFinish?.()\n } else if (config.type === 'spring') {\n sharedValue.value = withSpring(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n } else {\n sharedValue.value = withTiming(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n }\n },\n stop() {\n 'worklet'\n cancelAnimation(sharedValue)\n },\n }),\n [sharedValue]\n )\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n const instance = value.getInstance()\n return useAnimatedReaction(\n () => {\n return instance.value\n },\n (next, prev) => {\n if (prev !== next) {\n // @nate what is the point of this hook? is this necessary?\n // without runOnJS, onValue would need to be a worklet\n runOnJS(onValue)(next)\n }\n },\n // dependency array is very important here\n [onValue, instance]\n )\n },\n\n /**\n * `getStyle` must be a worklet\n */\n useAnimatedNumberStyle(val, getStyle) {\n const instance = val.getInstance()\n\n // this seems wrong but it works\n const derivedValue = useDerivedValue(() => {\n return instance.value\n // dependency array is very important here\n }, [instance, getStyle])\n\n return useAnimatedStyle(() => {\n return getStyle(derivedValue.value)\n // dependency array is very important here\n }, [val, getStyle, derivedValue, instance])\n },\n\n useAnimations: (animationProps) => {\n const { props, presence, style, componentState } = animationProps\n const animationKey = Array.isArray(props.transition)\n ? props.transition[0]\n : props.transition\n\n const isHydrating = componentState.unmounted === true\n const disableAnimation = isHydrating || !animationKey\n const presenceContext = React.useContext(PresenceContext)\n const [, themeState] = useThemeWithState({})\n // Check scheme first, then fall back to checking theme name for 'dark'\n const isDark = themeState?.scheme === 'dark' || themeState?.name?.startsWith('dark')\n\n // this memo is very important for performance, there's a big cost to\n // updating these values every render\n const { dontAnimate, motiProps } = useMemo(() => {\n let animate = {}\n let dontAnimate = {}\n\n if (disableAnimation) {\n // Resolve dynamic objects based on current theme\n for (const key in style) {\n const rawValue = style[key]\n const value = resolveDynamicValue(rawValue, isDark)\n if (value === undefined) continue\n dontAnimate[key] = value\n }\n } else {\n const animateOnly = props.animateOnly as string[]\n for (const key in style) {\n const rawValue = style[key]\n // Resolve dynamic theme values (like $theme-dark)\n const value = resolveDynamicValue(rawValue, isDark)\n if (value === undefined) continue\n if (\n !onlyAnimateKeys[key] ||\n value === 'auto' ||\n (typeof value === 'string' && value.startsWith('calc')) ||\n (animateOnly && !animateOnly.includes(key))\n ) {\n dontAnimate[key] = value\n } else {\n animate[key] = value\n }\n }\n }\n\n // if we don't do this moti seems to flicker a frame before applying animation\n if (componentState.unmounted === 'should-enter') {\n // Resolve dynamic objects based on current theme\n for (const key in style) {\n const rawValue = style[key]\n const value = resolveDynamicValue(rawValue, isDark)\n if (value === undefined) continue\n dontAnimate[key] = value\n }\n }\n\n const styles = animate\n const isExiting = Boolean(presence?.[1])\n const usePresenceValue = (presence || undefined) as any\n\n type UseMotiProps = Parameters<typeof useMotify>[0]\n\n // TODO moti is giving us type troubles, but this should work\n let transition = isHydrating\n ? { type: 'transition', duration: 0 }\n : (animations[animationKey as keyof typeof animations] as any)\n\n let hasClonedTransition = false\n\n if (Array.isArray(props.transition)) {\n const config = props.transition[1]\n if (config && typeof config === 'object') {\n for (const key in config) {\n const val = config[key]\n\n // performance - this seems to have (strangely) huge performance effect in uniswap\n // so instead of cloning up front, we clone only when we absolutely have to\n if (!hasClonedTransition) {\n transition = Object.assign({}, transition)\n hasClonedTransition = true\n }\n\n // referencing a pre-defined config\n if (typeof val === 'string') {\n transition[key] = animations[val]\n } else {\n transition[key] = val\n }\n }\n }\n }\n\n return {\n dontAnimate,\n motiProps: {\n animate: isExiting || componentState.unmounted === true ? {} : styles,\n transition: componentState.unmounted ? { duration: 0 } : transition,\n usePresenceValue,\n presenceContext,\n exit: isExiting ? styles : undefined,\n } satisfies UseMotiProps,\n }\n }, [\n presenceContext,\n presence,\n animationKey,\n componentState.unmounted,\n JSON.stringify(style),\n presenceContext,\n isDark,\n ])\n\n const moti = useMotify(motiProps)\n\n if (\n process.env.NODE_ENV === 'development' &&\n props['debug'] &&\n props['debug'] !== 'profile'\n ) {\n console.info(`useMotify(`, JSON.stringify(motiProps, null, 2) + ')', {\n 'componentState.unmounted': componentState.unmounted,\n animationProps,\n motiProps,\n moti,\n style: [dontAnimate, moti.style],\n })\n }\n\n return {\n style: [dontAnimate, moti.style],\n }\n },\n }\n}\n"
9
- ],
10
- "version": 3
9
+ "// @ts-nocheck - deprecated package, moti dependency intentionally not included\nimport { PresenceContext, ResetPresence, usePresence } from '@tamagui/use-presence'\n// we need core for hooks.usePropsTransform\nimport {\n getSplitStyles,\n hooks,\n isWeb,\n Text,\n useComposedRefs,\n useThemeWithState,\n View,\n type AnimationDriver,\n type UniversalAnimatedNumber,\n} from '@tamagui/core'\n\n// Helper to resolve dynamic theme values like {dynamic: {dark: \"value\", light: undefined}}\nconst resolveDynamicValue = (value: any, isDark: boolean): any => {\n if (value && typeof value === 'object' && 'dynamic' in value) {\n const dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light\n return dynamicValue\n }\n return value\n}\nimport type { TransitionConfig } from 'moti'\nimport { useMotify } from 'moti/author'\nimport type { CSSProperties } from 'react'\nimport React, { forwardRef, useMemo, useRef } from 'react'\nimport type { TextStyle } from 'react-native'\nimport type { SharedValue } from 'react-native-reanimated'\nimport Animated_, {\n cancelAnimation,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated'\n\n// fix for building with type module\n// see https://github.com/evanw/esbuild/issues/2480#issuecomment-1833104754\nconst safeESModule = <T,>(a: T | { default: T }): T => {\n const b = a as any\n const out = b.__esModule || b[Symbol.toStringTag] === 'Module' ? b.default : b\n // add metro support\n return out || a\n}\n\nconst Animated = safeESModule(Animated_)\n\ntype ReanimatedAnimatedNumber = SharedValue<number>\n\n// this is our own custom reanimated animated component so we can allow data- attributes, className etc\n// this should ultimately be merged with react-native-web-lite\n\nfunction createTamaguiAnimatedComponent(defaultTag = 'div') {\n const isText = defaultTag === 'span'\n\n const Component = Animated.createAnimatedComponent(\n forwardRef((propsIn: any, ref) => {\n const { forwardedRef, animation, render = defaultTag, ...propsRest } = propsIn\n const hostRef = useRef(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, hostRef)\n const stateRef = useRef<any>(null)\n if (!stateRef.current) {\n stateRef.current = {\n get host() {\n return hostRef.current\n },\n }\n }\n\n const [_, state] = useThemeWithState({})\n\n // get styles but only inline style\n const result = getSplitStyles(\n propsRest,\n isText ? Text.staticConfig : View.staticConfig,\n state?.theme,\n state?.name,\n {\n unmounted: false,\n } as any,\n {\n isAnimated: false,\n noClass: true,\n }\n )\n\n const props = result?.viewProps || {}\n const Element = render\n const transformedProps = hooks.usePropsTransform?.(render, props, stateRef, false)\n\n return <Element {...transformedProps} ref={composedRefs} />\n })\n )\n Component['acceptRenderProp'] = true\n return Component\n}\n\nconst AnimatedView = createTamaguiAnimatedComponent('div')\nconst AnimatedText = createTamaguiAnimatedComponent('span')\n\n// const AnimatedView = styled(View, {\n// disableClassName: true,\n// })\n\n// const AnimatedText = styled(Text, {\n// disableClassName: true,\n// })\n\nconst onlyAnimateKeys: { [key in keyof TextStyle | keyof CSSProperties]?: boolean } = {\n transform: true,\n opacity: true,\n height: true,\n width: true,\n backgroundColor: true,\n borderColor: true,\n borderLeftColor: true,\n borderRightColor: true,\n borderTopColor: true,\n borderBottomColor: true,\n borderRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderLeftWidth: true,\n borderRightWidth: true,\n borderTopWidth: true,\n borderBottomWidth: true,\n color: true,\n left: true,\n right: true,\n top: true,\n bottom: true,\n fontSize: true,\n fontWeight: true,\n lineHeight: true,\n letterSpacing: true,\n}\n\nexport function createAnimations<A extends Record<string, TransitionConfig>>(\n animations: A\n): AnimationDriver<A> {\n return {\n needsCustomComponent: true,\n View: isWeb ? AnimatedView : Animated.View,\n Text: isWeb ? AnimatedText : Animated.Text,\n // View: Animated.View,\n // Text: Animated.Text,\n isReactNative: true,\n inputStyle: 'value',\n outputStyle: 'inline',\n animations,\n usePresence,\n ResetPresence,\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<ReanimatedAnimatedNumber> {\n const sharedValue = useSharedValue(initial)\n\n return React.useMemo(\n () => ({\n getInstance() {\n 'worklet'\n return sharedValue\n },\n getValue() {\n 'worklet'\n return sharedValue.value\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n 'worklet'\n if (config.type === 'direct') {\n sharedValue.value = next\n onFinish?.()\n } else if (config.type === 'spring') {\n sharedValue.value = withSpring(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n } else {\n sharedValue.value = withTiming(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n }\n },\n stop() {\n 'worklet'\n cancelAnimation(sharedValue)\n },\n }),\n [sharedValue]\n )\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n const instance = value.getInstance()\n return useAnimatedReaction(\n () => {\n return instance.value\n },\n (next, prev) => {\n if (prev !== next) {\n // @nate what is the point of this hook? is this necessary?\n // without runOnJS, onValue would need to be a worklet\n runOnJS(onValue)(next)\n }\n },\n // dependency array is very important here\n [onValue, instance]\n )\n },\n\n /**\n * `getStyle` must be a worklet\n */\n useAnimatedNumberStyle(val, getStyle) {\n const instance = val.getInstance()\n\n // this seems wrong but it works\n const derivedValue = useDerivedValue(() => {\n return instance.value\n // dependency array is very important here\n }, [instance, getStyle])\n\n return useAnimatedStyle(() => {\n return getStyle(derivedValue.value)\n // dependency array is very important here\n }, [val, getStyle, derivedValue, instance])\n },\n\n useAnimations: (animationProps) => {\n const { props, presence, style, componentState } = animationProps\n const animationKey = Array.isArray(props.transition)\n ? props.transition[0]\n : props.transition\n\n const isHydrating = componentState.unmounted === true\n const disableAnimation = isHydrating || !animationKey\n const presenceContext = React.useContext(PresenceContext)\n const [, themeState] = useThemeWithState({})\n // Check scheme first, then fall back to checking theme name for 'dark'\n const isDark = themeState?.scheme === 'dark' || themeState?.name?.startsWith('dark')\n\n // this memo is very important for performance, there's a big cost to\n // updating these values every render\n const { dontAnimate, motiProps } = useMemo(() => {\n let animate = {}\n let dontAnimate = {}\n\n if (disableAnimation) {\n // Resolve dynamic objects based on current theme\n for (const key in style) {\n const rawValue = style[key]\n const value = resolveDynamicValue(rawValue, isDark)\n if (value === undefined) continue\n dontAnimate[key] = value\n }\n } else {\n const animateOnly = props.animateOnly as string[]\n for (const key in style) {\n const rawValue = style[key]\n // Resolve dynamic theme values (like $theme-dark)\n const value = resolveDynamicValue(rawValue, isDark)\n if (value === undefined) continue\n if (\n !onlyAnimateKeys[key] ||\n value === 'auto' ||\n (typeof value === 'string' && value.startsWith('calc')) ||\n (animateOnly && !animateOnly.includes(key))\n ) {\n dontAnimate[key] = value\n } else {\n animate[key] = value\n }\n }\n }\n\n // if we don't do this moti seems to flicker a frame before applying animation\n if (componentState.unmounted === 'should-enter') {\n // Resolve dynamic objects based on current theme\n for (const key in style) {\n const rawValue = style[key]\n const value = resolveDynamicValue(rawValue, isDark)\n if (value === undefined) continue\n dontAnimate[key] = value\n }\n }\n\n const styles = animate\n const isExiting = Boolean(presence?.[1])\n const usePresenceValue = (presence || undefined) as any\n\n type UseMotiProps = Parameters<typeof useMotify>[0]\n\n // TODO moti is giving us type troubles, but this should work\n let transition = isHydrating\n ? { type: 'transition', duration: 0 }\n : (animations[animationKey as keyof typeof animations] as any)\n\n let hasClonedTransition = false\n\n if (Array.isArray(props.transition)) {\n const config = props.transition[1]\n if (config && typeof config === 'object') {\n for (const key in config) {\n const val = config[key]\n\n // performance - this seems to have (strangely) huge performance effect in uniswap\n // so instead of cloning up front, we clone only when we absolutely have to\n if (!hasClonedTransition) {\n transition = Object.assign({}, transition)\n hasClonedTransition = true\n }\n\n // referencing a pre-defined config\n if (typeof val === 'string') {\n transition[key] = animations[val]\n } else {\n transition[key] = val\n }\n }\n }\n }\n\n return {\n dontAnimate,\n motiProps: {\n animate: isExiting || componentState.unmounted === true ? {} : styles,\n transition: componentState.unmounted ? { duration: 0 } : transition,\n usePresenceValue,\n presenceContext,\n exit: isExiting ? styles : undefined,\n } satisfies UseMotiProps,\n }\n }, [\n presenceContext,\n presence,\n animationKey,\n componentState.unmounted,\n JSON.stringify(style),\n presenceContext,\n isDark,\n ])\n\n const moti = useMotify(motiProps)\n\n if (\n process.env.NODE_ENV === 'development' &&\n props['debug'] &&\n props['debug'] !== 'profile'\n ) {\n console.info(`useMotify(`, JSON.stringify(motiProps, null, 2) + ')', {\n 'componentState.unmounted': componentState.unmounted,\n animationProps,\n motiProps,\n moti,\n style: [dontAnimate, moti.style],\n })\n }\n\n return {\n style: [dontAnimate, moti.style],\n }\n },\n }\n}\n"
10
+ ]
11
11
  }
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/index.ts"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import './polyfill'\n\nexport * from './createAnimations'\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/polyfill.ts"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "// for SSR\nif (typeof requestAnimationFrame === 'undefined') {\n globalThis['requestAnimationFrame'] = setTimeout\n}\n\n// for reanimated\nif (typeof global === 'undefined') {\n globalThis['global'] = globalThis\n}\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -1,220 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var createAnimations_exports = {};
24
- __export(createAnimations_exports, {
25
- createAnimations: () => createAnimations
26
- });
27
- module.exports = __toCommonJS(createAnimations_exports);
28
- var import_use_presence = require("@tamagui/use-presence"), import_core = require("@tamagui/core"), import_author = require("moti/author"), import_react = __toESM(require("react"), 1), import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1), import_jsx_runtime = require("react/jsx-runtime");
29
- const resolveDynamicValue = (value, isDark) => value && typeof value == "object" && "dynamic" in value ? isDark ? value.dynamic.dark : value.dynamic.light : value, safeESModule = (a) => {
30
- const b = a;
31
- return (b.__esModule || b[Symbol.toStringTag] === "Module" ? b.default : b) || a;
32
- }, Animated = safeESModule(import_react_native_reanimated.default);
33
- function createTamaguiAnimatedComponent(defaultTag = "div") {
34
- const isText = defaultTag === "span", Component = Animated.createAnimatedComponent(
35
- (0, import_react.forwardRef)((propsIn, ref) => {
36
- const { forwardedRef, animation, render = defaultTag, ...propsRest } = propsIn, hostRef = (0, import_react.useRef)(null), composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef), stateRef = (0, import_react.useRef)(null);
37
- stateRef.current || (stateRef.current = {
38
- get host() {
39
- return hostRef.current;
40
- }
41
- });
42
- const [_, state] = (0, import_core.useThemeWithState)({}), props = (0, import_core.getSplitStyles)(
43
- propsRest,
44
- isText ? import_core.Text.staticConfig : import_core.View.staticConfig,
45
- state?.theme,
46
- state?.name,
47
- {
48
- unmounted: !1
49
- },
50
- {
51
- isAnimated: !1,
52
- noClass: !0
53
- }
54
- )?.viewProps || {}, Element = render, transformedProps = import_core.hooks.usePropsTransform?.(render, props, stateRef, !1);
55
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Element, { ...transformedProps, ref: composedRefs });
56
- })
57
- );
58
- return Component.acceptTagProp = !0, Component;
59
- }
60
- const AnimatedView = createTamaguiAnimatedComponent("div"), AnimatedText = createTamaguiAnimatedComponent("span"), onlyAnimateKeys = {
61
- transform: !0,
62
- opacity: !0,
63
- height: !0,
64
- width: !0,
65
- backgroundColor: !0,
66
- borderColor: !0,
67
- borderLeftColor: !0,
68
- borderRightColor: !0,
69
- borderTopColor: !0,
70
- borderBottomColor: !0,
71
- borderRadius: !0,
72
- borderTopLeftRadius: !0,
73
- borderTopRightRadius: !0,
74
- borderBottomLeftRadius: !0,
75
- borderBottomRightRadius: !0,
76
- borderLeftWidth: !0,
77
- borderRightWidth: !0,
78
- borderTopWidth: !0,
79
- borderBottomWidth: !0,
80
- color: !0,
81
- left: !0,
82
- right: !0,
83
- top: !0,
84
- bottom: !0,
85
- fontSize: !0,
86
- fontWeight: !0,
87
- lineHeight: !0,
88
- letterSpacing: !0
89
- };
90
- function createAnimations(animations) {
91
- return {
92
- View: import_core.isWeb ? AnimatedView : Animated.View,
93
- Text: import_core.isWeb ? AnimatedText : Animated.Text,
94
- // View: Animated.View,
95
- // Text: Animated.Text,
96
- isReactNative: !0,
97
- supportsCSS: !1,
98
- inputStyle: "value",
99
- outputStyle: "inline",
100
- animations,
101
- usePresence: import_use_presence.usePresence,
102
- ResetPresence: import_use_presence.ResetPresence,
103
- useAnimatedNumber(initial) {
104
- const sharedValue = (0, import_react_native_reanimated.useSharedValue)(initial);
105
- return import_react.default.useMemo(
106
- () => ({
107
- getInstance() {
108
- "worklet";
109
- return sharedValue;
110
- },
111
- getValue() {
112
- "worklet";
113
- return sharedValue.value;
114
- },
115
- setValue(next, config = { type: "spring" }, onFinish) {
116
- "worklet";
117
- config.type === "direct" ? (sharedValue.value = next, onFinish?.()) : config.type === "spring" ? sharedValue.value = (0, import_react_native_reanimated.withSpring)(
118
- next,
119
- config,
120
- onFinish ? () => {
121
- "worklet";
122
- (0, import_react_native_reanimated.runOnJS)(onFinish)();
123
- } : void 0
124
- ) : sharedValue.value = (0, import_react_native_reanimated.withTiming)(
125
- next,
126
- config,
127
- onFinish ? () => {
128
- "worklet";
129
- (0, import_react_native_reanimated.runOnJS)(onFinish)();
130
- } : void 0
131
- );
132
- },
133
- stop() {
134
- "worklet";
135
- (0, import_react_native_reanimated.cancelAnimation)(sharedValue);
136
- }
137
- }),
138
- [sharedValue]
139
- );
140
- },
141
- useAnimatedNumberReaction({ value }, onValue) {
142
- const instance = value.getInstance();
143
- return (0, import_react_native_reanimated.useAnimatedReaction)(
144
- () => instance.value,
145
- (next, prev) => {
146
- prev !== next && (0, import_react_native_reanimated.runOnJS)(onValue)(next);
147
- },
148
- // dependency array is very important here
149
- [onValue, instance]
150
- );
151
- },
152
- /**
153
- * `getStyle` must be a worklet
154
- */
155
- useAnimatedNumberStyle(val, getStyle) {
156
- const instance = val.getInstance(), derivedValue = (0, import_react_native_reanimated.useDerivedValue)(() => instance.value, [instance, getStyle]);
157
- return (0, import_react_native_reanimated.useAnimatedStyle)(() => getStyle(derivedValue.value), [val, getStyle, derivedValue, instance]);
158
- },
159
- useAnimations: (animationProps) => {
160
- const { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.transition) ? props.transition[0] : props.transition, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey, presenceContext = import_react.default.useContext(import_use_presence.PresenceContext), [, themeState] = (0, import_core.useThemeWithState)({}), isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark"), { dontAnimate, motiProps } = (0, import_react.useMemo)(() => {
161
- let animate = {}, dontAnimate2 = {};
162
- if (disableAnimation)
163
- for (const key in style) {
164
- const rawValue = style[key], value = resolveDynamicValue(rawValue, isDark);
165
- value !== void 0 && (dontAnimate2[key] = value);
166
- }
167
- else {
168
- const animateOnly = props.animateOnly;
169
- for (const key in style) {
170
- const rawValue = style[key], value = resolveDynamicValue(rawValue, isDark);
171
- value !== void 0 && (!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value);
172
- }
173
- }
174
- if (componentState.unmounted === "should-enter")
175
- for (const key in style) {
176
- const rawValue = style[key], value = resolveDynamicValue(rawValue, isDark);
177
- value !== void 0 && (dontAnimate2[key] = value);
178
- }
179
- const styles = animate, isExiting = !!presence?.[1], usePresenceValue = presence || void 0;
180
- let transition = isHydrating ? { type: "transition", duration: 0 } : animations[animationKey], hasClonedTransition = !1;
181
- if (Array.isArray(props.transition)) {
182
- const config = props.transition[1];
183
- if (config && typeof config == "object")
184
- for (const key in config) {
185
- const val = config[key];
186
- hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
187
- }
188
- }
189
- return {
190
- dontAnimate: dontAnimate2,
191
- motiProps: {
192
- animate: isExiting || componentState.unmounted === !0 ? {} : styles,
193
- transition: componentState.unmounted ? { duration: 0 } : transition,
194
- usePresenceValue,
195
- presenceContext,
196
- exit: isExiting ? styles : void 0
197
- }
198
- };
199
- }, [
200
- presenceContext,
201
- presence,
202
- animationKey,
203
- componentState.unmounted,
204
- JSON.stringify(style),
205
- presenceContext,
206
- isDark
207
- ]), moti = (0, import_author.useMotify)(motiProps);
208
- return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
209
- "componentState.unmounted": componentState.unmounted,
210
- animationProps,
211
- motiProps,
212
- moti,
213
- style: [dontAnimate, moti.style]
214
- }), {
215
- style: [dontAnimate, moti.style]
216
- };
217
- }
218
- };
219
- }
220
- //# sourceMappingURL=createAnimations.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/createAnimations.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAA4D,kCAE5D,cAUO,0BAWP,gBAA0B,wBAE1B,eAAmD,8BAGnD,iCASO,gDAwDM;AA9Eb,MAAM,sBAAsB,CAAC,OAAY,WACnC,SAAS,OAAO,SAAU,YAAY,aAAa,QAChC,SAAS,MAAM,QAAQ,OAAO,MAAM,QAAQ,QAG5D,OAqBH,eAAe,CAAK,MAA6B;AACrD,QAAM,IAAI;AAGV,UAFY,EAAE,cAAc,EAAE,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QACA;AAAA,MACF,CAAC,GAEK,WAAO,yBAAU,SAAS;AAEhC,aACE,QAAQ,IAAI,aAAa,iBACzB,MAAM,SACN,MAAM,UAAa,aAEnB,QAAQ,KAAK,cAAc,KAAK,UAAU,WAAW,MAAM,CAAC,IAAI,KAAK;AAAA,QACnE,4BAA4B,eAAe;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC,CAAC,GAGI;AAAA,QACL,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AACF;",
5
- "names": ["Animated_", "React", "dontAnimate"]
6
- }
package/dist/cjs/index.js DELETED
@@ -1,16 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var index_exports = {};
13
- module.exports = __toCommonJS(index_exports);
14
- var import_polyfill = require("./polyfill");
15
- __reExport(index_exports, require("./createAnimations"), module.exports);
16
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,sBAAO;AAEP,0BAAc,+BAFd;",
5
- "names": []
6
- }
@@ -1,3 +0,0 @@
1
- typeof requestAnimationFrame > "u" && (globalThis.requestAnimationFrame = setTimeout);
2
- typeof global > "u" && (globalThis.global = globalThis);
3
- //# sourceMappingURL=polyfill.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/polyfill.ts"],
4
- "mappings": "AACI,OAAO,wBAA0B,QACnC,WAAW,wBAA2B;AAIpC,OAAO,SAAW,QACpB,WAAW,SAAY;",
5
- "names": []
6
- }
@@ -1,218 +0,0 @@
1
- import { PresenceContext, ResetPresence, usePresence } from "@tamagui/use-presence";
2
- import {
3
- getSplitStyles,
4
- hooks,
5
- isWeb,
6
- Text,
7
- useComposedRefs,
8
- useThemeWithState,
9
- View
10
- } from "@tamagui/core";
11
- import { useMotify } from "moti/author";
12
- import React, { forwardRef, useMemo, useRef } from "react";
13
- import Animated_, {
14
- cancelAnimation,
15
- runOnJS,
16
- useAnimatedReaction,
17
- useAnimatedStyle,
18
- useDerivedValue,
19
- useSharedValue,
20
- withSpring,
21
- withTiming
22
- } from "react-native-reanimated";
23
- import { jsx } from "react/jsx-runtime";
24
- const resolveDynamicValue = (value, isDark) => value && typeof value == "object" && "dynamic" in value ? isDark ? value.dynamic.dark : value.dynamic.light : value, safeESModule = (a) => {
25
- const b = a;
26
- return (b.__esModule || b[Symbol.toStringTag] === "Module" ? b.default : b) || a;
27
- }, Animated = safeESModule(Animated_);
28
- function createTamaguiAnimatedComponent(defaultTag = "div") {
29
- const isText = defaultTag === "span", Component = Animated.createAnimatedComponent(
30
- forwardRef((propsIn, ref) => {
31
- const { forwardedRef, animation, render = defaultTag, ...propsRest } = propsIn, hostRef = useRef(null), composedRefs = useComposedRefs(forwardedRef, ref, hostRef), stateRef = useRef(null);
32
- stateRef.current || (stateRef.current = {
33
- get host() {
34
- return hostRef.current;
35
- }
36
- });
37
- const [_, state] = useThemeWithState({}), props = getSplitStyles(
38
- propsRest,
39
- isText ? Text.staticConfig : View.staticConfig,
40
- state?.theme,
41
- state?.name,
42
- {
43
- unmounted: !1
44
- },
45
- {
46
- isAnimated: !1,
47
- noClass: !0
48
- }
49
- )?.viewProps || {}, Element = render, transformedProps = hooks.usePropsTransform?.(render, props, stateRef, !1);
50
- return /* @__PURE__ */ jsx(Element, { ...transformedProps, ref: composedRefs });
51
- })
52
- );
53
- return Component.acceptTagProp = !0, Component;
54
- }
55
- const AnimatedView = createTamaguiAnimatedComponent("div"), AnimatedText = createTamaguiAnimatedComponent("span"), onlyAnimateKeys = {
56
- transform: !0,
57
- opacity: !0,
58
- height: !0,
59
- width: !0,
60
- backgroundColor: !0,
61
- borderColor: !0,
62
- borderLeftColor: !0,
63
- borderRightColor: !0,
64
- borderTopColor: !0,
65
- borderBottomColor: !0,
66
- borderRadius: !0,
67
- borderTopLeftRadius: !0,
68
- borderTopRightRadius: !0,
69
- borderBottomLeftRadius: !0,
70
- borderBottomRightRadius: !0,
71
- borderLeftWidth: !0,
72
- borderRightWidth: !0,
73
- borderTopWidth: !0,
74
- borderBottomWidth: !0,
75
- color: !0,
76
- left: !0,
77
- right: !0,
78
- top: !0,
79
- bottom: !0,
80
- fontSize: !0,
81
- fontWeight: !0,
82
- lineHeight: !0,
83
- letterSpacing: !0
84
- };
85
- function createAnimations(animations) {
86
- return {
87
- View: isWeb ? AnimatedView : Animated.View,
88
- Text: isWeb ? AnimatedText : Animated.Text,
89
- // View: Animated.View,
90
- // Text: Animated.Text,
91
- isReactNative: !0,
92
- supportsCSS: !1,
93
- inputStyle: "value",
94
- outputStyle: "inline",
95
- animations,
96
- usePresence,
97
- ResetPresence,
98
- useAnimatedNumber(initial) {
99
- const sharedValue = useSharedValue(initial);
100
- return React.useMemo(
101
- () => ({
102
- getInstance() {
103
- "worklet";
104
- return sharedValue;
105
- },
106
- getValue() {
107
- "worklet";
108
- return sharedValue.value;
109
- },
110
- setValue(next, config = { type: "spring" }, onFinish) {
111
- "worklet";
112
- config.type === "direct" ? (sharedValue.value = next, onFinish?.()) : config.type === "spring" ? sharedValue.value = withSpring(
113
- next,
114
- config,
115
- onFinish ? () => {
116
- "worklet";
117
- runOnJS(onFinish)();
118
- } : void 0
119
- ) : sharedValue.value = withTiming(
120
- next,
121
- config,
122
- onFinish ? () => {
123
- "worklet";
124
- runOnJS(onFinish)();
125
- } : void 0
126
- );
127
- },
128
- stop() {
129
- "worklet";
130
- cancelAnimation(sharedValue);
131
- }
132
- }),
133
- [sharedValue]
134
- );
135
- },
136
- useAnimatedNumberReaction({ value }, onValue) {
137
- const instance = value.getInstance();
138
- return useAnimatedReaction(
139
- () => instance.value,
140
- (next, prev) => {
141
- prev !== next && runOnJS(onValue)(next);
142
- },
143
- // dependency array is very important here
144
- [onValue, instance]
145
- );
146
- },
147
- /**
148
- * `getStyle` must be a worklet
149
- */
150
- useAnimatedNumberStyle(val, getStyle) {
151
- const instance = val.getInstance(), derivedValue = useDerivedValue(() => instance.value, [instance, getStyle]);
152
- return useAnimatedStyle(() => getStyle(derivedValue.value), [val, getStyle, derivedValue, instance]);
153
- },
154
- useAnimations: (animationProps) => {
155
- const { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.transition) ? props.transition[0] : props.transition, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey, presenceContext = React.useContext(PresenceContext), [, themeState] = useThemeWithState({}), isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark"), { dontAnimate, motiProps } = useMemo(() => {
156
- let animate = {}, dontAnimate2 = {};
157
- if (disableAnimation)
158
- for (const key in style) {
159
- const rawValue = style[key], value = resolveDynamicValue(rawValue, isDark);
160
- value !== void 0 && (dontAnimate2[key] = value);
161
- }
162
- else {
163
- const animateOnly = props.animateOnly;
164
- for (const key in style) {
165
- const rawValue = style[key], value = resolveDynamicValue(rawValue, isDark);
166
- value !== void 0 && (!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value);
167
- }
168
- }
169
- if (componentState.unmounted === "should-enter")
170
- for (const key in style) {
171
- const rawValue = style[key], value = resolveDynamicValue(rawValue, isDark);
172
- value !== void 0 && (dontAnimate2[key] = value);
173
- }
174
- const styles = animate, isExiting = !!presence?.[1], usePresenceValue = presence || void 0;
175
- let transition = isHydrating ? { type: "transition", duration: 0 } : animations[animationKey], hasClonedTransition = !1;
176
- if (Array.isArray(props.transition)) {
177
- const config = props.transition[1];
178
- if (config && typeof config == "object")
179
- for (const key in config) {
180
- const val = config[key];
181
- hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
182
- }
183
- }
184
- return {
185
- dontAnimate: dontAnimate2,
186
- motiProps: {
187
- animate: isExiting || componentState.unmounted === !0 ? {} : styles,
188
- transition: componentState.unmounted ? { duration: 0 } : transition,
189
- usePresenceValue,
190
- presenceContext,
191
- exit: isExiting ? styles : void 0
192
- }
193
- };
194
- }, [
195
- presenceContext,
196
- presence,
197
- animationKey,
198
- componentState.unmounted,
199
- JSON.stringify(style),
200
- presenceContext,
201
- isDark
202
- ]), moti = useMotify(motiProps);
203
- return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
204
- "componentState.unmounted": componentState.unmounted,
205
- animationProps,
206
- motiProps,
207
- moti,
208
- style: [dontAnimate, moti.style]
209
- }), {
210
- style: [dontAnimate, moti.style]
211
- };
212
- }
213
- };
214
- }
215
- export {
216
- createAnimations
217
- };
218
- //# sourceMappingURL=createAnimations.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/createAnimations.tsx"],
4
- "mappings": "AACA,SAAS,iBAAiB,eAAe,mBAAmB;AAE5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAWP,SAAS,iBAAiB;AAE1B,OAAO,SAAS,YAAY,SAAS,cAAc;AAGnD,OAAO;AAAA,EACL;AAAA,EACA;AA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/D,YAAY,eAAe,YAAY,EAAE,UAAU,EAAE,IAAI;AAAA,YACzD;AAAA,YACA;AAAA,YACA,MAAM,YAAY,SAAS;AAAA,UAC7B;AAAA,QACF;AAAA,MACF,GAAG;AAAA,QACD;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf,KAAK,UAAU,KAAK;AAAA,QACpB;AAAA,QACA;AAAA,MACF,CAAC,GAEK,OAAO,UAAU,SAAS;AAEhC,aACE,QAAQ,IAAI,aAAa,iBACzB,MAAM,SACN,MAAM,UAAa,aAEnB,QAAQ,KAAK,cAAc,KAAK,UAAU,WAAW,MAAM,CAAC,IAAI,KAAK;AAAA,QACnE,4BAA4B,eAAe;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC,CAAC,GAGI;AAAA,QACL,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AACF;",
5
- "names": ["dontAnimate"]
6
- }
@@ -1,3 +0,0 @@
1
- typeof requestAnimationFrame > "u" && (globalThis.requestAnimationFrame = setTimeout);
2
- typeof global > "u" && (globalThis.global = globalThis);
3
- //# sourceMappingURL=polyfill.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/polyfill.ts"],
4
- "mappings": "AACI,OAAO,wBAA0B,QACnC,WAAW,wBAA2B;AAIpC,OAAO,SAAW,QACpB,WAAW,SAAY;",
5
- "names": []
6
- }