react-native-screen-transitions 2.0.3 → 2.0.4
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/utils/bounds/constants.js +3 -3
- package/lib/commonjs/utils/bounds/constants.js.map +1 -1
- package/lib/commonjs/utils/bounds/get-bounds.js +3 -3
- package/lib/commonjs/utils/bounds/get-bounds.js.map +1 -1
- package/lib/module/utils/bounds/constants.js +3 -3
- package/lib/module/utils/bounds/constants.js.map +1 -1
- package/lib/module/utils/bounds/get-bounds.js +3 -3
- package/lib/module/utils/bounds/get-bounds.js.map +1 -1
- package/lib/typescript/utils/bounds/_types/get-bounds.d.ts +2 -2
- package/lib/typescript/utils/bounds/_types/get-bounds.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/constants.d.ts +4 -4
- package/lib/typescript/utils/bounds/constants.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/get-bounds.d.ts +2 -2
- package/lib/typescript/utils/bounds/get-bounds.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/index.d.ts +1 -1
- package/lib/typescript/utils/bounds/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/utils/bounds/_types/get-bounds.ts +7 -7
- package/src/utils/bounds/constants.ts +22 -25
- package/src/utils/bounds/get-bounds.ts +40 -40
- package/src/utils/bounds/index.ts +1 -1
- package/lib/commonjs/__tests__ /geometry.test.js +0 -178
- package/lib/commonjs/__tests__ /geometry.test.js.map +0 -1
- package/lib/module/__tests__ /geometry.test.js +0 -178
- package/lib/module/__tests__ /geometry.test.js.map +0 -1
- /package/src/{__tests__ → __tests__}/geometry.test.ts +0 -0
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.FULLSCREEN_DIMENSIONS = exports.DEFAULT_BUILDER_OPTIONS = void 0;
|
|
7
7
|
const FULLSCREEN_DIMENSIONS = dimensions => {
|
|
8
|
-
|
|
8
|
+
'worklet';
|
|
9
9
|
|
|
10
10
|
return {
|
|
11
11
|
x: 0,
|
|
@@ -25,7 +25,7 @@ const DEFAULT_BUILDER_OPTIONS = exports.DEFAULT_BUILDER_OPTIONS = Object.freeze(
|
|
|
25
25
|
toFullscreen: false,
|
|
26
26
|
absolute: false,
|
|
27
27
|
relative: true,
|
|
28
|
-
method:
|
|
29
|
-
contentScaleMode:
|
|
28
|
+
method: 'transform',
|
|
29
|
+
contentScaleMode: 'auto'
|
|
30
30
|
});
|
|
31
31
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FULLSCREEN_DIMENSIONS","dimensions","x","y","pageX","pageY","width","height","exports","DEFAULT_BUILDER_OPTIONS","Object","freeze","gestures","toFullscreen","absolute","relative","method","contentScaleMode"],"sourceRoot":"../../../../src","sources":["utils/bounds/constants.ts"],"mappings":";;;;;;AAKO,MAAMA,qBAAqB,
|
|
1
|
+
{"version":3,"names":["FULLSCREEN_DIMENSIONS","dimensions","x","y","pageX","pageY","width","height","exports","DEFAULT_BUILDER_OPTIONS","Object","freeze","gestures","toFullscreen","absolute","relative","method","contentScaleMode"],"sourceRoot":"../../../../src","sources":["utils/bounds/constants.ts"],"mappings":";;;;;;AAKO,MAAMA,qBAAqB,GAAIC,UAAsB,IAAyB;EACnF,SAAS;;EACT,OAAO;IACLC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE,CAAC;IACJC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAEL,UAAU,CAACK,KAAK;IACvBC,MAAM,EAAEN,UAAU,CAACM;EACrB,CAAC;AACH,CAAC;AAACC,OAAA,CAAAR,qBAAA,GAAAA,qBAAA;AAEK,MAAMS,uBAAuD,GAAAD,OAAA,CAAAC,uBAAA,GAAGC,MAAM,CAACC,MAAM,CAAC;EACnFC,QAAQ,EAAE;IAAEV,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE;EAAE,CAAC;EACxBU,YAAY,EAAE,KAAK;EACnBC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,IAAI;EACdC,MAAM,EAAE,WAAW;EACnBC,gBAAgB,EAAE;AACpB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -16,15 +16,15 @@ const fallbackBounds = {
|
|
|
16
16
|
styles: {}
|
|
17
17
|
};
|
|
18
18
|
const getBounds = props => {
|
|
19
|
-
|
|
19
|
+
'worklet';
|
|
20
20
|
|
|
21
21
|
const boundId = props.id;
|
|
22
22
|
const phase = props.phase;
|
|
23
23
|
if (phase && boundId) {
|
|
24
24
|
let phaseBounds = null;
|
|
25
|
-
if (phase ===
|
|
25
|
+
if (phase === 'current') {
|
|
26
26
|
phaseBounds = props.current?.bounds[boundId];
|
|
27
|
-
} else if (phase ===
|
|
27
|
+
} else if (phase === 'next') {
|
|
28
28
|
phaseBounds = props.next?.bounds[boundId];
|
|
29
29
|
} else {
|
|
30
30
|
phaseBounds = props.previous?.bounds[boundId];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fallbackBounds","bounds","width","height","x","y","pageX","pageY","styles","getBounds","props","boundId","id","phase","phaseBounds","current","next","previous","previousBounds","nextBounds","exports"],"sourceRoot":"../../../../src","sources":["utils/bounds/get-bounds.ts"],"mappings":";;;;;;AAIA,MAAMA,cAAc,GAAG;
|
|
1
|
+
{"version":3,"names":["fallbackBounds","bounds","width","height","x","y","pageX","pageY","styles","getBounds","props","boundId","id","phase","phaseBounds","current","next","previous","previousBounds","nextBounds","exports"],"sourceRoot":"../../../../src","sources":["utils/bounds/get-bounds.ts"],"mappings":";;;;;;AAIA,MAAMA,cAAc,GAAG;EACrBC,MAAM,EAAE;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE,CAAC;IACJC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE;EACT,CAAC;EACDC,MAAM,EAAE,CAAC;AACX,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
'worklet';
|
|
5
5
|
|
|
6
6
|
return {
|
|
7
7
|
x: 0,
|
|
@@ -20,7 +20,7 @@ export const DEFAULT_BUILDER_OPTIONS = Object.freeze({
|
|
|
20
20
|
toFullscreen: false,
|
|
21
21
|
absolute: false,
|
|
22
22
|
relative: true,
|
|
23
|
-
method:
|
|
24
|
-
contentScaleMode:
|
|
23
|
+
method: 'transform',
|
|
24
|
+
contentScaleMode: 'auto'
|
|
25
25
|
});
|
|
26
26
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FULLSCREEN_DIMENSIONS","dimensions","x","y","pageX","pageY","width","height","DEFAULT_BUILDER_OPTIONS","Object","freeze","gestures","toFullscreen","absolute","relative","method","contentScaleMode"],"sourceRoot":"../../../../src","sources":["utils/bounds/constants.ts"],"mappings":";;AAKA,OAAO,MAAMA,qBAAqB,
|
|
1
|
+
{"version":3,"names":["FULLSCREEN_DIMENSIONS","dimensions","x","y","pageX","pageY","width","height","DEFAULT_BUILDER_OPTIONS","Object","freeze","gestures","toFullscreen","absolute","relative","method","contentScaleMode"],"sourceRoot":"../../../../src","sources":["utils/bounds/constants.ts"],"mappings":";;AAKA,OAAO,MAAMA,qBAAqB,GAAIC,UAAsB,IAAyB;EACnF,SAAS;;EACT,OAAO;IACLC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE,CAAC;IACJC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAEL,UAAU,CAACK,KAAK;IACvBC,MAAM,EAAEN,UAAU,CAACM;EACrB,CAAC;AACH,CAAC;AAED,OAAO,MAAMC,uBAAuD,GAAGC,MAAM,CAACC,MAAM,CAAC;EACnFC,QAAQ,EAAE;IAAET,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE;EAAE,CAAC;EACxBS,YAAY,EAAE,KAAK;EACnBC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,IAAI;EACdC,MAAM,EAAE,WAAW;EACnBC,gBAAgB,EAAE;AACpB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -12,15 +12,15 @@ const fallbackBounds = {
|
|
|
12
12
|
styles: {}
|
|
13
13
|
};
|
|
14
14
|
export const getBounds = props => {
|
|
15
|
-
|
|
15
|
+
'worklet';
|
|
16
16
|
|
|
17
17
|
const boundId = props.id;
|
|
18
18
|
const phase = props.phase;
|
|
19
19
|
if (phase && boundId) {
|
|
20
20
|
let phaseBounds = null;
|
|
21
|
-
if (phase ===
|
|
21
|
+
if (phase === 'current') {
|
|
22
22
|
phaseBounds = props.current?.bounds[boundId];
|
|
23
|
-
} else if (phase ===
|
|
23
|
+
} else if (phase === 'next') {
|
|
24
24
|
phaseBounds = props.next?.bounds[boundId];
|
|
25
25
|
} else {
|
|
26
26
|
phaseBounds = props.previous?.bounds[boundId];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fallbackBounds","bounds","width","height","x","y","pageX","pageY","styles","getBounds","props","boundId","id","phase","phaseBounds","current","next","previous","previousBounds","nextBounds"],"sourceRoot":"../../../../src","sources":["utils/bounds/get-bounds.ts"],"mappings":";;AAIA,MAAMA,cAAc,GAAG;
|
|
1
|
+
{"version":3,"names":["fallbackBounds","bounds","width","height","x","y","pageX","pageY","styles","getBounds","props","boundId","id","phase","phaseBounds","current","next","previous","previousBounds","nextBounds"],"sourceRoot":"../../../../src","sources":["utils/bounds/get-bounds.ts"],"mappings":";;AAIA,MAAMA,cAAc,GAAG;EACrBC,MAAM,EAAE;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE,CAAC;IACJC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE;EACT,CAAC;EACDC,MAAM,EAAE,CAAC;AACX,CAAC;AAED,OAAO,MAAMC,SAAS,GAAIC,KAAsB,IAAiB;EAC/D,SAAS;;EACT,MAAMC,OAAO,GAAGD,KAAK,CAACE,EAAE;EACxB,MAAMC,KAAK,GAAGH,KAAK,CAACG,KAAK;EAEzB,IAAIA,KAAK,IAAIF,OAAO,EAAE;IACpB,IAAIG,WAAW,GAAG,IAAI;IAEtB,IAAID,KAAK,KAAK,SAAS,EAAE;MACvBC,WAAW,GAAGJ,KAAK,CAACK,OAAO,EAAEd,MAAM,CAACU,OAAO,CAAC;IAC9C,CAAC,MAAM,IAAIE,KAAK,KAAK,MAAM,EAAE;MAC3BC,WAAW,GAAGJ,KAAK,CAACM,IAAI,EAAEf,MAAM,CAACU,OAAO,CAAC;IAC3C,CAAC,MAAM;MACLG,WAAW,GAAGJ,KAAK,CAACO,QAAQ,EAAEhB,MAAM,CAACU,OAAO,CAAC;IAC/C;IAEA,IAAI,CAACG,WAAW,EAAE;MAChB,OAAOd,cAAc;IACvB;IAEA,OAAO;MACLC,MAAM,EAAEa,WAAW,CAACb,MAAM;MAC1BO,MAAM,EAAEM,WAAW,EAAEN;IACvB,CAAC;EACH;EAEA,IAAI,CAACE,KAAK,CAACM,IAAI,IAAIL,OAAO,EAAE;IAC1B,MAAMO,cAAc,GAAGR,KAAK,CAACO,QAAQ,EAAEhB,MAAM,CAACU,OAAO,CAAC;IAEtD,OAAOO,cAAc,IAAIlB,cAAc;EACzC;EAEA,IAAIW,OAAO,EAAE;IACX,MAAMQ,UAAU,GAAGT,KAAK,CAACM,IAAI,EAAEf,MAAM,CAACU,OAAO,CAAC;IAE9C,OAAOQ,UAAU,IAAInB,cAAc;EACrC;EAEA,OAAOA,cAAc;AACvB,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ScreenPhase } from
|
|
2
|
-
import type { ScreenTransitionState } from
|
|
1
|
+
import type { ScreenPhase } from '../../../types/core';
|
|
2
|
+
import type { ScreenTransitionState } from '../../../types/animation';
|
|
3
3
|
export type GetBoundsParams = {
|
|
4
4
|
id: string | null;
|
|
5
5
|
phase?: ScreenPhase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-bounds.d.ts","sourceRoot":"","sources":["../../../../../src/utils/bounds/_types/get-bounds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"get-bounds.d.ts","sourceRoot":"","sources":["../../../../../src/utils/bounds/_types/get-bounds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,CAAC,EAAE,qBAAqB,CAAC;CAC9B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ScaledSize } from
|
|
2
|
-
import type { MeasuredDimensions } from
|
|
3
|
-
import type { Complete } from
|
|
4
|
-
import type { BoundsBuilderOptions } from
|
|
1
|
+
import type { ScaledSize } from 'react-native';
|
|
2
|
+
import type { MeasuredDimensions } from 'react-native-reanimated';
|
|
3
|
+
import type { Complete } from '../../types/utils';
|
|
4
|
+
import type { BoundsBuilderOptions } from './_types/builder';
|
|
5
5
|
export declare const FULLSCREEN_DIMENSIONS: (dimensions: ScaledSize) => MeasuredDimensions;
|
|
6
6
|
export declare const DEFAULT_BUILDER_OPTIONS: Complete<BoundsBuilderOptions>;
|
|
7
7
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/utils/bounds/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/utils/bounds/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,eAAO,MAAM,qBAAqB,GAAI,YAAY,UAAU,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,oBAAoB,CAOjE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BoundEntry } from
|
|
2
|
-
import type { GetBoundsParams } from
|
|
1
|
+
import type { BoundEntry } from '../../types/bounds';
|
|
2
|
+
import type { GetBoundsParams } from './_types/get-bounds';
|
|
3
3
|
export declare const getBounds: (props: GetBoundsParams) => BoundEntry;
|
|
4
4
|
//# sourceMappingURL=get-bounds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-bounds.d.ts","sourceRoot":"","sources":["../../../../src/utils/bounds/get-bounds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"get-bounds.d.ts","sourceRoot":"","sources":["../../../../src/utils/bounds/get-bounds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAc3D,eAAO,MAAM,SAAS,GAAI,OAAO,eAAe,KAAG,UAuClD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ScaledSize } from "react-native";
|
|
2
|
-
import type { ScreenPhase } from "
|
|
2
|
+
import type { ScreenPhase } from "../../types/core";
|
|
3
3
|
import type { ScreenTransitionState } from "../../types/animation";
|
|
4
4
|
export interface BuildBoundsAccessorParams {
|
|
5
5
|
activeBoundId: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/bounds/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/bounds/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAInE,MAAM,WAAW,yBAAyB;IACzC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACvB;AAED,eAAO,MAAM,mBAAmB,GAAI,mEAOjC,yBAAyB,YAGN,MAAM;eAWf,MAAM,UAAU,WAAW;CASvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-screen-transitions",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Easy screen transitions for React Native and Expo",
|
|
5
5
|
"author": "Ed",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@types/react": "~19.0.10",
|
|
51
51
|
"react-native-builder-bob": "0.39.0",
|
|
52
52
|
"tsup": "^8.5.0",
|
|
53
|
-
"typescript": ""
|
|
53
|
+
"typescript": "~5.8.3"
|
|
54
54
|
},
|
|
55
55
|
"react-native-builder-bob": {
|
|
56
56
|
"source": "src",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
]
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "38f75fc51e610d78d165d5fc78b94f71a1db0efe"
|
|
70
70
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ScreenPhase } from
|
|
2
|
-
import type { ScreenTransitionState } from
|
|
1
|
+
import type { ScreenPhase } from '../../../types/core';
|
|
2
|
+
import type { ScreenTransitionState } from '../../../types/animation';
|
|
3
3
|
|
|
4
4
|
export type GetBoundsParams = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
id: string | null;
|
|
6
|
+
phase?: ScreenPhase;
|
|
7
|
+
previous?: ScreenTransitionState;
|
|
8
|
+
current: ScreenTransitionState;
|
|
9
|
+
next?: ScreenTransitionState;
|
|
10
10
|
};
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import type { ScaledSize } from
|
|
2
|
-
import type { MeasuredDimensions } from
|
|
3
|
-
import type { Complete } from
|
|
4
|
-
import type { BoundsBuilderOptions } from
|
|
1
|
+
import type { ScaledSize } from 'react-native';
|
|
2
|
+
import type { MeasuredDimensions } from 'react-native-reanimated';
|
|
3
|
+
import type { Complete } from '../../types/utils';
|
|
4
|
+
import type { BoundsBuilderOptions } from './_types/builder';
|
|
5
5
|
|
|
6
|
-
export const FULLSCREEN_DIMENSIONS = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
height: dimensions.height,
|
|
17
|
-
};
|
|
6
|
+
export const FULLSCREEN_DIMENSIONS = (dimensions: ScaledSize): MeasuredDimensions => {
|
|
7
|
+
'worklet';
|
|
8
|
+
return {
|
|
9
|
+
x: 0,
|
|
10
|
+
y: 0,
|
|
11
|
+
pageX: 0,
|
|
12
|
+
pageY: 0,
|
|
13
|
+
width: dimensions.width,
|
|
14
|
+
height: dimensions.height,
|
|
15
|
+
};
|
|
18
16
|
};
|
|
19
17
|
|
|
20
|
-
export const DEFAULT_BUILDER_OPTIONS: Complete<BoundsBuilderOptions> =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
18
|
+
export const DEFAULT_BUILDER_OPTIONS: Complete<BoundsBuilderOptions> = Object.freeze({
|
|
19
|
+
gestures: { x: 0, y: 0 },
|
|
20
|
+
toFullscreen: false,
|
|
21
|
+
absolute: false,
|
|
22
|
+
relative: true,
|
|
23
|
+
method: 'transform',
|
|
24
|
+
contentScaleMode: 'auto',
|
|
25
|
+
});
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import type { BoundEntry } from
|
|
1
|
+
import type { BoundEntry } from '../../types/bounds';
|
|
2
2
|
|
|
3
|
-
import type { GetBoundsParams } from
|
|
3
|
+
import type { GetBoundsParams } from './_types/get-bounds';
|
|
4
4
|
|
|
5
5
|
const fallbackBounds = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
bounds: {
|
|
7
|
+
width: 0,
|
|
8
|
+
height: 0,
|
|
9
|
+
x: 0,
|
|
10
|
+
y: 0,
|
|
11
|
+
pageX: 0,
|
|
12
|
+
pageY: 0,
|
|
13
|
+
},
|
|
14
|
+
styles: {},
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const getBounds = (props: GetBoundsParams): BoundEntry => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
'worklet';
|
|
19
|
+
const boundId = props.id;
|
|
20
|
+
const phase = props.phase;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if (phase && boundId) {
|
|
23
|
+
let phaseBounds = null;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
if (phase === 'current') {
|
|
26
|
+
phaseBounds = props.current?.bounds[boundId];
|
|
27
|
+
} else if (phase === 'next') {
|
|
28
|
+
phaseBounds = props.next?.bounds[boundId];
|
|
29
|
+
} else {
|
|
30
|
+
phaseBounds = props.previous?.bounds[boundId];
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (!phaseBounds) {
|
|
34
|
+
return fallbackBounds;
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
return {
|
|
38
|
+
bounds: phaseBounds.bounds,
|
|
39
|
+
styles: phaseBounds?.styles,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (!props.next && boundId) {
|
|
44
|
+
const previousBounds = props.previous?.bounds[boundId];
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
return previousBounds || fallbackBounds;
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
if (boundId) {
|
|
50
|
+
const nextBounds = props.next?.bounds[boundId];
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
return nextBounds || fallbackBounds;
|
|
53
|
+
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
return fallbackBounds;
|
|
56
56
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ScaledSize } from "react-native";
|
|
2
|
-
import type { ScreenPhase } from "
|
|
2
|
+
import type { ScreenPhase } from "../../types/core";
|
|
3
3
|
import type { ScreenTransitionState } from "../../types/animation";
|
|
4
4
|
import { buildBoundStyles } from "./build-bound-styles";
|
|
5
5
|
import { getBounds } from "./get-bounds";
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _bunTest = require("bun:test");
|
|
4
|
-
var _geometry = require("../utils/bounds/geometry");
|
|
5
|
-
(0, _bunTest.describe)("computeRelativeGeometry", () => {
|
|
6
|
-
(0, _bunTest.it)("calculates correct relative geometry when entering", () => {
|
|
7
|
-
const start = {
|
|
8
|
-
x: 10,
|
|
9
|
-
y: 20,
|
|
10
|
-
pageX: 10,
|
|
11
|
-
pageY: 20,
|
|
12
|
-
width: 100,
|
|
13
|
-
height: 200
|
|
14
|
-
};
|
|
15
|
-
const end = {
|
|
16
|
-
x: 50,
|
|
17
|
-
y: 100,
|
|
18
|
-
pageX: 50,
|
|
19
|
-
pageY: 100,
|
|
20
|
-
width: 200,
|
|
21
|
-
height: 400
|
|
22
|
-
};
|
|
23
|
-
const result = (0, _geometry.computeRelativeGeometry)({
|
|
24
|
-
start,
|
|
25
|
-
end,
|
|
26
|
-
entering: true
|
|
27
|
-
});
|
|
28
|
-
(0, _bunTest.expect)(result.dx).toBe(-90); // center diff X
|
|
29
|
-
(0, _bunTest.expect)(result.dy).toBe(-180); // center diff Y
|
|
30
|
-
(0, _bunTest.expect)(result.scaleX).toBe(0.5); // width ratio
|
|
31
|
-
(0, _bunTest.expect)(result.scaleY).toBe(0.5); // height ratio
|
|
32
|
-
(0, _bunTest.expect)(result.ranges).toEqual([0, 1]);
|
|
33
|
-
(0, _bunTest.expect)(result.entering).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
(0, _bunTest.it)("calculates correct relative geometry when exiting", () => {
|
|
36
|
-
const start = {
|
|
37
|
-
x: 0,
|
|
38
|
-
y: 0,
|
|
39
|
-
pageX: 10,
|
|
40
|
-
pageY: 20,
|
|
41
|
-
width: 100,
|
|
42
|
-
height: 200
|
|
43
|
-
};
|
|
44
|
-
const end = {
|
|
45
|
-
x: 0,
|
|
46
|
-
y: 0,
|
|
47
|
-
pageX: 50,
|
|
48
|
-
pageY: 100,
|
|
49
|
-
width: 200,
|
|
50
|
-
height: 400
|
|
51
|
-
};
|
|
52
|
-
const result = (0, _geometry.computeRelativeGeometry)({
|
|
53
|
-
start,
|
|
54
|
-
end,
|
|
55
|
-
entering: false
|
|
56
|
-
});
|
|
57
|
-
(0, _bunTest.expect)(result.ranges).toEqual([1, 2]);
|
|
58
|
-
(0, _bunTest.expect)(result.entering).toBe(false);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
(0, _bunTest.describe)("computeContentTransformGeometry", () => {
|
|
62
|
-
const dimensions = {
|
|
63
|
-
width: 375,
|
|
64
|
-
height: 812,
|
|
65
|
-
scale: 1,
|
|
66
|
-
fontScale: 1
|
|
67
|
-
};
|
|
68
|
-
(0, _bunTest.it)("calculates transform with aspectFit mode", () => {
|
|
69
|
-
const start = {
|
|
70
|
-
x: 0,
|
|
71
|
-
y: 0,
|
|
72
|
-
pageX: 50,
|
|
73
|
-
pageY: 100,
|
|
74
|
-
width: 100,
|
|
75
|
-
height: 100
|
|
76
|
-
};
|
|
77
|
-
const end = {
|
|
78
|
-
x: 0,
|
|
79
|
-
y: 0,
|
|
80
|
-
pageX: 100,
|
|
81
|
-
pageY: 200,
|
|
82
|
-
width: 200,
|
|
83
|
-
height: 50
|
|
84
|
-
};
|
|
85
|
-
const result = (0, _geometry.computeContentTransformGeometry)({
|
|
86
|
-
start,
|
|
87
|
-
end,
|
|
88
|
-
entering: true,
|
|
89
|
-
dimensions,
|
|
90
|
-
contentScaleMode: "aspectFit"
|
|
91
|
-
});
|
|
92
|
-
(0, _bunTest.expect)(result.s).toBe(0.5);
|
|
93
|
-
(0, _bunTest.expect)(result.entering).toBe(true);
|
|
94
|
-
(0, _bunTest.expect)(result.ranges).toEqual([0, 1]);
|
|
95
|
-
});
|
|
96
|
-
(0, _bunTest.it)("calculates transform with aspectFill mode", () => {
|
|
97
|
-
const start = {
|
|
98
|
-
x: 0,
|
|
99
|
-
y: 0,
|
|
100
|
-
pageX: 50,
|
|
101
|
-
pageY: 100,
|
|
102
|
-
width: 100,
|
|
103
|
-
height: 100
|
|
104
|
-
};
|
|
105
|
-
const end = {
|
|
106
|
-
x: 0,
|
|
107
|
-
y: 0,
|
|
108
|
-
pageX: 100,
|
|
109
|
-
pageY: 200,
|
|
110
|
-
width: 200,
|
|
111
|
-
height: 50
|
|
112
|
-
};
|
|
113
|
-
const result = (0, _geometry.computeContentTransformGeometry)({
|
|
114
|
-
start,
|
|
115
|
-
end,
|
|
116
|
-
entering: true,
|
|
117
|
-
dimensions,
|
|
118
|
-
contentScaleMode: "aspectFill"
|
|
119
|
-
});
|
|
120
|
-
(0, _bunTest.expect)(result.s).toBe(2);
|
|
121
|
-
});
|
|
122
|
-
(0, _bunTest.it)("handles auto mode based on aspect ratio difference", () => {
|
|
123
|
-
const start = {
|
|
124
|
-
x: 0,
|
|
125
|
-
y: 0,
|
|
126
|
-
pageX: 0,
|
|
127
|
-
pageY: 0,
|
|
128
|
-
width: 100,
|
|
129
|
-
height: 100
|
|
130
|
-
};
|
|
131
|
-
const end = {
|
|
132
|
-
x: 0,
|
|
133
|
-
y: 0,
|
|
134
|
-
pageX: 0,
|
|
135
|
-
pageY: 0,
|
|
136
|
-
width: 200,
|
|
137
|
-
height: 195
|
|
138
|
-
};
|
|
139
|
-
const result = (0, _geometry.computeContentTransformGeometry)({
|
|
140
|
-
start,
|
|
141
|
-
end,
|
|
142
|
-
entering: true,
|
|
143
|
-
dimensions,
|
|
144
|
-
contentScaleMode: "auto"
|
|
145
|
-
});
|
|
146
|
-
(0, _bunTest.expect)(result.s).toBeCloseTo(0.512, 2);
|
|
147
|
-
});
|
|
148
|
-
(0, _bunTest.it)("handles zero dimensions safely", () => {
|
|
149
|
-
const start = {
|
|
150
|
-
x: 0,
|
|
151
|
-
y: 0,
|
|
152
|
-
pageX: 0,
|
|
153
|
-
pageY: 0,
|
|
154
|
-
width: 0,
|
|
155
|
-
height: 100
|
|
156
|
-
};
|
|
157
|
-
const end = {
|
|
158
|
-
x: 0,
|
|
159
|
-
y: 0,
|
|
160
|
-
pageX: 0,
|
|
161
|
-
pageY: 0,
|
|
162
|
-
width: 200,
|
|
163
|
-
height: 200
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
// Should not throw and use safe fallback
|
|
167
|
-
const result = (0, _geometry.computeContentTransformGeometry)({
|
|
168
|
-
start,
|
|
169
|
-
end,
|
|
170
|
-
entering: true,
|
|
171
|
-
dimensions,
|
|
172
|
-
contentScaleMode: "aspectFit"
|
|
173
|
-
});
|
|
174
|
-
(0, _bunTest.expect)(result.s).toBeDefined();
|
|
175
|
-
(0, _bunTest.expect)(Number.isFinite(result.s)).toBe(true);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
//# sourceMappingURL=geometry.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_bunTest","require","_geometry","describe","it","start","x","y","pageX","pageY","width","height","end","result","computeRelativeGeometry","entering","expect","dx","toBe","dy","scaleX","scaleY","ranges","toEqual","dimensions","scale","fontScale","computeContentTransformGeometry","contentScaleMode","s","toBeCloseTo","toBeDefined","Number","isFinite"],"sourceRoot":"../../../src","sources":["__tests__ /geometry.test.ts"],"mappings":";;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAQ,EAAC,yBAAyB,EAAE,MAAM;EACzC,IAAAC,WAAE,EAAC,oDAAoD,EAAE,MAAM;IAC9D,MAAMC,KAAK,GAAG;MACbC,CAAC,EAAE,EAAE;MACLC,C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use strict";
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it } from "bun:test";
|
|
4
|
-
import { computeContentTransformGeometry, computeRelativeGeometry } from "../utils/bounds/geometry";
|
|
5
|
-
describe("computeRelativeGeometry", () => {
|
|
6
|
-
it("calculates correct relative geometry when entering", () => {
|
|
7
|
-
const start = {
|
|
8
|
-
x: 10,
|
|
9
|
-
y: 20,
|
|
10
|
-
pageX: 10,
|
|
11
|
-
pageY: 20,
|
|
12
|
-
width: 100,
|
|
13
|
-
height: 200
|
|
14
|
-
};
|
|
15
|
-
const end = {
|
|
16
|
-
x: 50,
|
|
17
|
-
y: 100,
|
|
18
|
-
pageX: 50,
|
|
19
|
-
pageY: 100,
|
|
20
|
-
width: 200,
|
|
21
|
-
height: 400
|
|
22
|
-
};
|
|
23
|
-
const result = computeRelativeGeometry({
|
|
24
|
-
start,
|
|
25
|
-
end,
|
|
26
|
-
entering: true
|
|
27
|
-
});
|
|
28
|
-
expect(result.dx).toBe(-90); // center diff X
|
|
29
|
-
expect(result.dy).toBe(-180); // center diff Y
|
|
30
|
-
expect(result.scaleX).toBe(0.5); // width ratio
|
|
31
|
-
expect(result.scaleY).toBe(0.5); // height ratio
|
|
32
|
-
expect(result.ranges).toEqual([0, 1]);
|
|
33
|
-
expect(result.entering).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
it("calculates correct relative geometry when exiting", () => {
|
|
36
|
-
const start = {
|
|
37
|
-
x: 0,
|
|
38
|
-
y: 0,
|
|
39
|
-
pageX: 10,
|
|
40
|
-
pageY: 20,
|
|
41
|
-
width: 100,
|
|
42
|
-
height: 200
|
|
43
|
-
};
|
|
44
|
-
const end = {
|
|
45
|
-
x: 0,
|
|
46
|
-
y: 0,
|
|
47
|
-
pageX: 50,
|
|
48
|
-
pageY: 100,
|
|
49
|
-
width: 200,
|
|
50
|
-
height: 400
|
|
51
|
-
};
|
|
52
|
-
const result = computeRelativeGeometry({
|
|
53
|
-
start,
|
|
54
|
-
end,
|
|
55
|
-
entering: false
|
|
56
|
-
});
|
|
57
|
-
expect(result.ranges).toEqual([1, 2]);
|
|
58
|
-
expect(result.entering).toBe(false);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe("computeContentTransformGeometry", () => {
|
|
62
|
-
const dimensions = {
|
|
63
|
-
width: 375,
|
|
64
|
-
height: 812,
|
|
65
|
-
scale: 1,
|
|
66
|
-
fontScale: 1
|
|
67
|
-
};
|
|
68
|
-
it("calculates transform with aspectFit mode", () => {
|
|
69
|
-
const start = {
|
|
70
|
-
x: 0,
|
|
71
|
-
y: 0,
|
|
72
|
-
pageX: 50,
|
|
73
|
-
pageY: 100,
|
|
74
|
-
width: 100,
|
|
75
|
-
height: 100
|
|
76
|
-
};
|
|
77
|
-
const end = {
|
|
78
|
-
x: 0,
|
|
79
|
-
y: 0,
|
|
80
|
-
pageX: 100,
|
|
81
|
-
pageY: 200,
|
|
82
|
-
width: 200,
|
|
83
|
-
height: 50
|
|
84
|
-
};
|
|
85
|
-
const result = computeContentTransformGeometry({
|
|
86
|
-
start,
|
|
87
|
-
end,
|
|
88
|
-
entering: true,
|
|
89
|
-
dimensions,
|
|
90
|
-
contentScaleMode: "aspectFit"
|
|
91
|
-
});
|
|
92
|
-
expect(result.s).toBe(0.5);
|
|
93
|
-
expect(result.entering).toBe(true);
|
|
94
|
-
expect(result.ranges).toEqual([0, 1]);
|
|
95
|
-
});
|
|
96
|
-
it("calculates transform with aspectFill mode", () => {
|
|
97
|
-
const start = {
|
|
98
|
-
x: 0,
|
|
99
|
-
y: 0,
|
|
100
|
-
pageX: 50,
|
|
101
|
-
pageY: 100,
|
|
102
|
-
width: 100,
|
|
103
|
-
height: 100
|
|
104
|
-
};
|
|
105
|
-
const end = {
|
|
106
|
-
x: 0,
|
|
107
|
-
y: 0,
|
|
108
|
-
pageX: 100,
|
|
109
|
-
pageY: 200,
|
|
110
|
-
width: 200,
|
|
111
|
-
height: 50
|
|
112
|
-
};
|
|
113
|
-
const result = computeContentTransformGeometry({
|
|
114
|
-
start,
|
|
115
|
-
end,
|
|
116
|
-
entering: true,
|
|
117
|
-
dimensions,
|
|
118
|
-
contentScaleMode: "aspectFill"
|
|
119
|
-
});
|
|
120
|
-
expect(result.s).toBe(2);
|
|
121
|
-
});
|
|
122
|
-
it("handles auto mode based on aspect ratio difference", () => {
|
|
123
|
-
const start = {
|
|
124
|
-
x: 0,
|
|
125
|
-
y: 0,
|
|
126
|
-
pageX: 0,
|
|
127
|
-
pageY: 0,
|
|
128
|
-
width: 100,
|
|
129
|
-
height: 100
|
|
130
|
-
};
|
|
131
|
-
const end = {
|
|
132
|
-
x: 0,
|
|
133
|
-
y: 0,
|
|
134
|
-
pageX: 0,
|
|
135
|
-
pageY: 0,
|
|
136
|
-
width: 200,
|
|
137
|
-
height: 195
|
|
138
|
-
};
|
|
139
|
-
const result = computeContentTransformGeometry({
|
|
140
|
-
start,
|
|
141
|
-
end,
|
|
142
|
-
entering: true,
|
|
143
|
-
dimensions,
|
|
144
|
-
contentScaleMode: "auto"
|
|
145
|
-
});
|
|
146
|
-
expect(result.s).toBeCloseTo(0.512, 2);
|
|
147
|
-
});
|
|
148
|
-
it("handles zero dimensions safely", () => {
|
|
149
|
-
const start = {
|
|
150
|
-
x: 0,
|
|
151
|
-
y: 0,
|
|
152
|
-
pageX: 0,
|
|
153
|
-
pageY: 0,
|
|
154
|
-
width: 0,
|
|
155
|
-
height: 100
|
|
156
|
-
};
|
|
157
|
-
const end = {
|
|
158
|
-
x: 0,
|
|
159
|
-
y: 0,
|
|
160
|
-
pageX: 0,
|
|
161
|
-
pageY: 0,
|
|
162
|
-
width: 200,
|
|
163
|
-
height: 200
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
// Should not throw and use safe fallback
|
|
167
|
-
const result = computeContentTransformGeometry({
|
|
168
|
-
start,
|
|
169
|
-
end,
|
|
170
|
-
entering: true,
|
|
171
|
-
dimensions,
|
|
172
|
-
contentScaleMode: "aspectFit"
|
|
173
|
-
});
|
|
174
|
-
expect(result.s).toBeDefined();
|
|
175
|
-
expect(Number.isFinite(result.s)).toBe(true);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
//# sourceMappingURL=geometry.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["describe","expect","it","computeContentTransformGeometry","computeRelativeGeometry","start","x","y","pageX","pageY","width","height","end","result","entering","dx","toBe","dy","scaleX","scaleY","ranges","toEqual","dimensions","scale","fontScale","contentScaleMode","s","toBeCloseTo","toBeDefined","Number","isFinite"],"sourceRoot":"../../../src","sources":["__tests__ /geometry.test.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,UAAU;AAC/C,SACCC,+BAA+B,EAC/BC,uBAAuB,QACjB,0BAA0B;AAEjCJ,QAAQ,CAAC,yBAAyB,EAAE,MAAM;EACzCE,EAAE,CAAC,oDAAoD,EAAE,MAAM;IAC9D,MAAMG,KAAK,GAAG;MACbC,CAAC,EAAE,EAAE;MACLC,CAAC,EAAE,EAAE;MACLC,KAAK,EAAE,EAAE;MACTC,KAAK,EAAE,EAAE;MACTC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACT,CAAC;IACD,MAAMC,GAAG,GAAG;MACXN,CAAC,EAAE,EAAE;MACLC,CAAC,EAAE,GAAG;MACNC,KAAK,EAAE,EAAE;MACTC,KAAK,EAAE,GAAG;MACVC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACT,CAAC;IAED,MAAME,MAAM,GAAGT,uBAAuB,CAAC;MAAEC,KAAK;MAAEO,GAAG;MAAEE,QAAQ,EAAE;IAAK,CAAC,CAAC;IAEtEb,MAAM,CAACY,MAAM,CAACE,EAAE,CAAC,CAACC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7Bf,MAAM,CAACY,MAAM,CAACI,EAAE,CAAC,CAACD,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B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