react-native-smooth-clip-view 0.1.0 → 0.2.1
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 +171 -43
- package/SmoothClipView.podspec +8 -2
- package/android/CMakeLists.txt +39 -0
- package/android/build.gradle +69 -2
- package/android/proguard-rules.pro +6 -0
- package/android/src/main/cpp/SmoothClipAndroid.h +59 -0
- package/android/src/main/cpp/SmoothClipBindings.cpp +428 -0
- package/android/src/main/cpp/SmoothClipRegistry.cpp +945 -0
- package/android/src/main/java/com/smoothclipview/ClipGeometryNormalizer.kt +25 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipBindings.kt +55 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipModule.kt +128 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipView.kt +164 -30
- package/android/src/main/java/com/smoothclipview/SmoothClipViewManager.kt +107 -10
- package/android/src/main/java/com/smoothclipview/SmoothClipViewPackage.kt +18 -2
- package/cpp/SmoothClipRegistry.h +93 -0
- package/cpp/SmoothClipSharedGeometry.h +50 -0
- package/ios/SmoothClipModuleProvider.h +9 -0
- package/ios/SmoothClipModuleProvider.mm +16 -0
- package/ios/SmoothClipRegistry.mm +754 -0
- package/ios/SmoothClipTurboModule.cpp +290 -0
- package/ios/SmoothClipTurboModule.h +132 -0
- package/ios/SmoothClipView.mm +976 -85
- package/ios/SmoothClipViewRegistry.h +27 -0
- package/lib/module/NativeSmoothClipModule.js +5 -0
- package/lib/module/NativeSmoothClipModule.js.map +1 -0
- package/lib/module/SmoothClipView.android.js +4 -0
- package/lib/module/SmoothClipView.android.js.map +1 -0
- package/lib/module/SmoothClipView.ios.js +34 -0
- package/lib/module/SmoothClipView.ios.js.map +1 -0
- package/lib/module/SmoothClipView.js +26 -12
- package/lib/module/SmoothClipView.js.map +1 -1
- package/lib/module/SmoothClipView.web.js +28 -12
- package/lib/module/SmoothClipView.web.js.map +1 -1
- package/lib/module/SmoothClipViewNativeComponent.ts +14 -1
- package/lib/module/driverState.js +102 -0
- package/lib/module/driverState.js.map +1 -0
- package/lib/module/driverTypes.js +4 -0
- package/lib/module/driverTypes.js.map +1 -0
- package/lib/module/drivers.android.js +4 -0
- package/lib/module/drivers.android.js.map +1 -0
- package/lib/module/drivers.ios.js +380 -0
- package/lib/module/drivers.ios.js.map +1 -0
- package/lib/module/drivers.js +276 -0
- package/lib/module/drivers.js.map +1 -0
- package/lib/module/geometry.js +19 -0
- package/lib/module/geometry.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +2 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/nativeCompletion.js +21 -0
- package/lib/module/nativeCompletion.js.map +1 -0
- package/lib/module/reactRequests.js +50 -0
- package/lib/module/reactRequests.js.map +1 -0
- package/lib/module/smoothClipNative.android.js +15 -0
- package/lib/module/smoothClipNative.android.js.map +1 -0
- package/lib/module/smoothClipNative.js +8 -0
- package/lib/module/smoothClipNative.js.map +1 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts +19 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts.map +1 -0
- package/lib/typescript/src/SmoothClipView.android.d.ts +3 -0
- package/lib/typescript/src/SmoothClipView.android.d.ts.map +1 -0
- package/lib/typescript/src/SmoothClipView.d.ts +5 -6
- package/lib/typescript/src/SmoothClipView.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.ios.d.ts +9 -0
- package/lib/typescript/src/SmoothClipView.ios.d.ts.map +1 -0
- package/lib/typescript/src/SmoothClipView.web.d.ts +5 -7
- package/lib/typescript/src/SmoothClipView.web.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts +4 -0
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/driverState.d.ts +31 -0
- package/lib/typescript/src/driverState.d.ts.map +1 -0
- package/lib/typescript/src/driverTypes.d.ts +61 -0
- package/lib/typescript/src/driverTypes.d.ts.map +1 -0
- package/lib/typescript/src/drivers.android.d.ts +3 -0
- package/lib/typescript/src/drivers.android.d.ts.map +1 -0
- package/lib/typescript/src/drivers.d.ts +5 -0
- package/lib/typescript/src/drivers.d.ts.map +1 -0
- package/lib/typescript/src/drivers.ios.d.ts +5 -0
- package/lib/typescript/src/drivers.ios.d.ts.map +1 -0
- package/lib/typescript/src/geometry.d.ts +8 -0
- package/lib/typescript/src/geometry.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +4 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/nativeCompletion.d.ts +7 -0
- package/lib/typescript/src/nativeCompletion.d.ts.map +1 -0
- package/lib/typescript/src/reactRequests.d.ts +7 -0
- package/lib/typescript/src/reactRequests.d.ts.map +1 -0
- package/lib/typescript/src/smoothClipNative.android.d.ts +4 -0
- package/lib/typescript/src/smoothClipNative.android.d.ts.map +1 -0
- package/lib/typescript/src/smoothClipNative.d.ts +3 -0
- package/lib/typescript/src/smoothClipNative.d.ts.map +1 -0
- package/package.json +12 -7
- package/src/NativeSmoothClipModule.ts +104 -0
- package/src/SmoothClipView.android.tsx +2 -0
- package/src/SmoothClipView.ios.tsx +36 -0
- package/src/SmoothClipView.tsx +31 -27
- package/src/SmoothClipView.web.tsx +26 -22
- package/src/SmoothClipViewNativeComponent.ts +14 -1
- package/src/driverState.ts +150 -0
- package/src/driverTypes.ts +91 -0
- package/src/drivers.android.ts +6 -0
- package/src/drivers.ios.ts +665 -0
- package/src/drivers.ts +416 -0
- package/src/geometry.ts +39 -0
- package/src/index.ts +19 -1
- package/src/index.web.ts +19 -1
- package/src/nativeCompletion.ts +37 -0
- package/src/reactRequests.ts +64 -0
- package/src/smoothClipNative.android.ts +20 -0
- package/src/smoothClipNative.ts +5 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
#include <cstddef>
|
|
4
|
+
#include "SmoothClipRegistry.h"
|
|
5
|
+
|
|
6
|
+
@class SmoothClipView;
|
|
7
|
+
|
|
8
|
+
namespace smoothclip {
|
|
9
|
+
|
|
10
|
+
void registerView(
|
|
11
|
+
uint64_t driverId,
|
|
12
|
+
SmoothClipView *view,
|
|
13
|
+
Presentation initialPresentation);
|
|
14
|
+
void unregisterView(uint64_t driverId, SmoothClipView *view);
|
|
15
|
+
// Re-runs the mid-animation join for a registered view whose animation
|
|
16
|
+
// install was deferred because it had no layout yet. Returns false when the
|
|
17
|
+
// driver or its active animation no longer exists.
|
|
18
|
+
bool joinActiveAnimation(uint64_t driverId, SmoothClipView *view);
|
|
19
|
+
void viewAnimationDidStop(
|
|
20
|
+
uint64_t driverId,
|
|
21
|
+
int32_t animationId,
|
|
22
|
+
SmoothClipView *view,
|
|
23
|
+
bool finished);
|
|
24
|
+
size_t registeredViewCount(uint64_t driverId);
|
|
25
|
+
bool hasActiveAnimation(uint64_t driverId);
|
|
26
|
+
|
|
27
|
+
} // namespace smoothclip
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSmoothClipModule.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAsGlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,wBAAwB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SmoothClipView"],"sourceRoot":"../../src","sources":["SmoothClipView.android.tsx"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,yBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getDriverState } from "./driverState.js";
|
|
4
|
+
import NativeSmoothClipView from './SmoothClipViewNativeComponent';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export function SmoothClipView({
|
|
7
|
+
driver,
|
|
8
|
+
children,
|
|
9
|
+
...viewProps
|
|
10
|
+
}) {
|
|
11
|
+
const {
|
|
12
|
+
driverId,
|
|
13
|
+
initialPresentation
|
|
14
|
+
} = getDriverState(driver);
|
|
15
|
+
const {
|
|
16
|
+
clip
|
|
17
|
+
} = initialPresentation;
|
|
18
|
+
const nativeProps = {
|
|
19
|
+
...viewProps,
|
|
20
|
+
driverId,
|
|
21
|
+
initialClipX: clip.x,
|
|
22
|
+
initialClipY: clip.y,
|
|
23
|
+
initialClipWidth: clip.width,
|
|
24
|
+
initialClipHeight: clip.height,
|
|
25
|
+
initialClipRadius: clip.radius,
|
|
26
|
+
initialContentTranslateX: initialPresentation.contentTranslateX,
|
|
27
|
+
initialContentTranslateY: initialPresentation.contentTranslateY
|
|
28
|
+
};
|
|
29
|
+
return /*#__PURE__*/_jsx(NativeSmoothClipView, {
|
|
30
|
+
...nativeProps,
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=SmoothClipView.ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getDriverState","NativeSmoothClipView","jsx","_jsx","SmoothClipView","driver","children","viewProps","driverId","initialPresentation","clip","nativeProps","initialClipX","x","initialClipY","y","initialClipWidth","width","initialClipHeight","height","initialClipRadius","radius","initialContentTranslateX","contentTranslateX","initialContentTranslateY","contentTranslateY"],"sourceRoot":"../../src","sources":["SmoothClipView.ios.tsx"],"mappings":";;AAGA,SAASA,cAAc,QAAQ,kBAAe;AAC9C,OAAOC,oBAAoB,MAEpB,iCAAiC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOzC,OAAO,SAASC,cAAcA,CAAC;EAC7BC,MAAM;EACNC,QAAQ;EACR,GAAGC;AACgB,CAAC,EAAE;EACtB,MAAM;IAAEC,QAAQ;IAAEC;EAAoB,CAAC,GAAGT,cAAc,CAACK,MAAM,CAAC;EAChE,MAAM;IAAEK;EAAK,CAAC,GAAGD,mBAAmB;EACpC,MAAME,WAAwB,GAAG;IAC/B,GAAGJ,SAAS;IACZC,QAAQ;IACRI,YAAY,EAAEF,IAAI,CAACG,CAAC;IACpBC,YAAY,EAAEJ,IAAI,CAACK,CAAC;IACpBC,gBAAgB,EAAEN,IAAI,CAACO,KAAK;IAC5BC,iBAAiB,EAAER,IAAI,CAACS,MAAM;IAC9BC,iBAAiB,EAAEV,IAAI,CAACW,MAAM;IAC9BC,wBAAwB,EAAEb,mBAAmB,CAACc,iBAAiB;IAC/DC,wBAAwB,EAAEf,mBAAmB,CAACgB;EAChD,CAAC;EAED,oBACEtB,IAAA,CAACF,oBAAoB;IAAA,GAAKU,WAAW;IAAAL,QAAA,EAAGA;EAAQ,CAAuB,CAAC;AAE5E","ignoreList":[]}
|
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import Animated, { dispatchCommand, useAnimatedReaction, useAnimatedRef } from 'react-native-reanimated';
|
|
5
|
+
import { getDriverState, registerDriverView } from "./driverState.js";
|
|
6
|
+
import { clipPresentationEquals, isFiniteClipPresentation } from "./geometry.js";
|
|
4
7
|
import NativeSmoothClipView from './SmoothClipViewNativeComponent';
|
|
5
|
-
import { clipGeometryEquals, isFiniteClipGeometry } from "./geometry.js";
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
const AnimatedNativeSmoothClipView = Animated.createAnimatedComponent(NativeSmoothClipView);
|
|
10
|
+
/** Android fallback. iOS resolves SmoothClipView.ios.tsx instead. */
|
|
8
11
|
export function SmoothClipView({
|
|
9
|
-
|
|
10
|
-
animatedClip,
|
|
12
|
+
driver,
|
|
11
13
|
children,
|
|
12
14
|
...viewProps
|
|
13
15
|
}) {
|
|
16
|
+
const {
|
|
17
|
+
driverId,
|
|
18
|
+
initialPresentation,
|
|
19
|
+
source
|
|
20
|
+
} = getDriverState(driver);
|
|
21
|
+
const {
|
|
22
|
+
clip
|
|
23
|
+
} = initialPresentation;
|
|
24
|
+
useEffect(() => registerDriverView(driver), [driver]);
|
|
14
25
|
const nativeRef = useAnimatedRef();
|
|
15
|
-
useAnimatedReaction(() =>
|
|
16
|
-
if (!
|
|
26
|
+
useAnimatedReaction(() => source.value, (presentation, previousPresentation) => {
|
|
27
|
+
if (!isFiniteClipPresentation(presentation) || clipPresentationEquals(previousPresentation, presentation)) {
|
|
17
28
|
return;
|
|
18
29
|
}
|
|
19
|
-
dispatchCommand(nativeRef, '
|
|
20
|
-
}, [nativeRef,
|
|
30
|
+
dispatchCommand(nativeRef, 'setClipPresentation', [presentation.clip.x, presentation.clip.y, presentation.clip.width, presentation.clip.height, presentation.clip.radius, presentation.contentTranslateX, presentation.contentTranslateY]);
|
|
31
|
+
}, [nativeRef, source]);
|
|
21
32
|
const nativeProps = {
|
|
22
33
|
...viewProps,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
driverId,
|
|
35
|
+
initialClipX: clip.x,
|
|
36
|
+
initialClipY: clip.y,
|
|
37
|
+
initialClipWidth: clip.width,
|
|
38
|
+
initialClipHeight: clip.height,
|
|
39
|
+
initialClipRadius: clip.radius,
|
|
40
|
+
initialContentTranslateX: initialPresentation.contentTranslateX,
|
|
41
|
+
initialContentTranslateY: initialPresentation.contentTranslateY
|
|
28
42
|
};
|
|
29
43
|
return /*#__PURE__*/_jsx(AnimatedNativeSmoothClipView, {
|
|
30
44
|
ref: nativeRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Animated","dispatchCommand","useAnimatedReaction","useAnimatedRef","
|
|
1
|
+
{"version":3,"names":["useEffect","Animated","dispatchCommand","useAnimatedReaction","useAnimatedRef","getDriverState","registerDriverView","clipPresentationEquals","isFiniteClipPresentation","NativeSmoothClipView","jsx","_jsx","AnimatedNativeSmoothClipView","createAnimatedComponent","SmoothClipView","driver","children","viewProps","driverId","initialPresentation","source","clip","nativeRef","value","presentation","previousPresentation","x","y","width","height","radius","contentTranslateX","contentTranslateY","nativeProps","initialClipX","initialClipY","initialClipWidth","initialClipHeight","initialClipRadius","initialContentTranslateX","initialContentTranslateY","ref"],"sourceRoot":"../../src","sources":["SmoothClipView.tsx"],"mappings":";;AACA,SAAyBA,SAAS,QAAQ,OAAO;AAEjD,OAAOC,QAAQ,IACbC,eAAe,EACfC,mBAAmB,EACnBC,cAAc,QACT,yBAAyB;AAEhC,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,kBAAe;AAClE,SAASC,sBAAsB,EAAEC,wBAAwB,QAAQ,eAAY;AAC7E,OAAOC,oBAAoB,MAEpB,iCAAiC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEzC,MAAMC,4BAA4B,GAChCX,QAAQ,CAACY,uBAAuB,CAACJ,oBAAoB,CAAC;AAOxD;AACA,OAAO,SAASK,cAAcA,CAAC;EAC7BC,MAAM;EACNC,QAAQ;EACR,GAAGC;AACgB,CAAC,EAAE;EACtB,MAAM;IAAEC,QAAQ;IAAEC,mBAAmB;IAAEC;EAAO,CAAC,GAAGf,cAAc,CAACU,MAAM,CAAC;EACxE,MAAM;IAAEM;EAAK,CAAC,GAAGF,mBAAmB;EACpCnB,SAAS,CAAC,MAAMM,kBAAkB,CAACS,MAAM,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EACrD,MAAMO,SAAS,GACblB,cAAc,CAAkD,CAAC;EAEnED,mBAAmB,CACjB,MAAMiB,MAAM,CAACG,KAAK,EAClB,CAACC,YAAY,EAAEC,oBAAoB,KAAK;IACtC,IACE,CAACjB,wBAAwB,CAACgB,YAAY,CAAC,IACvCjB,sBAAsB,CAACkB,oBAAoB,EAAED,YAAY,CAAC,EAC1D;MACA;IACF;IAEAtB,eAAe,CAACoB,SAAS,EAAE,qBAAqB,EAAE,CAChDE,YAAY,CAACH,IAAI,CAACK,CAAC,EACnBF,YAAY,CAACH,IAAI,CAACM,CAAC,EACnBH,YAAY,CAACH,IAAI,CAACO,KAAK,EACvBJ,YAAY,CAACH,IAAI,CAACQ,MAAM,EACxBL,YAAY,CAACH,IAAI,CAACS,MAAM,EACxBN,YAAY,CAACO,iBAAiB,EAC9BP,YAAY,CAACQ,iBAAiB,CAC/B,CAAC;EACJ,CAAC,EACD,CAACV,SAAS,EAAEF,MAAM,CACpB,CAAC;EAED,MAAMa,WAAwB,GAAG;IAC/B,GAAGhB,SAAS;IACZC,QAAQ;IACRgB,YAAY,EAAEb,IAAI,CAACK,CAAC;IACpBS,YAAY,EAAEd,IAAI,CAACM,CAAC;IACpBS,gBAAgB,EAAEf,IAAI,CAACO,KAAK;IAC5BS,iBAAiB,EAAEhB,IAAI,CAACQ,MAAM;IAC9BS,iBAAiB,EAAEjB,IAAI,CAACS,MAAM;IAC9BS,wBAAwB,EAAEpB,mBAAmB,CAACY,iBAAiB;IAC/DS,wBAAwB,EAAErB,mBAAmB,CAACa;EAChD,CAAC;EAED,oBACErB,IAAA,CAACC,4BAA4B;IAAC6B,GAAG,EAAEnB,SAAU;IAAA,GAAKW,WAAW;IAAAjB,QAAA,EAC1DA;EAAQ,CACmB,CAAC;AAEnC","ignoreList":[]}
|
|
@@ -1,38 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import Animated, { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
4
|
-
import {
|
|
5
|
+
import { getDriverState, registerDriverView } from "./driverState.js";
|
|
6
|
+
import { clipPresentationEquals, isFiniteClipPresentation } from "./geometry.js";
|
|
5
7
|
import { createWebClipPath } from "./webClipPath.js";
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
/**
|
|
9
|
+
/** Fixed-layout CSS fallback. */
|
|
8
10
|
export function SmoothClipView({
|
|
9
|
-
|
|
10
|
-
animatedClip,
|
|
11
|
+
driver,
|
|
11
12
|
children,
|
|
12
13
|
style,
|
|
13
14
|
...viewProps
|
|
14
15
|
}) {
|
|
15
|
-
const
|
|
16
|
+
const {
|
|
17
|
+
initialPresentation,
|
|
18
|
+
source
|
|
19
|
+
} = getDriverState(driver);
|
|
20
|
+
useEffect(() => registerDriverView(driver), [driver]);
|
|
21
|
+
const acceptedPresentation = useSharedValue(initialPresentation);
|
|
16
22
|
const initialClipStyle = {
|
|
17
|
-
clipPath: createWebClipPath(
|
|
23
|
+
clipPath: createWebClipPath(initialPresentation.clip),
|
|
18
24
|
overflow: 'hidden'
|
|
19
25
|
};
|
|
20
|
-
useAnimatedReaction(() =>
|
|
21
|
-
if (
|
|
22
|
-
|
|
26
|
+
useAnimatedReaction(() => source.value, (presentation, previousPresentation) => {
|
|
27
|
+
if (isFiniteClipPresentation(presentation) && !clipPresentationEquals(previousPresentation, presentation)) {
|
|
28
|
+
acceptedPresentation.value = presentation;
|
|
23
29
|
}
|
|
24
|
-
}, [
|
|
30
|
+
}, [source, acceptedPresentation]);
|
|
25
31
|
const clipStyle = useAnimatedStyle(() => {
|
|
26
|
-
const clip =
|
|
32
|
+
const clip = acceptedPresentation.value.clip;
|
|
27
33
|
return {
|
|
28
34
|
clipPath: createWebClipPath(clip),
|
|
29
35
|
overflow: 'hidden'
|
|
30
36
|
};
|
|
31
37
|
});
|
|
38
|
+
const contentStyle = useAnimatedStyle(() => ({
|
|
39
|
+
transform: [{
|
|
40
|
+
translateX: acceptedPresentation.value.contentTranslateX
|
|
41
|
+
}, {
|
|
42
|
+
translateY: acceptedPresentation.value.contentTranslateY
|
|
43
|
+
}]
|
|
44
|
+
}));
|
|
32
45
|
return /*#__PURE__*/_jsx(Animated.View, {
|
|
33
46
|
...viewProps,
|
|
34
47
|
style: [style, initialClipStyle, clipStyle],
|
|
35
|
-
children:
|
|
48
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
49
|
+
style: contentStyle,
|
|
50
|
+
children: children
|
|
51
|
+
})
|
|
36
52
|
});
|
|
37
53
|
}
|
|
38
54
|
//# sourceMappingURL=SmoothClipView.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Animated","useAnimatedReaction","useAnimatedStyle","useSharedValue","
|
|
1
|
+
{"version":3,"names":["useEffect","Animated","useAnimatedReaction","useAnimatedStyle","useSharedValue","getDriverState","registerDriverView","clipPresentationEquals","isFiniteClipPresentation","createWebClipPath","jsx","_jsx","SmoothClipView","driver","children","style","viewProps","initialPresentation","source","acceptedPresentation","initialClipStyle","clipPath","clip","overflow","value","presentation","previousPresentation","clipStyle","contentStyle","transform","translateX","contentTranslateX","translateY","contentTranslateY","View"],"sourceRoot":"../../src","sources":["SmoothClipView.web.tsx"],"mappings":";;AAAA,SAAyBA,SAAS,QAAQ,OAAO;AAEjD,OAAOC,QAAQ,IACbC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,QACT,yBAAyB;AAEhC,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,kBAAe;AAClE,SAASC,sBAAsB,EAAEC,wBAAwB,QAAQ,eAAY;AAC7E,SAASC,iBAAiB,QAAQ,kBAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOlD;AACA,OAAO,SAASC,cAAcA,CAAC;EAC7BC,MAAM;EACNC,QAAQ;EACRC,KAAK;EACL,GAAGC;AACgB,CAAC,EAAE;EACtB,MAAM;IAAEC,mBAAmB;IAAEC;EAAO,CAAC,GAAGb,cAAc,CAACQ,MAAM,CAAC;EAC9Db,SAAS,CAAC,MAAMM,kBAAkB,CAACO,MAAM,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EACrD,MAAMM,oBAAoB,GAAGf,cAAc,CAACa,mBAAmB,CAAC;EAChE,MAAMG,gBAAgB,GAAG;IACvBC,QAAQ,EAAEZ,iBAAiB,CAACQ,mBAAmB,CAACK,IAAI,CAAC;IACrDC,QAAQ,EAAE;EACZ,CAAyB;EAEzBrB,mBAAmB,CACjB,MAAMgB,MAAM,CAACM,KAAK,EAClB,CAACC,YAAY,EAAEC,oBAAoB,KAAK;IACtC,IACElB,wBAAwB,CAACiB,YAAY,CAAC,IACtC,CAAClB,sBAAsB,CAACmB,oBAAoB,EAAED,YAAY,CAAC,EAC3D;MACAN,oBAAoB,CAACK,KAAK,GAAGC,YAAY;IAC3C;EACF,CAAC,EACD,CAACP,MAAM,EAAEC,oBAAoB,CAC/B,CAAC;EAED,MAAMQ,SAAS,GAAGxB,gBAAgB,CAAC,MAAM;IACvC,MAAMmB,IAAI,GAAGH,oBAAoB,CAACK,KAAK,CAACF,IAAI;IAC5C,OAAO;MACLD,QAAQ,EAAEZ,iBAAiB,CAACa,IAAI,CAAC;MACjCC,QAAQ,EAAE;IACZ,CAAC;EACH,CAAC,CAAC;EAEF,MAAMK,YAAY,GAAGzB,gBAAgB,CAAC,OAAO;IAC3C0B,SAAS,EAAE,CACT;MAAEC,UAAU,EAAEX,oBAAoB,CAACK,KAAK,CAACO;IAAkB,CAAC,EAC5D;MAAEC,UAAU,EAAEb,oBAAoB,CAACK,KAAK,CAACS;IAAkB,CAAC;EAEhE,CAAC,CAAC,CAAC;EAEH,oBACEtB,IAAA,CAACV,QAAQ,CAACiC,IAAI;IAAA,GAAKlB,SAAS;IAAED,KAAK,EAAE,CAACA,KAAK,EAAEK,gBAAgB,EAAEO,SAAS,CAAE;IAAAb,QAAA,eACxEH,IAAA,CAACV,QAAQ,CAACiC,IAAI;MAACnB,KAAK,EAAEa,YAAa;MAAAd,QAAA,EAAEA;IAAQ,CAAgB;EAAC,CACjD,CAAC;AAEpB","ignoreList":[]}
|
|
@@ -7,11 +7,14 @@ import {
|
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
|
|
9
9
|
export interface NativeProps extends ViewProps {
|
|
10
|
+
driverId: CodegenTypes.Double;
|
|
10
11
|
initialClipX: CodegenTypes.Double;
|
|
11
12
|
initialClipY: CodegenTypes.Double;
|
|
12
13
|
initialClipWidth: CodegenTypes.Double;
|
|
13
14
|
initialClipHeight: CodegenTypes.Double;
|
|
14
15
|
initialClipRadius: CodegenTypes.Double;
|
|
16
|
+
initialContentTranslateX: CodegenTypes.Double;
|
|
17
|
+
initialContentTranslateY: CodegenTypes.Double;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
interface NativeCommands {
|
|
@@ -23,10 +26,20 @@ interface NativeCommands {
|
|
|
23
26
|
height: CodegenTypes.Double,
|
|
24
27
|
radius: CodegenTypes.Double
|
|
25
28
|
) => void;
|
|
29
|
+
setClipPresentation: (
|
|
30
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
31
|
+
x: CodegenTypes.Double,
|
|
32
|
+
y: CodegenTypes.Double,
|
|
33
|
+
width: CodegenTypes.Double,
|
|
34
|
+
height: CodegenTypes.Double,
|
|
35
|
+
radius: CodegenTypes.Double,
|
|
36
|
+
contentTranslateX: CodegenTypes.Double,
|
|
37
|
+
contentTranslateY: CodegenTypes.Double
|
|
38
|
+
) => void;
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
29
|
-
supportedCommands: ['setClipGeometry'],
|
|
42
|
+
supportedCommands: ['setClipGeometry', 'setClipPresentation'],
|
|
30
43
|
});
|
|
31
44
|
|
|
32
45
|
export default codegenNativeComponent<NativeProps>(
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const states = new WeakMap();
|
|
4
|
+
const statesById = new Map();
|
|
5
|
+
let nextDriverId = Date.now() * 1024;
|
|
6
|
+
export function allocateDriverId() {
|
|
7
|
+
nextDriverId += 1;
|
|
8
|
+
if (!Number.isSafeInteger(nextDriverId)) nextDriverId = 1;
|
|
9
|
+
return nextDriverId;
|
|
10
|
+
}
|
|
11
|
+
export function setDriverState(driver, state) {
|
|
12
|
+
// WeakMap-only: safe to call from render (discarded renders leave nothing
|
|
13
|
+
// reachable) and survives effect replays so getDriverState keeps working.
|
|
14
|
+
states.set(driver, state);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// The strong by-id index is attached in the driver hook's effect and detached
|
|
18
|
+
// in its cleanup, so discarded renders never leak entries and StrictMode /
|
|
19
|
+
// <Activity> effect replays can re-attach the same state.
|
|
20
|
+
export function attachDriverState(state) {
|
|
21
|
+
statesById.set(state.driverId, state);
|
|
22
|
+
}
|
|
23
|
+
export function detachDriverState(state) {
|
|
24
|
+
if (statesById.get(state.driverId) === state) {
|
|
25
|
+
statesById.delete(state.driverId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createDriverState(driverId, initialPresentation, source, onAnimationComplete, activeAnimationId, ownership) {
|
|
29
|
+
return {
|
|
30
|
+
driverId,
|
|
31
|
+
initialPresentation,
|
|
32
|
+
source,
|
|
33
|
+
activeAnimationId,
|
|
34
|
+
ownership,
|
|
35
|
+
onAnimationComplete,
|
|
36
|
+
mountedViews: new Set(),
|
|
37
|
+
animationParticipants: new Map(),
|
|
38
|
+
failedAnimations: new Set(),
|
|
39
|
+
completionDeferrals: 0,
|
|
40
|
+
deferredCompletions: []
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function registerDriverView(driver) {
|
|
44
|
+
const state = getDriverState(driver);
|
|
45
|
+
const token = {};
|
|
46
|
+
state.mountedViews.add(token);
|
|
47
|
+
return () => {
|
|
48
|
+
state.mountedViews.delete(token);
|
|
49
|
+
for (const [animationId, participants] of state.animationParticipants) {
|
|
50
|
+
if (participants.has(token)) state.failedAnimations.add(animationId);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function snapshotDriverViews(driverId, animationId) {
|
|
55
|
+
const state = statesById.get(driverId);
|
|
56
|
+
if (state) {
|
|
57
|
+
state.animationParticipants.set(animationId, new Set(state.mountedViews));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function finishDriverAnimation(driverId, animationId, finished) {
|
|
61
|
+
const state = statesById.get(driverId);
|
|
62
|
+
if (!state) return finished;
|
|
63
|
+
const result = finished && !state.failedAnimations.has(animationId);
|
|
64
|
+
state.animationParticipants.delete(animationId);
|
|
65
|
+
state.failedAnimations.delete(animationId);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
export function deliverDriverCompletion(driverId, animationId, finished) {
|
|
69
|
+
const state = statesById.get(driverId);
|
|
70
|
+
if (!state) return;
|
|
71
|
+
const result = {
|
|
72
|
+
animationId,
|
|
73
|
+
finished
|
|
74
|
+
};
|
|
75
|
+
if (state.completionDeferrals > 0) {
|
|
76
|
+
state.deferredCompletions.push(result);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
state.onAnimationComplete.current?.(result);
|
|
80
|
+
}
|
|
81
|
+
export function deferDriverCompletions(driverId) {
|
|
82
|
+
const state = statesById.get(driverId);
|
|
83
|
+
if (state) state.completionDeferrals += 1;
|
|
84
|
+
}
|
|
85
|
+
export function releaseDriverCompletions(driverId) {
|
|
86
|
+
const state = statesById.get(driverId);
|
|
87
|
+
if (!state || state.completionDeferrals === 0) return;
|
|
88
|
+
state.completionDeferrals -= 1;
|
|
89
|
+
if (state.completionDeferrals !== 0) return;
|
|
90
|
+
const deferred = state.deferredCompletions.splice(0);
|
|
91
|
+
for (const result of deferred) {
|
|
92
|
+
state.onAnimationComplete.current?.(result);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function getDriverState(driver) {
|
|
96
|
+
const state = states.get(driver);
|
|
97
|
+
if (!state) {
|
|
98
|
+
throw new Error('[SmoothClipView] Drivers must be created by useSmoothClipDriver.');
|
|
99
|
+
}
|
|
100
|
+
return state;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=driverState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["states","WeakMap","statesById","Map","nextDriverId","Date","now","allocateDriverId","Number","isSafeInteger","setDriverState","driver","state","set","attachDriverState","driverId","detachDriverState","get","delete","createDriverState","initialPresentation","source","onAnimationComplete","activeAnimationId","ownership","mountedViews","Set","animationParticipants","failedAnimations","completionDeferrals","deferredCompletions","registerDriverView","getDriverState","token","add","animationId","participants","has","snapshotDriverViews","finishDriverAnimation","finished","result","deliverDriverCompletion","push","current","deferDriverCompletions","releaseDriverCompletions","deferred","splice","Error"],"sourceRoot":"../../src","sources":["driverState.ts"],"mappings":";;AAoBA,MAAMA,MAAM,GAAG,IAAIC,OAAO,CAAgC,CAAC;AAC3D,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAsB,CAAC;AACjD,IAAIC,YAAY,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI;AAEpC,OAAO,SAASC,gBAAgBA,CAAA,EAAW;EACzCH,YAAY,IAAI,CAAC;EACjB,IAAI,CAACI,MAAM,CAACC,aAAa,CAACL,YAAY,CAAC,EAAEA,YAAY,GAAG,CAAC;EACzD,OAAOA,YAAY;AACrB;AAEA,OAAO,SAASM,cAAcA,CAC5BC,MAAwB,EACxBC,KAAkB,EACZ;EACN;EACA;EACAZ,MAAM,CAACa,GAAG,CAACF,MAAM,EAAEC,KAAK,CAAC;AAC3B;;AAEA;AACA;AACA;AACA,OAAO,SAASE,iBAAiBA,CAACF,KAAkB,EAAQ;EAC1DV,UAAU,CAACW,GAAG,CAACD,KAAK,CAACG,QAAQ,EAAEH,KAAK,CAAC;AACvC;AAEA,OAAO,SAASI,iBAAiBA,CAACJ,KAAkB,EAAQ;EAC1D,IAAIV,UAAU,CAACe,GAAG,CAACL,KAAK,CAACG,QAAQ,CAAC,KAAKH,KAAK,EAAE;IAC5CV,UAAU,CAACgB,MAAM,CAACN,KAAK,CAACG,QAAQ,CAAC;EACnC;AACF;AAEA,OAAO,SAASI,iBAAiBA,CAC/BJ,QAAgB,EAChBK,mBAA2C,EAC3CC,MAA2C,EAC3CC,mBAAuD,EACvDC,iBAAuC,EACvCC,SAA+B,EAClB;EACb,OAAO;IACLT,Q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K,MAAMP,MAAM,IAAIM,QAAQ,EAAE;IAC7BnC,KAAK,CAACU,mBAAmB,CAACsB,OAAO,GAAGH,MAAM,CAAC;EAC7C;AACF;AAEA,OAAO,SAAST,cAAcA,CAACrB,MAAwB,EAAe;EACpE,MAAMC,KAAK,GAAGZ,MAAM,CAACiB,GAAG,CAACN,MAAM,CAAC;EAChC,IAAI,CAACC,KAAK,EAAE;IACV,MAAM,IAAIqC,KAAK,CACb,kEACF,CAAC;EACH;EACA,OAAOrC,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["driverTypes.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSmoothClipDriver"],"sourceRoot":"../../src","sources":["drivers.android.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,kBAAe","ignoreList":[]}
|