@octane-xplat/lottie 0.0.1 → 0.10.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 (361) hide show
  1. package/README.md +56 -2
  2. package/dist/native/cx.mobile.js +11 -0
  3. package/dist/native/escape-props.js +39 -0
  4. package/dist/native/index.js +183 -0
  5. package/dist/native/layout-child.js +38 -0
  6. package/dist/native/octane-client-build.json +8 -0
  7. package/dist/native/vendor/ui-lottie/index.android.js +286 -0
  8. package/dist/native/vendor/ui-lottie/index.ios.js +214 -0
  9. package/dist/native/vendor/ui-lottie/src/lottie/index.common.js +50 -0
  10. package/dist/native/vendor/ui-lottie/src/lottie/utils.js +6 -0
  11. package/dist/web/escape-props.web.js +17 -0
  12. package/dist/web/index.js +346 -0
  13. package/dist/web/layout-child.web.js +47 -0
  14. package/dist/web/octane-client-build.json +8 -0
  15. package/package.json +104 -11
  16. package/platforms/android/include.gradle +7 -0
  17. package/platforms/android/java/com/nativescript/lottie/LottieAnimationView.java +92 -0
  18. package/platforms/android/lottie.aar +0 -0
  19. package/platforms/android/native-api-usage.json +16 -0
  20. package/platforms/ios/Podfile +5 -0
  21. package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
  22. package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
  23. package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
  24. package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
  25. package/platforms/macos/UPSTREAM.md +13 -0
  26. package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
  27. package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
  28. package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
  29. package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
  30. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
  31. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
  32. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
  33. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
  34. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
  35. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
  36. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
  37. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
  38. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
  39. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
  40. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
  41. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
  42. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
  43. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
  44. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
  45. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
  46. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
  47. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
  48. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
  49. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
  50. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
  51. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
  52. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
  53. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
  54. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
  55. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
  56. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
  57. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
  58. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
  59. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
  60. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
  61. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
  62. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
  63. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
  64. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
  65. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
  66. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
  67. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
  68. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
  69. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
  70. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
  71. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
  72. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
  73. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
  74. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
  75. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
  76. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
  77. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
  78. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
  79. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
  80. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
  81. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
  82. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
  83. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
  84. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
  85. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
  86. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
  87. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
  88. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
  89. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
  90. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
  91. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
  92. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
  93. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
  94. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
  95. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
  96. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
  97. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
  98. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
  99. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
  100. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
  101. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
  102. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
  103. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
  104. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
  105. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
  106. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
  107. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
  108. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
  109. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
  110. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
  111. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
  112. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
  113. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
  114. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
  115. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
  116. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
  117. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
  118. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
  119. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
  120. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
  121. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
  122. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
  123. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
  124. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
  125. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
  126. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
  127. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
  128. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
  129. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
  130. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
  131. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
  132. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
  133. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
  134. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
  135. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
  136. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
  137. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
  138. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
  139. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
  140. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
  141. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
  142. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
  143. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
  144. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
  145. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
  146. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
  147. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
  148. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
  149. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
  150. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
  151. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
  152. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
  153. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
  154. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
  155. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
  156. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
  157. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
  158. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
  159. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
  160. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
  161. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
  162. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
  163. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
  164. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
  165. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
  166. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
  167. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
  168. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
  169. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
  170. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
  171. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
  172. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
  173. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
  174. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
  175. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
  176. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
  177. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
  178. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
  179. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
  180. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
  181. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
  182. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
  183. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
  184. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
  185. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
  186. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
  187. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
  188. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
  189. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
  190. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
  191. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
  192. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
  193. package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
  194. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
  195. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
  196. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
  197. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
  198. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
  199. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
  200. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
  201. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
  202. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
  203. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
  204. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
  205. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
  206. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
  207. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
  208. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
  209. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
  210. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
  211. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
  212. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
  213. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
  214. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
  215. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
  216. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
  217. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
  218. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
  219. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
  220. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
  221. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
  222. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
  223. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
  224. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
  225. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
  226. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
  227. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
  228. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
  229. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
  230. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
  231. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
  232. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
  233. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
  234. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
  235. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
  236. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
  237. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
  238. package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
  239. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
  240. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
  241. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
  242. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
  243. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
  244. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
  245. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
  246. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
  247. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
  248. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
  249. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
  250. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
  251. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
  252. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
  253. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
  254. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
  255. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
  256. package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
  257. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
  258. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
  259. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
  260. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
  261. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
  262. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
  263. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
  264. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
  265. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
  266. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
  267. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
  268. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
  269. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
  270. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
  271. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
  272. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
  273. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
  274. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
  275. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
  276. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
  277. package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
  278. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
  279. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
  280. package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
  281. package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
  282. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
  283. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
  284. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
  285. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
  286. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
  287. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
  288. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
  289. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
  290. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
  291. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
  292. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
  293. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
  294. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
  295. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
  296. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
  297. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
  298. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
  299. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
  300. package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
  301. package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
  302. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
  303. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
  304. package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
  305. package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
  306. package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
  307. package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
  308. package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
  309. package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
  310. package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
  311. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
  312. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
  313. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
  314. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
  315. package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
  316. package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
  317. package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
  318. package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
  319. package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
  320. package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
  321. package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
  322. package/src/Lottie.macos.tsrx +129 -0
  323. package/src/Lottie.tsrx +162 -0
  324. package/src/Lottie.web.tsrx +152 -0
  325. package/src/cx.mobile.ts +8 -0
  326. package/src/escape-props.ts +65 -0
  327. package/src/escape-props.web.ts +25 -0
  328. package/src/index.macos.ts +2 -0
  329. package/src/index.ts +2 -0
  330. package/src/index.web.ts +2 -0
  331. package/src/layout-child.ts +57 -0
  332. package/src/layout-child.web.ts +108 -0
  333. package/src/native-elements.d.ts +8 -0
  334. package/src/props.ts +133 -0
  335. package/src/references.d.ts +3 -0
  336. package/src/vendor/ui-lottie/LICENSE.md +21 -0
  337. package/src/vendor/ui-lottie/src/lottie/index.android.ts +447 -0
  338. package/src/vendor/ui-lottie/src/lottie/index.common.ts +84 -0
  339. package/src/vendor/ui-lottie/src/lottie/index.d.ts +133 -0
  340. package/src/vendor/ui-lottie/src/lottie/index.ios.ts +345 -0
  341. package/src/vendor/ui-lottie/src/lottie/typings/android.d.ts +4149 -0
  342. package/src/vendor/ui-lottie/src/lottie/typings/android.nativescript.d.ts +12 -0
  343. package/src/vendor/ui-lottie/src/lottie/typings/dotlottie.ios.d.ts +14 -0
  344. package/src/vendor/ui-lottie/src/lottie/typings/ios.d.ts +384 -0
  345. package/src/vendor/ui-lottie/src/lottie/utils.ts +9 -0
  346. package/types/generated/.tsrx-typegen-manifest.json +18 -0
  347. package/types/generated/Lottie.d.ts +7 -0
  348. package/types/generated/Lottie.web.d.ts +7 -0
  349. package/types/generated/cx.mobile.d.ts +6 -0
  350. package/types/generated/escape-props.d.ts +15 -0
  351. package/types/generated/escape-props.web.d.ts +5 -0
  352. package/types/generated/index.d.ts +2 -0
  353. package/types/generated/index.web.d.ts +2 -0
  354. package/types/generated/layout-child.d.ts +6 -0
  355. package/types/generated/layout-child.web.d.ts +15 -0
  356. package/types/generated/props.d.ts +110 -0
  357. package/types/generated/vendor/ui-lottie/src/lottie/index.common.d.ts +30 -0
  358. package/types/generated/vendor/ui-lottie/src/lottie/index.ios.d.ts +35 -0
  359. package/types/generated/vendor/ui-lottie/src/lottie/utils.d.ts +1 -0
  360. package/index.d.ts +0 -1
  361. package/index.js +0 -2
