react-native-smooth-clip-view 0.2.8 → 0.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.
Files changed (132) hide show
  1. package/README.md +86 -21
  2. package/android/CMakeLists.txt +7 -0
  3. package/android/build.gradle +14 -2
  4. package/android/proguard-rules.pro +3 -3
  5. package/android/src/main/cpp/SmoothClipAndroid.h +10 -0
  6. package/android/src/main/cpp/SmoothClipBindings.cpp +896 -6
  7. package/android/src/main/cpp/SmoothClipRegistry.cpp +1067 -46
  8. package/android/src/main/cpp/SmoothClipTrace.h +25 -0
  9. package/android/src/main/java/com/smoothclipview/ClipGeometryNormalizer.kt +265 -0
  10. package/android/src/main/java/com/smoothclipview/SmoothClipBindings.kt +21 -0
  11. package/android/src/main/java/com/smoothclipview/SmoothClipModule.kt +283 -0
  12. package/android/src/main/java/com/smoothclipview/SmoothClipView.kt +385 -24
  13. package/android/src/main/java/com/smoothclipview/SmoothClipViewManager.kt +138 -24
  14. package/cpp/SmoothClipAnimationCurve.h +151 -122
  15. package/cpp/SmoothClipRegistry.h +102 -4
  16. package/cpp/SmoothClipSharedGeometry.h +146 -7
  17. package/cpp/SmoothClipVelocityTracker.h +13 -9
  18. package/ios/SmoothClipGeometry.h +184 -6
  19. package/ios/SmoothClipRegistry.mm +1033 -25
  20. package/ios/SmoothClipRegistrySnapshot.h +13 -0
  21. package/ios/SmoothClipTurboModule.cpp +857 -2
  22. package/ios/SmoothClipTurboModule.h +310 -0
  23. package/ios/SmoothClipView.mm +714 -183
  24. package/ios/SmoothClipViewRegistry.h +1 -0
  25. package/ios/reactnativesmoothclipview.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  26. package/ios/reactnativesmoothclipview.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  27. package/lib/module/NativeSmoothClipModule.js.map +1 -1
  28. package/lib/module/SmoothClipView.ios.js +22 -6
  29. package/lib/module/SmoothClipView.ios.js.map +1 -1
  30. package/lib/module/SmoothClipView.js +1 -46
  31. package/lib/module/SmoothClipView.js.map +1 -1
  32. package/lib/module/SmoothClipViewNativeComponent.ts +27 -1
  33. package/lib/module/capabilities.js +4 -0
  34. package/lib/module/capabilities.js.map +1 -0
  35. package/lib/module/capabilities.native.js +36 -0
  36. package/lib/module/capabilities.native.js.map +1 -0
  37. package/lib/module/capabilityTypes.js +11 -0
  38. package/lib/module/capabilityTypes.js.map +1 -0
  39. package/lib/module/driverState.js +0 -28
  40. package/lib/module/driverState.js.map +1 -1
  41. package/lib/module/drivers.js +1 -281
  42. package/lib/module/drivers.js.map +1 -1
  43. package/lib/module/drivers.native.js +340 -75
  44. package/lib/module/drivers.native.js.map +1 -1
  45. package/lib/module/geometry.js +147 -17
  46. package/lib/module/geometry.js.map +1 -1
  47. package/lib/module/groupDriverTypes.js +4 -0
  48. package/lib/module/groupDriverTypes.js.map +1 -0
  49. package/lib/module/groupDrivers.android.js +4 -0
  50. package/lib/module/groupDrivers.android.js.map +1 -0
  51. package/lib/module/groupDrivers.ios.js +4 -0
  52. package/lib/module/groupDrivers.ios.js.map +1 -0
  53. package/lib/module/groupDrivers.js +4 -0
  54. package/lib/module/groupDrivers.js.map +1 -0
  55. package/lib/module/groupDrivers.native.js +799 -0
  56. package/lib/module/groupDrivers.native.js.map +1 -0
  57. package/lib/module/index.js +3 -2
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/presentationProtocol.js +15 -0
  60. package/lib/module/presentationProtocol.js.map +1 -0
  61. package/lib/typescript/src/NativeSmoothClipModule.d.ts +25 -0
  62. package/lib/typescript/src/NativeSmoothClipModule.d.ts.map +1 -1
  63. package/lib/typescript/src/SmoothClipView.d.ts +2 -10
  64. package/lib/typescript/src/SmoothClipView.d.ts.map +1 -1
  65. package/lib/typescript/src/SmoothClipView.ios.d.ts +133 -2
  66. package/lib/typescript/src/SmoothClipView.ios.d.ts.map +1 -1
  67. package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts +8 -0
  68. package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts.map +1 -1
  69. package/lib/typescript/src/capabilities.d.ts +3 -0
  70. package/lib/typescript/src/capabilities.d.ts.map +1 -0
  71. package/lib/typescript/src/capabilities.native.d.ts +3 -0
  72. package/lib/typescript/src/capabilities.native.d.ts.map +1 -0
  73. package/lib/typescript/src/capabilityTypes.d.ts +10 -0
  74. package/lib/typescript/src/capabilityTypes.d.ts.map +1 -0
  75. package/lib/typescript/src/driverState.d.ts +1 -6
  76. package/lib/typescript/src/driverState.d.ts.map +1 -1
  77. package/lib/typescript/src/driverTypes.d.ts +39 -11
  78. package/lib/typescript/src/driverTypes.d.ts.map +1 -1
  79. package/lib/typescript/src/drivers.d.ts +2 -4
  80. package/lib/typescript/src/drivers.d.ts.map +1 -1
  81. package/lib/typescript/src/drivers.native.d.ts.map +1 -1
  82. package/lib/typescript/src/geometry.d.ts +36 -2
  83. package/lib/typescript/src/geometry.d.ts.map +1 -1
  84. package/lib/typescript/src/groupDriverTypes.d.ts +66 -0
  85. package/lib/typescript/src/groupDriverTypes.d.ts.map +1 -0
  86. package/lib/typescript/src/groupDrivers.android.d.ts +2 -0
  87. package/lib/typescript/src/groupDrivers.android.d.ts.map +1 -0
  88. package/lib/typescript/src/groupDrivers.d.ts +2 -0
  89. package/lib/typescript/src/groupDrivers.d.ts.map +1 -0
  90. package/lib/typescript/src/groupDrivers.ios.d.ts +2 -0
  91. package/lib/typescript/src/groupDrivers.ios.d.ts.map +1 -0
  92. package/lib/typescript/src/groupDrivers.native.d.ts +4 -0
  93. package/lib/typescript/src/groupDrivers.native.d.ts.map +1 -0
  94. package/lib/typescript/src/index.d.ts +6 -3
  95. package/lib/typescript/src/index.d.ts.map +1 -1
  96. package/lib/typescript/src/presentationProtocol.d.ts +4 -0
  97. package/lib/typescript/src/presentationProtocol.d.ts.map +1 -0
  98. package/package.json +10 -11
  99. package/src/NativeSmoothClipModule.ts +275 -0
  100. package/src/SmoothClipView.ios.tsx +30 -11
  101. package/src/SmoothClipView.tsx +2 -76
  102. package/src/SmoothClipViewNativeComponent.ts +27 -1
  103. package/src/capabilities.native.ts +69 -0
  104. package/src/capabilities.ts +2 -0
  105. package/src/capabilityTypes.ts +17 -0
  106. package/src/driverState.ts +1 -41
  107. package/src/driverTypes.ts +56 -11
  108. package/src/drivers.native.ts +921 -151
  109. package/src/drivers.ts +2 -423
  110. package/src/geometry.ts +231 -27
  111. package/src/groupDriverTypes.ts +117 -0
  112. package/src/groupDrivers.android.ts +1 -0
  113. package/src/groupDrivers.ios.ts +1 -0
  114. package/src/groupDrivers.native.ts +1189 -0
  115. package/src/groupDrivers.ts +1 -0
  116. package/src/index.ts +30 -2
  117. package/src/presentationProtocol.ts +28 -0
  118. package/lib/module/SmoothClipView.web.js +0 -54
  119. package/lib/module/SmoothClipView.web.js.map +0 -1
  120. package/lib/module/index.web.js +0 -8
  121. package/lib/module/index.web.js.map +0 -1
  122. package/lib/module/webClipPath.js +0 -25
  123. package/lib/module/webClipPath.js.map +0 -1
  124. package/lib/typescript/src/SmoothClipView.web.d.ts +0 -10
  125. package/lib/typescript/src/SmoothClipView.web.d.ts.map +0 -1
  126. package/lib/typescript/src/index.web.d.ts +0 -9
  127. package/lib/typescript/src/index.web.d.ts.map +0 -1
  128. package/lib/typescript/src/webClipPath.d.ts +0 -7
  129. package/lib/typescript/src/webClipPath.d.ts.map +0 -1
  130. package/src/SmoothClipView.web.tsx +0 -66
  131. package/src/index.web.ts +0 -23
  132. package/src/webClipPath.ts +0 -30
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include <cstddef>
4
4
  #include "SmoothClipRegistry.h"
