react-native-smooth-clip-view 0.3.0 → 0.4.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.
Files changed (199) hide show
  1. package/README.md +135 -386
  2. package/android/build.gradle +4 -7
  3. package/android/proguard-rules.pro +2 -2
  4. package/android/src/main/cpp/SmoothClipAndroid.h +9 -12
  5. package/android/src/main/cpp/SmoothClipBindings.cpp +300 -704
  6. package/android/src/main/cpp/SmoothClipRegistry.cpp +348 -594
  7. package/android/src/main/java/com/smoothclipview/ClipGeometryNormalizer.kt +36 -227
  8. package/android/src/main/java/com/smoothclipview/SmoothClipBindings.kt +16 -19
  9. package/android/src/main/java/com/smoothclipview/SmoothClipModule.kt +36 -294
  10. package/android/src/main/java/com/smoothclipview/SmoothClipView.kt +369 -486
  11. package/android/src/main/java/com/smoothclipview/SmoothClipViewManager.kt +75 -77
  12. package/cpp/SmoothClipAnimationCurve.h +237 -346
  13. package/cpp/SmoothClipRegistry.h +24 -52
  14. package/cpp/SmoothClipSharedGeometry.h +64 -94
  15. package/cpp/SmoothClipVelocityTracker.h +5 -5
  16. package/ios/SmoothClipGeometry.h +23 -34
  17. package/ios/SmoothClipRegistry.mm +206 -711
  18. package/ios/SmoothClipTurboModule.cpp +217 -715
  19. package/ios/SmoothClipTurboModule.h +54 -297
  20. package/ios/SmoothClipView.mm +599 -505
  21. package/ios/SmoothClipViewRegistry.h +2 -7
  22. package/lib/module/NativeSmoothClipModule.js.map +1 -1
  23. package/lib/module/SmoothClipView.ios.js +84 -17
  24. package/lib/module/SmoothClipView.ios.js.map +1 -1
  25. package/lib/module/SmoothClipView.js +1 -1
  26. package/lib/module/SmoothClipView.js.map +1 -1
  27. package/lib/module/SmoothClipViewNativeComponent.ts +20 -26
  28. package/lib/module/capabilities.native.js +1 -19
  29. package/lib/module/capabilities.native.js.map +1 -1
  30. package/lib/module/capabilityTypes.js +0 -9
  31. package/lib/module/capabilityTypes.js.map +1 -1
  32. package/lib/module/controllerInternals.js +28 -0
  33. package/lib/module/controllerInternals.js.map +1 -0
  34. package/lib/module/controllerLifecycle.js +9 -0
  35. package/lib/module/controllerLifecycle.js.map +1 -0
  36. package/lib/module/controllerTypes.js +4 -0
  37. package/lib/module/controllerTypes.js.map +1 -0
  38. package/lib/module/controllers.android.js +4 -0
  39. package/lib/module/controllers.android.js.map +1 -0
  40. package/lib/module/controllers.ios.js +4 -0
  41. package/lib/module/controllers.ios.js.map +1 -0
  42. package/lib/module/controllers.js +4 -0
  43. package/lib/module/controllers.js.map +1 -0
  44. package/lib/module/controllers.native.js +89 -0
  45. package/lib/module/controllers.native.js.map +1 -0
  46. package/lib/module/geometry.js +71 -51
  47. package/lib/module/geometry.js.map +1 -1
  48. package/lib/module/groupTypes.js +4 -0
  49. package/lib/module/{groupDriverTypes.js.map → groupTypes.js.map} +1 -1
  50. package/lib/module/groups.android.js +4 -0
  51. package/lib/module/groups.android.js.map +1 -0
  52. package/lib/module/groups.ios.js +4 -0
  53. package/lib/module/groups.ios.js.map +1 -0
  54. package/lib/module/groups.js +4 -0
  55. package/lib/module/groups.js.map +1 -0
  56. package/lib/module/groups.native.js +399 -0
  57. package/lib/module/groups.native.js.map +1 -0
  58. package/lib/module/ids.js +8 -0
  59. package/lib/module/ids.js.map +1 -0
  60. package/lib/module/index.js +3 -3
  61. package/lib/module/index.js.map +1 -1
  62. package/lib/module/nativeCompletion.js +37 -16
  63. package/lib/module/nativeCompletion.js.map +1 -1
  64. package/lib/module/presentationCodec.js +81 -0
  65. package/lib/module/presentationCodec.js.map +1 -0
  66. package/lib/typescript/src/NativeSmoothClipModule.d.ts +14 -23
  67. package/lib/typescript/src/NativeSmoothClipModule.d.ts.map +1 -1
  68. package/lib/typescript/src/SmoothClipView.d.ts +1 -1
  69. package/lib/typescript/src/SmoothClipView.d.ts.map +1 -1
  70. package/lib/typescript/src/SmoothClipView.ios.d.ts +18 -14
  71. package/lib/typescript/src/SmoothClipView.ios.d.ts.map +1 -1
  72. package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts +10 -5
  73. package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts.map +1 -1
  74. package/lib/typescript/src/capabilities.native.d.ts +1 -1
  75. package/lib/typescript/src/capabilities.native.d.ts.map +1 -1
  76. package/lib/typescript/src/capabilityTypes.d.ts +0 -6
  77. package/lib/typescript/src/capabilityTypes.d.ts.map +1 -1
  78. package/lib/typescript/src/controllerInternals.d.ts +14 -0
  79. package/lib/typescript/src/controllerInternals.d.ts.map +1 -0
  80. package/lib/typescript/src/controllerLifecycle.d.ts +3 -0
  81. package/lib/typescript/src/controllerLifecycle.d.ts.map +1 -0
  82. package/lib/typescript/src/controllerTypes.d.ts +62 -0
  83. package/lib/typescript/src/controllerTypes.d.ts.map +1 -0
  84. package/lib/typescript/src/controllers.android.d.ts +2 -0
  85. package/lib/typescript/src/controllers.android.d.ts.map +1 -0
  86. package/lib/typescript/src/controllers.d.ts +2 -0
  87. package/lib/typescript/src/controllers.d.ts.map +1 -0
  88. package/lib/typescript/src/controllers.ios.d.ts +2 -0
  89. package/lib/typescript/src/controllers.ios.d.ts.map +1 -0
  90. package/lib/typescript/src/controllers.native.d.ts +3 -0
  91. package/lib/typescript/src/controllers.native.d.ts.map +1 -0
  92. package/lib/typescript/src/geometry.d.ts +22 -12
  93. package/lib/typescript/src/geometry.d.ts.map +1 -1
  94. package/lib/typescript/src/groupTypes.d.ts +31 -0
  95. package/lib/typescript/src/groupTypes.d.ts.map +1 -0
  96. package/lib/typescript/src/groups.android.d.ts +2 -0
  97. package/lib/typescript/src/groups.android.d.ts.map +1 -0
  98. package/lib/typescript/src/groups.d.ts +2 -0
  99. package/lib/typescript/src/groups.d.ts.map +1 -0
  100. package/lib/typescript/src/groups.ios.d.ts +2 -0
  101. package/lib/typescript/src/groups.ios.d.ts.map +1 -0
  102. package/lib/typescript/src/groups.native.d.ts +3 -0
  103. package/lib/typescript/src/groups.native.d.ts.map +1 -0
  104. package/lib/typescript/src/ids.d.ts +2 -0
  105. package/lib/typescript/src/ids.d.ts.map +1 -0
  106. package/lib/typescript/src/index.d.ts +6 -6
  107. package/lib/typescript/src/index.d.ts.map +1 -1
  108. package/lib/typescript/src/nativeCompletion.d.ts +16 -6
  109. package/lib/typescript/src/nativeCompletion.d.ts.map +1 -1
  110. package/lib/typescript/src/presentationCodec.d.ts +10 -0
  111. package/lib/typescript/src/presentationCodec.d.ts.map +1 -0
  112. package/package.json +8 -3
  113. package/src/NativeSmoothClipModule.ts +41 -292
  114. package/src/SmoothClipView.ios.tsx +130 -23
  115. package/src/SmoothClipView.tsx +5 -1
  116. package/src/SmoothClipViewNativeComponent.ts +20 -26
  117. package/src/capabilities.native.ts +2 -52
  118. package/src/capabilityTypes.ts +0 -14
  119. package/src/controllerInternals.ts +52 -0
  120. package/src/controllerLifecycle.ts +6 -0
  121. package/src/controllerTypes.ts +87 -0
  122. package/src/controllers.android.ts +1 -0
  123. package/src/controllers.ios.ts +1 -0
  124. package/src/controllers.native.ts +104 -0
  125. package/src/controllers.ts +1 -0
  126. package/src/geometry.ts +118 -74
  127. package/src/groupTypes.ts +53 -0
  128. package/src/groups.android.ts +1 -0
  129. package/src/groups.ios.ts +1 -0
  130. package/src/groups.native.ts +604 -0
  131. package/src/groups.ts +1 -0
  132. package/src/ids.ts +6 -0
  133. package/src/index.ts +20 -28
  134. package/src/nativeCompletion.ts +67 -32
  135. package/src/presentationCodec.ts +134 -0
  136. package/lib/module/driverState.js +0 -82
  137. package/lib/module/driverState.js.map +0 -1
  138. package/lib/module/driverTypes.js +0 -4
  139. package/lib/module/driverTypes.js.map +0 -1
  140. package/lib/module/drivers.android.js +0 -6
  141. package/lib/module/drivers.android.js.map +0 -1
  142. package/lib/module/drivers.ios.js +0 -6
  143. package/lib/module/drivers.ios.js.map +0 -1
  144. package/lib/module/drivers.js +0 -4
  145. package/lib/module/drivers.js.map +0 -1
  146. package/lib/module/drivers.native.js +0 -756
  147. package/lib/module/drivers.native.js.map +0 -1
  148. package/lib/module/groupDriverTypes.js +0 -4
  149. package/lib/module/groupDrivers.android.js +0 -4
  150. package/lib/module/groupDrivers.android.js.map +0 -1
  151. package/lib/module/groupDrivers.ios.js +0 -4
  152. package/lib/module/groupDrivers.ios.js.map +0 -1
  153. package/lib/module/groupDrivers.js +0 -4
  154. package/lib/module/groupDrivers.js.map +0 -1
  155. package/lib/module/groupDrivers.native.js +0 -799
  156. package/lib/module/groupDrivers.native.js.map +0 -1
  157. package/lib/module/presentationProtocol.js +0 -15
  158. package/lib/module/presentationProtocol.js.map +0 -1
  159. package/lib/module/reactRequests.js +0 -56
  160. package/lib/module/reactRequests.js.map +0 -1
  161. package/lib/typescript/src/driverState.d.ts +0 -26
  162. package/lib/typescript/src/driverState.d.ts.map +0 -1
  163. package/lib/typescript/src/driverTypes.d.ts +0 -121
  164. package/lib/typescript/src/driverTypes.d.ts.map +0 -1
  165. package/lib/typescript/src/drivers.android.d.ts +0 -3
  166. package/lib/typescript/src/drivers.android.d.ts.map +0 -1
  167. package/lib/typescript/src/drivers.d.ts +0 -3
  168. package/lib/typescript/src/drivers.d.ts.map +0 -1
  169. package/lib/typescript/src/drivers.ios.d.ts +0 -3
  170. package/lib/typescript/src/drivers.ios.d.ts.map +0 -1
  171. package/lib/typescript/src/drivers.native.d.ts +0 -5
  172. package/lib/typescript/src/drivers.native.d.ts.map +0 -1
  173. package/lib/typescript/src/groupDriverTypes.d.ts +0 -66
  174. package/lib/typescript/src/groupDriverTypes.d.ts.map +0 -1
  175. package/lib/typescript/src/groupDrivers.android.d.ts +0 -2
  176. package/lib/typescript/src/groupDrivers.android.d.ts.map +0 -1
  177. package/lib/typescript/src/groupDrivers.d.ts +0 -2
  178. package/lib/typescript/src/groupDrivers.d.ts.map +0 -1
  179. package/lib/typescript/src/groupDrivers.ios.d.ts +0 -2
  180. package/lib/typescript/src/groupDrivers.ios.d.ts.map +0 -1
  181. package/lib/typescript/src/groupDrivers.native.d.ts +0 -4
  182. package/lib/typescript/src/groupDrivers.native.d.ts.map +0 -1
  183. package/lib/typescript/src/presentationProtocol.d.ts +0 -4
  184. package/lib/typescript/src/presentationProtocol.d.ts.map +0 -1
  185. package/lib/typescript/src/reactRequests.d.ts +0 -9
  186. package/lib/typescript/src/reactRequests.d.ts.map +0 -1
  187. package/src/driverState.ts +0 -118
  188. package/src/driverTypes.ts +0 -171
  189. package/src/drivers.android.ts +0 -8
  190. package/src/drivers.ios.ts +0 -8
  191. package/src/drivers.native.ts +0 -1599
  192. package/src/drivers.ts +0 -6
  193. package/src/groupDriverTypes.ts +0 -117
  194. package/src/groupDrivers.android.ts +0 -1
  195. package/src/groupDrivers.ios.ts +0 -1
  196. package/src/groupDrivers.native.ts +0 -1189
  197. package/src/groupDrivers.ts +0 -1
  198. package/src/presentationProtocol.ts +0 -28
  199. package/src/reactRequests.ts +0 -76
