react-native-screen-transitions 3.4.0-alpha.6 → 3.4.0-alpha.7

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 (205) hide show
  1. package/README.md +136 -46
  2. package/lib/commonjs/blank-stack/navigators/create-blank-stack-navigator.js +27 -45
  3. package/lib/commonjs/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -1
  4. package/lib/commonjs/component-stack/navigators/create-component-stack-navigator.js +1 -1
  5. package/lib/commonjs/shared/components/create-boundary-component/components/boundary-target.js +39 -0
  6. package/lib/commonjs/shared/components/create-boundary-component/components/boundary-target.js.map +1 -0
  7. package/lib/commonjs/shared/components/create-boundary-component/create-boundary-component.js +232 -0
  8. package/lib/commonjs/shared/components/create-boundary-component/create-boundary-component.js.map +1 -0
  9. package/lib/commonjs/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js +2 -4
  10. package/lib/commonjs/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js.map +1 -1
  11. package/lib/commonjs/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js +4 -3
  12. package/lib/commonjs/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js.map +1 -1
  13. package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js +2 -1
  14. package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js.map +1 -1
  15. package/lib/commonjs/shared/components/create-boundary-component/index.js +20 -214
  16. package/lib/commonjs/shared/components/create-boundary-component/index.js.map +1 -1
  17. package/lib/commonjs/shared/components/create-boundary-component/providers/boundary-owner.provider.js +63 -0
  18. package/lib/commonjs/shared/components/create-boundary-component/providers/boundary-owner.provider.js.map +1 -0
  19. package/lib/commonjs/shared/components/create-transition-aware-component.js +29 -7
  20. package/lib/commonjs/shared/components/create-transition-aware-component.js.map +1 -1
  21. package/lib/commonjs/shared/components/overlay/variations/float-overlay.js +1 -1
  22. package/lib/commonjs/shared/components/screen-container/index.js +8 -12
  23. package/lib/commonjs/shared/components/screen-container/index.js.map +1 -1
  24. package/lib/commonjs/shared/components/screen-container/layers/backdrop.js +4 -4
  25. package/lib/commonjs/shared/components/screen-container/layers/backdrop.js.map +1 -1
  26. package/lib/commonjs/shared/components/screen-container/layers/content.js +4 -4
  27. package/lib/commonjs/shared/components/screen-container/layers/content.js.map +1 -1
  28. package/lib/commonjs/shared/components/screen-container/layers/maybe-masked-navigation-container.js +4 -4
  29. package/lib/commonjs/shared/components/screen-container/layers/maybe-masked-navigation-container.js.map +1 -1
  30. package/lib/commonjs/shared/components/screen-container/layers/surface-container.js +4 -4
  31. package/lib/commonjs/shared/components/screen-container/layers/surface-container.js.map +1 -1
  32. package/lib/commonjs/shared/constants.js +2 -1
  33. package/lib/commonjs/shared/constants.js.map +1 -1
  34. package/lib/commonjs/shared/providers/screen/screen-composer.js +1 -1
  35. package/lib/commonjs/shared/providers/screen/screen-composer.js.map +1 -1
  36. package/lib/commonjs/shared/providers/screen/styles/helpers/build-resolved-style-map.js +144 -0
  37. package/lib/commonjs/shared/providers/screen/styles/helpers/build-resolved-style-map.js.map +1 -0
  38. package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js +28 -0
  39. package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js.map +1 -0
  40. package/lib/commonjs/shared/providers/screen/styles/helpers/split-normalized-style-maps.js +39 -0
  41. package/lib/commonjs/shared/providers/screen/styles/helpers/split-normalized-style-maps.js.map +1 -0
  42. package/lib/commonjs/shared/providers/screen/styles/index.js +25 -0
  43. package/lib/commonjs/shared/providers/screen/styles/index.js.map +1 -0
  44. package/lib/commonjs/shared/providers/screen/{styles.provider.js → styles/styles.provider.js} +47 -39
  45. package/lib/commonjs/shared/providers/screen/styles/styles.provider.js.map +1 -0
  46. package/lib/commonjs/shared/utils/bounds/helpers/compute-bounds-styles.js +1 -1
  47. package/lib/commonjs/shared/utils/bounds/helpers/compute-bounds-styles.js.map +1 -1
  48. package/lib/commonjs/shared/utils/bounds/helpers/style-composers.js +21 -10
  49. package/lib/commonjs/shared/utils/bounds/helpers/style-composers.js.map +1 -1
  50. package/lib/commonjs/shared/utils/bounds/zoom/build.js +56 -30
  51. package/lib/commonjs/shared/utils/bounds/zoom/build.js.map +1 -1
  52. package/lib/module/blank-stack/navigators/create-blank-stack-navigator.js +27 -45
  53. package/lib/module/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -1
  54. package/lib/module/component-stack/navigators/create-component-stack-navigator.js +1 -1
  55. package/lib/module/shared/components/create-boundary-component/components/boundary-target.js +34 -0
  56. package/lib/module/shared/components/create-boundary-component/components/boundary-target.js.map +1 -0
  57. package/lib/module/shared/components/create-boundary-component/create-boundary-component.js +227 -0
  58. package/lib/module/shared/components/create-boundary-component/create-boundary-component.js.map +1 -0
  59. package/lib/module/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js +2 -4
  60. package/lib/module/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js.map +1 -1
  61. package/lib/module/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js +4 -3
  62. package/lib/module/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js.map +1 -1
  63. package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js +2 -1
  64. package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js.map +1 -1
  65. package/lib/module/shared/components/create-boundary-component/index.js +16 -213
  66. package/lib/module/shared/components/create-boundary-component/index.js.map +1 -1
  67. package/lib/module/shared/components/create-boundary-component/providers/boundary-owner.provider.js +56 -0
  68. package/lib/module/shared/components/create-boundary-component/providers/boundary-owner.provider.js.map +1 -0
  69. package/lib/module/shared/components/create-transition-aware-component.js +30 -8
  70. package/lib/module/shared/components/create-transition-aware-component.js.map +1 -1
  71. package/lib/module/shared/components/overlay/variations/float-overlay.js +1 -1
  72. package/lib/module/shared/components/overlay/variations/float-overlay.js.map +1 -1
  73. package/lib/module/shared/components/screen-container/index.js +8 -12
  74. package/lib/module/shared/components/screen-container/index.js.map +1 -1
  75. package/lib/module/shared/components/screen-container/layers/backdrop.js +4 -4
  76. package/lib/module/shared/components/screen-container/layers/backdrop.js.map +1 -1
  77. package/lib/module/shared/components/screen-container/layers/content.js +4 -4
  78. package/lib/module/shared/components/screen-container/layers/content.js.map +1 -1
  79. package/lib/module/shared/components/screen-container/layers/maybe-masked-navigation-container.js +4 -4
  80. package/lib/module/shared/components/screen-container/layers/maybe-masked-navigation-container.js.map +1 -1
  81. package/lib/module/shared/components/screen-container/layers/surface-container.js +4 -4
  82. package/lib/module/shared/components/screen-container/layers/surface-container.js.map +1 -1
  83. package/lib/module/shared/constants.js +2 -1
  84. package/lib/module/shared/constants.js.map +1 -1
  85. package/lib/module/shared/providers/screen/screen-composer.js +1 -1
  86. package/lib/module/shared/providers/screen/screen-composer.js.map +1 -1
  87. package/lib/module/shared/providers/screen/styles/helpers/build-resolved-style-map.js +139 -0
  88. package/lib/module/shared/providers/screen/styles/helpers/build-resolved-style-map.js.map +1 -0
  89. package/lib/module/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js +23 -0
  90. package/lib/module/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.js.map +1 -0
  91. package/lib/module/shared/providers/screen/styles/helpers/split-normalized-style-maps.js +34 -0
  92. package/lib/module/shared/providers/screen/styles/helpers/split-normalized-style-maps.js.map +1 -0
  93. package/lib/module/shared/providers/screen/styles/index.js +4 -0
  94. package/lib/module/shared/providers/screen/styles/index.js.map +1 -0
  95. package/lib/module/shared/providers/screen/{styles.provider.js → styles/styles.provider.js} +48 -40
  96. package/lib/module/shared/providers/screen/styles/styles.provider.js.map +1 -0
  97. package/lib/module/shared/utils/bounds/helpers/compute-bounds-styles.js +2 -2
  98. package/lib/module/shared/utils/bounds/helpers/compute-bounds-styles.js.map +1 -1
  99. package/lib/module/shared/utils/bounds/helpers/style-composers.js +21 -10
  100. package/lib/module/shared/utils/bounds/helpers/style-composers.js.map +1 -1
  101. package/lib/module/shared/utils/bounds/zoom/build.js +55 -28
  102. package/lib/module/shared/utils/bounds/zoom/build.js.map +1 -1
  103. package/lib/typescript/blank-stack/navigators/create-blank-stack-navigator.d.ts +9 -15
  104. package/lib/typescript/blank-stack/navigators/create-blank-stack-navigator.d.ts.map +1 -1
  105. package/lib/typescript/blank-stack/types.d.ts +6 -4
  106. package/lib/typescript/blank-stack/types.d.ts.map +1 -1
  107. package/lib/typescript/component-stack/navigators/create-component-stack-navigator.d.ts +1 -1
  108. package/lib/typescript/shared/components/create-boundary-component/components/boundary-target.d.ts +209 -0
  109. package/lib/typescript/shared/components/create-boundary-component/components/boundary-target.d.ts.map +1 -0
  110. package/lib/typescript/shared/components/create-boundary-component/create-boundary-component.d.ts +8 -0
  111. package/lib/typescript/shared/components/create-boundary-component/create-boundary-component.d.ts.map +1 -0
  112. package/lib/typescript/shared/components/create-boundary-component/hooks/helpers/measurement-rules.d.ts.map +1 -1
  113. package/lib/typescript/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.d.ts +2 -8
  114. package/lib/typescript/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.d.ts.map +1 -1
  115. package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.d.ts +0 -1
  116. package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.d.ts.map +1 -1
  117. package/lib/typescript/shared/components/create-boundary-component/index.d.ts +216 -12
  118. package/lib/typescript/shared/components/create-boundary-component/index.d.ts.map +1 -1
  119. package/lib/typescript/shared/components/create-boundary-component/providers/boundary-owner.provider.d.ts +35 -0
  120. package/lib/typescript/shared/components/create-boundary-component/providers/boundary-owner.provider.d.ts.map +1 -0
  121. package/lib/typescript/shared/components/create-transition-aware-component.d.ts.map +1 -1
  122. package/lib/typescript/shared/components/screen-container/index.d.ts.map +1 -1
  123. package/lib/typescript/shared/components/screen-container/layers/maybe-masked-navigation-container.d.ts.map +1 -1
  124. package/lib/typescript/shared/constants.d.ts +1 -0
  125. package/lib/typescript/shared/constants.d.ts.map +1 -1
  126. package/lib/typescript/shared/index.d.ts +209 -2
  127. package/lib/typescript/shared/index.d.ts.map +1 -1
  128. package/lib/typescript/shared/providers/screen/styles/helpers/build-resolved-style-map.d.ts +11 -0
  129. package/lib/typescript/shared/providers/screen/styles/helpers/build-resolved-style-map.d.ts.map +1 -0
  130. package/lib/typescript/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.d.ts +7 -0
  131. package/lib/typescript/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.d.ts.map +1 -0
  132. package/lib/typescript/shared/providers/screen/styles/helpers/split-normalized-style-maps.d.ts +6 -0
  133. package/lib/typescript/shared/providers/screen/styles/helpers/split-normalized-style-maps.d.ts.map +1 -0
  134. package/lib/typescript/shared/providers/screen/styles/index.d.ts +2 -0
  135. package/lib/typescript/shared/providers/screen/styles/index.d.ts.map +1 -0
  136. package/lib/typescript/shared/providers/screen/{styles.provider.d.ts → styles/styles.provider.d.ts} +3 -5
  137. package/lib/typescript/shared/providers/screen/styles/styles.provider.d.ts.map +1 -0
  138. package/lib/typescript/shared/types/animation.types.d.ts +3 -9
  139. package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
  140. package/lib/typescript/shared/types/index.d.ts +1 -1
  141. package/lib/typescript/shared/types/index.d.ts.map +1 -1
  142. package/lib/typescript/shared/types/screen.types.d.ts +2 -4
  143. package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
  144. package/lib/typescript/shared/utils/bounds/helpers/compute-bounds-styles.d.ts +1 -11
  145. package/lib/typescript/shared/utils/bounds/helpers/compute-bounds-styles.d.ts.map +1 -1
  146. package/lib/typescript/shared/utils/bounds/helpers/style-composers.d.ts.map +1 -1
  147. package/lib/typescript/shared/utils/bounds/zoom/build.d.ts +1 -1
  148. package/lib/typescript/shared/utils/bounds/zoom/build.d.ts.map +1 -1
  149. package/package.json +1 -1
  150. package/src/blank-stack/navigators/create-blank-stack-navigator.tsx +37 -80
  151. package/src/blank-stack/types.ts +7 -4
  152. package/src/component-stack/navigators/create-component-stack-navigator.tsx +1 -1
  153. package/src/shared/components/create-boundary-component/components/boundary-target.tsx +45 -0
  154. package/src/shared/components/create-boundary-component/create-boundary-component.tsx +282 -0
  155. package/src/shared/components/create-boundary-component/hooks/helpers/measurement-rules.ts +2 -7
  156. package/src/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.ts +6 -10
  157. package/src/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.ts +3 -2
  158. package/src/shared/components/create-boundary-component/index.tsx +16 -252
  159. package/src/shared/components/create-boundary-component/providers/boundary-owner.provider.tsx +109 -0
  160. package/src/shared/components/create-transition-aware-component.tsx +33 -5
  161. package/src/shared/components/overlay/variations/float-overlay.tsx +1 -1
  162. package/src/shared/components/screen-container/index.tsx +10 -13
  163. package/src/shared/components/screen-container/layers/backdrop.tsx +4 -4
  164. package/src/shared/components/screen-container/layers/content.tsx +4 -4
  165. package/src/shared/components/screen-container/layers/maybe-masked-navigation-container.tsx +6 -4
  166. package/src/shared/components/screen-container/layers/surface-container.tsx +4 -4
  167. package/src/shared/constants.ts +1 -0
  168. package/src/shared/index.ts +0 -1
  169. package/src/shared/providers/screen/screen-composer.tsx +1 -1
  170. package/src/shared/providers/screen/styles/helpers/build-resolved-style-map.ts +185 -0
  171. package/src/shared/providers/screen/styles/helpers/resolve-interpolated-style-output.ts +31 -0
  172. package/src/shared/providers/screen/styles/helpers/split-normalized-style-maps.ts +44 -0
  173. package/src/shared/providers/screen/styles/index.tsx +5 -0
  174. package/src/shared/providers/screen/styles/styles.provider.tsx +173 -0
  175. package/src/shared/types/animation.types.ts +3 -10
  176. package/src/shared/types/index.ts +0 -1
  177. package/src/shared/types/screen.types.ts +2 -4
  178. package/src/shared/utils/bounds/helpers/compute-bounds-styles.ts +2 -1
  179. package/src/shared/utils/bounds/helpers/style-composers.ts +11 -0
  180. package/src/shared/utils/bounds/zoom/build.ts +85 -70
  181. package/lib/commonjs/shared/components/screen-container/deferred-visibility-host.js +0 -45
  182. package/lib/commonjs/shared/components/screen-container/deferred-visibility-host.js.map +0 -1
  183. package/lib/commonjs/shared/hooks/animation/use-associated-style.js +0 -234
  184. package/lib/commonjs/shared/hooks/animation/use-associated-style.js.map +0 -1
  185. package/lib/commonjs/shared/providers/screen/helpers/resolve-interpolated-style-output.js +0 -50
  186. package/lib/commonjs/shared/providers/screen/helpers/resolve-interpolated-style-output.js.map +0 -1
  187. package/lib/commonjs/shared/providers/screen/styles.provider.js.map +0 -1
  188. package/lib/module/shared/components/screen-container/deferred-visibility-host.js +0 -40
  189. package/lib/module/shared/components/screen-container/deferred-visibility-host.js.map +0 -1
  190. package/lib/module/shared/hooks/animation/use-associated-style.js +0 -229
  191. package/lib/module/shared/hooks/animation/use-associated-style.js.map +0 -1
  192. package/lib/module/shared/providers/screen/helpers/resolve-interpolated-style-output.js +0 -44
  193. package/lib/module/shared/providers/screen/helpers/resolve-interpolated-style-output.js.map +0 -1
  194. package/lib/module/shared/providers/screen/styles.provider.js.map +0 -1
  195. package/lib/typescript/shared/components/screen-container/deferred-visibility-host.d.ts +0 -14
  196. package/lib/typescript/shared/components/screen-container/deferred-visibility-host.d.ts.map +0 -1
  197. package/lib/typescript/shared/hooks/animation/use-associated-style.d.ts +0 -32
  198. package/lib/typescript/shared/hooks/animation/use-associated-style.d.ts.map +0 -1
  199. package/lib/typescript/shared/providers/screen/helpers/resolve-interpolated-style-output.d.ts +0 -14
  200. package/lib/typescript/shared/providers/screen/helpers/resolve-interpolated-style-output.d.ts.map +0 -1
  201. package/lib/typescript/shared/providers/screen/styles.provider.d.ts.map +0 -1
  202. package/src/shared/components/screen-container/deferred-visibility-host.tsx +0 -44
  203. package/src/shared/hooks/animation/use-associated-style.ts +0 -297
  204. package/src/shared/providers/screen/helpers/resolve-interpolated-style-output.ts +0 -61
  205. package/src/shared/providers/screen/styles.provider.tsx +0 -164