5
+ #include "SmoothClipRegistrySnapshot.h"
5
6
 
6
7
  @class SmoothClipView;
7
8
 
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSmoothClipModule.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAuGlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,wBAAwB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSmoothClipModule.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AA0XlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,wBAAwB,CAAC","ignoreList":[]}
@@ -1,20 +1,28 @@
1
1
  "use strict";
2
2
 
3
+ import { forwardRef } from 'react';
3
4
  import { getDriverState } from "./driverState.js";
5
+ import { getSmoothClipCapabilities } from './capabilities';
6
+ import { canonicalizeClipPresentation } from "./geometry.js";
7
+ import { assertInitialPresentationProtocol } from "./presentationProtocol.js";
4
8
  import NativeSmoothClipView from './SmoothClipViewNativeComponent';
5
9
  import { jsx as _jsx } from "react/jsx-runtime";
6
- export function SmoothClipView({
10
+ export const SmoothClipView = /*#__PURE__*/forwardRef(function SmoothClipViewComponent({
7
11
  driver,
8
12
  children,
9
13
  ...viewProps
10
- }) {
14
+ }, forwardedRef) {
11
15
  const {
12
16
  driverId,
13
17
  initialPresentation
14
18
  } = getDriverState(driver);
19
+ const canonical = canonicalizeClipPresentation(initialPresentation);
20
+ if (canonical === null) return null;
15
21
  const {
16
22
  clip
17
- } = initialPresentation;
23
+ } = canonical;
24
+ const protocolVersion = getSmoothClipCapabilities().presentationProtocolVersion;
25
+ assertInitialPresentationProtocol(canonical, protocolVersion);
18
26
  const nativeProps = {
19
27
  ...viewProps,
20
28
  driverId,
@@ -23,12 +31,20 @@ export function SmoothClipView({
23
31
  initialClipWidth: clip.width,
24
32
  initialClipHeight: clip.height,
25
33
  initialClipRadius: clip.radius,
26
- initialContentTranslateX: initialPresentation.contentTranslateX,
27
- initialContentTranslateY: initialPresentation.contentTranslateY
34
+ presentationVersion: protocolVersion,
35
+ initialClipTopLeftRadius: clip.topLeftRadius,
36
+ initialClipTopRightRadius: clip.topRightRadius,
37
+ initialClipBottomRightRadius: clip.bottomRightRadius,
38
+ initialClipBottomLeftRadius: clip.bottomLeftRadius,
39
+ initialClipCurve: clip.curve === 'continuous' ? 1 : 0,
40
+ initialContentTranslateX: canonical.contentTranslateX,
41
+ initialContentTranslateY: canonical.contentTranslateY,
42
+ initialContentScale: canonical.contentScale
28
43
  };
29
44
  return /*#__PURE__*/_jsx(NativeSmoothClipView, {
45
+ ref: forwardedRef,
30
46
  ...nativeProps,
31
47
  children: children
32
48
  });
33
- }
49
+ });
34
50
  //# sourceMappingURL=SmoothClipView.ios.js.map
@@ -1 +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
+ {"version":3,"names":["forwardRef","getDriverState","getSmoothClipCapabilities","canonicalizeClipPresentation","assertInitialPresentationProtocol","NativeSmoothClipView","jsx","_jsx","SmoothClipView","SmoothClipViewComponent","driver","children","viewProps","forwardedRef","driverId","initialPresentation","canonical","clip","protocolVersion","presentationProtocolVersion","nativeProps","initialClipX","x","initialClipY","y","initialClipWidth","width","initialClipHeight","height","initialClipRadius","radius","presentationVersion","initialClipTopLeftRadius","topLeftRadius","initialClipTopRightRadius","topRightRadius","initialClipBottomRightRadius","bottomRightRadius","initialClipBottomLeftRadius","bottomLeftRadius","initialClipCurve","curve","initialContentTranslateX","contentTranslateX","initialContentTranslateY","contentTranslateY","initialContentScale","contentScale","ref"],"sourceRoot":"../../src","sources":["SmoothClipView.ios.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAA2C,OAAO;AAGrE,SAASC,cAAc,QAAQ,kBAAe;AAC9C,SAASC,yBAAyB,QAAQ,gBAAgB;AAC1D,SAASC,4BAA4B,QAAQ,eAAY;AACzD,SAASC,iCAAiC,QAAQ,2BAAwB;AAC1E,OAAOC,oBAAoB,MAEpB,iCAAiC;AAAC,SAAAC,GAAA,IAAAC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nC,YAAa;IAAA,GAAKO,WAAW;IAAAT,QAAA,EACrDA;EAAQ,CACW,CAAC;AAE3B,CAAC,CAAC","ignoreList":[]}
@@ -1,49 +1,4 @@
1
1
  "use strict";
2
2
 
3
- import { useEffect } from 'react';
4
- import Animated, { dispatchCommand, useAnimatedReaction, useAnimatedRef } from 'react-native-reanimated';
5
- import { getDriverState, registerDriverView } from "./driverState.js";
6
- import { clipPresentationEquals, isFiniteClipPresentation } from "./geometry.js";
7
- import NativeSmoothClipView from './SmoothClipViewNativeComponent';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- const AnimatedNativeSmoothClipView = Animated.createAnimatedComponent(NativeSmoothClipView);
10
- /** Android fallback. iOS resolves SmoothClipView.ios.tsx instead. */
11
- export function SmoothClipView({
12
- driver,
13
- children,
14
- ...viewProps
15
- }) {
16
- const {
17
- driverId,
18
- initialPresentation,
19
- source
20
- } = getDriverState(driver);
21
- const {
22
- clip
23
- } = initialPresentation;
24
- useEffect(() => registerDriverView(driver), [driver]);
25
- const nativeRef = useAnimatedRef();
26
- useAnimatedReaction(() => source.value, (presentation, previousPresentation) => {
27
- if (!isFiniteClipPresentation(presentation) || clipPresentationEquals(previousPresentation, presentation)) {
28
- return;
29
- }
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]);
32
- const nativeProps = {
33
- ...viewProps,
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
42
- };
43
- return /*#__PURE__*/_jsx(AnimatedNativeSmoothClipView, {
44
- ref: nativeRef,
45
- ...nativeProps,
46
- children: children
47
- });
48
- }
3
+ export { SmoothClipView } from "./SmoothClipView.ios.js";
49
4
  //# sourceMappingURL=SmoothClipView.js.map
@@ -1 +1 @@
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
+ {"version":3,"names":["SmoothClipView"],"sourceRoot":"../../src","sources":["SmoothClipView.tsx"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,yBAAsB","ignoreList":[]}
@@ -13,8 +13,15 @@ export interface NativeProps extends ViewProps {
13
13
  initialClipWidth: CodegenTypes.Double;
14
14
  initialClipHeight: CodegenTypes.Double;
15
15
  initialClipRadius: CodegenTypes.Double;
16
+ presentationVersion: CodegenTypes.Int32;
17
+ initialClipTopLeftRadius: CodegenTypes.Double;
18
+ initialClipTopRightRadius: CodegenTypes.Double;
19
+ initialClipBottomRightRadius: CodegenTypes.Double;
20
+ initialClipBottomLeftRadius: CodegenTypes.Double;
21
+ initialClipCurve: CodegenTypes.Int32;
16
22
  initialContentTranslateX: CodegenTypes.Double;
17
23
  initialContentTranslateY: CodegenTypes.Double;
24
+ initialContentScale: CodegenTypes.Double;
18
25
  }
19
26
 
20
27
  interface NativeCommands {
@@ -36,10 +43,29 @@ interface NativeCommands {
36
43
  contentTranslateX: CodegenTypes.Double,
37
44
  contentTranslateY: CodegenTypes.Double
38
45
  ) => void;
46
+ setClipPresentationV2: (
47
+ viewRef: React.ElementRef<HostComponent<NativeProps>>,
48
+ x: CodegenTypes.Double,
49
+ y: CodegenTypes.Double,
50
+ width: CodegenTypes.Double,
51
+ height: CodegenTypes.Double,
52
+ topLeftRadius: CodegenTypes.Double,
53
+ topRightRadius: CodegenTypes.Double,
54
+ bottomRightRadius: CodegenTypes.Double,
55
+ bottomLeftRadius: CodegenTypes.Double,
56
+ curveCode: CodegenTypes.Int32,
57
+ contentTranslateX: CodegenTypes.Double,
58
+ contentTranslateY: CodegenTypes.Double,
59
+ contentScale: CodegenTypes.Double
60
+ ) => void;
39
61
  }
40
62
 
41
63
  export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
42
- supportedCommands: ['setClipGeometry', 'setClipPresentation'],
64
+ supportedCommands: [
65
+ 'setClipGeometry',
66
+ 'setClipPresentation',
67
+ 'setClipPresentationV2',
68
+ ],
43
69
  });
44
70
 
45
71
  export default codegenNativeComponent<NativeProps>(
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { getSmoothClipCapabilities } from "./capabilities.native.js";
4
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getSmoothClipCapabilities"],"sourceRoot":"../../src","sources":["capabilities.ts"],"mappings":";;AAAA,SAASA,yBAAyB,QAAQ,0BAAuB","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ import NativeSmoothClipModule from './smoothClipNative';
4
+ import { SMOOTH_CLIP_V1_CAPABILITIES } from "./capabilityTypes.js";
5
+ let cached;
6
+ export function getSmoothClipCapabilities() {
7
+ if (cached) return cached;
8
+ const module = NativeSmoothClipModule;
9
+ let version = 1;
10
+ try {
11
+ version = module.getPresentationProtocolVersion?.() === 2 ? 2 : 1;
12
+ } catch {
13
+ version = 1;
14
+ }
15
+ if (version !== 2) {
16
+ cached = SMOOTH_CLIP_V1_CAPABILITIES;
17
+ return cached;
18
+ }
19
+ let autonomousComplexPathAnimation = false;
20
+ try {
21
+ autonomousComplexPathAnimation = module.supportsAutonomousComplexPathAnimation?.() === true;
22
+ } catch {
23
+ autonomousComplexPathAnimation = false;
24
+ }
25
+ const groups = typeof module.beginGroupInteractionV2 === 'function' && typeof module.snapshotGroupV2 === 'function' && typeof module.setClipPresentationBatchV2 === 'function' && typeof module.animateTimingGroupV2 === 'function' && typeof module.animateSpringGroupV2 === 'function' && typeof module.animateKeyframesGroupV2 === 'function' && typeof module.cancelAnimationGroupV2 === 'function' && typeof module.onClipGroupAnimationComplete === 'function';
26
+ cached = {
27
+ presentationProtocolVersion: 2,
28
+ groups,
29
+ perCornerRadii: true,
30
+ continuousCurve: true,
31
+ contentScale: true,
32
+ autonomousComplexPathAnimation
33
+ };
34
+ return cached;
35
+ }
36
+ //# sourceMappingURL=capabilities.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeSmoothClipModule","SMOOTH_CLIP_V1_CAPABILITIES","cached","getSmoothClipCapabilities","module","version","getPresentationProtocolVersion","autonomousComplexPathAnimation","supportsAutonomousComplexPathAnimation","groups","beginGroupInteractionV2","snapshotGroupV2","setClipPresentationBatchV2","animateTimingGroupV2","animateSpringGroupV2","animateKeyframesGroupV2","cancelAnimationGroupV2","onClipGroupAnimationComplete","presentationProtocolVersion","perCornerRadii","continuousCurve","contentScale"],"sourceRoot":"../../src","sources":["capabilities.native.ts"],"mappings":";;AAAA,OAAOA,sBAAsB,MAAM,oBAAoB;AACvD,SACEC,2BAA2B,QAEtB,sBAAmB;AAO1B,IAAIC,MAA0C;AAE9C,OAAO,SAASC,yBAAyBA,CAAA,EAA2B;EAClE,IAAID,MAAM,EAAE,OAAOA,MAAM;EACzB,MAAME,MAAM,GAAGJ,sBAAyC;EACxD,IAAIK,OAAO,GAAG,CAAC;EACf,IAAI;IACFA,OAAO,GAAGD,MAAM,CAACE,8BAA8B,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;EACnE,CAAC,CAAC,MAAM;IACND,OAAO,GAAG,CAAC;EACb;EACA,IAAIA,OAAO,KAAK,CAAC,EAAE;IACjBH,MAAM,GAAGD,2BAA2B;IACpC,OAAOC,MAAM;EACf;EACA,IAAIK,8BAA8B,GAAG,KAAK;EAC1C,IAAI;IACFA,8BAA8B,GAC5BH,MAAM,CAACI,sCAAsC,GAAG,CAAC,KAAK,IAAI;EAC9D,CAAC,CAAC,MAAM;IACND,8BAA8B,GAAG,KAAK;EACxC;EACA,MAAME,MAAM,GACV,OACEL,MAAM,CASNM,uBAAuB,KAAK,UAAU,IACxC,OAAQN,MAAM,CAA2CO,eAAe,KACtE,UAAU,IACZ,OAAQP,MAAM,CACXQ,0BAA0B,KAAK,UAAU,IAC5C,OAAQR,MAAM,CACXS,oBAAoB,KAAK,UAAU,IACtC,OAAQT,MAAM,CACXU,oBAAoB,KAAK,UAAU,IACtC,OAAQV,MAAM,CACXW,uBAAuB,KAAK,UAAU,IACzC,OAAQX,MAAM,CACXY,sBAAsB,KAAK,UAAU,IACxC,OAAQZ,MAAM,CACXa,4BAA4B,KAAK,UAAU;EAChDf,MAAM,GAAG;IACPgB,2BAA2B,EAAE,CAAC;IAC9BT,MAAM;IACNU,cAAc,EAAE,IAAI;IACpBC,eAAe,EAAE,IAAI;IACrBC,YAAY,EAAE,IAAI;IAClBd;EACF,CAAC;EACD,OAAOL,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ export const SMOOTH_CLIP_V1_CAPABILITIES = {
4
+ presentationProtocolVersion: 1,
5
+ groups: false,
6
+ perCornerRadii: false,
7
+ continuousCurve: false,
8
+ contentScale: false,
9
+ autonomousComplexPathAnimation: false
10
+ };
11
+ //# sourceMappingURL=capabilityTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SMOOTH_CLIP_V1_CAPABILITIES","presentationProtocolVersion","groups","perCornerRadii","continuousCurve","contentScale","autonomousComplexPathAnimation"],"sourceRoot":"../../src","sources":["capabilityTypes.ts"],"mappings":";;AASA,OAAO,MAAMA,2BAAmD,GAAG;EACjEC,2BAA2B,EAAE,CAAC;EAC9BC,MAAM,EAAE,KAAK;EACbC,cAAc,EAAE,KAAK;EACrBC,eAAe,EAAE,KAAK;EACtBC,YAAY,EAAE,KAAK;EACnBC,8BAA8B,EAAE;AAClC,CAAC","ignoreList":[]}
@@ -41,38 +41,10 @@ export function createDriverState(driverId, initialPresentation, source, onAnima
41
41
  activeAnimationId,
42
42
  ownership,
43
43
  onAnimationComplete,
44
- mountedViews: new Set(),
45
- animationParticipants: new Map(),
46
- failedAnimations: new Set(),
47
44
  completionDeferrals: 0,
48
45
  deferredCompletions: []
49
46
  };
50
47
  }
51
- export function registerDriverView(driver) {
52
- const state = getDriverState(driver);
53
- const token = {};
54
- state.mountedViews.add(token);
55
- return () => {
56
- state.mountedViews.delete(token);
57
- for (const [animationId, participants] of state.animationParticipants) {
58
- if (participants.has(token)) state.failedAnimations.add(animationId);
59
- }
60
- };
61
- }
62
- export function snapshotDriverViews(driverId, animationId) {
63
- const state = statesById.get(driverId);
64
- if (state) {
65
- state.animationParticipants.set(animationId, new Set(state.mountedViews));
66
- }
67
- }
68
- export function finishDriverAnimation(driverId, animationId, finished) {
69
- const state = statesById.get(driverId);
70
- if (!state) return finished;
71
- const result = finished && !state.failedAnimations.has(animationId);
72
- state.animationParticipants.delete(animationId);
73
- state.failedAnimations.delete(animationId);
74
- return result;
75
- }
76
48
  export function deliverDriverCompletion(driverId, animationId, finished) {
77
49
  const state = statesById.get(driverId);
78
50
  if (!state) return;
@@ -1 +1 @@
1
- {"version":3,"names":["states","WeakMap","statesById","Map","nextDriverId","Date","now","allocateDriverId","Number","isSafeInteger","setDriverState","driver","state","set","attachDriverState","driverId","detachDriverState","get","delete","completionDeferrals","deferredCompletions","length","createDriverState","initialPresentation","source","onAnimationComplete","activeAnimationId","ownership","mountedViews","Set","animationParticipants","failedAnimations","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,I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EAAEA,KAAK,CAACO,mBAAmB,IAAI,CAAC;AAC3C;AAEA,OAAO,SAAS4B,wBAAwBA,CAAChC,QAAgB,EAAQ;EAC/D,MAAMH,KAAK,GAAGV,UAAU,CAACe,GAAG,CAACF,QAAQ,CAAC;EACtC,IAAI,CAACH,KAAK,IAAIA,KAAK,CAACO,mBAAmB,KAAK,CAAC,EAAE;EAC/CP,KAAK,CAACO,mBAAmB,IAAI,CAAC;EAC9B,IAAIP,KAAK,CAACO,mBAAmB,KAAK,CAAC,EAAE;EACrC,MAAM6B,QAAQ,GAAGpC,KAAK,CAACQ,mBAAmB,CAAC6B,MAAM,CAAC,CAAC,CAAC;EACpD,KAAK,MAAMP,MAAM,IAAIM,QAAQ,EAAE;IAC7BpC,KAAK,CAACa,mBAAmB,CAACoB,OAAO,GAAGH,MAAM,CAAC;EAC7C;AACF;AAEA,OAAO,SAAST,cAAcA,CAACtB,MAAwB,EAAe;EACpE,MAAMC,KAAK,GAAGZ,MAAM,CAACiB,GAAG,CAACN,MAAM,CAAC;EAChC,IAAI,CAACC,KAAK,EAAE;IACV,MAAM,IAAIsC,KAAK,CACb,kEACF,CAAC;EACH;EACA,OAAOtC,KAAK;AACd","ignoreList":[]}
1
+ {"version":3,"names":["states","WeakMap","statesById","Map","nextDriverId","Date","now","allocateDriverId","Number","isSafeInteger","setDriverState","driver","state","set","attachDriverState","driverId","detachDriverState","get","delete","completionDeferrals","deferredCompletions","length","createDriverState","initialPresentation","source","onAnimationComplete","activeAnimationId","ownership","deliverDriverCompletion","animationId","finished","result","push","current","deferDriverCompletions","releaseDriverCompletions","deferred","splice","getDriverState","Error"],"sourceRoot":"../../src","sources":["driverState.ts"],"mappings":";;AAkBA,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,O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AAMmB,MAAM,GAAG;IAAEF,WAAW;IAAEC;EAAS,CAAC;EACxC,IAAIlB,KAAK,CAACO,mBAAmB,GAAG,CAAC,EAAE;IACjCP,KAAK,CAACQ,mBAAmB,CAACY,IAAI,CAACD,MAAM,CAAC;IACtC;EACF;EACAnB,KAAK,CAACa,mBAAmB,CAACQ,OAAO,GAAGF,MAAM,CAAC;AAC7C;AAEA,OAAO,SAASG,sBAAsBA,CAACnB,QAAgB,EAAQ;EAC7D,MAAMH,KAAK,GAAGV,UAAU,CAACe,GAAG,CAACF,QAAQ,CAAC;EACtC,IAAIH,KAAK,EAAEA,KAAK,CAACO,mBAAmB,IAAI,CAAC;AAC3C;AAEA,OAAO,SAASgB,wBAAwBA,CAACpB,QAAgB,EAAQ;EAC/D,MAAMH,KAAK,GAAGV,UAAU,CAACe,GAAG,CAACF,QAAQ,CAAC;EACtC,IAAI,CAACH,KAAK,IAAIA,KAAK,CAACO,mBAAmB,KAAK,CAAC,EAAE;EAC/CP,KAAK,CAACO,mBAAmB,IAAI,CAAC;EAC9B,IAAIP,KAAK,CAACO,mBAAmB,KAAK,CAAC,EAAE;EACrC,MAAMiB,QAAQ,GAAGxB,KAAK,CAACQ,mBAAmB,CAACiB,MAAM,CAAC,CAAC,CAAC;EACpD,KAAK,MAAMN,MAAM,IAAIK,QAAQ,EAAE;IAC7BxB,KAAK,CAACa,mBAAmB,CAACQ,OAAO,GAAGF,MAAM,CAAC;EAC7C;AACF;AAEA,OAAO,SAASO,cAAcA,CAAC3B,MAAwB,EAAe;EACpE,MAAMC,KAAK,GAAGZ,MAAM,CAACiB,GAAG,CAACN,MAAM,CAAC;EAChC,IAAI,CAACC,KAAK,EAAE;IACV,MAAM,IAAI2B,KAAK,CACb,kEACF,CAAC;EACH;EACA,OAAO3B,KAAK;AACd","ignoreList":[]}
@@ -1,284 +1,4 @@
1
1
  "use strict";
2
2
 
3
- import { useEffect, useRef } from 'react';
4
- import { cancelAnimation as cancelReanimatedAnimation, Easing, ReduceMotion, useAnimatedReaction, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
5
- import { scheduleOnRN, scheduleOnUI } from 'react-native-worklets';
6
- import { allocateDriverId, attachDriverState, createDriverState, deliverDriverCompletion, detachDriverState, finishDriverAnimation, getDriverState, setDriverState, snapshotDriverViews } from "./driverState.js";
7
- import { createClipPresentation, clipPresentationEquals, isFiniteClipPresentation } from "./geometry.js";
8
- import { createReactRequest, rejectDriverRequests, resolveReactRequest } from "./reactRequests.js";
9
- function toReanimatedReduceMotion(value) {
10
- switch (value) {
11
- case 'always':
12
- return ReduceMotion.Always;
13
- case 'never':
14
- return ReduceMotion.Never;
15
- default:
16
- return ReduceMotion.System;
17
- }
18
- }
19
- function animationIsFinite(animation) {
20
- 'worklet';
21
-
22
- if (animation.from !== undefined && !isFiniteClipPresentation(animation.from)) {
23
- return false;
24
- }
25
- if (animation.type === 'timing') {
26
- return Number.isFinite(animation.duration) && animation.controlPoints.every(Number.isFinite);
27
- }
28
- if (animation.type === 'spring') {
29
- return [animation.mass ?? 1, animation.stiffness ?? 100, animation.damping ?? 10, animation.initialVelocity === 'inherit' ? 0 : animation.initialVelocity ?? 0].every(Number.isFinite);
30
- }
31
- let previousOffset = -1;
32
- if (!Number.isFinite(animation.duration) || animation.frames.length < 2) {
33
- return false;
34
- }
35
- for (const frame of animation.frames) {
36
- if (!Number.isFinite(frame.offset) || frame.offset < 0 || frame.offset > 1 || frame.offset <= previousOffset || !isFiniteClipPresentation(frame.presentation)) {
37
- return false;
38
- }
39
- previousOffset = frame.offset;
40
- }
41
- return animation.frames[0]?.offset === 0 && previousOffset === 1;
42
- }
43
- function interpolatePresentation(from, to, progress) {
44
- 'worklet';
45
-
46
- const mix = (start, end) => start + (end - start) * progress;
47
- return {
48
- clip: {
49
- x: mix(from.clip.x, to.clip.x),
50
- y: mix(from.clip.y, to.clip.y),
51
- width: mix(from.clip.width, to.clip.width),
52
- height: mix(from.clip.height, to.clip.height),
53
- radius: mix(from.clip.radius, to.clip.radius)
54
- },
55
- contentTranslateX: mix(from.contentTranslateX, to.contentTranslateX),
56
- contentTranslateY: mix(from.contentTranslateY, to.contentTranslateY)
57
- };
58
- }
59
- function finishFallback(driverId, animationId, finished) {
60
- deliverDriverCompletion(driverId, animationId, finishDriverAnimation(driverId, animationId, finished));
61
- }
62
- export function useSmoothClipDriver(initialValue, options = {}) {
63
- const initialPresentation = 'clip' in initialValue ? initialValue : createClipPresentation(initialValue);
64
- const presentation = useSharedValue(initialPresentation);
65
- const activeAnimationId = useSharedValue(0);
66
- const nextAnimationId = useSharedValue(0);
67
- const latestTarget = useSharedValue(initialPresentation);
68
- const animationStart = useSharedValue(initialPresentation);
69
- const animationProgress = useSharedValue(0);
70
- const keyframes = useSharedValue([]);
71
- const callbackRef = useRef(options.onAnimationComplete);
72
- const driverRef = useRef(null);
73
- callbackRef.current = options.onAnimationComplete;
74
- useAnimatedReaction(() => animationProgress.value, progress => {
75
- const frames = keyframes.value;
76
- if (frames.length >= 2) {
77
- let upperIndex = 1;
78
- while (upperIndex < frames.length - 1 && progress > (frames[upperIndex]?.offset ?? 1)) {
79
- upperIndex += 1;
80
- }
81
- const lower = frames[upperIndex - 1];
82
- const upper = frames[upperIndex];
83
- if (!lower || !upper) return;
84
- const span = upper.offset - lower.offset;
85
- const localProgress = span <= 0 ? 1 : (progress - lower.offset) / span;
86
- presentation.value = interpolatePresentation(lower.presentation, upper.presentation, Math.min(1, Math.max(0, localProgress)));
87
- return;
88
- }
89
- presentation.value = interpolatePresentation(animationStart.value, latestTarget.value, progress);
90
- }, [animationProgress, animationStart, keyframes, latestTarget, presentation]);
91
- if (driverRef.current === null) {
92
- const driverId = allocateDriverId();
93
- const reduceMotion = toReanimatedReduceMotion(options.reduceMotion ?? 'system');
94
- const beginOnUI = () => {
95
- 'worklet';
96
-
97
- cancelReanimatedAnimation(animationProgress);
98
- activeAnimationId.value = 0;
99
- return presentation.value;
100
- };
101
- const setOnUI = next => {
102
- 'worklet';
103
-
104
- if (!isFiniteClipPresentation(next)) return;
105
- cancelReanimatedAnimation(animationProgress);
106
- activeAnimationId.value = 0;
107
- latestTarget.value = next;
108
- presentation.value = next;
109
- };
110
- const animateOnUI = (next, animation) => {
111
- 'worklet';
112
-
113
- nextAnimationId.value = nextAnimationId.value % 0x7ffffffe + 1;
114
- const animationId = nextAnimationId.value;
115
- if (!isFiniteClipPresentation(next) || !animationIsFinite(animation)) {
116
- scheduleOnRN(finishFallback, driverId, animationId, false);
117
- return animationId;
118
- }
119
- if (animation.from !== undefined) {
120
- // Fused explicit start: on the fallback driver the setScalars hot
121
- // path is a plain presentation write, so the desugar is the same.
122
- presentation.value = animation.from;
123
- }
124
- activeAnimationId.value = animationId;
125
- animationStart.value = presentation.value;
126
- latestTarget.value = next;
127
- keyframes.value = [];
128
- animationProgress.value = 0;
129
- scheduleOnRN(snapshotDriverViews, driverId, animationId);
130
- const onComplete = finished => {
131
- 'worklet';
132
-
133
- if (activeAnimationId.value === animationId) {
134
- activeAnimationId.value = 0;
135
- }
136
- scheduleOnRN(finishFallback, driverId, animationId, finished === true);
137
- };
138
- if (animation.type === 'timing') {
139
- const [x1, y1, x2, y2] = animation.controlPoints;
140
- animationProgress.value = withTiming(1, {
141
- duration: Math.max(0, animation.duration),
142
- easing: Easing.bezier(x1, y1, x2, y2),
143
- reduceMotion
144
- }, onComplete);
145
- } else if (animation.type === 'spring') {
146
- const configuredVelocity = animation.initialVelocity;
147
- animationProgress.value = withSpring(1, {
148
- damping: animation.damping ?? 10,
149
- mass: animation.mass ?? 1,
150
- reduceMotion,
151
- stiffness: animation.stiffness ?? 100,
152
- // The fallback driver cannot sample native presentation motion,
153
- // so 'inherit' (and undefined) degrade to zero launch velocity.
154
- velocity: typeof configuredVelocity === 'number' ? configuredVelocity : 0
155
- }, onComplete);
156
- } else {
157
- if (!clipPresentationEquals(animation.frames[animation.frames.length - 1]?.presentation ?? null, next)) {
158
- scheduleOnRN(finishFallback, driverId, animationId, false);
159
- activeAnimationId.value = 0;
160
- return animationId;
161
- }
162
- keyframes.value = animation.frames;
163
- animationProgress.value = withTiming(1, {
164
- duration: Math.max(0, animation.duration),
165
- easing: Easing.linear,
166
- reduceMotion
167
- }, onComplete);
168
- }
169
- return animationId;
170
- };
171
- const cancelOnUI = (animationId = 0, behavior = 'current') => {
172
- 'worklet';
173
-
174
- if (animationId !== 0 && animationId !== activeAnimationId.value) {
175
- return presentation.value;
176
- }
177
- cancelReanimatedAnimation(animationProgress);
178
- activeAnimationId.value = 0;
179
- if (behavior === 'target') presentation.value = latestTarget.value;
180
- return presentation.value;
181
- };
182
- const setScalarsOnUI = (x, y, width, height, radius, contentTranslateX, contentTranslateY) => {
183
- 'worklet';
184
-
185
- setOnUI({
186
- clip: {
187
- x,
188
- y,
189
- width,
190
- height,
191
- radius
192
- },
193
- contentTranslateX,
194
- contentTranslateY
195
- });
196
- };
197
- const driver = {
198
- kind: 'hybrid',
199
- presentation,
200
- // Every worklet here shares the single JS runtime, so unlike the native
201
- // driver there is no runtime guard on `ui`: calling it from React code
202
- // is harmless in this fallback.
203
- ui: {
204
- beginInteraction: beginOnUI,
205
- set: setOnUI,
206
- setScalars: setScalarsOnUI,
207
- animateTo: animateOnUI,
208
- cancel: cancelOnUI
209
- },
210
- react: {
211
- beginInteraction() {
212
- const {
213
- requestId,
214
- promise
215
- } = createReactRequest(driverId);
216
- scheduleOnUI(() => {
217
- 'worklet';
218
-
219
- const result = beginOnUI();
220
- scheduleOnRN(resolveReactRequest, driverId, requestId, result);
221
- });
222
- return promise;
223
- },
224
- set(next) {
225
- const {
226
- requestId,
227
- promise
228
- } = createReactRequest(driverId);
229
- scheduleOnUI(() => {
230
- 'worklet';
231
-
232
- setOnUI(next);
233
- scheduleOnRN(resolveReactRequest, driverId, requestId, undefined);
234
- });
235
- return promise;
236
- },
237
- animateTo(next, animation) {
238
- const {
239
- requestId,
240
- promise
241
- } = createReactRequest(driverId, true);
242
- scheduleOnUI(() => {
243
- 'worklet';
244
-
245
- const result = animateOnUI(next, animation);
246
- scheduleOnRN(resolveReactRequest, driverId, requestId, result, true);
247
- });
248
- return promise;
249
- },
250
- cancel(animationId = 0, behavior = 'current') {
251
- const {
252
- requestId,
253
- promise
254
- } = createReactRequest(driverId, true);
255
- scheduleOnUI(() => {
256
- 'worklet';
257
-
258
- const result = cancelOnUI(animationId, behavior);
259
- scheduleOnRN(resolveReactRequest, driverId, requestId, result, true);
260
- });
261
- return promise;
262
- }
263
- }
264
- };
265
- setDriverState(driver, createDriverState(driverId, initialPresentation, presentation, callbackRef, activeAnimationId));
266
- driverRef.current = driver;
267
- }
268
- const driver = driverRef.current;
269
- useEffect(() => {
270
- const currentDriver = driverRef.current;
271
- if (!currentDriver) return undefined;
272
- const state = getDriverState(currentDriver);
273
- // Re-attach on effect replays (StrictMode/<Activity>) after a cleanup
274
- // detached this state.
275
- attachDriverState(state);
276
- return () => {
277
- cancelReanimatedAnimation(animationProgress);
278
- rejectDriverRequests(state.driverId);
279
- detachDriverState(state);
280
- };
281
- }, [animationProgress]);
282
- return driver;
283
- }
3
+ export { useSmoothClipDriver } from "./drivers.native.js";
284
4
  //# sourceMappingURL=drivers.js.map