@@ -1,171 +0,0 @@
1
- import type { SharedValue } from 'react-native-reanimated';
2
- import type {
3
- CanonicalSmoothClipPresentation,
4
- SmoothClipPresentation,
5
- } from './geometry';
6
-
7
- export type ClipReduceMotion = 'system' | 'always' | 'never';
8
-
9
- /** Options shared by every animation kind. */
10
- type ClipAnimationBase = Readonly<{
11
- /**
12
- * Explicit start: fuses a `setScalars(from…)` take-ownership hot write
13
- * immediately before the animation, so native starts from exactly this
14
- * presentation instead of its last delivered value. Use at a gesture
15
- * release when the freshest sample (e.g. the UP event's position) never
16
- * reached native — a gated per-frame reaction may not have flushed it.
17
- * Also re-grabs from a running animation (which an implicit interactive
18
- * start would silently skip). Non-finite `from` rejects the whole call.
19
- * `driver.presentation.value` is not written from `from`; it stays stale
20
- * until success sets it to the target. Against a held pending-animation
21
- * latch, explicit `from` is newer intent: the fused write cancels that latch
22
- * once unfinished, applies `from`, and starts the replacement from that
23
- * native value.
24
- *
25
- * Keyframes interpolate absolutely, so pass `frames[0].presentation` —
26
- * the seed renders it before the first animation frame, making the
27
- * handoff continuous.
28
- *
29
- * iOS note: keyframes start exactly at `from` (frame 0 travels in-band);
30
- * timing/spring sample their Core Animation from-value off the
31
- * presentation layer — the last committed frame, at most one frame behind
32
- * `from` — identical to the two-call pattern this option desugars to.
33
- */
34
- from?: SmoothClipPresentation;
35
- }>;
36
-
37
- export type TimingClipAnimation = ClipAnimationBase &
38
- Readonly<{
39
- type: 'timing';
40
- duration: number;
41
- controlPoints: readonly [number, number, number, number];
42
- }>;
43
-
44
- export type SpringClipAnimation = ClipAnimationBase &
45
- Readonly<{
46
- type: 'spring';
47
- mass?: number;
48
- stiffness?: number;
49
- damping?: number;
50
- initialVelocity?: number | 'inherit';
51
- }>;
52
-
53
- export type KeyframedClipAnimation = ClipAnimationBase &
54
- Readonly<{
55
- type: 'keyframes';
56
- duration: number;
57
- frames: readonly Readonly<{
58
- offset: number;
59
- presentation: SmoothClipPresentation;
60
- }>[];
61
- }>;
62
-
63
- export type SmoothClipAnimation =
64
- TimingClipAnimation | SpringClipAnimation | KeyframedClipAnimation;
65
-
66
- export type ClipAnimationResult = Readonly<{
67
- animationId: number;
68
- finished: boolean;
69
- }>;
70
-
71
- export type SmoothClipDriverOptions = Readonly<{
72
- reduceMotion?: ClipReduceMotion;
73
- onAnimationComplete?: (result: ClipAnimationResult) => void;
74
- /**
75
- * Android only; captured at driver creation. Records two-sample velocity
76
- * history on `setScalars` hot writes so a spring `initialVelocity: 'inherit'`
77
- * can project its launch speed from the live drag. Off by default: the
78
- * recording (a clock read plus channel copies) rides the per-frame
79
- * `setScalars` hot path, and drivers that never hand off into an inherit
80
- * spring should not pay it. Without this flag, `'inherit'` inherits 0 after
81
- * a `setScalars` drag on Android (each skipped write also invalidates older
82
- * samples, so stale pre-drag motion never leaks in). `set()`, the fused
83
- * `animateTo` `from` seed, and the declarative `presentation.value` channel
84
- * always record regardless of the flag. iOS always records; the flag is a
85
- * no-op there.
86
- */
87
- velocityTracking?: boolean;
88
- }>;
89
-
90
- export type SmoothClipUIControls = Readonly<{
91
- beginInteraction(): CanonicalSmoothClipPresentation;
92
- set(presentation: SmoothClipPresentation): void;
93
- /**
94
- * Per-frame hot path: writes geometry straight to native without touching
95
- * `driver.presentation`. Skips SharedValue bookkeeping (dirty marking, RN
96
- * mirror sync, listener dispatch) for high-frequency streams such as
97
- * gestures. `driver.presentation.value` is stale after hot writes by design;
98
- * `beginInteraction()` remains the source of truth for visible geometry.
99
- * Do not interleave with `presentation.value` writes on the same driver —
100
- * the listener's duplicate suppression may skip a later equal value.
101
- * To hand off into an animation from a fresher value than the last hot
102
- * write, pass the geometry as `animation.from` to `animateTo` — it fuses
103
- * this call and the handoff into one.
104
- */
105
- setScalars(
106
- x: number,
107
- y: number,
108
- width: number,
109
- height: number,
110
- radius: number,
111
- contentTranslateX: number,
112
- contentTranslateY: number
113
- ): void;
114
- /**
115
- * V2 per-frame hot path. Curve code is 0 for circular and 1 for continuous;
116
- * invalid codes reject the complete write.
117
- */
118
- setPresentationScalars(
119
- x: number,
120
- y: number,
121
- width: number,
122
- height: number,
123
- topLeftRadius: number,
124
- topRightRadius: number,
125
- bottomRightRadius: number,
126
- bottomLeftRadius: number,
127
- curveCode: number,
128
- contentTranslateX: number,
129
- contentTranslateY: number,
130
- contentScale: number
131
- ): void;
132
- animateTo(
133
- presentation: SmoothClipPresentation,
134
- animation: SmoothClipAnimation
135
- ): number;
136
- cancel(
137
- animationId?: number,
138
- behavior?: 'current' | 'target'
139
- ): CanonicalSmoothClipPresentation;
140
- }>;
141
-
142
- export type SmoothClipReactControls = Readonly<{
143
- beginInteraction(): Promise<CanonicalSmoothClipPresentation>;
144
- set(presentation: SmoothClipPresentation): Promise<void>;
145
- animateTo(
146
- presentation: SmoothClipPresentation,
147
- animation: SmoothClipAnimation
148
- ): Promise<number>;
149
- cancel(
150
- animationId?: number,
151
- behavior?: 'current' | 'target'
152
- ): Promise<CanonicalSmoothClipPresentation>;
153
- }>;
154
-
155
- /** @internal Worklet-serializable driver identity used by atomic groups. */
156
- export type SmoothClipDriverHandle = Readonly<{
157
- driverId: number;
158
- presentation: SharedValue<SmoothClipPresentation>;
159
- ownership: SharedValue<number>;
160
- activeAnimationId: SharedValue<number>;
161
- disposed: SharedValue<number>;
162
- }>;
163
-
164
- export type SmoothClipDriver = Readonly<{
165
- kind: 'hybrid';
166
- presentation: SharedValue<SmoothClipPresentation>;
167
- ui: SmoothClipUIControls;
168
- react: SmoothClipReactControls;
169
- /** @internal Do not read or mutate directly. */
170
- __smoothClipHandle?: SmoothClipDriverHandle;
171
- }>;
@@ -1,8 +0,0 @@
1
- // Platform re-export only — the implementation is shared with iOS.
2
- // Edit drivers.native.ts, not this file.
3
- export { useSmoothClipDriver } from './drivers.native';
4
- export type {
5
- KeyframedClipAnimation,
6
- SpringClipAnimation,
7
- TimingClipAnimation,
8
- } from './drivers.native';
@@ -1,8 +0,0 @@
1
- // Platform re-export only — the implementation is shared with Android.
2
- // Edit drivers.native.ts, not this file.
3
- export { useSmoothClipDriver } from './drivers.native';
4
- export type {
5
- KeyframedClipAnimation,
6
- SpringClipAnimation,
7
- TimingClipAnimation,
8
- } from './drivers.native';