@@ -0,0 +1,185 @@
1
+ import { NO_STYLES } from "../../../../constants";
2
+ import type {
3
+ NormalizedTransitionInterpolatedStyle,
4
+ NormalizedTransitionSlotStyle,
5
+ } from "../../../../types/animation.types";
6
+
7
+ export type StyleKeySet = Record<string, true>;
8
+
9
+ type StyleKeyMeta = {
10
+ keys: StyleKeySet;
11
+ hasAny: boolean;
12
+ };
13
+
14
+ const IDENTITY_TRANSFORM = [
15
+ { translateX: 0 },
16
+ { translateY: 0 },
17
+ { scaleX: 1 },
18
+ { scaleY: 1 },
19
+ ] as const;
20
+
21
+ const ALWAYS_RESET_STYLE_VALUES = {
22
+ zIndex: 0,
23
+ elevation: 0,
24
+ } as const;
25
+
26
+ const hasAnyKeys = (record: Record<string, unknown>) => {
27
+ "worklet";
28
+ for (const _key in record) {
29
+ return true;
30
+ }
31
+ return false;
32
+ };
33
+
34
+ const collectStyleKeyMeta = (
35
+ record?: Record<string, unknown>,
36
+ ): StyleKeyMeta => {
37
+ "worklet";
38
+ const keys: StyleKeySet = {};
39
+ let hasAny = false;
40
+
41
+ if (!record) {
42
+ return { keys, hasAny };
43
+ }
44
+
45
+ for (const key in record) {
46
+ keys[key] = true;
47
+ hasAny = true;
48
+ }
49
+
50
+ return { keys, hasAny };
51
+ };
52
+
53
+ const collectRelevantSlotIds = ({
54
+ currentStylesMap,
55
+ fallbackStylesMap,
56
+ previousStyleKeysBySlot,
57
+ }: {
58
+ currentStylesMap: NormalizedTransitionInterpolatedStyle;
59
+ fallbackStylesMap: NormalizedTransitionInterpolatedStyle;
60
+ previousStyleKeysBySlot: Record<string, StyleKeySet>;
61
+ }) => {
62
+ "worklet";
63
+ const slotIds: Record<string, true> = {};
64
+
65
+ for (const slotId in currentStylesMap) {
66
+ slotIds[slotId] = true;
67
+ }
68
+
69
+ for (const slotId in fallbackStylesMap) {
70
+ slotIds[slotId] = true;
71
+ }
72
+
73
+ for (const slotId in previousStyleKeysBySlot) {
74
+ slotIds[slotId] = true;
75
+ }
76
+
77
+ return slotIds;
78
+ };
79
+
80
+ const buildUnsetPatch = ({
81
+ previousKeys,
82
+ currentKeys,
83
+ }: {
84
+ previousKeys: StyleKeySet;
85
+ currentKeys: StyleKeySet;
86
+ }) => {
87
+ "worklet";
88
+ const unsetPatch: Record<string, any> = {};
89
+
90
+ for (const key in previousKeys) {
91
+ if (currentKeys[key]) continue;
92
+
93
+ if (key === "transform") {
94
+ unsetPatch.transform = IDENTITY_TRANSFORM;
95
+ continue;
96
+ }
97
+
98
+ if (key in ALWAYS_RESET_STYLE_VALUES) {
99
+ unsetPatch[key] =
100
+ ALWAYS_RESET_STYLE_VALUES[
101
+ key as keyof typeof ALWAYS_RESET_STYLE_VALUES
102
+ ];
103
+ continue;
104
+ }
105
+
106
+ unsetPatch[key] = undefined;
107
+ }
108
+
109
+ return unsetPatch;
110
+ };
111
+
112
+ export const buildResolvedStyleMap = ({
113
+ currentStylesMap,
114
+ fallbackStylesMap,
115
+ previousStyleKeysBySlot,
116
+ }: {
117
+ currentStylesMap: NormalizedTransitionInterpolatedStyle;
118
+ fallbackStylesMap: NormalizedTransitionInterpolatedStyle;
119
+ previousStyleKeysBySlot: Record<string, StyleKeySet>;
120
+ }): {
121
+ resolvedStylesMap: NormalizedTransitionInterpolatedStyle;
122
+ nextPreviousStyleKeysBySlot: Record<string, StyleKeySet>;
123
+ } => {
124
+ "worklet";
125
+ const resolvedStylesMap: NormalizedTransitionInterpolatedStyle = {};
126
+ const nextPreviousStyleKeysBySlot: Record<string, StyleKeySet> = {};
127
+
128
+ const slotIds = collectRelevantSlotIds({
129
+ currentStylesMap,
130
+ fallbackStylesMap,
131
+ previousStyleKeysBySlot,
132
+ });
133
+
134
+ for (const slotId in slotIds) {
135
+ const slot = currentStylesMap[slotId] ?? fallbackStylesMap[slotId];
136
+ const baseStyle = slot?.style as Record<string, unknown> | undefined;
137
+ const { keys: currentKeys, hasAny: hasCurrentStyleKeys } =
138
+ collectStyleKeyMeta(baseStyle);
139
+
140
+ const unsetPatch = buildUnsetPatch({
141
+ previousKeys: previousStyleKeysBySlot[slotId] ?? {},
142
+ currentKeys,
143
+ });
144
+
145
+ const hasUnsetPatch = hasAnyKeys(unsetPatch);
146
+ const hasProps = slot?.props !== undefined;
147
+
148
+ if (!slot && !hasUnsetPatch) {
149
+ continue;
150
+ }
151
+
152
+ const resolvedStyle =
153
+ hasCurrentStyleKeys || hasUnsetPatch
154
+ ? {
155
+ ...unsetPatch,
156
+ ...(slot?.style ?? NO_STYLES),
157
+ }
158
+ : undefined;
159
+
160
+ if (resolvedStyle === undefined && !hasProps) {
161
+ continue;
162
+ }
163
+
164
+ const resolvedSlot = {} as NormalizedTransitionSlotStyle;
165
+
166
+ if (resolvedStyle !== undefined) {
167
+ resolvedSlot.style = resolvedStyle;
168
+ }
169
+
170
+ if (hasProps) {
171
+ resolvedSlot.props = slot?.props;
172
+ }
173
+
174
+ resolvedStylesMap[slotId] = resolvedSlot;
175
+
176
+ if (hasCurrentStyleKeys) {
177
+ nextPreviousStyleKeysBySlot[slotId] = currentKeys;
178
+ }
179
+ }
180
+
181
+ return {
182
+ resolvedStylesMap,
183
+ nextPreviousStyleKeysBySlot,
184
+ };
185
+ };
@@ -0,0 +1,31 @@
1
+ import { NO_STYLES } from "../../../../constants";
2
+ import type {
3
+ NormalizedTransitionInterpolatedStyle,
4
+ TransitionInterpolatedStyle,
5
+ } from "../../../../types/animation.types";
6
+ import { normalizeInterpolatedStyle } from "../../../../utils/normalize-interpolated-style";
7
+
8
+ export type ResolvedInterpolatedStyleOutput = {
9
+ stylesMap: NormalizedTransitionInterpolatedStyle;
10
+ wasLegacy: boolean;
11
+ };
12
+
13
+ export const resolveInterpolatedStyleOutput = (
14
+ raw: TransitionInterpolatedStyle | null | undefined,
15
+ ): ResolvedInterpolatedStyleOutput => {
16
+ "worklet";
17
+
18
+ if (raw == null || typeof raw !== "object") {
19
+ return {
20
+ stylesMap: NO_STYLES,
21
+ wasLegacy: false,
22
+ };
23
+ }
24
+
25
+ const { result, wasLegacy } = normalizeInterpolatedStyle(raw);
26
+
27
+ return {
28
+ stylesMap: result,
29
+ wasLegacy,
30
+ };
31
+ };
@@ -0,0 +1,44 @@
1
+ import {
2
+ NAVIGATION_MASK_CONTAINER_STYLE_ID,
3
+ NAVIGATION_MASK_ELEMENT_STYLE_ID,
4
+ } from "../../../../constants";
5
+ import type { NormalizedTransitionInterpolatedStyle } from "../../../../types/animation.types";
6
+
7
+ const LAYER_STYLE_SLOT_IDS = {
8
+ content: true,
9
+ backdrop: true,
10
+ surface: true,
11
+ [NAVIGATION_MASK_ELEMENT_STYLE_ID]: true,
12
+ [NAVIGATION_MASK_CONTAINER_STYLE_ID]: true,
13
+ } as const;
14
+
15
+ const isLayerStyleSlotId = (slotId: string) => {
16
+ "worklet";
17
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: <Typescript lib target is ES2020>
18
+ return Object.prototype.hasOwnProperty.call(LAYER_STYLE_SLOT_IDS, slotId);
19
+ };
20
+
21
+ export const splitNormalizedStyleMaps = (
22
+ stylesMap: NormalizedTransitionInterpolatedStyle,
23
+ ): {
24
+ layerStylesMap: NormalizedTransitionInterpolatedStyle;
25
+ elementStylesMap: NormalizedTransitionInterpolatedStyle;
26
+ } => {
27
+ "worklet";
28
+ const layerStylesMap: NormalizedTransitionInterpolatedStyle = {};
29
+ const elementStylesMap: NormalizedTransitionInterpolatedStyle = {};
30
+
31
+ for (const slotId in stylesMap) {
32
+ if (isLayerStyleSlotId(slotId)) {
33
+ layerStylesMap[slotId] = stylesMap[slotId];
34
+ continue;
35
+ }
36
+
37
+ elementStylesMap[slotId] = stylesMap[slotId];
38
+ }
39
+
40
+ return {
41
+ layerStylesMap,
42
+ elementStylesMap,
43
+ };
44
+ };
@@ -0,0 +1,5 @@
1
+ export {
2
+ ScreenStylesContext,
3
+ ScreenStylesProvider,
4
+ useScreenStyles,
5
+ } from "./styles.provider";
@@ -0,0 +1,173 @@
1
+ import { type ReactNode, useContext, useMemo } from "react";
2
+ import {
3
+ type SharedValue,
4
+ useDerivedValue,
5
+ useSharedValue,
6
+ } from "react-native-reanimated";
7
+ import { NO_STYLES } from "../../../constants";
8
+ import type { NormalizedTransitionInterpolatedStyle } from "../../../types/animation.types";
9
+ import createProvider from "../../../utils/create-provider";
10
+ import { logger } from "../../../utils/logger";
11
+ import { useScreenAnimationContext } from "../animation";
12
+ import {
13
+ buildResolvedStyleMap,
14
+ type StyleKeySet,
15
+ } from "./helpers/build-resolved-style-map";
16
+ import { resolveInterpolatedStyleOutput } from "./helpers/resolve-interpolated-style-output";
17
+ import { splitNormalizedStyleMaps } from "./helpers/split-normalized-style-maps";
18
+
19
+ type Props = {
20
+ children: ReactNode;
21
+ };
22
+
23
+ type ScreenStylesContextValue = {
24
+ layerStylesMap: SharedValue<NormalizedTransitionInterpolatedStyle>;
25
+ elementStylesMap: SharedValue<NormalizedTransitionInterpolatedStyle>;
26
+ };
27
+
28
+ export const {
29
+ ScreenStylesProvider,
30
+ ScreenStylesContext,
31
+ useScreenStylesContext: useScreenStyles,
32
+ } = createProvider("ScreenStyles", {
33
+ guarded: true,
34
+ })<Props, ScreenStylesContextValue>(
35
+ ({ children }): { value: ScreenStylesContextValue; children: ReactNode } => {
36
+ const parentContext = useContext(ScreenStylesContext);
37
+
38
+ const {
39
+ screenInterpolatorProps,
40
+ nextInterpolator,
41
+ currentInterpolator,
42
+ boundsAccessor,
43
+ } = useScreenAnimationContext();
44
+
45
+ const isGesturingDuringCloseAnimation = useSharedValue(false);
46
+ const hasWarnedLegacy = useSharedValue(false);
47
+ const previousLayerStyleKeysBySlot = useSharedValue<
48
+ Record<string, StyleKeySet>
49
+ >({});
50
+ const previousElementStyleKeysBySlot = useSharedValue<
51
+ Record<string, StyleKeySet>
52
+ >({});
53
+
54
+ const rawStyleResolution = useDerivedValue<{
55
+ layerStylesMap: NormalizedTransitionInterpolatedStyle;
56
+ elementStylesMap: NormalizedTransitionInterpolatedStyle;
57
+ }>(() => {
58
+ "worklet";
59
+ const props = screenInterpolatorProps.value;
60
+ const { current, next, progress } = props;
61
+ const isDragging = current.gesture.dragging;
62
+ const isNextClosing = !!next?.closing;
63
+
64
+ if (isDragging && isNextClosing) {
65
+ isGesturingDuringCloseAnimation.value = true;
66
+ }
67
+
68
+ if (!isDragging && !isNextClosing) {
69
+ isGesturingDuringCloseAnimation.value = false;
70
+ }
71
+
72
+ const isInGestureMode =
73
+ isDragging || isGesturingDuringCloseAnimation.value;
74
+
75
+ const interpolator = isInGestureMode
76
+ ? currentInterpolator
77
+ : (nextInterpolator ?? currentInterpolator);
78
+
79
+ if (!interpolator) {
80
+ return {
81
+ layerStylesMap: NO_STYLES,
82
+ elementStylesMap: NO_STYLES,
83
+ };
84
+ }
85
+
86
+ let effectiveProgress = progress;
87
+ let effectiveNext = next;
88
+
89
+ if (isInGestureMode) {
90
+ effectiveProgress = current.progress;
91
+ effectiveNext = undefined;
92
+ }
93
+
94
+ try {
95
+ const raw = interpolator({
96
+ ...props,
97
+ progress: effectiveProgress,
98
+ next: effectiveNext,
99
+ bounds: boundsAccessor,
100
+ });
101
+
102
+ const { stylesMap, wasLegacy } = resolveInterpolatedStyleOutput(raw);
103
+
104
+ const { layerStylesMap, elementStylesMap } =
105
+ splitNormalizedStyleMaps(stylesMap);
106
+
107
+ if (__DEV__ && wasLegacy && !hasWarnedLegacy.value) {
108
+ hasWarnedLegacy.value = true;
109
+ logger.warn(
110
+ "Flat interpolator return shape (contentStyle/backdropStyle) is deprecated. " +
111
+ "Use the nested format instead: { content: { style }, backdrop: { style } }.",
112
+ );
113
+ }
114
+
115
+ return {
116
+ layerStylesMap,
117
+ elementStylesMap,
118
+ };
119
+ } catch (err) {
120
+ if (__DEV__) {
121
+ console.warn(
122
+ "[react-native-screen-transitions] screenStyleInterpolator must be a worklet",
123
+ err,
124
+ );
125
+ }
126
+
127
+ return {
128
+ layerStylesMap: NO_STYLES,
129
+ elementStylesMap: NO_STYLES,
130
+ };
131
+ }
132
+ });
133
+
134
+ const layerStylesMap =
135
+ useDerivedValue<NormalizedTransitionInterpolatedStyle>(() => {
136
+ "worklet";
137
+ const { resolvedStylesMap, nextPreviousStyleKeysBySlot } =
138
+ buildResolvedStyleMap({
139
+ currentStylesMap: rawStyleResolution.value.layerStylesMap,
140
+ fallbackStylesMap: NO_STYLES,
141
+ previousStyleKeysBySlot: previousLayerStyleKeysBySlot.value,
142
+ });
143
+
144
+ previousLayerStyleKeysBySlot.value = nextPreviousStyleKeysBySlot;
145
+ return resolvedStylesMap;
146
+ });
147
+
148
+ const elementStylesMap =
149
+ useDerivedValue<NormalizedTransitionInterpolatedStyle>(() => {
150
+ "worklet";
151
+ const { resolvedStylesMap, nextPreviousStyleKeysBySlot } =
152
+ buildResolvedStyleMap({
153
+ currentStylesMap: rawStyleResolution.value.elementStylesMap,
154
+ fallbackStylesMap:
155
+ parentContext?.elementStylesMap.value ?? NO_STYLES,
156
+ previousStyleKeysBySlot: previousElementStyleKeysBySlot.value,
157
+ });
158
+
159
+ previousElementStyleKeysBySlot.value = nextPreviousStyleKeysBySlot;
160
+
161
+ return resolvedStylesMap;
162
+ });
163
+
164
+ const value = useMemo<ScreenStylesContextValue>(() => {
165
+ return {
166
+ layerStylesMap,
167
+ elementStylesMap,
168
+ };
169
+ }, [elementStylesMap, layerStylesMap]);
170
+
171
+ return { value, children };
172
+ },
173
+ );
@@ -209,19 +209,12 @@ export interface ScreenInterpolationProps {
209
209
  }