@@ -0,0 +1,476 @@
1
+ // Created by Cal Stephens on 12/14/21.
2
+ // Copyright © 2021 Airbnb Inc. All rights reserved.
3
+
4
+ import QuartzCore
5
+
6
+ extension CALayer {
7
+
8
+ // MARK: Internal
9
+
10
+ /// Constructs a `CAKeyframeAnimation` that reflects the given keyframes,
11
+ /// and adds it to this `CALayer`.
12
+ @nonobjc
13
+ func addAnimation<KeyframeValue: AnyInterpolatable, ValueRepresentation>(
14
+ for property: LayerProperty<ValueRepresentation>,
15
+ keyframes: KeyframeGroup<KeyframeValue>,
16
+ value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation,
17
+ context: LayerAnimationContext
18
+ ) throws {
19
+ if let customAnimation = try customizedAnimation(for: property, context: context) {
20
+ add(customAnimation, timedWith: context)
21
+ }
22
+
23
+ else if
24
+ let defaultAnimation = try defaultAnimation(
25
+ for: property,
26
+ keyframes: keyframes,
27
+ value: keyframeValueMapping,
28
+ context: context
29
+ )
30
+ {
31
+ let timedAnimation = defaultAnimation.timed(with: context, for: self)
32
+ add(timedAnimation, forKey: property.caLayerKeypath)
33
+ }
34
+ }
35
+
36
+ // MARK: Private
37
+
38
+ /// Constructs a `CAAnimation` that reflects the given keyframes
39
+ /// - If the value can be applied directly to the CALayer using KVC,
40
+ /// then no `CAAnimation` will be created and the value will be applied directly.
41
+ @nonobjc
42
+ private func defaultAnimation<KeyframeValue: AnyInterpolatable, ValueRepresentation>(
43
+ for property: LayerProperty<ValueRepresentation>,
44
+ keyframes keyframeGroup: KeyframeGroup<KeyframeValue>,
45
+ value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation,
46
+ context: LayerAnimationContext
47
+ ) throws -> CAAnimation? {
48
+ let keyframes = keyframeGroup.keyframes
49
+ guard !keyframes.isEmpty else { return nil }
50
+
51
+ // Check if this set of keyframes uses After Effects expressions, which aren't supported.
52
+ // - We only log this once per `CoreAnimationLayer` instance.
53
+ if keyframeGroup.unsupportedAfterEffectsExpression != nil, !context.loggingState.hasLoggedAfterEffectsExpressionsWarning {
54
+ context.loggingState.hasLoggedAfterEffectsExpressionsWarning = true
55
+ context.logger.info("""
56
+ `\(property.caLayerKeypath)` animation for "\(context.currentKeypath.fullPath)" \
57
+ includes an After Effects expression (https://helpx.adobe.com/after-effects/using/expression-language.html), \
58
+ which is not supported by lottie-ios (expressions are only supported by lottie-web). \
59
+ This animation may not play correctly.
60
+ """)
61
+ }
62
+
63
+ // If there is exactly one keyframe value that doesn't animate,
64
+ // we can improve performance by applying that value directly to the layer
65
+ // instead of creating a relatively expensive `CAKeyframeAnimation`.
66
+ if keyframes.count == 1 {
67
+ return singleKeyframeAnimation(
68
+ for: property,
69
+ keyframeValue: try keyframeValueMapping(keyframes[0].value),
70
+ writeDirectlyToPropertyIfPossible: true
71
+ )
72
+ }
73
+
74
+ /// If we're required to use the `complexTimeRemapping` from some parent `PreCompLayer`,
75
+ /// we have to manually interpolate the keyframes with the time remapping applied.
76
+ if context.mustUseComplexTimeRemapping {
77
+ return try defaultAnimation(
78
+ for: property,
79
+ keyframes: Keyframes.manuallyInterpolatedWithTimeRemapping(keyframeGroup, context: context),
80
+ value: keyframeValueMapping,
81
+ context: context.withoutTimeRemapping()
82
+ )
83
+ }
84
+
85
+ // Split the keyframes into segments with the same `CAAnimationCalculationMode` value
86
+ // - Each of these segments will become their own `CAKeyframeAnimation`
87
+ let animationSegments = keyframes.segmentsSplitByCalculationMode()
88
+
89
+ // If we only have a single segment, we can just create a single `CAKeyframeAnimation`
90
+ // instead of wrapping it in a `CAAnimationGroup` -- this reduces allocation overhead a bit.
91
+ if animationSegments.count == 1 {
92
+ return try keyframeAnimation(
93
+ for: property,
94
+ keyframes: animationSegments[0],
95
+ value: keyframeValueMapping,
96
+ context: context
97
+ )
98
+ } else {
99
+ return try animationGroup(
100
+ for: property,
101
+ animationSegments: animationSegments,
102
+ value: keyframeValueMapping,
103
+ context: context
104
+ )
105
+ }
106
+ }
107
+
108
+ /// A `CAAnimation` that applies the custom value from the `AnyValueProvider`
109
+ /// registered for this specific property's `AnimationKeypath`,
110
+ /// if one has been registered using `LottieAnimationView.setValueProvider(_:keypath:)`.
111
+ @nonobjc
112
+ private func customizedAnimation<ValueRepresentation>(
113
+ for property: LayerProperty<ValueRepresentation>,
114
+ context: LayerAnimationContext
115
+ ) throws -> CAPropertyAnimation? {
116
+ guard
117
+ let customizableProperty = property.customizableProperty,
118
+ let customKeyframes = try context.valueProviderStore.customKeyframes(
119
+ of: customizableProperty,
120
+ for: AnimationKeypath(keys: context.currentKeypath.keys + customizableProperty.name.map { $0.rawValue }),
121
+ context: context
122
+ )
123
+ else { return nil }
124
+
125
+ // Since custom animations are overriding an existing animation,
126
+ // we always have to create a CAAnimation and can't write directly
127
+ // to the layer property
128
+ if
129
+ customKeyframes.keyframes.count == 1,
130
+ let singleKeyframeAnimation = singleKeyframeAnimation(
131
+ for: property,
132
+ keyframeValue: customKeyframes.keyframes[0].value,
133
+ writeDirectlyToPropertyIfPossible: false
134
+ )
135
+ {
136
+ return singleKeyframeAnimation
137
+ }
138
+
139
+ return try keyframeAnimation(
140
+ for: property,
141
+ keyframes: Array(customKeyframes.keyframes),
142
+ value: { $0 },
143
+ context: context
144
+ )
145
+ }
146
+
147
+ /// Creates an animation that applies a single keyframe to this layer property
148
+ /// - In many cases this animation can be omitted entirely, and the underlying
149
+ /// property can be set directly. In that case, no animation will be created.
150
+ private func singleKeyframeAnimation<ValueRepresentation>(
151
+ for property: LayerProperty<ValueRepresentation>,
152
+ keyframeValue: ValueRepresentation,
153
+ writeDirectlyToPropertyIfPossible: Bool
154
+ ) -> CABasicAnimation? {
155
+ if writeDirectlyToPropertyIfPossible {
156
+ // If the keyframe value is the same as the layer's default value for this property,
157
+ // then we can just ignore this set of keyframes.
158
+ if property.isDefaultValue(keyframeValue) {
159
+ return nil
160
+ }
161
+
162
+ // If the property on the CALayer being animated hasn't been modified from the default yet,
163
+ // then we can apply the keyframe value directly to the layer using KVC instead
164
+ // of creating a `CAAnimation`.
165
+ let currentValue = value(forKey: property.caLayerKeypath) as? ValueRepresentation
166
+ if property.isDefaultValue(currentValue) {
167
+ setValue(keyframeValue, forKeyPath: property.caLayerKeypath)
168
+ return nil
169
+ }
170
+ }
171
+
172
+ // Otherwise, we still need to create a `CAAnimation`, but we can
173
+ // create a simple `CABasicAnimation` that is still less expensive
174
+ // than computing a `CAKeyframeAnimation`.
175
+ let animation = CABasicAnimation(keyPath: property.caLayerKeypath)
176
+ animation.fromValue = keyframeValue
177
+ animation.toValue = keyframeValue
178
+ return animation
179
+ }
180
+
181
+ /// Creates a `CAAnimationGroup` that wraps a `CAKeyframeAnimation` for each
182
+ /// of the given `animationSegments`
183
+ private func animationGroup<KeyframeValue, ValueRepresentation>(
184
+ for property: LayerProperty<ValueRepresentation>,
185
+ animationSegments: [[Keyframe<KeyframeValue>]],
186
+ value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation,
187
+ context: LayerAnimationContext
188
+ ) throws -> CAAnimationGroup {
189
+ // Build the `CAKeyframeAnimation` for each segment of keyframes
190
+ // with the same `CAAnimationCalculationMode`.
191
+ // - Here we have a non-zero number of animation segments,
192
+ // all of which have a non-zero number of keyframes.
193
+ let segmentAnimations: [CAKeyframeAnimation] = try animationSegments.indices.map { index in
194
+ let animationSegment = animationSegments[index]
195
+ var segmentStartTime = try context.time(forFrame: animationSegment.first!.time)
196
+ var segmentEndTime = try context.time(forFrame: animationSegment.last!.time)
197
+
198
+ // Every portion of the animation timeline has to be covered by a `CAKeyframeAnimation`,
199
+ // so if this is the first or last segment then the start/end time should be exactly
200
+ // the start/end time of the animation itself.
201
+ let isFirstSegment = (index == animationSegments.indices.first!)
202
+ let isLastSegment = (index == animationSegments.indices.last!)
203
+
204
+ if isFirstSegment {
205
+ segmentStartTime = min(
206
+ try context.time(forFrame: context.animation.startFrame),
207
+ segmentStartTime
208
+ )
209
+ }
210
+
211
+ if isLastSegment {
212
+ segmentEndTime = max(
213
+ try context.time(forFrame: context.animation.endFrame),
214
+ segmentEndTime
215
+ )
216
+ }
217
+
218
+ let segmentDuration = segmentEndTime - segmentStartTime
219
+
220
+ // We're building `CAKeyframeAnimation`s, so the `keyTimes` are expressed
221
+ // relative to 0 (`segmentStartTime`) and 1 (`segmentEndTime`). This is different
222
+ // from the default behavior of the `keyframeAnimation` method, where times
223
+ // are expressed relative to the entire animation duration.
224
+ let customKeyTimes = try animationSegment.map { keyframeModel -> NSNumber in
225
+ let keyframeTime = try context.time(forFrame: keyframeModel.time)
226
+ let segmentProgressTime = ((keyframeTime - segmentStartTime) / segmentDuration)
227
+ return segmentProgressTime as NSNumber
228
+ }
229
+
230
+ let animation = try keyframeAnimation(
231
+ for: property,
232
+ keyframes: animationSegment,
233
+ value: keyframeValueMapping,
234
+ customKeyTimes: customKeyTimes,
235
+ context: context
236
+ )
237
+
238
+ animation.duration = segmentDuration
239
+ animation.beginTime = segmentStartTime
240
+ return animation
241
+ }
242
+
243
+ let fullAnimation = CAAnimationGroup()
244
+ fullAnimation.animations = segmentAnimations
245
+ return fullAnimation
246
+ }
247
+
248
+ /// Creates and validates a `CAKeyframeAnimation` for the given keyframes
249
+ private func keyframeAnimation<KeyframeValue, ValueRepresentation>(
250
+ for property: LayerProperty<ValueRepresentation>,
251
+ keyframes: [Keyframe<KeyframeValue>],
252
+ value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation,
253
+ customKeyTimes: [NSNumber]? = nil,
254
+ context: LayerAnimationContext
255
+ ) throws -> CAKeyframeAnimation {
256
+ // Convert the list of `Keyframe<T>` into
257
+ // the representation used by `CAKeyframeAnimation`
258
+ var keyTimes = try customKeyTimes ?? keyframes.map { keyframeModel -> NSNumber in
259
+ NSNumber(value: Float(try context.progressTime(for: keyframeModel.time)))
260
+ }
261
+
262
+ var timingFunctions = timingFunctions(for: keyframes)
263
+ let calculationMode = calculationMode(for: keyframes)
264
+
265
+ let animation = CAKeyframeAnimation(keyPath: property.caLayerKeypath)
266
+
267
+ // Position animations define a `CGPath` curve that should be followed,
268
+ // instead of animating directly between keyframe point values.
269
+ if property.caLayerKeypath == LayerProperty<CGPoint>.position.caLayerKeypath {
270
+ animation.path = try path(keyframes: keyframes, value: { value in
271
+ guard let point = try keyframeValueMapping(value) as? CGPoint else {
272
+ context.logger.assertionFailure("Cannot create point from keyframe with value \(value)")
273
+ return .zero
274
+ }
275
+
276
+ return point
277
+ })
278
+ }
279
+
280
+ // All other types of keyframes provide individual values that are interpolated by Core Animation
281
+ else {
282
+ var values = try keyframes.map { keyframeModel in
283
+ try keyframeValueMapping(keyframeModel.value)
284
+ }
285
+
286
+ validate(
287
+ values: &values,
288
+ keyTimes: &keyTimes,
289
+ timingFunctions: &timingFunctions,
290
+ for: calculationMode,
291
+ context: context
292
+ )
293
+
294
+ animation.values = values
295
+ }
296
+
297
+ animation.calculationMode = calculationMode
298
+ animation.keyTimes = keyTimes
299
+ animation.timingFunctions = timingFunctions
300
+ return animation
301
+ }
302
+
303
+ /// The `CAAnimationCalculationMode` that should be used for a `CAKeyframeAnimation`
304
+ /// animating the given keyframes
305
+ private func calculationMode<KeyframeValue>(
306
+ for keyframes: [Keyframe<KeyframeValue>]
307
+ ) -> CAAnimationCalculationMode {
308
+ // At this point we expect all of the animations to have been split in
309
+ // to segments based on the `CAAnimationCalculationMode`, so we can just
310
+ // check the first keyframe.
311
+ if keyframes[0].isHold {
312
+ .discrete
313
+ } else {
314
+ .linear
315
+ }
316
+ }
317
+
318
+ /// `timingFunctions` to apply to a `CAKeyframeAnimation` animating the given keyframes
319
+ private func timingFunctions<KeyframeValue>(
320
+ for keyframes: [Keyframe<KeyframeValue>]
321
+ ) -> [CAMediaTimingFunction] {
322
+ // Compute the timing function between each keyframe and the subsequent keyframe
323
+ var timingFunctions = [CAMediaTimingFunction]()
324
+
325
+ for (index, keyframe) in keyframes.enumerated()
326
+ where index != keyframes.indices.last
327
+ {
328
+ let nextKeyframe = keyframes[index + 1]
329
+
330
+ let controlPoint1 = keyframe.outTangent?.pointValue ?? .zero
331
+ let controlPoint2 = nextKeyframe.inTangent?.pointValue ?? CGPoint(x: 1, y: 1)
332
+
333
+ timingFunctions.append(CAMediaTimingFunction(
334
+ controlPoints:
335
+ Float(controlPoint1.x),
336
+ Float(controlPoint1.y),
337
+ Float(controlPoint2.x),
338
+ Float(controlPoint2.y)
339
+ ))
340
+ }
341
+
342
+ return timingFunctions
343
+ }
344
+
345
+ /// Creates a `CGPath` for the given `position` keyframes,
346
+ /// which accounts for `spatialInTangent`s and `spatialOutTangents`
347
+ private func path<KeyframeValue>(
348
+ keyframes positionKeyframes: [Keyframe<KeyframeValue>],
349
+ value keyframeValueMapping: (KeyframeValue) throws -> CGPoint
350
+ ) rethrows -> CGPath {
351
+ let path = CGMutablePath()
352
+
353
+ for (index, keyframe) in positionKeyframes.enumerated() {
354
+ if index == positionKeyframes.indices.first {
355
+ path.move(to: try keyframeValueMapping(keyframe.value))
356
+ }
357
+
358
+ if index != positionKeyframes.indices.last {
359
+ let nextKeyframe = positionKeyframes[index + 1]
360
+
361
+ if
362
+ let controlPoint1 = keyframe.spatialOutTangent?.pointValue,
363
+ let controlPoint2 = nextKeyframe.spatialInTangent?.pointValue,
364
+ !(controlPoint1 == .zero && controlPoint2 == .zero)
365
+ {
366
+ path.addCurve(
367
+ to: try keyframeValueMapping(nextKeyframe.value),
368
+ control1: try keyframeValueMapping(keyframe.value) + controlPoint1,
369
+ control2: try keyframeValueMapping(nextKeyframe.value) + controlPoint2
370
+ )
371
+ }
372
+
373
+ else {
374
+ path.addLine(to: try keyframeValueMapping(nextKeyframe.value))
375
+ }
376
+ }
377
+ }
378
+
379
+ path.closeSubpath()
380
+ return path
381
+ }
382
+
383
+ /// Validates that the requirements of the `CAKeyframeAnimation` API are met correctly
384
+ private func validate<ValueRepresentation>(
385
+ values: inout [ValueRepresentation],
386
+ keyTimes: inout [NSNumber],
387
+ timingFunctions: inout [CAMediaTimingFunction],
388
+ for calculationMode: CAAnimationCalculationMode,
389
+ context: LayerAnimationContext
390
+ ) {
391
+ // Validate that we have correct start (0.0) and end (1.0) keyframes.
392
+ // From the documentation of `CAKeyframeAnimation.keyTimes`:
393
+ // - The first value in the `keyTimes` array must be 0.0 and the last value must be 1.0.
394
+ if keyTimes.first != 0.0 {
395
+ keyTimes.insert(0.0, at: 0)
396
+ values.insert(values[0], at: 0)
397
+ timingFunctions.insert(CAMediaTimingFunction(name: .linear), at: 0)
398
+ }
399
+
400
+ if keyTimes.last != 1.0 {
401
+ keyTimes.append(1.0)
402
+ values.append(values.last!)
403
+ timingFunctions.append(CAMediaTimingFunction(name: .linear))
404
+ }
405
+
406
+ switch calculationMode {
407
+ case .linear, .cubic:
408
+ // From the documentation of `CAKeyframeAnimation.keyTimes`:
409
+ // - The number of elements in the keyTimes array
410
+ // should match the number of elements in the values property
411
+ context.logger.assert(
412
+ values.count == keyTimes.count,
413
+ "`values.count` must exactly equal `keyTimes.count`"
414
+ )
415
+
416
+ context.logger.assert(
417
+ timingFunctions.count == (values.count - 1),
418
+ "`timingFunctions.count` must exactly equal `values.count - 1`"
419
+ )
420
+
421
+ case .discrete:
422
+ // From the documentation of `CAKeyframeAnimation.keyTimes`:
423
+ // - If the calculationMode is set to discrete... the keyTimes array
424
+ // should have one more entry than appears in the values array.
425
+ values.removeLast()
426
+
427
+ context.logger.assert(
428
+ keyTimes.count == values.count + 1,
429
+ "`keyTimes.count` must exactly equal `values.count + 1`"
430
+ )
431
+
432
+ default:
433
+ context.logger.assertionFailure("""
434
+ Unexpected keyframe calculation mode \(calculationMode)
435
+ """)
436
+ }
437
+ }
438
+
439
+ }
440
+
441
+ extension RandomAccessCollection {
442
+ /// Splits this array of `Keyframe`s into segments with the same `CAAnimationCalculationMode`
443
+ /// - Keyframes with `isHold=true` become `discrete`, and keyframes with `isHold=false`
444
+ /// become linear. Each `CAKeyframeAnimation` can only be one or the other, so each
445
+ /// `calculationModeSegment` becomes its own `CAKeyframeAnimation`.
446
+ func segmentsSplitByCalculationMode<KeyframeValue>() -> [[Element]]
447
+ where Element == Keyframe<KeyframeValue>, Index == Int
448
+ {
449
+ var segments = [[Element]]()
450
+ var currentSegment = [Element]()
451
+
452
+ for keyframe in self {
453
+ guard let mostRecentKeyframe = currentSegment.last else {
454
+ currentSegment.append(keyframe)
455
+ continue
456
+ }
457
+
458
+ // When `isHold` changes between any two given keyframes, we have to create a new segment
459
+ if keyframe.isHold != mostRecentKeyframe.isHold {
460
+ // Add this keyframe to both the existing segment that is ending,
461
+ // so we know how long that segment is, and the new segment,
462
+ // so we know when that segment starts.
463
+ currentSegment.append(keyframe)
464
+ segments.append(currentSegment)
465
+ currentSegment = [keyframe]
466
+ }
467
+
468
+ else {
469
+ currentSegment.append(keyframe)
470
+ }
471
+ }
472
+
473
+ segments.append(currentSegment)
474
+ return segments
475
+ }
476
+ }
@@ -0,0 +1,92 @@
1
+ // Created by Cal Stephens on 1/28/22.
2
+ // Copyright © 2022 Airbnb Inc. All rights reserved.
3
+
4
+ import QuartzCore
5
+
6
+ extension CAShapeLayer {
7
+ /// Adds animations for the given `CombinedShapeItem` to this `CALayer`
8
+ @nonobjc
9
+ func addAnimations(
10
+ for combinedShapes: CombinedShapeItem,
11
+ context: LayerAnimationContext,
12
+ pathMultiplier: PathMultiplier
13
+ ) throws {
14
+ try addAnimation(
15
+ for: .path,
16
+ keyframes: combinedShapes.shapes,
17
+ value: { paths in
18
+ let combinedPath = CGMutablePath()
19
+ for path in paths {
20
+ combinedPath.addPath(path.cgPath().duplicated(times: pathMultiplier))
21
+ }
22
+ return combinedPath
23
+ },
24
+ context: context
25
+ )
26
+ }
27
+ }
28
+
29
+ // MARK: - CombinedShapeItem
30
+
31
+ /// A custom `ShapeItem` subclass that combines multiple `Shape`s into a single `KeyframeGroup`
32
+ final class CombinedShapeItem: ShapeItem {
33
+
34
+ // MARK: Lifecycle
35
+
36
+ init(shapes: KeyframeGroup<[BezierPath]>, name: String) {
37
+ self.shapes = shapes
38
+ super.init(name: name, type: .shape, hidden: false)
39
+ }
40
+
41
+ required init(from _: Decoder) throws {
42
+ fatalError("init(from:) has not been implemented")
43
+ }
44
+
45
+ required init(dictionary _: [String: Any]) throws {
46
+ fatalError("init(dictionary:) has not been implemented")
47
+ }
48
+
49
+ // MARK: Internal
50
+
51
+ let shapes: KeyframeGroup<[BezierPath]>
52
+
53
+ }
54
+
55
+ extension CombinedShapeItem {
56
+ /// Manually combines the given shape keyframes by manually interpolating at each frame
57
+ static func manuallyInterpolating(
58
+ shapes: [KeyframeGroup<BezierPath>],
59
+ name: String
60
+ ) -> CombinedShapeItem {
61
+ let interpolators = shapes.map { shape in
62
+ KeyframeInterpolator(keyframes: shape.keyframes)
63
+ }
64
+
65
+ let times = shapes.flatMap { $0.keyframes.map { $0.time } }
66
+
67
+ let minimumTime = times.min() ?? 0
68
+ let maximumTime = times.max() ?? 0
69
+ let animationLocalTimeRange = Int(minimumTime)...Int(maximumTime)
70
+
71
+ let interpolatedKeyframes = animationLocalTimeRange.map { localTime in
72
+ Keyframe(
73
+ value: interpolators.compactMap { interpolator in
74
+ interpolator.value(frame: AnimationFrameTime(localTime)) as? BezierPath
75
+ },
76
+ time: AnimationFrameTime(localTime)
77
+ )
78
+ }
79
+
80
+ return CombinedShapeItem(
81
+ shapes: KeyframeGroup(keyframes: ContiguousArray(interpolatedKeyframes)),
82
+ name: name
83
+ )
84
+ }
85
+ }
86
+
87
+ // MARK: @unchecked Sendable
88
+
89
+ /// `CombinedShapeItem` inherits `@unchecked Sendable` from `ShapeItem` and
90
+ /// we need to restate that here to avoid a warning in Xcode 16
91
+ // swiftlint:disable:next no_unchecked_sendable
92
+ extension CombinedShapeItem: @unchecked Sendable { }
@@ -0,0 +1,89 @@
1
+ // Created by Cal Stephens on 12/21/21.
2
+ // Copyright © 2021 Airbnb Inc. All rights reserved.
3
+
4
+ import QuartzCore
5
+
6
+ extension CAShapeLayer {
7
+ /// Adds animations for the given `BezierPath` keyframes to this `CALayer`
8
+ @nonobjc
9
+ func addAnimations(
10
+ for customPath: KeyframeGroup<BezierPath>,
11
+ context: LayerAnimationContext,
12
+ pathMultiplier: PathMultiplier = 1,
13
+ transformPath: (CGPath) -> CGPath = { $0 },
14
+ roundedCorners: RoundedCorners? = nil
15
+ ) throws {
16
+ let combinedKeyframes = try BezierPathKeyframe.combining(
17
+ path: customPath,
18
+ cornerRadius: roundedCorners?.radius
19
+ )
20
+
21
+ try addAnimation(
22
+ for: .path,
23
+ keyframes: combinedKeyframes,
24
+ value: { pathKeyframe in
25
+ var path = pathKeyframe.path
26
+ if let cornerRadius = pathKeyframe.cornerRadius {
27
+ path = path.roundCorners(radius: cornerRadius.cgFloatValue)
28
+ }
29
+
30
+ return transformPath(path.cgPath().duplicated(times: pathMultiplier))
31
+ },
32
+ context: context
33
+ )
34
+ }
35
+ }
36
+
37
+ extension CGPath {
38
+ /// Duplicates this `CGPath` so that it is repeated the given number of times
39
+ func duplicated(times: Int) -> CGPath {
40
+ if times <= 1 {
41
+ return self
42
+ }
43
+
44
+ let cgPath = CGMutablePath()
45
+
46
+ for _ in 0..<times {
47
+ cgPath.addPath(self)
48
+ }
49
+
50
+ return cgPath
51
+ }
52
+ }
53
+
54
+ // MARK: - BezierPathKeyframe
55
+
56
+ /// Data that represents how to render a bezier path at a specific point in time
57
+ struct BezierPathKeyframe: Interpolatable {
58
+ let path: BezierPath
59
+ let cornerRadius: LottieVector1D?
60
+
61
+ /// Creates a single array of animatable keyframes from the given sets of keyframes
62
+ /// that can have different counts / timing parameters
63
+ static func combining(
64
+ path: KeyframeGroup<BezierPath>,
65
+ cornerRadius: KeyframeGroup<LottieVector1D>?
66
+ ) throws -> KeyframeGroup<BezierPathKeyframe> {
67
+ guard
68
+ let cornerRadius,
69
+ cornerRadius.keyframes.contains(where: { $0.value.cgFloatValue > 0 })
70
+ else {
71
+ return path.map { path in
72
+ BezierPathKeyframe(path: path, cornerRadius: nil)
73
+ }
74
+ }
75
+
76
+ return Keyframes.combined(
77
+ path,
78
+ cornerRadius,
79
+ makeCombinedResult: BezierPathKeyframe.init
80
+ )
81
+ }
82
+
83
+ func interpolate(to: BezierPathKeyframe, amount: CGFloat) -> BezierPathKeyframe {
84
+ BezierPathKeyframe(
85
+ path: path.interpolate(to: to.path, amount: amount),
86
+ cornerRadius: cornerRadius.interpolate(to: to.cornerRadius, amount: amount)
87
+ )
88
+ }
89
+ }