react-native-screen-transitions 3.0.0-beta.1 → 3.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -5
- package/lib/commonjs/blank-stack/components/Overlay.js +20 -6
- package/lib/commonjs/blank-stack/components/Overlay.js.map +1 -1
- package/lib/commonjs/blank-stack/components/Screens.js +5 -5
- package/lib/commonjs/blank-stack/components/Screens.js.map +1 -1
- package/lib/commonjs/blank-stack/components/StackView.js +14 -8
- package/lib/commonjs/blank-stack/components/StackView.js.map +1 -1
- package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js +5 -9
- package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js.map +1 -1
- package/lib/commonjs/blank-stack/index.js +7 -0
- package/lib/commonjs/blank-stack/index.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.native.js +4 -3
- package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/shared/components/controllers/screen-lifecycle.js +25 -11
- package/lib/commonjs/shared/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/commonjs/shared/components/create-transition-aware-component.js +11 -14
- package/lib/commonjs/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/shared/components/root-transition-aware.js +1 -1
- package/lib/commonjs/shared/components/root-transition-aware.js.map +1 -1
- package/lib/commonjs/shared/configs/presets.js +20 -9
- package/lib/commonjs/shared/configs/presets.js.map +1 -1
- package/lib/commonjs/shared/constants.js +0 -1
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-associated-style.js +9 -10
- package/lib/commonjs/shared/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +10 -25
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +48 -36
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-parent-gesture-registry.js +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js +1 -1
- package/lib/commonjs/shared/hooks/reanimated/use-shared-value-state.js.map +1 -0
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js +7 -1
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/commonjs/shared/hooks/use-stable-callback.js.map +1 -1
- package/lib/commonjs/shared/providers/{gestures.js → gestures.provider.js} +7 -4
- package/lib/commonjs/shared/providers/gestures.provider.js.map +1 -0
- package/lib/commonjs/shared/providers/{keys.js → keys.provider.js} +1 -1
- package/lib/commonjs/shared/providers/keys.provider.js.map +1 -0
- package/lib/commonjs/shared/providers/register-bounds.provider.js +207 -0
- package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -0
- package/lib/commonjs/shared/providers/{screen-transition-provider.js → screen-transition.provider.js} +4 -4
- package/lib/commonjs/shared/providers/{screen-transition-provider.js.map → screen-transition.provider.js.map} +1 -1
- package/lib/commonjs/shared/providers/{transition-styles.js → transition-styles.provider.js} +7 -9
- package/lib/commonjs/shared/providers/transition-styles.provider.js.map +1 -0
- package/lib/commonjs/shared/stores/{animation-store.js → animation.store.js} +13 -4
- package/lib/commonjs/shared/stores/animation.store.js.map +1 -0
- package/lib/commonjs/shared/stores/bounds.store.js +141 -0
- package/lib/commonjs/shared/stores/bounds.store.js.map +1 -0
- package/lib/commonjs/shared/stores/{gesture-store.js → gesture.store.js} +11 -1
- package/lib/commonjs/shared/stores/gesture.store.js.map +1 -0
- package/lib/commonjs/shared/types/{core.js → animation.types.js} +1 -1
- package/lib/commonjs/shared/types/animation.types.js.map +1 -0
- package/lib/commonjs/shared/types/{bounds.js → bounds.types.js} +1 -1
- package/lib/commonjs/shared/types/bounds.types.js.map +1 -0
- package/lib/commonjs/shared/types/{animation.js → core.types.js} +1 -1
- package/lib/commonjs/shared/types/{animation.js.map → core.types.js.map} +1 -1
- package/lib/commonjs/shared/types/{gesture.js → gesture.types.js} +1 -1
- package/lib/commonjs/shared/types/gesture.types.js.map +1 -0
- package/lib/commonjs/shared/types/utils.types.js +2 -0
- package/lib/commonjs/shared/types/{core.js.map → utils.types.js.map} +1 -1
- package/lib/commonjs/shared/utils/animation/derivations.js +1 -7
- package/lib/commonjs/shared/utils/animation/derivations.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/helpers/geometry.js.map +1 -0
- package/lib/commonjs/shared/utils/bounds/helpers/is-bounds-equal.js +19 -0
- package/lib/commonjs/shared/utils/bounds/helpers/is-bounds-equal.js.map +1 -0
- package/lib/commonjs/shared/utils/bounds/helpers/style-composers.js.map +1 -0
- package/lib/commonjs/shared/utils/bounds/helpers/styles.js.map +1 -0
- package/lib/commonjs/shared/utils/bounds/index.js +45 -35
- package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/types/builder.js.map +1 -0
- package/lib/commonjs/shared/utils/bounds/{_types/builder.js.map → types/geometry.js.map} +1 -1
- package/lib/commonjs/shared/utils/create-provider.js +51 -0
- package/lib/commonjs/shared/utils/create-provider.js.map +1 -0
- package/lib/commonjs/shared/utils/gesture/apply-offset-rules.js +1 -1
- package/lib/commonjs/shared/utils/gesture/check-gesture-activation.js +1 -1
- package/lib/commonjs/shared/utils/reset-stores-for-screen.js +17 -0
- package/lib/commonjs/shared/utils/reset-stores-for-screen.js.map +1 -0
- package/lib/module/blank-stack/components/Overlay.js +20 -6
- package/lib/module/blank-stack/components/Overlay.js.map +1 -1
- package/lib/module/blank-stack/components/Screens.js +4 -4
- package/lib/module/blank-stack/components/Screens.js.map +1 -1
- package/lib/module/blank-stack/components/StackView.js +12 -7
- package/lib/module/blank-stack/components/StackView.js.map +1 -1
- package/lib/module/blank-stack/hooks/use-overlay-animation.js +5 -9
- package/lib/module/blank-stack/hooks/use-overlay-animation.js.map +1 -1
- package/lib/module/blank-stack/index.js +1 -0
- package/lib/module/blank-stack/index.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.native.js +3 -2
- package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/shared/components/controllers/screen-lifecycle.js +24 -10
- package/lib/module/shared/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/module/shared/components/create-transition-aware-component.js +11 -14
- package/lib/module/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/shared/components/root-transition-aware.js +1 -1
- package/lib/module/shared/components/root-transition-aware.js.map +1 -1
- package/lib/module/shared/configs/presets.js +20 -9
- package/lib/module/shared/configs/presets.js.map +1 -1
- package/lib/module/shared/constants.js +0 -1
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-associated-style.js +9 -10
- package/lib/module/shared/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js +7 -22
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js +46 -34
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-parent-gesture-registry.js +1 -1
- package/lib/module/shared/hooks/gestures/use-parent-gesture-registry.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js +1 -1
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
- package/lib/module/shared/hooks/reanimated/use-shared-value-state.js.map +1 -0
- package/lib/module/shared/hooks/use-stable-callback-value.js +8 -2
- package/lib/module/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/module/shared/hooks/use-stable-callback.js.map +1 -1
- package/lib/module/shared/providers/{gestures.js → gestures.provider.js} +7 -4
- package/lib/module/shared/providers/gestures.provider.js.map +1 -0
- package/lib/module/shared/providers/{keys.js → keys.provider.js} +1 -1
- package/lib/module/shared/providers/keys.provider.js.map +1 -0
- package/lib/module/shared/providers/register-bounds.provider.js +202 -0
- package/lib/module/shared/providers/register-bounds.provider.js.map +1 -0
- package/lib/module/shared/providers/{screen-transition-provider.js → screen-transition.provider.js} +4 -4
- package/lib/module/shared/providers/{screen-transition-provider.js.map → screen-transition.provider.js.map} +1 -1
- package/lib/module/shared/providers/{transition-styles.js → transition-styles.provider.js} +6 -9
- package/lib/module/shared/providers/transition-styles.provider.js.map +1 -0
- package/lib/module/shared/stores/animation.store.js +44 -0
- package/lib/module/shared/stores/animation.store.js.map +1 -0
- package/lib/module/shared/stores/bounds.store.js +137 -0
- package/lib/module/shared/stores/bounds.store.js.map +1 -0
- package/lib/module/shared/stores/{gesture-store.js → gesture.store.js} +12 -2
- package/lib/module/shared/stores/gesture.store.js.map +1 -0
- package/lib/module/shared/types/animation.types.js +4 -0
- package/lib/module/shared/types/animation.types.js.map +1 -0
- package/lib/module/shared/types/bounds.types.js +4 -0
- package/lib/module/shared/types/bounds.types.js.map +1 -0
- package/lib/module/shared/types/core.types.js +4 -0
- package/lib/{commonjs/shared/types/bounds.js.map → module/shared/types/core.types.js.map} +1 -1
- package/lib/module/shared/types/{gesture.js → gesture.types.js} +1 -1
- package/lib/module/shared/types/gesture.types.js.map +1 -0
- package/lib/module/shared/types/utils.types.js +2 -0
- package/lib/{commonjs/shared/types/utils.js.map → module/shared/types/utils.types.js.map} +1 -1
- package/lib/module/shared/utils/animation/derivations.js +1 -7
- package/lib/module/shared/utils/animation/derivations.js.map +1 -1
- package/lib/module/shared/utils/bounds/helpers/geometry.js.map +1 -0
- package/lib/module/shared/utils/bounds/helpers/is-bounds-equal.js +14 -0
- package/lib/module/shared/utils/bounds/helpers/is-bounds-equal.js.map +1 -0
- package/lib/module/shared/utils/bounds/helpers/style-composers.js.map +1 -0
- package/lib/module/shared/utils/bounds/helpers/styles.js.map +1 -0
- package/lib/module/shared/utils/bounds/index.js +45 -35
- package/lib/module/shared/utils/bounds/index.js.map +1 -1
- package/lib/module/shared/utils/bounds/types/builder.js.map +1 -0
- package/lib/module/shared/utils/bounds/{_types/builder.js.map → types/geometry.js.map} +1 -1
- package/lib/module/shared/utils/create-provider.js +46 -0
- package/lib/module/shared/utils/create-provider.js.map +1 -0
- package/lib/module/shared/utils/gesture/apply-offset-rules.js +1 -1
- package/lib/module/shared/utils/gesture/apply-offset-rules.js.map +1 -1
- package/lib/module/shared/utils/gesture/check-gesture-activation.js +1 -1
- package/lib/module/shared/utils/gesture/check-gesture-activation.js.map +1 -1
- package/lib/module/shared/utils/reset-stores-for-screen.js +13 -0
- package/lib/module/shared/utils/reset-stores-for-screen.js.map +1 -0
- package/lib/typescript/blank-stack/components/Overlay.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/Screens.d.ts +2 -3
- package/lib/typescript/blank-stack/components/Screens.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/StackView.d.ts.map +1 -1
- package/lib/typescript/blank-stack/hooks/use-overlay-animation.d.ts +1 -1
- package/lib/typescript/blank-stack/hooks/use-overlay-animation.d.ts.map +1 -1
- package/lib/typescript/blank-stack/index.d.ts +1 -0
- package/lib/typescript/blank-stack/index.d.ts.map +1 -1
- package/lib/typescript/blank-stack/types.d.ts +6 -2
- package/lib/typescript/blank-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/types.d.ts +1 -1
- package/lib/typescript/native-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/shared/components/controllers/screen-lifecycle.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/shared/configs/index.d.ts +15 -9
- package/lib/typescript/shared/configs/index.d.ts.map +1 -1
- package/lib/typescript/shared/configs/presets.d.ts +10 -4
- package/lib/typescript/shared/configs/presets.d.ts.map +1 -1
- package/lib/typescript/shared/constants.d.ts +6 -6
- package/lib/typescript/shared/constants.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/animation/use-associated-style.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts +2 -2
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts +5 -2
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/reanimated/use-shared-value-state.d.ts.map +1 -0
- package/lib/typescript/shared/hooks/use-stable-callback-value.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/use-stable-callback.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +25 -18
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/{gestures.d.ts → gestures.provider.d.ts} +5 -3
- package/lib/typescript/shared/providers/gestures.provider.d.ts.map +1 -0
- package/lib/typescript/shared/providers/{keys.d.ts → keys.provider.d.ts} +2 -2
- package/lib/typescript/shared/providers/keys.provider.d.ts.map +1 -0
- package/lib/typescript/shared/providers/register-bounds.provider.d.ts +17 -0
- package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -0
- package/lib/typescript/shared/providers/{screen-transition-provider.d.ts → screen-transition.provider.d.ts} +2 -2
- package/lib/typescript/shared/providers/{screen-transition-provider.d.ts.map → screen-transition.provider.d.ts.map} +1 -1
- package/lib/typescript/shared/providers/transition-styles.provider.d.ts +14 -0
- package/lib/typescript/shared/providers/transition-styles.provider.d.ts.map +1 -0
- package/lib/typescript/shared/stores/{animation-store.d.ts → animation.store.d.ts} +6 -4
- package/lib/typescript/shared/stores/animation.store.d.ts.map +1 -0
- package/lib/typescript/shared/stores/bounds.store.d.ts +29 -0
- package/lib/typescript/shared/stores/bounds.store.d.ts.map +1 -0
- package/lib/typescript/shared/stores/{gesture-store.d.ts → gesture.store.d.ts} +3 -3
- package/lib/typescript/shared/stores/gesture.store.d.ts.map +1 -0
- package/lib/typescript/shared/types/{animation.d.ts → animation.types.d.ts} +48 -20
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -0
- package/lib/typescript/shared/types/{bounds.d.ts → bounds.types.d.ts} +4 -4
- package/lib/typescript/shared/types/bounds.types.d.ts.map +1 -0
- package/lib/typescript/shared/types/{core.d.ts → core.types.d.ts} +3 -3
- package/lib/typescript/shared/types/core.types.d.ts.map +1 -0
- package/lib/typescript/shared/types/{gesture.d.ts → gesture.types.d.ts} +1 -1
- package/lib/typescript/shared/types/gesture.types.d.ts.map +1 -0
- package/lib/typescript/shared/types/{utils.d.ts → utils.types.d.ts} +1 -1
- package/lib/typescript/shared/types/utils.types.d.ts.map +1 -0
- package/lib/typescript/shared/utils/animation/derivations.d.ts +2 -4
- package/lib/typescript/shared/utils/animation/derivations.d.ts.map +1 -1
- package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts +2 -2
- package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/constants.d.ts +3 -3
- package/lib/typescript/shared/utils/bounds/constants.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/{_utils → helpers}/geometry.d.ts +3 -3
- package/lib/typescript/shared/utils/bounds/helpers/geometry.d.ts.map +1 -0
- package/lib/typescript/shared/utils/bounds/helpers/is-bounds-equal.d.ts.map +1 -0
- package/lib/typescript/shared/utils/bounds/{_utils → helpers}/style-composers.d.ts +2 -2
- package/lib/typescript/shared/utils/bounds/helpers/style-composers.d.ts.map +1 -0
- package/lib/typescript/shared/utils/bounds/{_utils → helpers}/styles.d.ts +1 -1
- package/lib/typescript/shared/utils/bounds/helpers/styles.d.ts.map +1 -0
- package/lib/typescript/shared/utils/bounds/index.d.ts +3 -4
- package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/{_types → types}/builder.d.ts +13 -34
- package/lib/typescript/shared/utils/bounds/types/builder.d.ts.map +1 -0
- package/lib/typescript/shared/utils/bounds/types/geometry.d.ts.map +1 -0
- package/lib/typescript/shared/utils/create-provider.d.ts +14 -0
- package/lib/typescript/shared/utils/create-provider.d.ts.map +1 -0
- package/lib/typescript/shared/utils/gesture/apply-offset-rules.d.ts +2 -2
- package/lib/typescript/shared/utils/gesture/apply-offset-rules.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts +2 -2
- package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/reset-gesture-values.d.ts +2 -2
- package/lib/typescript/shared/utils/gesture/reset-gesture-values.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/velocity.d.ts +1 -1
- package/lib/typescript/shared/utils/reset-stores-for-screen.d.ts +6 -0
- package/lib/typescript/shared/utils/reset-stores-for-screen.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/blank-stack/components/Overlay.tsx +25 -5
- package/src/blank-stack/components/Screens.tsx +6 -6
- package/src/blank-stack/components/StackView.tsx +11 -5
- package/src/blank-stack/hooks/use-overlay-animation.tsx +6 -21
- package/src/blank-stack/index.ts +1 -0
- package/src/blank-stack/types.ts +6 -2
- package/src/native-stack/types.ts +1 -1
- package/src/native-stack/views/NativeStackView.native.tsx +4 -2
- package/src/shared/components/controllers/screen-lifecycle.tsx +26 -11
- package/src/shared/components/create-transition-aware-component.tsx +23 -27
- package/src/shared/components/root-transition-aware.tsx +1 -1
- package/src/shared/configs/presets.ts +31 -17
- package/src/shared/constants.ts +6 -7
- package/src/shared/hooks/animation/use-associated-style.tsx +8 -9
- package/src/shared/hooks/animation/use-screen-animation.tsx +8 -26
- package/src/shared/hooks/gestures/use-build-gestures.tsx +66 -38
- package/src/shared/hooks/gestures/use-parent-gesture-registry.tsx +1 -1
- package/src/shared/hooks/gestures/use-scroll-registry.tsx +2 -2
- package/src/shared/hooks/{use-stable-callback-value.tsx → use-stable-callback-value.ts} +10 -1
- package/src/shared/index.ts +4 -1
- package/src/shared/providers/{gestures.tsx → gestures.provider.tsx} +17 -8
- package/src/shared/providers/{keys.tsx → keys.provider.tsx} +1 -1
- package/src/shared/providers/register-bounds.provider.tsx +284 -0
- package/src/shared/providers/{screen-transition-provider.tsx → screen-transition.provider.tsx} +3 -3
- package/src/shared/providers/{transition-styles.tsx → transition-styles.provider.tsx} +13 -14
- package/src/shared/stores/{animation-store.ts → animation.store.ts} +20 -4
- package/src/shared/stores/bounds.store.ts +166 -0
- package/src/shared/stores/{gesture-store.ts → gesture.store.ts} +17 -3
- package/src/shared/types/{animation.ts → animation.types.ts} +60 -19
- package/src/shared/types/{bounds.ts → bounds.types.ts} +3 -3
- package/src/shared/types/{core.ts → core.types.ts} +10 -2
- package/src/shared/utils/animation/derivations.ts +2 -8
- package/src/shared/utils/animation/start-screen-transition.ts +2 -2
- package/src/shared/utils/bounds/constants.ts +3 -3
- package/src/shared/utils/bounds/{_utils → helpers}/geometry.ts +3 -3
- package/src/shared/utils/bounds/{_utils → helpers}/is-bounds-equal.ts +3 -3
- package/src/shared/utils/bounds/{_utils → helpers}/style-composers.ts +2 -2
- package/src/shared/utils/bounds/{_utils → helpers}/styles.ts +1 -1
- package/src/shared/utils/bounds/index.ts +53 -55
- package/src/shared/utils/bounds/{_types → types}/builder.ts +19 -37
- package/src/shared/utils/create-provider.tsx +71 -0
- package/src/shared/utils/gesture/apply-offset-rules.ts +2 -2
- package/src/shared/utils/gesture/check-gesture-activation.ts +2 -2
- package/src/shared/utils/gesture/reset-gesture-values.ts +2 -2
- package/src/shared/utils/gesture/velocity.ts +1 -1
- package/src/shared/utils/reset-stores-for-screen.ts +11 -0
- package/lib/commonjs/shared/hooks/bounds/use-bound-registry.js +0 -131
- package/lib/commonjs/shared/hooks/bounds/use-bound-registry.js.map +0 -1
- package/lib/commonjs/shared/hooks/use-shared-value-state.js.map +0 -1
- package/lib/commonjs/shared/providers/gestures.js.map +0 -1
- package/lib/commonjs/shared/providers/keys.js.map +0 -1
- package/lib/commonjs/shared/providers/transition-styles.js.map +0 -1
- package/lib/commonjs/shared/providers/utils/create-provider.js +0 -39
- package/lib/commonjs/shared/providers/utils/create-provider.js.map +0 -1
- package/lib/commonjs/shared/stores/animation-store.js.map +0 -1
- package/lib/commonjs/shared/stores/bound-store/_utils.js +0 -118
- package/lib/commonjs/shared/stores/bound-store/_utils.js.map +0 -1
- package/lib/commonjs/shared/stores/bound-store/index.js +0 -116
- package/lib/commonjs/shared/stores/bound-store/index.js.map +0 -1
- package/lib/commonjs/shared/stores/gesture-store.js.map +0 -1
- package/lib/commonjs/shared/stores/navigator-dismiss-state.js +0 -23
- package/lib/commonjs/shared/stores/navigator-dismiss-state.js.map +0 -1
- package/lib/commonjs/shared/stores/utils/reset-stores-for-screen.js +0 -19
- package/lib/commonjs/shared/stores/utils/reset-stores-for-screen.js.map +0 -1
- package/lib/commonjs/shared/types/gesture.js.map +0 -1
- package/lib/commonjs/shared/types/utils.js +0 -2
- package/lib/commonjs/shared/utils/bounds/_types/geometry.js.map +0 -1
- package/lib/commonjs/shared/utils/bounds/_types/get-bounds.js +0 -6
- package/lib/commonjs/shared/utils/bounds/_types/get-bounds.js.map +0 -1
- package/lib/commonjs/shared/utils/bounds/_utils/flatten-styles.js +0 -27
- package/lib/commonjs/shared/utils/bounds/_utils/flatten-styles.js.map +0 -1
- package/lib/commonjs/shared/utils/bounds/_utils/geometry.js.map +0 -1
- package/lib/commonjs/shared/utils/bounds/_utils/get-bounds.js +0 -49
- package/lib/commonjs/shared/utils/bounds/_utils/get-bounds.js.map +0 -1
- package/lib/commonjs/shared/utils/bounds/_utils/is-bounds-equal.js +0 -19
- package/lib/commonjs/shared/utils/bounds/_utils/is-bounds-equal.js.map +0 -1
- package/lib/commonjs/shared/utils/bounds/_utils/style-composers.js.map +0 -1
- package/lib/commonjs/shared/utils/bounds/_utils/styles.js.map +0 -1
- package/lib/module/shared/hooks/bounds/use-bound-registry.js +0 -125
- package/lib/module/shared/hooks/bounds/use-bound-registry.js.map +0 -1
- package/lib/module/shared/hooks/use-shared-value-state.js.map +0 -1
- package/lib/module/shared/providers/gestures.js.map +0 -1
- package/lib/module/shared/providers/keys.js.map +0 -1
- package/lib/module/shared/providers/transition-styles.js.map +0 -1
- package/lib/module/shared/providers/utils/create-provider.js +0 -33
- package/lib/module/shared/providers/utils/create-provider.js.map +0 -1
- package/lib/module/shared/stores/animation-store.js +0 -33
- package/lib/module/shared/stores/animation-store.js.map +0 -1
- package/lib/module/shared/stores/bound-store/_utils.js +0 -113
- package/lib/module/shared/stores/bound-store/_utils.js.map +0 -1
- package/lib/module/shared/stores/bound-store/index.js +0 -112
- package/lib/module/shared/stores/bound-store/index.js.map +0 -1
- package/lib/module/shared/stores/gesture-store.js.map +0 -1
- package/lib/module/shared/stores/navigator-dismiss-state.js +0 -19
- package/lib/module/shared/stores/navigator-dismiss-state.js.map +0 -1
- package/lib/module/shared/stores/utils/reset-stores-for-screen.js +0 -15
- package/lib/module/shared/stores/utils/reset-stores-for-screen.js.map +0 -1
- package/lib/module/shared/types/animation.js +0 -4
- package/lib/module/shared/types/animation.js.map +0 -1
- package/lib/module/shared/types/bounds.js +0 -4
- package/lib/module/shared/types/bounds.js.map +0 -1
- package/lib/module/shared/types/core.js +0 -4
- package/lib/module/shared/types/core.js.map +0 -1
- package/lib/module/shared/types/gesture.js.map +0 -1
- package/lib/module/shared/types/utils.js +0 -2
- package/lib/module/shared/types/utils.js.map +0 -1
- package/lib/module/shared/utils/bounds/_types/geometry.js.map +0 -1
- package/lib/module/shared/utils/bounds/_types/get-bounds.js +0 -4
- package/lib/module/shared/utils/bounds/_types/get-bounds.js.map +0 -1
- package/lib/module/shared/utils/bounds/_utils/flatten-styles.js +0 -23
- package/lib/module/shared/utils/bounds/_utils/flatten-styles.js.map +0 -1
- package/lib/module/shared/utils/bounds/_utils/geometry.js.map +0 -1
- package/lib/module/shared/utils/bounds/_utils/get-bounds.js +0 -44
- package/lib/module/shared/utils/bounds/_utils/get-bounds.js.map +0 -1
- package/lib/module/shared/utils/bounds/_utils/is-bounds-equal.js +0 -14
- package/lib/module/shared/utils/bounds/_utils/is-bounds-equal.js.map +0 -1
- package/lib/module/shared/utils/bounds/_utils/style-composers.js.map +0 -1
- package/lib/module/shared/utils/bounds/_utils/styles.js.map +0 -1
- package/lib/typescript/shared/hooks/bounds/use-bound-registry.d.ts +0 -17
- package/lib/typescript/shared/hooks/bounds/use-bound-registry.d.ts.map +0 -1
- package/lib/typescript/shared/hooks/use-shared-value-state.d.ts.map +0 -1
- package/lib/typescript/shared/providers/gestures.d.ts.map +0 -1
- package/lib/typescript/shared/providers/keys.d.ts.map +0 -1
- package/lib/typescript/shared/providers/transition-styles.d.ts +0 -11
- package/lib/typescript/shared/providers/transition-styles.d.ts.map +0 -1
- package/lib/typescript/shared/providers/utils/create-provider.d.ts +0 -32
- package/lib/typescript/shared/providers/utils/create-provider.d.ts.map +0 -1
- package/lib/typescript/shared/stores/animation-store.d.ts.map +0 -1
- package/lib/typescript/shared/stores/bound-store/_utils.d.ts +0 -24
- package/lib/typescript/shared/stores/bound-store/_utils.d.ts.map +0 -1
- package/lib/typescript/shared/stores/bound-store/index.d.ts +0 -22
- package/lib/typescript/shared/stores/bound-store/index.d.ts.map +0 -1
- package/lib/typescript/shared/stores/gesture-store.d.ts.map +0 -1
- package/lib/typescript/shared/stores/navigator-dismiss-state.d.ts +0 -7
- package/lib/typescript/shared/stores/navigator-dismiss-state.d.ts.map +0 -1
- package/lib/typescript/shared/stores/utils/reset-stores-for-screen.d.ts +0 -6
- package/lib/typescript/shared/stores/utils/reset-stores-for-screen.d.ts.map +0 -1
- package/lib/typescript/shared/types/animation.d.ts.map +0 -1
- package/lib/typescript/shared/types/bounds.d.ts.map +0 -1
- package/lib/typescript/shared/types/core.d.ts.map +0 -1
- package/lib/typescript/shared/types/gesture.d.ts.map +0 -1
- package/lib/typescript/shared/types/utils.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_types/builder.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_types/geometry.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_types/get-bounds.d.ts +0 -10
- package/lib/typescript/shared/utils/bounds/_types/get-bounds.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_utils/flatten-styles.d.ts +0 -2
- package/lib/typescript/shared/utils/bounds/_utils/flatten-styles.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_utils/geometry.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_utils/get-bounds.d.ts +0 -4
- package/lib/typescript/shared/utils/bounds/_utils/get-bounds.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_utils/is-bounds-equal.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_utils/style-composers.d.ts.map +0 -1
- package/lib/typescript/shared/utils/bounds/_utils/styles.d.ts.map +0 -1
- package/src/shared/hooks/bounds/use-bound-registry.tsx +0 -153
- package/src/shared/providers/utils/create-provider.ts +0 -64
- package/src/shared/stores/bound-store/_utils.ts +0 -161
- package/src/shared/stores/bound-store/index.ts +0 -125
- package/src/shared/stores/navigator-dismiss-state.ts +0 -17
- package/src/shared/stores/utils/reset-stores-for-screen.ts +0 -13
- package/src/shared/utils/bounds/_types/get-bounds.ts +0 -10
- package/src/shared/utils/bounds/_utils/flatten-styles.ts +0 -21
- package/src/shared/utils/bounds/_utils/get-bounds.ts +0 -54
- /package/lib/commonjs/shared/hooks/{use-shared-value-state.js → reanimated/use-shared-value-state.js} +0 -0
- /package/lib/commonjs/shared/utils/bounds/{_utils → helpers}/geometry.js +0 -0
- /package/lib/commonjs/shared/utils/bounds/{_utils → helpers}/style-composers.js +0 -0
- /package/lib/commonjs/shared/utils/bounds/{_utils → helpers}/styles.js +0 -0
- /package/lib/commonjs/shared/utils/bounds/{_types → types}/builder.js +0 -0
- /package/lib/commonjs/shared/utils/bounds/{_types → types}/geometry.js +0 -0
- /package/lib/module/shared/hooks/{use-shared-value-state.js → reanimated/use-shared-value-state.js} +0 -0
- /package/lib/module/shared/utils/bounds/{_utils → helpers}/geometry.js +0 -0
- /package/lib/module/shared/utils/bounds/{_utils → helpers}/style-composers.js +0 -0
- /package/lib/module/shared/utils/bounds/{_utils → helpers}/styles.js +0 -0
- /package/lib/module/shared/utils/bounds/{_types → types}/builder.js +0 -0
- /package/lib/module/shared/utils/bounds/{_types → types}/geometry.js +0 -0
- /package/lib/typescript/shared/hooks/{use-shared-value-state.d.ts → reanimated/use-shared-value-state.d.ts} +0 -0
- /package/lib/typescript/shared/utils/bounds/{_utils → helpers}/is-bounds-equal.d.ts +0 -0
- /package/lib/typescript/shared/utils/bounds/{_types → types}/geometry.d.ts +0 -0
- /package/src/shared/hooks/{use-shared-value-state.ts → reanimated/use-shared-value-state.ts} +0 -0
- /package/src/shared/hooks/{use-stable-callback.tsx → use-stable-callback.ts} +0 -0
- /package/src/shared/types/{gesture.ts → gesture.types.ts} +0 -0
- /package/src/shared/types/{utils.ts → utils.types.ts} +0 -0
- /package/src/shared/utils/bounds/{_types → types}/geometry.ts +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ReactNode,
|
|
3
|
+
useCallback,
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
} from "react";
|
|
8
|
+
import type { View } from "react-native";
|
|
9
|
+
import {
|
|
10
|
+
type AnimatedRef,
|
|
11
|
+
measure,
|
|
12
|
+
runOnJS,
|
|
13
|
+
runOnUI,
|
|
14
|
+
type StyleProps,
|
|
15
|
+
useAnimatedReaction,
|
|
16
|
+
useSharedValue,
|
|
17
|
+
} from "react-native-reanimated";
|
|
18
|
+
import type { SharedValue } from "react-native-reanimated/lib/typescript/commonTypes";
|
|
19
|
+
import useStableCallback from "../hooks/use-stable-callback";
|
|
20
|
+
import useStableCallbackValue from "../hooks/use-stable-callback-value";
|
|
21
|
+
import { AnimationStore } from "../stores/animation.store";
|
|
22
|
+
import { BoundStore } from "../stores/bounds.store";
|
|
23
|
+
import { prepareStyleForBounds } from "../utils/bounds/helpers/styles";
|
|
24
|
+
import createProvider from "../utils/create-provider";
|
|
25
|
+
import { type TransitionDescriptor, useKeys } from "./keys.provider";
|
|
26
|
+
|
|
27
|
+
interface MaybeMeasureAndStoreParams {
|
|
28
|
+
onPress?: ((...args: unknown[]) => void) | undefined;
|
|
29
|
+
shouldSetSource?: boolean;
|
|
30
|
+
shouldSetDestination?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface RegisterBoundsRenderProps {
|
|
34
|
+
handleInitialLayout: () => void;
|
|
35
|
+
captureActiveOnPress: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface RegisterBoundsProviderProps {
|
|
39
|
+
sharedBoundTag?: string;
|
|
40
|
+
animatedRef: AnimatedRef<View>;
|
|
41
|
+
style: StyleProps;
|
|
42
|
+
onPress?: ((...args: unknown[]) => void) | undefined;
|
|
43
|
+
children: (props: RegisterBoundsRenderProps) => ReactNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface RegisterBoundsContextValue {
|
|
47
|
+
updateSignal: SharedValue<number>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets the parent screen's route key for nested navigators.
|
|
52
|
+
* Returns undefined if we're not inside a nested navigator.
|
|
53
|
+
*/
|
|
54
|
+
const getParentScreenKey = (current: TransitionDescriptor) => {
|
|
55
|
+
const parent = current.navigation.getParent();
|
|
56
|
+
if (!parent) return undefined;
|
|
57
|
+
|
|
58
|
+
const parentState = parent.getState();
|
|
59
|
+
if (!parentState?.routes) return undefined;
|
|
60
|
+
|
|
61
|
+
// Check if our route key exists directly in parent's routes
|
|
62
|
+
const existsInParent = parentState.routes.some(
|
|
63
|
+
(r) => r.key === current.route.key,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// If we don't exist in parent's routes, we're nested inside the focused route
|
|
67
|
+
if (!existsInParent && parentState.index !== undefined) {
|
|
68
|
+
return parentState.routes[parentState.index]?.key;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Handles initial layout measurement for destination elements.
|
|
76
|
+
* Only measures if an animation is in progress (local or parent).
|
|
77
|
+
*/
|
|
78
|
+
const useInitialLayoutHandler = (params: {
|
|
79
|
+
sharedBoundTag?: string;
|
|
80
|
+
currentScreenKey: string;
|
|
81
|
+
parentScreenKey?: string;
|
|
82
|
+
maybeMeasureAndStore: (options: MaybeMeasureAndStoreParams) => void;
|
|
83
|
+
}) => {
|
|
84
|
+
const {
|
|
85
|
+
sharedBoundTag,
|
|
86
|
+
currentScreenKey,
|
|
87
|
+
parentScreenKey,
|
|
88
|
+
maybeMeasureAndStore,
|
|
89
|
+
} = params;
|
|
90
|
+
|
|
91
|
+
const isAnimating = AnimationStore.getAnimation(
|
|
92
|
+
currentScreenKey,
|
|
93
|
+
"animating",
|
|
94
|
+
);
|
|
95
|
+
const isParentAnimating = parentScreenKey
|
|
96
|
+
? AnimationStore.getAnimation(parentScreenKey, "animating")
|
|
97
|
+
: null;
|
|
98
|
+
|
|
99
|
+
const hasMeasuredOnLayout = useSharedValue(false);
|
|
100
|
+
|
|
101
|
+
return useCallback(() => {
|
|
102
|
+
"worklet";
|
|
103
|
+
if (!sharedBoundTag || hasMeasuredOnLayout.value) return;
|
|
104
|
+
if (!isAnimating.value && !isParentAnimating?.value) return;
|
|
105
|
+
|
|
106
|
+
maybeMeasureAndStore({
|
|
107
|
+
shouldSetSource: false,
|
|
108
|
+
shouldSetDestination: true,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
hasMeasuredOnLayout.value = true;
|
|
112
|
+
}, [
|
|
113
|
+
sharedBoundTag,
|
|
114
|
+
hasMeasuredOnLayout,
|
|
115
|
+
isAnimating,
|
|
116
|
+
isParentAnimating,
|
|
117
|
+
maybeMeasureAndStore,
|
|
118
|
+
]);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Measures non-pressable elements when screen becomes blurred.
|
|
123
|
+
* Captures bounds right before transition starts.
|
|
124
|
+
*/
|
|
125
|
+
const useBlurMeasurement = (params: {
|
|
126
|
+
sharedBoundTag?: string;
|
|
127
|
+
next?: TransitionDescriptor;
|
|
128
|
+
onPress?: () => void;
|
|
129
|
+
maybeMeasureAndStore: (options: MaybeMeasureAndStoreParams) => void;
|
|
130
|
+
}) => {
|
|
131
|
+
const { sharedBoundTag, next, onPress, maybeMeasureAndStore } = params;
|
|
132
|
+
const prevNextRef = useRef(next);
|
|
133
|
+
|
|
134
|
+
useLayoutEffect(() => {
|
|
135
|
+
if (!sharedBoundTag || onPress) return;
|
|
136
|
+
|
|
137
|
+
const hadNext = !!prevNextRef.current;
|
|
138
|
+
const hasNext = !!next;
|
|
139
|
+
|
|
140
|
+
// Screen went from focused to blurred
|
|
141
|
+
if (!hadNext && hasNext) {
|
|
142
|
+
runOnUI(maybeMeasureAndStore)({ shouldSetSource: true });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
prevNextRef.current = next;
|
|
146
|
+
}, [next, sharedBoundTag, onPress, maybeMeasureAndStore]);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Syncs child measurements when parent updates.
|
|
151
|
+
*/
|
|
152
|
+
const useParentSyncReaction = (params: {
|
|
153
|
+
parentContext: RegisterBoundsContextValue | null;
|
|
154
|
+
maybeMeasureAndStore: (options?: MaybeMeasureAndStoreParams) => void;
|
|
155
|
+
}) => {
|
|
156
|
+
const { parentContext, maybeMeasureAndStore } = params;
|
|
157
|
+
|
|
158
|
+
useAnimatedReaction(
|
|
159
|
+
() => parentContext?.updateSignal.value,
|
|
160
|
+
(value) => {
|
|
161
|
+
"worklet";
|
|
162
|
+
if (value === 0 || value === undefined) return;
|
|
163
|
+
maybeMeasureAndStore();
|
|
164
|
+
},
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
169
|
+
"RegisterBounds",
|
|
170
|
+
{ guarded: false },
|
|
171
|
+
)<RegisterBoundsProviderProps, RegisterBoundsContextValue>(
|
|
172
|
+
({ style, onPress, sharedBoundTag, animatedRef, children }) => {
|
|
173
|
+
const { current, next } = useKeys();
|
|
174
|
+
const currentScreenKey = current.route.key;
|
|
175
|
+
const parentScreenKey = getParentScreenKey(current);
|
|
176
|
+
|
|
177
|
+
// Context & signals
|
|
178
|
+
const parentContext: RegisterBoundsContextValue | null =
|
|
179
|
+
useRegisterBoundsContext();
|
|
180
|
+
const ownSignal = useSharedValue(0);
|
|
181
|
+
const updateSignal: SharedValue<number> =
|
|
182
|
+
parentContext?.updateSignal ?? ownSignal;
|
|
183
|
+
|
|
184
|
+
const isAnimating = AnimationStore.getAnimation(
|
|
185
|
+
currentScreenKey,
|
|
186
|
+
"animating",
|
|
187
|
+
);
|
|
188
|
+
const preparedStyles = useMemo(() => prepareStyleForBounds(style), [style]);
|
|
189
|
+
|
|
190
|
+
const emitUpdate = useStableCallbackValue(() => {
|
|
191
|
+
"worklet";
|
|
192
|
+
const isRoot = !parentContext;
|
|
193
|
+
if (isRoot) updateSignal.value = updateSignal.value + 1;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const maybeMeasureAndStore = useStableCallbackValue(
|
|
197
|
+
({
|
|
198
|
+
onPress,
|
|
199
|
+
shouldSetSource,
|
|
200
|
+
shouldSetDestination,
|
|
201
|
+
}: MaybeMeasureAndStoreParams = {}) => {
|
|
202
|
+
"worklet";
|
|
203
|
+
if (!sharedBoundTag) return;
|
|
204
|
+
|
|
205
|
+
const measured = measure(animatedRef);
|
|
206
|
+
if (!measured) return;
|
|
207
|
+
|
|
208
|
+
emitUpdate();
|
|
209
|
+
|
|
210
|
+
// Always register occurrence
|
|
211
|
+
BoundStore.registerOccurrence(
|
|
212
|
+
sharedBoundTag,
|
|
213
|
+
currentScreenKey,
|
|
214
|
+
measured,
|
|
215
|
+
preparedStyles,
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
// Set as source (on press or blur)
|
|
219
|
+
if (shouldSetSource) {
|
|
220
|
+
if (isAnimating.value) {
|
|
221
|
+
const existing = BoundStore.getOccurrence(
|
|
222
|
+
sharedBoundTag,
|
|
223
|
+
currentScreenKey,
|
|
224
|
+
);
|
|
225
|
+
BoundStore.setLinkSource(
|
|
226
|
+
sharedBoundTag,
|
|
227
|
+
currentScreenKey,
|
|
228
|
+
existing.bounds,
|
|
229
|
+
preparedStyles,
|
|
230
|
+
parentScreenKey,
|
|
231
|
+
);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
BoundStore.setLinkSource(
|
|
235
|
+
sharedBoundTag,
|
|
236
|
+
currentScreenKey,
|
|
237
|
+
measured,
|
|
238
|
+
preparedStyles,
|
|
239
|
+
parentScreenKey,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Set as destination (on mount during animation)
|
|
244
|
+
if (shouldSetDestination) {
|
|
245
|
+
BoundStore.setLinkDestination(
|
|
246
|
+
sharedBoundTag,
|
|
247
|
+
currentScreenKey,
|
|
248
|
+
measured,
|
|
249
|
+
preparedStyles,
|
|
250
|
+
parentScreenKey,
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (onPress) runOnJS(onPress)();
|
|
255
|
+
},
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const handleInitialLayout = useInitialLayoutHandler({
|
|
259
|
+
sharedBoundTag,
|
|
260
|
+
currentScreenKey,
|
|
261
|
+
parentScreenKey,
|
|
262
|
+
maybeMeasureAndStore,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const captureActiveOnPress = useStableCallback(() => {
|
|
266
|
+
if (!sharedBoundTag) {
|
|
267
|
+
onPress?.();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
runOnUI(maybeMeasureAndStore)({ onPress, shouldSetSource: true });
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Side effects
|
|
274
|
+
useBlurMeasurement({ sharedBoundTag, next, onPress, maybeMeasureAndStore });
|
|
275
|
+
useParentSyncReaction({ parentContext, maybeMeasureAndStore });
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
value: { updateSignal },
|
|
279
|
+
children: children({ handleInitialLayout, captureActiveOnPress }),
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
export { RegisterBoundsProvider };
|
package/src/shared/providers/{screen-transition-provider.tsx → screen-transition.provider.tsx}
RENAMED
|
@@ -2,9 +2,9 @@ import type React from "react";
|
|
|
2
2
|
import type { ComponentType } from "react";
|
|
3
3
|
import type { ScreenLifecycleProps } from "../components/controllers/screen-lifecycle";
|
|
4
4
|
import { RootTransitionAware } from "../components/root-transition-aware";
|
|
5
|
-
import { ScreenGestureProvider } from "
|
|
6
|
-
import { KeysProvider, type TransitionDescriptor } from "
|
|
7
|
-
import { TransitionStylesProvider } from "
|
|
5
|
+
import { ScreenGestureProvider } from "./gestures.provider";
|
|
6
|
+
import { KeysProvider, type TransitionDescriptor } from "./keys.provider";
|
|
7
|
+
import { TransitionStylesProvider } from "./transition-styles.provider";
|
|
8
8
|
|
|
9
9
|
type Props<TDescriptor extends TransitionDescriptor> = {
|
|
10
10
|
previous?: TDescriptor;
|
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo } from "react";
|
|
2
|
-
import { useDerivedValue } from "react-native-reanimated";
|
|
2
|
+
import { type SharedValue, useDerivedValue } from "react-native-reanimated";
|
|
3
3
|
import { NO_STYLES } from "../constants";
|
|
4
4
|
import { _useScreenAnimation } from "../hooks/animation/use-screen-animation";
|
|
5
|
-
import type { TransitionInterpolatedStyle } from "../types/animation";
|
|
5
|
+
import type { TransitionInterpolatedStyle } from "../types/animation.types";
|
|
6
6
|
import { createBounds } from "../utils/bounds";
|
|
7
7
|
|
|
8
8
|
type Props = {
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
type TransitionStylesContextValue = {
|
|
13
|
+
stylesMap: SharedValue<TransitionInterpolatedStyle>;
|
|
14
|
+
parentStylesMap?: SharedValue<TransitionInterpolatedStyle>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const TransitionStylesContext =
|
|
18
|
+
createContext<TransitionStylesContextValue | null>(null);
|
|
17
19
|
|
|
18
20
|
export function TransitionStylesProvider({ children }: Props) {
|
|
21
|
+
const parentCtx = useContext(TransitionStylesContext);
|
|
19
22
|
const { screenInterpolatorProps, screenStyleInterpolator } =
|
|
20
23
|
_useScreenAnimation();
|
|
21
24
|
|
|
22
25
|
const stylesMap = useDerivedValue<TransitionInterpolatedStyle>(() => {
|
|
23
26
|
"worklet";
|
|
24
27
|
|
|
25
|
-
/**
|
|
26
|
-
* ### Maintainer note
|
|
27
|
-
*
|
|
28
|
-
* From my understanding, reanimated will serialize the DerivedValue result. Thus resulting in us receiving a `bounds is not a function, it is an object` error. We'll build the bounds function inside here (the final step) and pass it alongside the interpolator instead.
|
|
29
|
-
*/
|
|
30
28
|
const props = screenInterpolatorProps.value;
|
|
31
|
-
|
|
32
29
|
const bounds = createBounds(props);
|
|
30
|
+
|
|
33
31
|
try {
|
|
34
32
|
if (!screenStyleInterpolator) return NO_STYLES;
|
|
35
33
|
|
|
@@ -51,8 +49,9 @@ export function TransitionStylesProvider({ children }: Props) {
|
|
|
51
49
|
const value = useMemo(() => {
|
|
52
50
|
return {
|
|
53
51
|
stylesMap,
|
|
52
|
+
parentStylesMap: parentCtx?.stylesMap,
|
|
54
53
|
};
|
|
55
|
-
}, [stylesMap]);
|
|
54
|
+
}, [stylesMap, parentCtx?.stylesMap]);
|
|
56
55
|
|
|
57
56
|
return (
|
|
58
57
|
<TransitionStylesContext.Provider value={value}>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
cancelAnimation,
|
|
3
|
+
makeMutable,
|
|
4
|
+
type SharedValue,
|
|
5
|
+
} from "react-native-reanimated";
|
|
6
|
+
import type { ScreenKey } from "../types/core.types";
|
|
3
7
|
|
|
4
8
|
export type AnimationStoreMap = {
|
|
5
9
|
progress: SharedValue<number>;
|
|
@@ -22,24 +26,36 @@ const ensure = (key: ScreenKey) => {
|
|
|
22
26
|
return bag;
|
|
23
27
|
};
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
function getAnimation(
|
|
26
30
|
key: ScreenKey,
|
|
27
31
|
type: "progress" | "closing" | "animating",
|
|
28
32
|
): SharedValue<number> {
|
|
29
33
|
return ensure(key)[type];
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
function getAll(key: ScreenKey) {
|
|
33
37
|
return ensure(key);
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
function clear(routeKey: ScreenKey) {
|
|
37
41
|
"worklet";
|
|
42
|
+
const bag = store[routeKey];
|
|
43
|
+
if (bag) {
|
|
44
|
+
cancelAnimation(bag.progress);
|
|
45
|
+
cancelAnimation(bag.closing);
|
|
46
|
+
cancelAnimation(bag.animating);
|
|
47
|
+
}
|
|
38
48
|
delete store[routeKey];
|
|
39
49
|
}
|
|
40
50
|
|
|
51
|
+
function debugStoreSize() {
|
|
52
|
+
console.log("[AnimationStore] Size:", Object.keys(store).length);
|
|
53
|
+
console.log("[AnimationStore] Keys:", Object.keys(store));
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
export const AnimationStore = {
|
|
42
57
|
getAnimation,
|
|
43
58
|
clear,
|
|
44
59
|
getAll,
|
|
60
|
+
debugStoreSize,
|
|
45
61
|
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type MeasuredDimensions,
|
|
3
|
+
makeMutable,
|
|
4
|
+
type StyleProps,
|
|
5
|
+
} from "react-native-reanimated";
|
|
6
|
+
import type { Any } from "../types/utils.types";
|
|
7
|
+
|
|
8
|
+
type TagID = string;
|
|
9
|
+
type ScreenKey = string;
|
|
10
|
+
|
|
11
|
+
export type TagData = {
|
|
12
|
+
bounds: MeasuredDimensions;
|
|
13
|
+
styles: StyleProps;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type ScreenIdentifier = {
|
|
17
|
+
screenKey: ScreenKey;
|
|
18
|
+
parentScreenKey?: ScreenKey;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type TagLink = {
|
|
22
|
+
source: ScreenIdentifier & TagData;
|
|
23
|
+
destination: (ScreenIdentifier & TagData) | null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type TagState = {
|
|
27
|
+
occurrences: Record<ScreenKey, TagData>;
|
|
28
|
+
linkStack: TagLink[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Note on cleanup: We intentionally skip automatic cleanup of old links.
|
|
33
|
+
* The linkStack grows by one entry per navigation, but `getActiveLink`
|
|
34
|
+
* finds the correct link via screenKey matching regardless of stack size.
|
|
35
|
+
* This is unlikely to cause performance issues in typical apps, but if
|
|
36
|
+
* memory becomes a concern in apps with heavy navigation (hundreds of
|
|
37
|
+
* transitions), we should consider implementing cleanup on screen unmount using
|
|
38
|
+
* screenKey filtering.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
const registry = makeMutable<Record<TagID, TagState>>({});
|
|
42
|
+
|
|
43
|
+
function registerOccurrence(
|
|
44
|
+
tag: TagID,
|
|
45
|
+
screenKey: ScreenKey,
|
|
46
|
+
bounds: MeasuredDimensions,
|
|
47
|
+
styles: StyleProps = {},
|
|
48
|
+
) {
|
|
49
|
+
"worklet";
|
|
50
|
+
registry.modify((state: Any) => {
|
|
51
|
+
"worklet";
|
|
52
|
+
if (!state[tag]) {
|
|
53
|
+
state[tag] = { occurrences: {}, linkStack: [] };
|
|
54
|
+
}
|
|
55
|
+
state[tag].occurrences[screenKey] = { bounds, styles };
|
|
56
|
+
return state;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function setLinkSource(
|
|
61
|
+
tag: TagID,
|
|
62
|
+
screenKey: ScreenKey,
|
|
63
|
+
bounds: MeasuredDimensions,
|
|
64
|
+
styles: StyleProps = {},
|
|
65
|
+
parentScreenKey?: ScreenKey,
|
|
66
|
+
) {
|
|
67
|
+
"worklet";
|
|
68
|
+
registry.modify((state: Any) => {
|
|
69
|
+
"worklet";
|
|
70
|
+
if (!state[tag]) state[tag] = { occurrences: {}, linkStack: [] };
|
|
71
|
+
|
|
72
|
+
// Push new link onto stack
|
|
73
|
+
state[tag].linkStack.push({
|
|
74
|
+
source: { screenKey, parentScreenKey, bounds, styles },
|
|
75
|
+
destination: null,
|
|
76
|
+
});
|
|
77
|
+
return state;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function setLinkDestination(
|
|
82
|
+
tag: TagID,
|
|
83
|
+
screenKey: ScreenKey,
|
|
84
|
+
bounds: MeasuredDimensions,
|
|
85
|
+
styles: StyleProps = {},
|
|
86
|
+
parentScreenKey?: ScreenKey,
|
|
87
|
+
) {
|
|
88
|
+
"worklet";
|
|
89
|
+
registry.modify((state: Any) => {
|
|
90
|
+
"worklet";
|
|
91
|
+
const stack = state[tag]?.linkStack;
|
|
92
|
+
if (!stack || stack.length === 0) return state;
|
|
93
|
+
|
|
94
|
+
// Find the topmost link without a destination
|
|
95
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
96
|
+
if (stack[i].destination === null) {
|
|
97
|
+
stack[i].destination = { screenKey, parentScreenKey, bounds, styles };
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return state;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getOccurrence(tag: TagID, key: ScreenKey) {
|
|
106
|
+
"worklet";
|
|
107
|
+
return registry.value[tag]?.occurrences[key] ?? null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Helper to check if a screen identifier matches a given key
|
|
111
|
+
function matchesScreenKey(
|
|
112
|
+
identifier: ScreenIdentifier | null | undefined,
|
|
113
|
+
key: ScreenKey,
|
|
114
|
+
): boolean {
|
|
115
|
+
"worklet";
|
|
116
|
+
if (!identifier) return false;
|
|
117
|
+
return identifier.screenKey === key || identifier.parentScreenKey === key;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function getActiveLink(tag: TagID, screenKey?: ScreenKey, isClosing?: boolean) {
|
|
121
|
+
"worklet";
|
|
122
|
+
const stack = registry.value[tag]?.linkStack;
|
|
123
|
+
|
|
124
|
+
if (!stack || stack.length === 0) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// If screenKey provided, find link involving that screen
|
|
129
|
+
if (screenKey) {
|
|
130
|
+
// When closing (backward nav), we want the link where this screen is the DESTINATION
|
|
131
|
+
// When opening (forward nav), we want the link where this screen is the DESTINATION too
|
|
132
|
+
// The source is always the "from" screen, destination is the "to" screen
|
|
133
|
+
|
|
134
|
+
if (isClosing) {
|
|
135
|
+
// Backward: find link where I am the destination (I'm going back to source)
|
|
136
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
137
|
+
const link = stack[i];
|
|
138
|
+
if (matchesScreenKey(link.destination, screenKey)) {
|
|
139
|
+
return link;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Forward or fallback: find any link involving this screen
|
|
145
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
146
|
+
const link = stack[i];
|
|
147
|
+
if (
|
|
148
|
+
matchesScreenKey(link.source, screenKey) ||
|
|
149
|
+
matchesScreenKey(link.destination, screenKey)
|
|
150
|
+
) {
|
|
151
|
+
return link;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return stack[stack.length - 1] ?? null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export const BoundStore = {
|
|
161
|
+
registerOccurrence,
|
|
162
|
+
setLinkSource,
|
|
163
|
+
setLinkDestination,
|
|
164
|
+
getActiveLink,
|
|
165
|
+
getOccurrence,
|
|
166
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
cancelAnimation,
|
|
3
|
+
makeMutable,
|
|
4
|
+
type SharedValue,
|
|
5
|
+
} from "react-native-reanimated";
|
|
6
|
+
import type { ScreenKey } from "../types/core.types";
|
|
7
|
+
import type { GestureDirection } from "../types/gesture.types";
|
|
4
8
|
|
|
5
9
|
export type GestureKey =
|
|
6
10
|
| "x"
|
|
@@ -50,6 +54,16 @@ function getRouteGestures(routeKey: ScreenKey) {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
function clear(routeKey: ScreenKey) {
|
|
57
|
+
const bag = store[routeKey];
|
|
58
|
+
if (bag) {
|
|
59
|
+
cancelAnimation(bag.x);
|
|
60
|
+
cancelAnimation(bag.y);
|
|
61
|
+
cancelAnimation(bag.normalizedX);
|
|
62
|
+
cancelAnimation(bag.normalizedY);
|
|
63
|
+
cancelAnimation(bag.isDismissing);
|
|
64
|
+
cancelAnimation(bag.isDragging);
|
|
65
|
+
cancelAnimation(bag.direction);
|
|
66
|
+
}
|
|
53
67
|
delete store[routeKey];
|
|
54
68
|
}
|
|
55
69
|
|