210
210
 
211
211
  /**
212
- * Explicit signal for hiding a screen's visual subtree until the interpolator
213
- * becomes ready for the current transition frame.
214
- */
215
- export type DeferredScreenStyleSignal = "defer";
216
-
217
- /**
218
- * Returning `'defer'` explicitly hides the screen's visual subtree until the
219
- * transition is ready. Returning `null`, `undefined`, or `{}` applies no
220
- * transition styles for the current frame.
212
+ * Returning `null`, `undefined`, or `{}` applies no transition styles for the
213
+ * current frame.
221
214
  */
222
215
  export type ScreenStyleInterpolator = (
223
216
  props: ScreenInterpolationProps,
224
- ) => TransitionInterpolatedStyle | DeferredScreenStyleSignal | null | undefined;
217
+ ) => TransitionInterpolatedStyle | null | undefined;
225
218
 
226
219
  /**
227
220
  * Animated style properties with full autocomplete.
@@ -2,7 +2,6 @@ export { FALSE, TRUE } from "../constants";
2
2
  export type {
3
3
  AnimatedViewStyle,
4
4
  AnimationConfig,
5
- DeferredScreenStyleSignal,
6
5
  ScreenInterpolationProps,
7
6
  ScreenStyleInterpolator,
8
7
  ScreenTransitionState,
@@ -83,10 +83,8 @@ export type ScreenTransitionConfig = {
83
83
  /**
84
84
  * The user-provided function to calculate styles based on animation progress.
85
85
  *
86
- * Return `null` to explicitly defer rendering of the screen's visual subtree
87
- * until a later frame. This is useful for transitions such as
88
- * `bounds().navigation.zoom()` where the screen should stay hidden until the
89
- * interpolator has enough state to produce a safe first frame.
86
+ * Return `null`, `undefined`, or `{}` to apply no transition styles for the
87
+ * current frame.
90
88
  */
