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