react-native-screen-transitions 2.2.0 → 2.3.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.
- package/lib/commonjs/components/bound-capture.js +7 -2
- package/lib/commonjs/components/bound-capture.js.map +1 -1
- package/lib/commonjs/components/controllers/screen-lifecycle.js +3 -9
- package/lib/commonjs/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/commonjs/components/create-transition-aware-component.js +2 -1
- package/lib/commonjs/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/components/root-transition-aware.js +3 -1
- package/lib/commonjs/components/root-transition-aware.js.map +1 -1
- package/lib/commonjs/configs/presets.js +10 -16
- package/lib/commonjs/configs/presets.js.map +1 -1
- package/lib/commonjs/hooks/animation/use-associated-style.js +41 -6
- package/lib/commonjs/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/commonjs/hooks/animation/use-screen-animation.js +8 -2
- package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/hooks/bounds/use-bound-registry.js +8 -6
- package/lib/commonjs/hooks/bounds/use-bound-registry.js.map +1 -1
- package/lib/commonjs/providers/transition-styles.js +5 -1
- package/lib/commonjs/providers/transition-styles.js.map +1 -1
- package/lib/commonjs/stores/bounds/_utils.js +118 -0
- package/lib/commonjs/stores/bounds/_utils.js.map +1 -0
- package/lib/commonjs/stores/bounds/index.js +116 -0
- package/lib/commonjs/stores/bounds/index.js.map +1 -0
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js +1 -4
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/commonjs/utils/animation/derivations.js +14 -1
- package/lib/commonjs/utils/animation/derivations.js.map +1 -1
- package/lib/module/components/bound-capture.js +7 -2
- package/lib/module/components/bound-capture.js.map +1 -1
- package/lib/module/components/controllers/screen-lifecycle.js +3 -9
- package/lib/module/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/module/components/create-transition-aware-component.js +2 -1
- package/lib/module/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/components/root-transition-aware.js +3 -1
- package/lib/module/components/root-transition-aware.js.map +1 -1
- package/lib/module/configs/presets.js +10 -16
- package/lib/module/configs/presets.js.map +1 -1
- package/lib/module/hooks/animation/use-associated-style.js +42 -7
- package/lib/module/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/module/hooks/animation/use-screen-animation.js +8 -2
- package/lib/module/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/hooks/bounds/use-bound-registry.js +8 -6
- package/lib/module/hooks/bounds/use-bound-registry.js.map +1 -1
- package/lib/module/providers/transition-styles.js +5 -1
- package/lib/module/providers/transition-styles.js.map +1 -1
- package/lib/module/stores/bounds/_utils.js +113 -0
- package/lib/module/stores/bounds/_utils.js.map +1 -0
- package/lib/module/stores/bounds/index.js +112 -0
- package/lib/module/stores/bounds/index.js.map +1 -0
- package/lib/module/stores/utils/reset-stores-for-screen.js +1 -4
- package/lib/module/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/module/utils/animation/derivations.js +14 -1
- package/lib/module/utils/animation/derivations.js.map +1 -1
- package/lib/typescript/components/bound-capture.d.ts.map +1 -1
- package/lib/typescript/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/configs/index.d.ts.map +1 -1
- package/lib/typescript/configs/presets.d.ts.map +1 -1
- package/lib/typescript/hooks/animation/use-associated-style.d.ts +4 -4
- package/lib/typescript/hooks/animation/use-associated-style.d.ts.map +1 -1
- package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/hooks/bounds/use-bound-registry.d.ts.map +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/providers/transition-styles.d.ts +4 -1
- package/lib/typescript/providers/transition-styles.d.ts.map +1 -1
- package/lib/typescript/stores/bounds/_utils.d.ts +24 -0
- package/lib/typescript/stores/bounds/_utils.d.ts.map +1 -0
- package/lib/typescript/stores/{bounds.d.ts → bounds/index.d.ts} +3 -13
- package/lib/typescript/stores/bounds/index.d.ts.map +1 -0
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts +1 -3
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts.map +1 -1
- package/lib/typescript/types/animation.d.ts +6 -0
- package/lib/typescript/types/animation.d.ts.map +1 -1
- package/lib/typescript/utils/animation/derivations.d.ts +3 -0
- package/lib/typescript/utils/animation/derivations.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/bounds.store.test.ts +185 -0
- package/src/components/bound-capture.tsx +5 -2
- package/src/components/controllers/screen-lifecycle.tsx +3 -3
- package/src/components/create-transition-aware-component.tsx +1 -0
- package/src/components/root-transition-aware.tsx +1 -1
- package/src/configs/presets.ts +9 -25
- package/src/hooks/animation/use-associated-style.tsx +42 -7
- package/src/hooks/animation/use-screen-animation.tsx +12 -1
- package/src/hooks/bounds/use-bound-registry.tsx +9 -12
- package/src/providers/transition-styles.tsx +8 -2
- package/src/stores/bounds/_utils.ts +161 -0
- package/src/stores/bounds/index.ts +125 -0
- package/src/stores/utils/reset-stores-for-screen.ts +1 -7
- package/src/types/animation.ts +6 -0
- package/src/utils/animation/derivations.ts +20 -1
- package/LICENSE +0 -21
- package/lib/commonjs/stores/bounds.js +0 -205
- package/lib/commonjs/stores/bounds.js.map +0 -1
- package/lib/module/stores/bounds.js +0 -201
- package/lib/module/stores/bounds.js.map +0 -1
- package/lib/typescript/stores/bounds.d.ts.map +0 -1
- package/src/stores/bounds.ts +0 -227
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { makeMutable } from "react-native-reanimated";
|
|
4
|
-
const registry = makeMutable({});
|
|
5
|
-
const activeBoundId = makeMutable(null);
|
|
6
|
-
const lastActiveByRoute = makeMutable({});
|
|
7
|
-
const pairHints = makeMutable({});
|
|
8
|
-
function pairKey(fromKey, toKey) {
|
|
9
|
-
"worklet";
|
|
10
|
-
|
|
11
|
-
return fromKey && toKey ? `${fromKey}|${toKey}` : "";
|
|
12
|
-
}
|
|
13
|
-
function setBounds(screenId, boundId, bounds = null, styles = {}) {
|
|
14
|
-
"worklet";
|
|
15
|
-
|
|
16
|
-
registry.modify(state => {
|
|
17
|
-
"worklet";
|
|
18
|
-
|
|
19
|
-
if (!state[screenId]) {
|
|
20
|
-
state[screenId] = {};
|
|
21
|
-
}
|
|
22
|
-
state[screenId][boundId] = {
|
|
23
|
-
bounds,
|
|
24
|
-
styles
|
|
25
|
-
};
|
|
26
|
-
return state;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function getBounds(screenId) {
|
|
30
|
-
"worklet";
|
|
31
|
-
|
|
32
|
-
return registry.value[screenId] ?? {};
|
|
33
|
-
}
|
|
34
|
-
function setActiveBoundId(boundId) {
|
|
35
|
-
"worklet";
|
|
36
|
-
|
|
37
|
-
activeBoundId.value = boundId;
|
|
38
|
-
}
|
|
39
|
-
function getActiveBoundId() {
|
|
40
|
-
"worklet";
|
|
41
|
-
|
|
42
|
-
return activeBoundId.value;
|
|
43
|
-
}
|
|
44
|
-
function setRouteActive(routeKey, boundId) {
|
|
45
|
-
"worklet";
|
|
46
|
-
|
|
47
|
-
lastActiveByRoute.modify(state => {
|
|
48
|
-
"worklet";
|
|
49
|
-
|
|
50
|
-
state[routeKey] = boundId;
|
|
51
|
-
return state;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function getRouteActive(routeKey) {
|
|
55
|
-
"worklet";
|
|
56
|
-
|
|
57
|
-
return lastActiveByRoute.value[routeKey] ?? null;
|
|
58
|
-
}
|
|
59
|
-
function setTransitionHint(fromKey, toKey, boundId) {
|
|
60
|
-
"worklet";
|
|
61
|
-
|
|
62
|
-
const key = pairKey(fromKey, toKey);
|
|
63
|
-
if (!key) return;
|
|
64
|
-
pairHints.modify(state => {
|
|
65
|
-
"worklet";
|
|
66
|
-
|
|
67
|
-
state[key] = boundId;
|
|
68
|
-
return state;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function getTransitionHint(fromKey, toKey) {
|
|
72
|
-
"worklet";
|
|
73
|
-
|
|
74
|
-
const key = pairKey(fromKey, toKey);
|
|
75
|
-
if (!key) return null;
|
|
76
|
-
return pairHints.value[key] ?? null;
|
|
77
|
-
}
|
|
78
|
-
function clear(routeKey) {
|
|
79
|
-
"worklet";
|
|
80
|
-
|
|
81
|
-
registry.modify(state => {
|
|
82
|
-
"worklet";
|
|
83
|
-
|
|
84
|
-
delete state[routeKey];
|
|
85
|
-
return state;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
function clearActive() {
|
|
89
|
-
"worklet";
|
|
90
|
-
|
|
91
|
-
activeBoundId.value = null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Helpers for readability
|
|
95
|
-
function hasBound(s, id) {
|
|
96
|
-
"worklet";
|
|
97
|
-
|
|
98
|
-
return !!id && !!s && !!s.bounds && !!s.bounds[id];
|
|
99
|
-
}
|
|
100
|
-
function keysOf(s) {
|
|
101
|
-
"worklet";
|
|
102
|
-
|
|
103
|
-
return Object.keys(s?.bounds || {});
|
|
104
|
-
}
|
|
105
|
-
function getRoutePair(current, next, previous) {
|
|
106
|
-
"worklet";
|
|
107
|
-
|
|
108
|
-
const isClosing = !!next;
|
|
109
|
-
const fromKey = isClosing ? current.route.key : previous?.route.key;
|
|
110
|
-
const toKey = isClosing ? next?.route.key : current.route.key;
|
|
111
|
-
const other = next ?? previous;
|
|
112
|
-
return {
|
|
113
|
-
fromKey,
|
|
114
|
-
toKey,
|
|
115
|
-
other
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function resolveFromHints(fromKey, toKey, other) {
|
|
119
|
-
"worklet";
|
|
120
|
-
|
|
121
|
-
if (fromKey && toKey) {
|
|
122
|
-
const hinted = getTransitionHint(fromKey, toKey);
|
|
123
|
-
if (hasBound(other, hinted)) return hinted;
|
|
124
|
-
}
|
|
125
|
-
return "";
|
|
126
|
-
}
|
|
127
|
-
function resolveFromRequested(reqId, current, other) {
|
|
128
|
-
"worklet";
|
|
129
|
-
|
|
130
|
-
const otherHasAny = !!other && keysOf(other).length > 0;
|
|
131
|
-
if (hasBound(other, reqId)) return reqId;
|
|
132
|
-
if (!otherHasAny && hasBound(current, reqId)) return reqId;
|
|
133
|
-
return "";
|
|
134
|
-
}
|
|
135
|
-
function resolveFromSets(current, other, fromKey) {
|
|
136
|
-
"worklet";
|
|
137
|
-
|
|
138
|
-
if (!other) return "";
|
|
139
|
-
const a = keysOf(current);
|
|
140
|
-
const b = keysOf(other);
|
|
141
|
-
const inter = a.filter(k => b.includes(k));
|
|
142
|
-
const otherHasAny = b.length > 0;
|
|
143
|
-
const routeActive = fromKey ? getRouteActive(fromKey) : null;
|
|
144
|
-
if (inter.length > 0) {
|
|
145
|
-
if (routeActive && inter.includes(routeActive)) return routeActive;
|
|
146
|
-
return inter[0];
|
|
147
|
-
}
|
|
148
|
-
if (routeActive && hasBound(other, routeActive)) return routeActive;
|
|
149
|
-
if (b.length === 1) return b[0];
|
|
150
|
-
if (!otherHasAny) {
|
|
151
|
-
if (routeActive && hasBound(current, routeActive)) return routeActive;
|
|
152
|
-
if (a.length === 1) return a[0];
|
|
153
|
-
}
|
|
154
|
-
return "";
|
|
155
|
-
}
|
|
156
|
-
function getActiveBound(current, next, previous) {
|
|
157
|
-
"worklet";
|
|
158
|
-
|
|
159
|
-
const requestedId = activeBoundId.value;
|
|
160
|
-
const {
|
|
161
|
-
fromKey,
|
|
162
|
-
toKey,
|
|
163
|
-
other
|
|
164
|
-
} = getRoutePair(current, next, previous);
|
|
165
|
-
|
|
166
|
-
// check last remembered hint
|
|
167
|
-
const byHint = resolveFromHints(fromKey, toKey, other);
|
|
168
|
-
if (byHint) {
|
|
169
|
-
if (fromKey && toKey) setTransitionHint(fromKey, toKey, byHint);
|
|
170
|
-
return byHint;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// check the active id
|
|
174
|
-
const byRequested = resolveFromRequested(requestedId, current, other);
|
|
175
|
-
if (byRequested) {
|
|
176
|
-
if (fromKey && toKey) setTransitionHint(fromKey, toKey, byRequested);
|
|
177
|
-
return byRequested;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// check the sets (intersection/MRU/fallbacks)
|
|
181
|
-
const bySets = resolveFromSets(current, other, fromKey);
|
|
182
|
-
if (bySets) {
|
|
183
|
-
if (fromKey && toKey) setTransitionHint(fromKey, toKey, bySets);
|
|
184
|
-
return bySets;
|
|
185
|
-
}
|
|
186
|
-
return "";
|
|
187
|
-
}
|
|
188
|
-
export const Bounds = {
|
|
189
|
-
setBounds,
|
|
190
|
-
getBounds,
|
|
191
|
-
setActiveBoundId,
|
|
192
|
-
getActiveBoundId,
|
|
193
|
-
setRouteActive,
|
|
194
|
-
getRouteActive,
|
|
195
|
-
setTransitionHint,
|
|
196
|
-
getTransitionHint,
|
|
197
|
-
clear,
|
|
198
|
-
clearActive,
|
|
199
|
-
getActiveBound
|
|
200
|
-
};
|
|
201
|
-
//# sourceMappingURL=bounds.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["makeMutable","registry","activeBoundId","lastActiveByRoute","pairHints","pairKey","fromKey","toKey","setBounds","screenId","boundId","bounds","styles","modify","state","getBounds","value","setActiveBoundId","getActiveBoundId","setRouteActive","routeKey","getRouteActive","setTransitionHint","key","getTransitionHint","clear","clearActive","hasBound","s","id","keysOf","Object","keys","getRoutePair","current","next","previous","isClosing","route","other","resolveFromHints","hinted","resolveFromRequested","reqId","otherHasAny","length","resolveFromSets","a","b","inter","filter","k","includes","routeActive","getActiveBound","requestedId","byHint","byRequested","bySets","Bounds"],"sourceRoot":"../../../src","sources":["stores/bounds.ts"],"mappings":";;AAAA,SAECA,WAAW,QAEL,yBAAyB;AAUhC,MAAMC,QAAQ,GAAGD,WAAW,CAAa,CAAC,CAAC,CAAC;AAC5C,MAAME,aAAa,GAAGF,WAAW,CAAgB,IAAI,CAAC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,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAkBpD,iBAAS,SAAS,CACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,kBAAkB,GAAG,IAAW,EACxC,MAAM,GAAE,UAAe,QAYvB;AAED,iBAAS,SAAS,CAAC,QAAQ,EAAE,MAAM;YA/BT,kBAAkB;YAAU,UAAU;GAkC/D;AAED,iBAAS,gBAAgB,CAAC,OAAO,EAAE,MAAM,QAGxC;AAED,iBAAS,gBAAgB,kBAGxB;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAOxD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,MAAM,UAGvC;AAED,iBAAS,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QASzE;AAED,iBAAS,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAKxD;AAED,iBAAS,KAAK,CAAC,QAAQ,EAAE,SAAS,QAOjC;AAED,iBAAS,WAAW,SAGnB;AAgFD,iBAAS,cAAc,CACtB,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE,qBAAqB,GAAG,SAAS,EACvC,QAAQ,EAAE,qBAAqB,GAAG,SAAS,UA4B3C;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;CAYlB,CAAC"}
|
package/src/stores/bounds.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type MeasuredDimensions,
|
|
3
|
-
makeMutable,
|
|
4
|
-
type StyleProps,
|
|
5
|
-
} from "react-native-reanimated";
|
|
6
|
-
import type { ScreenTransitionState } from "../types/animation";
|
|
7
|
-
import type { ScreenKey } from "../types/navigator";
|
|
8
|
-
import type { Any } from "../types/utils";
|
|
9
|
-
|
|
10
|
-
type BoundsDict = Record<
|
|
11
|
-
string,
|
|
12
|
-
Record<string, { bounds: MeasuredDimensions; styles: StyleProps }>
|
|
13
|
-
>;
|
|
14
|
-
|
|
15
|
-
const registry = makeMutable<BoundsDict>({});
|
|
16
|
-
const activeBoundId = makeMutable<string | null>(null);
|
|
17
|
-
const lastActiveByRoute = makeMutable<Record<string, string>>({});
|
|
18
|
-
const pairHints = makeMutable<Record<string, string>>({});
|
|
19
|
-
|
|
20
|
-
function pairKey(fromKey?: string, toKey?: string) {
|
|
21
|
-
"worklet";
|
|
22
|
-
return fromKey && toKey ? `${fromKey}|${toKey}` : "";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function setBounds(
|
|
26
|
-
screenId: string,
|
|
27
|
-
boundId: string,
|
|
28
|
-
bounds: MeasuredDimensions | null = null,
|
|
29
|
-
styles: StyleProps = {},
|
|
30
|
-
) {
|
|
31
|
-
"worklet";
|
|
32
|
-
registry.modify((state: Any) => {
|
|
33
|
-
"worklet";
|
|
34
|
-
if (!state[screenId]) {
|
|
35
|
-
state[screenId] = {};
|
|
36
|
-
}
|
|
37
|
-
state[screenId][boundId] = { bounds, styles };
|
|
38
|
-
|
|
39
|
-
return state;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getBounds(screenId: string) {
|
|
44
|
-
"worklet";
|
|
45
|
-
return registry.value[screenId] ?? {};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function setActiveBoundId(boundId: string) {
|
|
49
|
-
"worklet";
|
|
50
|
-
activeBoundId.value = boundId;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function getActiveBoundId() {
|
|
54
|
-
"worklet";
|
|
55
|
-
return activeBoundId.value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function setRouteActive(routeKey: string, boundId: string) {
|
|
59
|
-
"worklet";
|
|
60
|
-
lastActiveByRoute.modify((state: Any) => {
|
|
61
|
-
"worklet";
|
|
62
|
-
state[routeKey] = boundId;
|
|
63
|
-
return state;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getRouteActive(routeKey: string) {
|
|
68
|
-
"worklet";
|
|
69
|
-
return lastActiveByRoute.value[routeKey] ?? null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function setTransitionHint(fromKey: string, toKey: string, boundId: string) {
|
|
73
|
-
"worklet";
|
|
74
|
-
const key = pairKey(fromKey, toKey);
|
|
75
|
-
if (!key) return;
|
|
76
|
-
pairHints.modify((state: Any) => {
|
|
77
|
-
"worklet";
|
|
78
|
-
state[key] = boundId;
|
|
79
|
-
return state;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function getTransitionHint(fromKey: string, toKey: string) {
|
|
84
|
-
"worklet";
|
|
85
|
-
const key = pairKey(fromKey, toKey);
|
|
86
|
-
if (!key) return null;
|
|
87
|
-
return pairHints.value[key] ?? null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function clear(routeKey: ScreenKey) {
|
|
91
|
-
"worklet";
|
|
92
|
-
registry.modify((state: Any) => {
|
|
93
|
-
"worklet";
|
|
94
|
-
delete state[routeKey];
|
|
95
|
-
return state;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function clearActive() {
|
|
100
|
-
"worklet";
|
|
101
|
-
activeBoundId.value = null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Helpers for readability
|
|
105
|
-
function hasBound(s: ScreenTransitionState | undefined, id?: string | null) {
|
|
106
|
-
"worklet";
|
|
107
|
-
return !!id && !!s && !!s.bounds && !!s.bounds[id];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function keysOf(s: ScreenTransitionState | undefined) {
|
|
111
|
-
"worklet";
|
|
112
|
-
return Object.keys(s?.bounds || {});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function getRoutePair(
|
|
116
|
-
current: ScreenTransitionState,
|
|
117
|
-
next: ScreenTransitionState | undefined,
|
|
118
|
-
previous: ScreenTransitionState | undefined,
|
|
119
|
-
) {
|
|
120
|
-
"worklet";
|
|
121
|
-
const isClosing = !!next;
|
|
122
|
-
const fromKey = isClosing ? current.route.key : previous?.route.key;
|
|
123
|
-
const toKey = isClosing ? next?.route.key : current.route.key;
|
|
124
|
-
const other = next ?? previous;
|
|
125
|
-
return { fromKey, toKey, other } as const;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function resolveFromHints(
|
|
129
|
-
fromKey: string | undefined,
|
|
130
|
-
toKey: string | undefined,
|
|
131
|
-
other: ScreenTransitionState | undefined,
|
|
132
|
-
) {
|
|
133
|
-
"worklet";
|
|
134
|
-
if (fromKey && toKey) {
|
|
135
|
-
const hinted = getTransitionHint(fromKey, toKey);
|
|
136
|
-
if (hasBound(other, hinted)) return hinted as string;
|
|
137
|
-
}
|
|
138
|
-
return "";
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function resolveFromRequested(
|
|
142
|
-
reqId: string | null,
|
|
143
|
-
current: ScreenTransitionState,
|
|
144
|
-
other: ScreenTransitionState | undefined,
|
|
145
|
-
) {
|
|
146
|
-
"worklet";
|
|
147
|
-
const otherHasAny = !!other && keysOf(other).length > 0;
|
|
148
|
-
if (hasBound(other, reqId)) return reqId as string;
|
|
149
|
-
if (!otherHasAny && hasBound(current, reqId)) return reqId as string;
|
|
150
|
-
return "";
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function resolveFromSets(
|
|
154
|
-
current: ScreenTransitionState,
|
|
155
|
-
other: ScreenTransitionState | undefined,
|
|
156
|
-
fromKey: string | undefined,
|
|
157
|
-
) {
|
|
158
|
-
"worklet";
|
|
159
|
-
if (!other) return "";
|
|
160
|
-
const a = keysOf(current);
|
|
161
|
-
const b = keysOf(other);
|
|
162
|
-
const inter = a.filter((k) => b.includes(k));
|
|
163
|
-
const otherHasAny = b.length > 0;
|
|
164
|
-
const routeActive = fromKey ? getRouteActive(fromKey) : null;
|
|
165
|
-
|
|
166
|
-
if (inter.length > 0) {
|
|
167
|
-
if (routeActive && inter.includes(routeActive)) return routeActive;
|
|
168
|
-
return inter[0];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (routeActive && hasBound(other, routeActive)) return routeActive;
|
|
172
|
-
if (b.length === 1) return b[0];
|
|
173
|
-
|
|
174
|
-
if (!otherHasAny) {
|
|
175
|
-
if (routeActive && hasBound(current, routeActive)) return routeActive;
|
|
176
|
-
if (a.length === 1) return a[0];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return "";
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function getActiveBound(
|
|
183
|
-
current: ScreenTransitionState,
|
|
184
|
-
next: ScreenTransitionState | undefined,
|
|
185
|
-
previous: ScreenTransitionState | undefined,
|
|
186
|
-
) {
|
|
187
|
-
"worklet";
|
|
188
|
-
const requestedId = activeBoundId.value;
|
|
189
|
-
const { fromKey, toKey, other } = getRoutePair(current, next, previous);
|
|
190
|
-
|
|
191
|
-
// check last remembered hint
|
|
192
|
-
const byHint = resolveFromHints(fromKey, toKey, other);
|
|
193
|
-
if (byHint) {
|
|
194
|
-
if (fromKey && toKey) setTransitionHint(fromKey, toKey, byHint);
|
|
195
|
-
return byHint;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// check the active id
|
|
199
|
-
const byRequested = resolveFromRequested(requestedId, current, other);
|
|
200
|
-
if (byRequested) {
|
|
201
|
-
if (fromKey && toKey) setTransitionHint(fromKey, toKey, byRequested);
|
|
202
|
-
return byRequested;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// check the sets (intersection/MRU/fallbacks)
|
|
206
|
-
const bySets = resolveFromSets(current, other, fromKey);
|
|
207
|
-
if (bySets) {
|
|
208
|
-
if (fromKey && toKey) setTransitionHint(fromKey, toKey, bySets);
|
|
209
|
-
return bySets;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return "";
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export const Bounds = {
|
|
216
|
-
setBounds,
|
|
217
|
-
getBounds,
|
|
218
|
-
setActiveBoundId,
|
|
219
|
-
getActiveBoundId,
|
|
220
|
-
setRouteActive,
|
|
221
|
-
getRouteActive,
|
|
222
|
-
setTransitionHint,
|
|
223
|
-
getTransitionHint,
|
|
224
|
-
clear,
|
|
225
|
-
clearActive,
|
|
226
|
-
getActiveBound,
|
|
227
|
-
};
|