91
89
  screenStyleInterpolator?: ScreenStyleInterpolator;
92
90
 
@@ -5,6 +5,7 @@ import {
5
5
  EXIT_RANGE,
6
6
  FULLSCREEN_DIMENSIONS,
7
7
  HIDDEN_STYLE,
8
+ NO_STYLES,
8
9
  } from "../../../constants";
9
10
  import {
10
11
  BoundStore,
@@ -127,7 +128,7 @@ export const computeBoundStyles = (
127
128
  if (computeOptions.raw) {
128
129
  return EMPTY_BOUND_HELPER_RESULT_RAW;
129
130
  }
130
- return HIDDEN_STYLE;
131
+ return NO_STYLES;
131
132
  }
132
133
 
133
134
  const {
@@ -1,4 +1,5 @@
1
1
  import type { MeasuredDimensions, StyleProps } from "react-native-reanimated";
2
+ import { VISIBLE_STYLE } from "../../../constants";
2
3
  import type {
3
4
  ContentTransformGeometry,
4
5
  RelativeGeometry,
@@ -132,6 +133,7 @@ export function composeSizeAbsolute(params: ElementComposeParams): StyleProps {
132
133
  height,
133
134
  translateX,
134
135
  translateY,
136
+ ...VISIBLE_STYLE,
135
137
  };
136
138
  }
137
139
 
@@ -139,6 +141,7 @@ export function composeSizeAbsolute(params: ElementComposeParams): StyleProps {
139
141
  width,
140
142
  height,
141
143
  transform: [{ translateX }, { translateY }],
144
+ ...VISIBLE_STYLE,
142
145
  };
143
146
  }
144
147
 
@@ -175,6 +178,7 @@ export function composeSizeRelative(params: ElementComposeParams): StyleProps {
175
178
  translateY,
176
179
  width,
177
180
  height,
181
+ ...VISIBLE_STYLE,
178
182
  };
179
183
  }
