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
@@ -0,0 +1 @@
1
+ export { useSmoothClipGroupDriver } from './groupDrivers.native';
package/src/index.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export { SmoothClipView } from './SmoothClipView';
2
2
  export type { SmoothClipViewProps } from './SmoothClipView';
3
3
  export { useSmoothClipDriver } from './drivers';
4
+ export { useSmoothClipGroupDriver } from './groupDrivers';
5
+ export { getSmoothClipCapabilities } from './capabilities';
6
+ export type { SmoothClipCapabilities } from './capabilityTypes';
4
7
  export type {
5
8
  ClipAnimationResult,
6
9
  ClipReduceMotion,
@@ -13,11 +16,36 @@ export type {
13
16
  SpringClipAnimation,
14
17
  TimingClipAnimation,
15
18
  } from './driverTypes';
19
+ export type {
20
+ SmoothClipBatchEntry,
21
+ SmoothClipGroupAnimationResult,
22
+ SmoothClipGroupCancelBehavior,
23
+ SmoothClipGroupDriver,
24
+ SmoothClipGroupDriverOptions,
25
+ SmoothClipGroupKeyframeAnimation,
26
+ SmoothClipGroupKeyframeEntry,
27
+ SmoothClipGroupMotionAnimation,
28
+ SmoothClipGroupMotionEntry,
29
+ SmoothClipGroupReactControls,
30
+ SmoothClipGroupSnapshot,
31
+ SmoothClipGroupSpringAnimation,
32
+ SmoothClipGroupSuspensionPolicy,
33
+ SmoothClipGroupTimingAnimation,
34
+ SmoothClipGroupUIControls,
35
+ } from './groupDriverTypes';
16
36
  export { ClipEasings } from './easings';
17
- export { normalizeClipGeometry } from './geometry';
18
- export { createClipPresentation } from './geometry';
37
+ export {
38
+ canonicalizeClipGeometry,
39
+ canonicalizeClipPresentation,
40
+ createClipPresentation,
41
+ normalizeClipGeometry,
42
+ normalizeClipPresentation,
43
+ } from './geometry';
19
44
  export type {
45
+ CanonicalClipGeometry,
46
+ CanonicalSmoothClipPresentation,
20
47
  ClipBounds,
48
+ ClipCurve,
21
49
  ClipGeometry,
22
50
  SmoothClipPresentation,
23
51
  } from './geometry';
@@ -0,0 +1,28 @@
1
+ import type { CanonicalSmoothClipPresentation } from './geometry';
2
+
3
+ export function isV1CompatiblePresentation(
4
+ presentation: CanonicalSmoothClipPresentation
5
+ ): boolean {
6
+ const { clip } = presentation;
7
+ return (
8
+ clip.curve === 'circular' &&
9
+ clip.topLeftRadius === clip.radius &&
10
+ clip.topRightRadius === clip.radius &&
11
+ clip.bottomRightRadius === clip.radius &&
12
+ clip.bottomLeftRadius === clip.radius &&
13
+ presentation.contentScale === 1
14
+ );
15
+ }
16
+
17
+ export function assertInitialPresentationProtocol(
18
+ presentation: CanonicalSmoothClipPresentation,
19
+ protocolVersion: 1 | 2
20
+ ): void {
21
+ if (protocolVersion === 2 || isV1CompatiblePresentation(presentation)) {
22
+ return;
23
+ }
24
+
25
+ throw new Error(
26
+ '[SmoothClipView] The initial presentation requires native presentation protocol V2, but the installed native library only supports V1. Rebuild the native app or select an explicit streaming fallback.'
27
+ );
28
+ }
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- import { useEffect } from 'react';
4
- import Animated, { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
5
- import { getDriverState, registerDriverView } from "./driverState.js";
6
- import { clipPresentationEquals, isFiniteClipPresentation } from "./geometry.js";
7
- import { createWebClipPath } from "./webClipPath.js";
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- /** Fixed-layout CSS fallback. */
10
- export function SmoothClipView({
11
- driver,
12
- children,
13
- style,
14
- ...viewProps
15
- }) {
16
- const {
17
- initialPresentation,
18
- source
19
- } = getDriverState(driver);
20
- useEffect(() => registerDriverView(driver), [driver]);
21
- const acceptedPresentation = useSharedValue(initialPresentation);
22
- const initialClipStyle = {
23
- clipPath: createWebClipPath(initialPresentation.clip),
24
- overflow: 'hidden'
25
- };
26
- useAnimatedReaction(() => source.value, (presentation, previousPresentation) => {
27
- if (isFiniteClipPresentation(presentation) && !clipPresentationEquals(previousPresentation, presentation)) {
28
- acceptedPresentation.value = presentation;
29
- }
30
- }, [source, acceptedPresentation]);
31
- const clipStyle = useAnimatedStyle(() => {
32
- const clip = acceptedPresentation.value.clip;
33
- return {
34
- clipPath: createWebClipPath(clip),
35
- overflow: 'hidden'
36
- };
37
- });
38
- const contentStyle = useAnimatedStyle(() => ({
39
- transform: [{
40
- translateX: acceptedPresentation.value.contentTranslateX
41
- }, {
42
- translateY: acceptedPresentation.value.contentTranslateY
43
- }]
44
- }));
45
- return /*#__PURE__*/_jsx(Animated.View, {
46
- ...viewProps,
47
- style: [style, initialClipStyle, clipStyle],
48
- children: /*#__PURE__*/_jsx(Animated.View, {
49
- style: contentStyle,
50
- children: children
51
- })
52
- });
53
- }
54
- //# sourceMappingURL=SmoothClipView.web.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- export { SmoothClipView } from "./SmoothClipView.web.js";
4
- export { useSmoothClipDriver } from './drivers';
5
- export { ClipEasings } from "./easings.js";
6
- export { normalizeClipGeometry } from "./geometry.js";
7
- export { createClipPresentation } from "./geometry.js";
8
- //# sourceMappingURL=index.web.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["SmoothClipView","useSmoothClipDriver","ClipEasings","normalizeClipGeometry","createClipPresentation"],"sourceRoot":"../../src","sources":["index.web.ts"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,yBAAsB;AAErD,SAASC,mBAAmB,QAAQ,WAAW;AAa/C,SAASC,WAAW,QAAQ,cAAW;AACvC,SAASC,qBAAqB,QAAQ,eAAY;AAClD,SAASC,sBAAsB,QAAQ,eAAY","ignoreList":[]}
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- function px(value) {
4
- 'worklet';
5
-
6
- return `${value}px`;
7
- }
8
-
9
- /**
10
- * Creates a fixed-host CSS clip. Percentage/right/bottom anchored descendants
11
- * continue resolving against the host because this never changes its layout.
12
- */
13
- export function createWebClipPath(geometry) {
14
- 'worklet';
15
-
16
- const width = Math.max(0, geometry.width);
17
- const height = Math.max(0, geometry.height);
18
- const left = Math.max(0, geometry.x);
19
- const top = Math.max(0, geometry.y);
20
- const rightEdge = Math.max(0, geometry.x + width);
21
- const bottomEdge = Math.max(0, geometry.y + height);
22
- const radius = Math.min(Math.max(0, geometry.radius), Math.min(width, height) / 2);
23
- return `inset(${px(top)} max(0px, calc(100% - ${px(rightEdge)})) max(0px, calc(100% - ${px(bottomEdge)})) ${px(left)} round ${px(radius)})`;
24
- }
25
- //# sourceMappingURL=webClipPath.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["px","value","createWebClipPath","geometry","width","Math","max","height","left","x","top","y","rightEdge","bottomEdge","radius","min"],"sourceRoot":"../../src","sources":["webClipPath.ts"],"mappings":";;AAEA,SAASA,EAAEA,CAACC,KAAa,EAAU;EACjC,SAAS;;EACT,OAAO,GAAGA,KAAK,IAAI;AACrB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,QAAsB,EAAU;EAChE,SAAS;;EACT,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAACC,KAAK,CAAC;EACzC,MAAMG,MAAM,GAAGF,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAACI,MAAM,CAAC;EAC3C,MAAMC,IAAI,GAAGH,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAACM,CAAC,CAAC;EACpC,MAAMC,GAAG,GAAGL,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAACQ,CAAC,CAAC;EACnC,MAAMC,SAAS,GAAGP,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAACM,CAAC,GAAGL,KAAK,CAAC;EACjD,MAAMS,UAAU,GAAGR,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAACQ,CAAC,GAAGJ,MAAM,CAAC;EACnD,MAAMO,MAAM,GAAGT,IAAI,CAACU,GAAG,CACrBV,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAACW,MAAM,CAAC,EAC5BT,IAAI,CAACU,GAAG,CAACX,KAAK,EAAEG,MAAM,CAAC,GAAG,CAC5B,CAAC;EAED,OAAO,SAASP,EAAE,CAACU,GAAG,CAAC,yBAAyBV,EAAE,CAChDY,SACF,CAAC,2BAA2BZ,EAAE,CAACa,UAAU,CAAC,MAAMb,EAAE,CAChDQ,IACF,CAAC,UAAUR,EAAE,CAACc,MAAM,CAAC,GAAG;AAC1B","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import { type ViewProps } from 'react-native';
3
- import type { SmoothClipDriver } from './driverTypes.js';
4
- export type SmoothClipViewProps = ViewProps & {
5
- driver: SmoothClipDriver;
6
- children?: ReactNode;
7
- };
8
- /** Fixed-layout CSS fallback. */
9
- export declare function SmoothClipView({ driver, children, style, ...viewProps }: SmoothClipViewProps): import("react").JSX.Element;
10
- //# sourceMappingURL=SmoothClipView.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SmoothClipView.web.d.ts","sourceRoot":"","sources":["../../../src/SmoothClipView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,cAAc,CAAC;AAM9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAe,CAAC;AAKtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG;IAC5C,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,iCAAiC;AACjC,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,KAAK,EACL,GAAG,SAAS,EACb,EAAE,mBAAmB,+BA0CrB"}
@@ -1,9 +0,0 @@
1
- export { SmoothClipView } from './SmoothClipView.web.js';
2
- export type { SmoothClipViewProps } from './SmoothClipView.web.js';
3
- export { useSmoothClipDriver } from './drivers';
4
- export type { ClipAnimationResult, ClipReduceMotion, KeyframedClipAnimation, SmoothClipDriver, SmoothClipDriverOptions, SmoothClipReactControls, SmoothClipUIControls, SmoothClipAnimation, SpringClipAnimation, TimingClipAnimation, } from './driverTypes.js';
5
- export { ClipEasings } from './easings.js';
6
- export { normalizeClipGeometry } from './geometry.js';
7
- export { createClipPresentation } from './geometry.js';
8
- export type { ClipBounds, ClipGeometry, SmoothClipPresentation, } from './geometry.js';
9
- //# sourceMappingURL=index.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAsB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAsB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAW,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAY,CAAC;AACpD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,GACvB,MAAM,eAAY,CAAC"}
@@ -1,7 +0,0 @@
1
- import type { ClipGeometry } from './geometry.js';
2
- /**
3
- * Creates a fixed-host CSS clip. Percentage/right/bottom anchored descendants
4
- * continue resolving against the host because this never changes its layout.
5
- */
6
- export declare function createWebClipPath(geometry: ClipGeometry): string;
7
- //# sourceMappingURL=webClipPath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webClipPath.d.ts","sourceRoot":"","sources":["../../../src/webClipPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAY,CAAC;AAO/C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAkBhE"}
@@ -1,66 +0,0 @@
1
- import { type ReactNode, useEffect } from 'react';
2
- import { type ViewProps, type ViewStyle } from 'react-native';
3
- import Animated, {
4
- useAnimatedReaction,
5
- useAnimatedStyle,
6
- useSharedValue,
7
- } from 'react-native-reanimated';
8
- import type { SmoothClipDriver } from './driverTypes';
9
- import { getDriverState, registerDriverView } from './driverState';
10
- import { clipPresentationEquals, isFiniteClipPresentation } from './geometry';
11
- import { createWebClipPath } from './webClipPath';
12
-
13
- export type SmoothClipViewProps = ViewProps & {
14
- driver: SmoothClipDriver;
15
- children?: ReactNode;
16
- };
17
-
18
- /** Fixed-layout CSS fallback. */
19
- export function SmoothClipView({
20
- driver,
21
- children,
22
- style,
23
- ...viewProps
24
- }: SmoothClipViewProps) {
25
- const { initialPresentation, source } = getDriverState(driver);
26
- useEffect(() => registerDriverView(driver), [driver]);
27
- const acceptedPresentation = useSharedValue(initialPresentation);
28
- const initialClipStyle = {
29
- clipPath: createWebClipPath(initialPresentation.clip),
30
- overflow: 'hidden',
31
- } as unknown as ViewStyle;
32
-
33
- useAnimatedReaction(
34
- () => source.value,
35
- (presentation, previousPresentation) => {
36
- if (
37
- isFiniteClipPresentation(presentation) &&
38
- !clipPresentationEquals(previousPresentation, presentation)
39
- ) {
40
- acceptedPresentation.value = presentation;
41
- }
42
- },
43
- [source, acceptedPresentation]
44
- );
45
-
46
- const clipStyle = useAnimatedStyle(() => {
47
- const clip = acceptedPresentation.value.clip;
48
- return {
49
- clipPath: createWebClipPath(clip),
50
- overflow: 'hidden',
51
- };
52
- });
53
-
54
- const contentStyle = useAnimatedStyle(() => ({
55
- transform: [
56
- { translateX: acceptedPresentation.value.contentTranslateX },
57
- { translateY: acceptedPresentation.value.contentTranslateY },
58
- ],
59
- }));
60
-
61
- return (
62
- <Animated.View {...viewProps} style={[style, initialClipStyle, clipStyle]}>
63
- <Animated.View style={contentStyle}>{children}</Animated.View>
64
- </Animated.View>
65
- );
66
- }
package/src/index.web.ts DELETED
@@ -1,23 +0,0 @@
1
- export { SmoothClipView } from './SmoothClipView.web';
2
- export type { SmoothClipViewProps } from './SmoothClipView.web';
3
- export { useSmoothClipDriver } from './drivers';
4
- export type {
5
- ClipAnimationResult,
6
- ClipReduceMotion,
7
- KeyframedClipAnimation,
8
- SmoothClipDriver,
9
- SmoothClipDriverOptions,
10
- SmoothClipReactControls,
11
- SmoothClipUIControls,
12
- SmoothClipAnimation,
13
- SpringClipAnimation,
14
- TimingClipAnimation,
15
- } from './driverTypes';
16
- export { ClipEasings } from './easings';
17
- export { normalizeClipGeometry } from './geometry';
18
- export { createClipPresentation } from './geometry';
19
- export type {
20
- ClipBounds,
21
- ClipGeometry,
22
- SmoothClipPresentation,
23
- } from './geometry';
@@ -1,30 +0,0 @@
1
- import type { ClipGeometry } from './geometry';
2
-
3
- function px(value: number): string {
4
- 'worklet';
5
- return `${value}px`;
6
- }
7
-
8
- /**
9
- * Creates a fixed-host CSS clip. Percentage/right/bottom anchored descendants
10
- * continue resolving against the host because this never changes its layout.
11
- */
12
- export function createWebClipPath(geometry: ClipGeometry): string {
13
- 'worklet';
14
- const width = Math.max(0, geometry.width);
15
- const height = Math.max(0, geometry.height);
16
- const left = Math.max(0, geometry.x);
17
- const top = Math.max(0, geometry.y);
18
- const rightEdge = Math.max(0, geometry.x + width);
19
- const bottomEdge = Math.max(0, geometry.y + height);
20
- const radius = Math.min(
21
- Math.max(0, geometry.radius),
22
- Math.min(width, height) / 2
23
- );
24
-
25
- return `inset(${px(top)} max(0px, calc(100% - ${px(
26
- rightEdge
27
- )})) max(0px, calc(100% - ${px(bottomEdge)})) ${px(
28
- left
29
- )} round ${px(radius)})`;
30
- }