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
@@ -1,5 +1,8 @@
1
1
  import type { SharedValue } from 'react-native-reanimated';
2
- import type { SmoothClipPresentation } from './geometry';
2
+ import type {
3
+ CanonicalSmoothClipPresentation,
4
+ SmoothClipPresentation,
5
+ } from './geometry';
3
6
 
4
7
  export type ClipReduceMotion = 'system' | 'always' | 'never';
5
8
 
@@ -13,12 +16,11 @@ type ClipAnimationBase = Readonly<{
13
16
  * reached native — a gated per-frame reaction may not have flushed it.
14
17
  * Also re-grabs from a running animation (which an implicit interactive
15
18
  * 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.
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.
22
24
  *
23
25
  * Keyframes interpolate absolutely, so pass `frames[0].presentation` —
24
26
  * the seed renders it before the first animation frame, making the
@@ -69,10 +71,24 @@ export type ClipAnimationResult = Readonly<{
69
71
  export type SmoothClipDriverOptions = Readonly<{
70
72
  reduceMotion?: ClipReduceMotion;
71
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;
72
88
  }>;
73
89
 
74
90
  export type SmoothClipUIControls = Readonly<{
75
- beginInteraction(): SmoothClipPresentation;
91
+ beginInteraction(): CanonicalSmoothClipPresentation;
76
92
  set(presentation: SmoothClipPresentation): void;
77
93
  /**
78
94
  * Per-frame hot path: writes geometry straight to native without touching
@@ -95,6 +111,24 @@ export type SmoothClipUIControls = Readonly<{
95
111
  contentTranslateX: number,
96
112
  contentTranslateY: number
97
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;
98
132
  animateTo(
99
133
  presentation: SmoothClipPresentation,
100
134
  animation: SmoothClipAnimation
@@ -102,11 +136,11 @@ export type SmoothClipUIControls = Readonly<{
102
136
  cancel(
103
137
  animationId?: number,
104
138
  behavior?: 'current' | 'target'
105
- ): SmoothClipPresentation;
139
+ ): CanonicalSmoothClipPresentation;
106
140
  }>;
107
141
 
108
142
  export type SmoothClipReactControls = Readonly<{
109
- beginInteraction(): Promise<SmoothClipPresentation>;
143
+ beginInteraction(): Promise<CanonicalSmoothClipPresentation>;
110
144
  set(presentation: SmoothClipPresentation): Promise<void>;
111
145
  animateTo(
112
146
  presentation: SmoothClipPresentation,
@@ -115,7 +149,16 @@ export type SmoothClipReactControls = Readonly<{
115
149
  cancel(
116
150
  animationId?: number,
117
151
  behavior?: 'current' | 'target'
118
- ): Promise<SmoothClipPresentation>;
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>;
119
162
  }>;
120
163
 
121
164
  export type SmoothClipDriver = Readonly<{
@@ -123,4 +166,6 @@ export type SmoothClipDriver = Readonly<{
123
166
  presentation: SharedValue<SmoothClipPresentation>;
124
167
  ui: SmoothClipUIControls;
125
168
  react: SmoothClipReactControls;
169
+ /** @internal Do not read or mutate directly. */
170
+ __smoothClipHandle?: SmoothClipDriverHandle;
126
171
  }>;