180
184
 
@@ -182,6 +186,7 @@ export function composeSizeRelative(params: ElementComposeParams): StyleProps {
182
186
  transform: [{ translateX }, { translateY }],
183
187
  width,
184
188
  height,
189
+ ...VISIBLE_STYLE,
185
190
  };
186
191
  }
187
192
 
@@ -210,11 +215,13 @@ export function composeTransformAbsolute(
210
215
  translateY,
211
216
  scaleX,
212
217
  scaleY,
218
+ ...VISIBLE_STYLE,
213
219
  };
214
220
  }
215
221
 
216
222
  return {
217
223
  transform: [{ translateX }, { translateY }, { scaleX }, { scaleY }],
224
+ ...VISIBLE_STYLE,
218
225
  };
219
226
  }
220
227
 
@@ -243,6 +250,7 @@ export function composeTransformRelative(
243
250
  translateY,
244
251
  scaleX,
245
252
  scaleY,
253
+ ...VISIBLE_STYLE,
246
254
  };
247
255
  }
248
256
 
@@ -255,6 +263,7 @@ export function composeTransformRelative(
255
263
  { scaleX },
256
264
  { scaleY },
257
265
  ],
266
+ ...VISIBLE_STYLE,
258
267
  };
259
268
  }
260
269
 
@@ -283,10 +292,12 @@ export function composeContentStyle(params: ContentComposeParams): StyleProps {
283
292
  translateX,
284
293
  translateY,
285
294
  scale,
295
+ ...VISIBLE_STYLE,
286
296
  };
287
297
  }
288
298
 
289
299
  return {
290
300
  transform: [{ translateX }, { translateY }, { scale }],
301
+ ...VISIBLE_STYLE,
291
302
  };
292
303
  }