@octane-xplat/lottie 0.9.0 → 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 (313) hide show
  1. package/README.md +36 -16
  2. package/dist/native/index.js +10 -9
  3. package/dist/native/octane-client-build.json +1 -1
  4. package/dist/web/index.js +39 -25
  5. package/dist/web/octane-client-build.json +1 -1
  6. package/package.json +25 -3
  7. package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
  8. package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
  9. package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
  10. package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
  11. package/platforms/macos/UPSTREAM.md +13 -0
  12. package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
  13. package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
  14. package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
  15. package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
  16. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
  17. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
  18. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
  19. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
  20. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
  21. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
  22. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
  23. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
  24. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
  25. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
  26. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
  27. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
  28. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
  29. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
  30. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
  31. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
  32. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
  33. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
  34. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
  35. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
  36. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
  37. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
  38. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
  39. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
  40. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
  41. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
  42. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
  43. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
  44. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
  45. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
  46. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
  47. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
  48. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
  49. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
  50. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
  51. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
  52. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
  53. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
  54. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
  55. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
  56. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
  57. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
  58. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
  59. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
  60. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
  61. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
  62. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
  63. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
  64. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
  65. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
  66. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
  67. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
  68. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
  69. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
  70. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
  71. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
  72. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
  73. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
  74. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
  75. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
  76. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
  77. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
  78. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
  79. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
  80. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
  81. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
  82. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
  83. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
  84. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
  85. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
  86. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
  87. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
  88. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
  89. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
  90. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
  91. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
  92. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
  93. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
  94. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
  95. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
  96. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
  97. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
  98. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
  99. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
  100. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
  101. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
  102. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
  103. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
  104. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
  105. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
  106. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
  107. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
  108. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
  109. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
  110. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
  111. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
  112. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
  113. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
  114. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
  115. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
  116. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
  117. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
  118. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
  119. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
  120. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
  121. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
  122. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
  123. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
  124. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
  125. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
  126. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
  127. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
  128. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
  129. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
  130. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
  131. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
  132. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
  133. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
  134. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
  135. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
  136. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
  137. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
  138. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
  139. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
  140. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
  141. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
  142. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
  143. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
  144. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
  145. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
  146. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
  147. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
  148. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
  149. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
  150. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
  151. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
  152. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
  153. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
  154. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
  155. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
  156. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
  157. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
  158. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
  159. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
  160. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
  161. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
  162. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
  163. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
  164. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
  165. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
  166. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
  167. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
  168. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
  169. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
  170. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
  171. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
  172. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
  173. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
  174. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
  175. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
  176. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
  177. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
  178. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
  179. package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
  180. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
  181. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
  182. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
  183. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
  184. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
  185. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
  186. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
  187. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
  188. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
  189. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
  190. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
  191. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
  192. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
  193. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
  194. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
  195. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
  196. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
  197. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
  198. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
  199. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
  200. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
  201. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
  202. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
  203. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
  204. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
  205. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
  206. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
  207. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
  208. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
  209. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
  210. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
  211. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
  212. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
  213. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
  214. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
  215. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
  216. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
  217. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
  218. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
  219. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
  220. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
  221. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
  222. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
  223. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
  224. package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
  225. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
  226. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
  227. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
  228. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
  229. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
  230. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
  231. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
  232. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
  233. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
  234. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
  235. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
  236. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
  237. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
  238. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
  239. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
  240. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
  241. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
  242. package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
  243. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
  244. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
  245. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
  246. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
  247. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
  248. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
  249. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
  250. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
  251. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
  252. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
  253. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
  254. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
  255. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
  256. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
  257. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
  258. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
  259. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
  260. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
  261. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
  262. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
  263. package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
  264. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
  265. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
  266. package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
  267. package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
  268. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
  269. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
  270. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
  271. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
  272. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
  273. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
  274. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
  275. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
  276. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
  277. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
  278. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
  279. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
  280. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
  281. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
  282. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
  283. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
  284. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
  285. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
  286. package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
  287. package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
  288. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
  289. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
  290. package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
  291. package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
  292. package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
  293. package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
  294. package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
  295. package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
  296. package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
  297. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
  298. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
  299. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
  300. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
  301. package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
  302. package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
  303. package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
  304. package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
  305. package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
  306. package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
  307. package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
  308. package/src/Lottie.macos.tsrx +129 -0
  309. package/src/Lottie.tsrx +3 -2
  310. package/src/Lottie.web.tsrx +28 -11
  311. package/src/index.macos.ts +2 -0
  312. package/src/props.ts +6 -1
  313. package/types/generated/props.d.ts +5 -1
@@ -0,0 +1,1090 @@
1
+ //
2
+ // LottieAnimationView.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/23/19.
6
+ //
7
+
8
+ import QuartzCore
9
+
10
+ // MARK: - LottieBackgroundBehavior
11
+
12
+ /// Describes the behavior of an AnimationView when the app is moved to the background.
13
+ public enum LottieBackgroundBehavior {
14
+ /// Stop the animation and reset it to the beginning of its current play time. The completion block is called.
15
+ case stop
16
+
17
+ /// Pause the animation in its current state. The completion block is called.
18
+ case pause
19
+
20
+ /// Pause the animation and restart it when the application moves to the foreground.
21
+ /// The completion block is stored and called when the animation completes.
22
+ /// - This is the default when using the Main Thread rendering engine.
23
+ case pauseAndRestore
24
+
25
+ /// Stops the animation and sets it to the end of its current play time. The completion block is called.
26
+ case forceFinish
27
+
28
+ /// The animation continues playing in the background.
29
+ /// - This is the default when using the Core Animation rendering engine.
30
+ /// Playing an animation using the Core Animation engine doesn't come with any CPU overhead,
31
+ /// so using `.continuePlaying` avoids the need to stop and then resume the animation
32
+ /// (which does come with some CPU overhead).
33
+ /// - This mode should not be used with the Main Thread rendering engine.
34
+ case continuePlaying
35
+
36
+ // MARK: Public
37
+
38
+ /// The default background behavior, based on the rendering engine being used to play the animation.
39
+ /// - Playing an animation using the Main Thread rendering engine comes with CPU overhead,
40
+ /// so the animation should be paused or stopped when the `LottieAnimationView` is not visible.
41
+ /// - Playing an animation using the Core Animation rendering engine does not come with any
42
+ /// CPU overhead, so these animations do not need to be paused in the background.
43
+ public static func `default`(for renderingEngine: RenderingEngine) -> LottieBackgroundBehavior {
44
+ switch renderingEngine {
45
+ case .mainThread:
46
+ .pauseAndRestore
47
+ case .coreAnimation:
48
+ .continuePlaying
49
+ }
50
+ }
51
+ }
52
+
53
+ // MARK: - LottieLoopMode
54
+
55
+ /// Defines animation loop behavior
56
+ public enum LottieLoopMode: Hashable {
57
+ /// Animation is played once then stops.
58
+ case playOnce
59
+ /// Animation will loop from beginning to end until stopped.
60
+ case loop
61
+ /// Animation will play forward, then backwards and loop until stopped.
62
+ case autoReverse
63
+ /// Animation will loop from beginning to end up to defined amount of times.
64
+ case `repeat`(Float)
65
+ /// Animation will play forward, then backwards a defined amount of times.
66
+ case repeatBackwards(Float)
67
+ }
68
+
69
+ // MARK: Equatable
70
+
71
+ extension LottieLoopMode: Equatable {
72
+ public static func ==(lhs: LottieLoopMode, rhs: LottieLoopMode) -> Bool {
73
+ switch (lhs, rhs) {
74
+ case (.repeat(let lhsAmount), .repeat(let rhsAmount)),
75
+ (.repeatBackwards(let lhsAmount), .repeatBackwards(let rhsAmount)):
76
+ lhsAmount == rhsAmount
77
+ case (.playOnce, .playOnce),
78
+ (.loop, .loop),
79
+ (.autoReverse, .autoReverse):
80
+ true
81
+ default:
82
+ false
83
+ }
84
+ }
85
+ }
86
+
87
+ // MARK: - LottieAnimationView
88
+
89
+ /// A UIView subclass for rendering Lottie animations.
90
+ /// - Also available as a SwiftUI view (`LottieView`) and a CALayer subclass (`LottieAnimationLayer`)
91
+ @IBDesignable
92
+ open class LottieAnimationView: LottieAnimationViewBase {
93
+
94
+ // MARK: Lifecycle
95
+
96
+ /// Initializes an AnimationView with an animation.
97
+ public init(
98
+ animation: LottieAnimation?,
99
+ imageProvider: AnimationImageProvider? = nil,
100
+ textProvider: AnimationKeypathTextProvider = DefaultTextProvider(),
101
+ fontProvider: AnimationFontProvider = DefaultFontProvider(),
102
+ configuration: LottieConfiguration = .shared,
103
+ logger: LottieLogger = .shared
104
+ ) {
105
+ lottieAnimationLayer = LottieAnimationLayer(
106
+ animation: animation,
107
+ imageProvider: imageProvider,
108
+ textProvider: textProvider,
109
+ fontProvider: fontProvider,
110
+ configuration: configuration,
111
+ logger: logger
112
+ )
113
+ self.logger = logger
114
+ super.init(frame: .zero)
115
+ commonInit()
116
+ if let animation {
117
+ frame = animation.bounds
118
+ }
119
+ }
120
+
121
+ /// Initializes an AnimationView with a .lottie file.
122
+ public init(
123
+ dotLottie: DotLottieFile?,
124
+ animationId: String? = nil,
125
+ textProvider: AnimationKeypathTextProvider = DefaultTextProvider(),
126
+ fontProvider: AnimationFontProvider = DefaultFontProvider(),
127
+ configuration: LottieConfiguration = .shared,
128
+ logger: LottieLogger = .shared
129
+ ) {
130
+ lottieAnimationLayer = LottieAnimationLayer(
131
+ dotLottie: dotLottie,
132
+ animationId: animationId,
133
+ textProvider: textProvider,
134
+ fontProvider: fontProvider,
135
+ configuration: configuration,
136
+ logger: logger
137
+ )
138
+ self.logger = logger
139
+ super.init(frame: .zero)
140
+ commonInit()
141
+ if let animation {
142
+ frame = animation.bounds
143
+ }
144
+ }
145
+
146
+ public init(
147
+ configuration: LottieConfiguration = .shared,
148
+ logger: LottieLogger = .shared
149
+ ) {
150
+ lottieAnimationLayer = LottieAnimationLayer(configuration: configuration, logger: logger)
151
+ self.logger = logger
152
+ super.init(frame: .zero)
153
+ commonInit()
154
+ }
155
+
156
+ public override init(frame: CGRect) {
157
+ lottieAnimationLayer = LottieAnimationLayer(
158
+ animation: nil,
159
+ imageProvider: BundleImageProvider(bundle: Bundle.main, searchPath: nil),
160
+ textProvider: DefaultTextProvider(),
161
+ fontProvider: DefaultFontProvider(),
162
+ configuration: .shared,
163
+ logger: .shared
164
+ )
165
+ logger = .shared
166
+ super.init(frame: frame)
167
+ commonInit()
168
+ }
169
+
170
+ required public init?(coder aDecoder: NSCoder) {
171
+ lottieAnimationLayer = LottieAnimationLayer(
172
+ animation: nil,
173
+ imageProvider: BundleImageProvider(bundle: Bundle.main, searchPath: nil),
174
+ textProvider: DefaultTextProvider(),
175
+ fontProvider: DefaultFontProvider(),
176
+ configuration: .shared,
177
+ logger: .shared
178
+ )
179
+ logger = .shared
180
+ super.init(coder: aDecoder)
181
+ commonInit()
182
+ }
183
+
184
+ convenience init(
185
+ animationSource: LottieAnimationSource?,
186
+ imageProvider: AnimationImageProvider? = nil,
187
+ textProvider: AnimationKeypathTextProvider = DefaultTextProvider(),
188
+ fontProvider: AnimationFontProvider = DefaultFontProvider(),
189
+ configuration: LottieConfiguration = .shared,
190
+ logger: LottieLogger = .shared
191
+ ) {
192
+ switch animationSource {
193
+ case .lottieAnimation(let animation):
194
+ self.init(
195
+ animation: animation,
196
+ imageProvider: imageProvider,
197
+ textProvider: textProvider,
198
+ fontProvider: fontProvider,
199
+ configuration: configuration,
200
+ logger: logger
201
+ )
202
+
203
+ case .dotLottieFile(let dotLottieFile):
204
+ self.init(
205
+ dotLottie: dotLottieFile,
206
+ textProvider: textProvider,
207
+ fontProvider: fontProvider,
208
+ configuration: configuration,
209
+ logger: logger
210
+ )
211
+
212
+ case nil:
213
+ self.init(
214
+ animation: nil,
215
+ imageProvider: imageProvider,
216
+ textProvider: textProvider,
217
+ fontProvider: fontProvider,
218
+ configuration: configuration,
219
+ logger: logger
220
+ )
221
+ }
222
+ }
223
+
224
+ // MARK: Open
225
+
226
+ /// Applies the given `LottiePlaybackMode` to this layer.
227
+ /// - Parameter completion: A closure that is called after
228
+ /// an animation triggered by this method completes.
229
+ open func play(_ mode: LottiePlaybackMode.PlaybackMode, completion: LottieCompletionBlock? = nil) {
230
+ lottieAnimationLayer.play(mode, completion: completion)
231
+ }
232
+
233
+ /// Plays the animation from its current state to the end.
234
+ ///
235
+ /// - Parameter completion: An optional completion closure to be called when the animation completes playing.
236
+ open func play(completion: LottieCompletionBlock? = nil) {
237
+ lottieAnimationLayer.play(completion: completion)
238
+ }
239
+
240
+ /// Plays the animation from a progress (0-1) to a progress (0-1).
241
+ ///
242
+ /// - Parameter fromProgress: The start progress of the animation. If `nil` the animation will start at the current progress.
243
+ /// - Parameter toProgress: The end progress of the animation.
244
+ /// - Parameter loopMode: The loop behavior of the animation. If `nil` the view's `loopMode` property will be used.
245
+ /// - Parameter completion: An optional completion closure to be called when the animation stops.
246
+ open func play(
247
+ fromProgress: AnimationProgressTime? = nil,
248
+ toProgress: AnimationProgressTime,
249
+ loopMode: LottieLoopMode? = nil,
250
+ completion: LottieCompletionBlock? = nil
251
+ ) {
252
+ lottieAnimationLayer.play(fromProgress: fromProgress, toProgress: toProgress, loopMode: loopMode, completion: completion)
253
+ }
254
+
255
+ /// Plays the animation from a start frame to an end frame in the animation's framerate.
256
+ ///
257
+ /// - Parameter fromFrame: The start frame of the animation. If `nil` the animation will start at the current frame.
258
+ /// - Parameter toFrame: The end frame of the animation.
259
+ /// - Parameter loopMode: The loop behavior of the animation. If `nil` the view's `loopMode` property will be used.
260
+ /// - Parameter completion: An optional completion closure to be called when the animation stops.
261
+ open func play(
262
+ fromFrame: AnimationFrameTime? = nil,
263
+ toFrame: AnimationFrameTime,
264
+ loopMode: LottieLoopMode? = nil,
265
+ completion: LottieCompletionBlock? = nil
266
+ ) {
267
+ lottieAnimationLayer.play(fromFrame: fromFrame, toFrame: toFrame, loopMode: loopMode, completion: completion)
268
+ }
269
+
270
+ /// Plays the animation from a named marker to another marker.
271
+ ///
272
+ /// Markers are point in time that are encoded into the Animation data and assigned
273
+ /// a name.
274
+ ///
275
+ /// NOTE: If markers are not found the play command will exit.
276
+ ///
277
+ /// - Parameter fromMarker: The start marker for the animation playback. If `nil` the
278
+ /// animation will start at the current progress.
279
+ /// - Parameter toMarker: The end marker for the animation playback.
280
+ /// - Parameter playEndMarkerFrame: A flag to determine whether or not to play the frame of the end marker. If the
281
+ /// end marker represents the end of the section to play, it should be to true. If the provided end marker
282
+ /// represents the beginning of the next section, it should be false.
283
+ /// - Parameter loopMode: The loop behavior of the animation. If `nil` the view's `loopMode` property will be used.
284
+ /// - Parameter completion: An optional completion closure to be called when the animation stops.
285
+ open func play(
286
+ fromMarker: String? = nil,
287
+ toMarker: String,
288
+ playEndMarkerFrame: Bool = true,
289
+ loopMode: LottieLoopMode? = nil,
290
+ completion: LottieCompletionBlock? = nil
291
+ ) {
292
+ lottieAnimationLayer.play(
293
+ fromMarker: fromMarker,
294
+ toMarker: toMarker,
295
+ playEndMarkerFrame: playEndMarkerFrame,
296
+ loopMode: loopMode,
297
+ completion: completion
298
+ )
299
+ }
300
+
301
+ /// Plays the animation from a named marker to the end of the marker's duration.
302
+ ///
303
+ /// A marker is a point in time with an associated duration that is encoded into the
304
+ /// animation data and assigned a name.
305
+ ///
306
+ /// NOTE: If marker is not found the play command will exit.
307
+ ///
308
+ /// - Parameter marker: The start marker for the animation playback.
309
+ /// - Parameter loopMode: The loop behavior of the animation. If `nil` the view's `loopMode` property will be used.
310
+ /// - Parameter completion: An optional completion closure to be called when the animation stops.
311
+ open func play(
312
+ marker: String,
313
+ loopMode: LottieLoopMode? = nil,
314
+ completion: LottieCompletionBlock? = nil
315
+ ) {
316
+ lottieAnimationLayer.play(marker: marker, loopMode: loopMode, completion: completion)
317
+ }
318
+
319
+ /// Plays the given markers sequentially in order.
320
+ ///
321
+ /// A marker is a point in time with an associated duration that is encoded into the
322
+ /// animation data and assigned a name. Multiple markers can be played sequentially
323
+ /// to create programmable animations.
324
+ ///
325
+ /// If a marker is not found, it will be skipped.
326
+ ///
327
+ /// If a marker doesn't have a duration value, it will play with a duration of 0
328
+ /// (effectively being skipped).
329
+ ///
330
+ /// If another animation is played (by calling any `play` method) while this
331
+ /// marker sequence is playing, the marker sequence will be cancelled.
332
+ ///
333
+ /// - Parameter markers: The list of markers to play sequentially.
334
+ /// - Parameter completion: An optional completion closure to be called when the animation stops.
335
+ open func play(
336
+ markers: [String],
337
+ completion: LottieCompletionBlock? = nil
338
+ ) {
339
+ lottieAnimationLayer.play(markers: markers, completion: completion)
340
+ }
341
+
342
+ /// Stops the animation and resets the view to its start frame.
343
+ ///
344
+ /// The completion closure will be called with `false`
345
+ open func stop() {
346
+ lottieAnimationLayer.stop()
347
+ }
348
+
349
+ /// Pauses the animation in its current state.
350
+ ///
351
+ /// The completion closure will be called with `false`
352
+ open func pause() {
353
+ lottieAnimationLayer.pause()
354
+ }
355
+
356
+ @available(*, deprecated, renamed: "setPlaybackMode(_:completion:)", message: "Will be removed in a future major release.")
357
+ open func play(
358
+ _ playbackMode: LottiePlaybackMode,
359
+ animationCompletionHandler: LottieCompletionBlock? = nil
360
+ ) {
361
+ lottieAnimationLayer.setPlaybackMode(playbackMode, completion: animationCompletionHandler)
362
+ }
363
+
364
+ /// Applies the given `LottiePlaybackMode` to this layer.
365
+ /// - Parameter completion: A closure that is called after
366
+ /// an animation triggered by this method completes.
367
+ open func setPlaybackMode(
368
+ _ playbackMode: LottiePlaybackMode,
369
+ completion: LottieCompletionBlock? = nil
370
+ ) {
371
+ lottieAnimationLayer.setPlaybackMode(playbackMode, completion: completion)
372
+ }
373
+
374
+ // MARK: Public
375
+
376
+ /// Whether or not transform and position changes of the view should animate alongside
377
+ /// any existing animation context.
378
+ /// - Defaults to `true` which will grab the current animation context and animate position and
379
+ /// transform changes matching the current context's curve and duration.
380
+ /// `false` will cause transform and position changes to happen unanimated
381
+ public var animateLayoutChangesWithCurrentCoreAnimationContext = true
382
+
383
+ /// Behavior when the view is added to or removed from the window hierarchy.
384
+ ///
385
+ /// Views may be removed from the window hierarchy in scenarios such as:
386
+ /// - SwiftUI navigation (`NavigationStack`, `TabView`, `LazyVStack`, sheets)
387
+ /// - `UICollectionView` / `UITableView` cell reuse
388
+ /// - `UIPageViewController` page transitions
389
+ /// - Custom container view controllers
390
+ ///
391
+ /// By default, this uses the same value as `backgroundBehavior`. Set this property
392
+ /// when you need different behavior for window attachment changes versus app
393
+ /// foreground/background transitions.
394
+ ///
395
+ /// For example, use `.continuePlaying` here with the Core Animation rendering engine
396
+ /// if you want animations to seamlessly resume after navigation, while still using
397
+ /// a different `backgroundBehavior` for app background transitions.
398
+ public var windowBackgroundBehavior: LottieBackgroundBehavior?
399
+
400
+ /// The configuration that this `LottieAnimationView` uses when playing its animation
401
+ public var configuration: LottieConfiguration {
402
+ get { lottieAnimationLayer.configuration }
403
+ set { lottieAnimationLayer.configuration = newValue }
404
+ }
405
+
406
+ /// Value Providers that have been registered using `setValueProvider(_:keypath:)`
407
+ public var valueProviders: [AnimationKeypath: AnyValueProvider] {
408
+ lottieAnimationLayer.valueProviders
409
+ }
410
+
411
+ /// Describes the behavior of an AnimationView when the app is moved to the background.
412
+ ///
413
+ /// The default for the Main Thread animation engine is `pause`,
414
+ /// which pauses the animation when the application moves to
415
+ /// the background. This prevents the animation from consuming CPU
416
+ /// resources when not on-screen. The completion block is called with
417
+ /// `false` for completed.
418
+ ///
419
+ /// The default for the Core Animation engine is `continuePlaying`,
420
+ /// since the Core Animation engine does not have any CPU overhead.
421
+ public var backgroundBehavior: LottieBackgroundBehavior {
422
+ get { lottieAnimationLayer.backgroundBehavior }
423
+ set { lottieAnimationLayer.backgroundBehavior = newValue }
424
+ }
425
+
426
+ /// Sets the animation backing the animation view. Setting this will clear the
427
+ /// view's contents, completion blocks and current state. The new animation will
428
+ /// be loaded up and set to the beginning of its timeline.
429
+ public var animation: LottieAnimation? {
430
+ get { lottieAnimationLayer.animation }
431
+ set { lottieAnimationLayer.animation = newValue }
432
+ }
433
+
434
+ /// A closure that is called when `self.animation` is loaded. When setting this closure,
435
+ /// it is called immediately if `self.animation` is non-nil.
436
+ ///
437
+ /// When initializing a `LottieAnimationView`, the animation will either be loaded
438
+ /// synchronously (when loading a `LottieAnimation` from a .json file on disk)
439
+ /// or asynchronously (when loading a `DotLottieFile` from disk, or downloading
440
+ /// an animation from a URL). This closure is called in both cases once the
441
+ /// animation is loaded and applied, so can be a useful way to configure this
442
+ /// `LottieAnimationView` regardless of which initializer was used. For example:
443
+ ///
444
+ /// ```
445
+ /// let animationView: LottieAnimationView
446
+ ///
447
+ /// if loadDotLottieFile {
448
+ /// // Loads the .lottie file asynchronously
449
+ /// animationView = LottieAnimationView(dotLottieName: "animation")
450
+ /// } else {
451
+ /// // Loads the .json file synchronously
452
+ /// animationView = LottieAnimationView(name: "animation")
453
+ /// }
454
+ ///
455
+ /// animationView.animationLoaded = { animationView, animation in
456
+ /// // If using a .lottie file, this is called once the file finishes loading.
457
+ /// // If using a .json file, this is called immediately (since the animation is loaded synchronously).
458
+ /// animationView.play()
459
+ /// }
460
+ /// ```
461
+ public var animationLoaded: ((_ animationView: LottieAnimationView, _ animation: LottieAnimation) -> Void)? {
462
+ didSet {
463
+ if let animation {
464
+ animationLoaded?(self, animation)
465
+ }
466
+ }
467
+ }
468
+
469
+ /// Sets the image provider for the animation view. An image provider provides the
470
+ /// animation with its required image data.
471
+ ///
472
+ /// Setting this will cause the animation to reload its image contents.
473
+ public var imageProvider: AnimationImageProvider {
474
+ get { lottieAnimationLayer.imageProvider }
475
+ set { lottieAnimationLayer.imageProvider = newValue }
476
+ }
477
+
478
+ /// Sets the text provider for animation view. A text provider provides the
479
+ /// animation with values for text layers
480
+ public var textProvider: AnimationKeypathTextProvider {
481
+ get { lottieAnimationLayer.textProvider }
482
+ set { lottieAnimationLayer.textProvider = newValue }
483
+ }
484
+
485
+ /// Sets the text provider for animation view. A text provider provides the
486
+ /// animation with values for text layers
487
+ public var fontProvider: AnimationFontProvider {
488
+ get { lottieAnimationLayer.fontProvider }
489
+ set { lottieAnimationLayer.fontProvider = newValue }
490
+ }
491
+
492
+ /// Whether or not the animation is masked to the bounds. Defaults to true.
493
+ public var maskAnimationToBounds: Bool {
494
+ get { lottieAnimationLayer.maskAnimationToBounds }
495
+ set { lottieAnimationLayer.maskAnimationToBounds = newValue }
496
+ }
497
+
498
+ /// Returns `true` if the animation is currently playing.
499
+ public var isAnimationPlaying: Bool {
500
+ lottieAnimationLayer.isAnimationPlaying
501
+ }
502
+
503
+ /// Returns `true` if the animation will start playing when this view is added to a window.
504
+ public var isAnimationQueued: Bool {
505
+ lottieAnimationLayer.hasAnimationContext && waitingToPlayAnimation
506
+ }
507
+
508
+ /// Sets the loop behavior for `play` calls. Defaults to `playOnce`
509
+ public var loopMode: LottieLoopMode {
510
+ get { lottieAnimationLayer.loopMode }
511
+ set { lottieAnimationLayer.loopMode = newValue }
512
+ }
513
+
514
+ /// When `true` the animation view will rasterize its contents when not animating.
515
+ /// Rasterizing will improve performance of static animations.
516
+ ///
517
+ /// Note: this will not produce crisp results at resolutions above the animations natural resolution.
518
+ ///
519
+ /// Defaults to `false`
520
+ public var shouldRasterizeWhenIdle: Bool {
521
+ get { lottieAnimationLayer.shouldRasterizeWhenIdle }
522
+ set { lottieAnimationLayer.shouldRasterizeWhenIdle = newValue }
523
+ }
524
+
525
+ /// Sets the current animation time with a Progress Time
526
+ ///
527
+ /// Note: Setting this will stop the current animation, if any.
528
+ /// Note 2: If `animation` is nil, setting this will fallback to 0
529
+ public var currentProgress: AnimationProgressTime {
530
+ get { lottieAnimationLayer.currentProgress }
531
+ set { lottieAnimationLayer.currentProgress = newValue }
532
+ }
533
+
534
+ /// Sets the current animation time with a time in seconds.
535
+ ///
536
+ /// Note: Setting this will stop the current animation, if any.
537
+ /// Note 2: If `animation` is nil, setting this will fallback to 0
538
+ public var currentTime: TimeInterval {
539
+ get { lottieAnimationLayer.currentTime }
540
+ set { lottieAnimationLayer.currentTime = newValue }
541
+ }
542
+
543
+ /// Sets the current animation time with a frame in the animations framerate.
544
+ ///
545
+ /// Note: Setting this will stop the current animation, if any.
546
+ public var currentFrame: AnimationFrameTime {
547
+ get { lottieAnimationLayer.currentFrame }
548
+ set { lottieAnimationLayer.currentFrame = newValue }
549
+ }
550
+
551
+ /// Returns the current animation frame while an animation is playing.
552
+ public var realtimeAnimationFrame: AnimationFrameTime {
553
+ lottieAnimationLayer.realtimeAnimationFrame
554
+ }
555
+
556
+ /// Returns the current animation frame while an animation is playing.
557
+ public var realtimeAnimationProgress: AnimationProgressTime {
558
+ lottieAnimationLayer.realtimeAnimationProgress
559
+ }
560
+
561
+ /// Sets the speed of the animation playback. Defaults to 1
562
+ public var animationSpeed: CGFloat {
563
+ get { lottieAnimationLayer.animationSpeed }
564
+ set { lottieAnimationLayer.animationSpeed = newValue }
565
+ }
566
+
567
+ /// When `true` the animation will play back at the framerate encoded in the
568
+ /// `LottieAnimation` model. When `false` the animation will play at the framerate
569
+ /// of the device.
570
+ ///
571
+ /// Defaults to false
572
+ public var respectAnimationFrameRate: Bool {
573
+ get { lottieAnimationLayer.respectAnimationFrameRate }
574
+ set { lottieAnimationLayer.respectAnimationFrameRate = newValue }
575
+ }
576
+
577
+ /// Controls the cropping of an Animation. Setting this property will crop the animation
578
+ /// to the current views bounds by the viewport frame. The coordinate space is specified
579
+ /// in the animation's coordinate space.
580
+ ///
581
+ /// Animatable.
582
+ public var viewportFrame: CGRect? {
583
+ didSet {
584
+ // This is really ugly, but is needed to trigger a layout pass within an animation block.
585
+ // Typically this happens automatically, when layout objects are UIView based.
586
+ // The animation layer is a CALayer which will not implicitly grab the animation
587
+ // duration of a UIView animation block.
588
+ //
589
+ // By setting bounds and then resetting bounds the UIView animation block's
590
+ // duration and curve are captured and added to the layer. This is used in the
591
+ // layout block to animate the animationLayer's position and size.
592
+ let rect = bounds
593
+ bounds = CGRect.zero
594
+ bounds = rect
595
+ setNeedsLayout()
596
+ }
597
+ }
598
+
599
+ override public var intrinsicContentSize: CGSize {
600
+ if let animation = lottieAnimationLayer.animation {
601
+ return animation.bounds.size
602
+ }
603
+ return .zero
604
+ }
605
+
606
+ /// The rendering engine currently being used by this view.
607
+ /// - This will only be `nil` in cases where the configuration is `automatic`
608
+ /// but a `RootAnimationLayer` hasn't been constructed yet
609
+ public var currentRenderingEngine: RenderingEngine? {
610
+ lottieAnimationLayer.currentRenderingEngine
611
+ }
612
+
613
+ /// The current `LottiePlaybackMode` that is being used
614
+ public var currentPlaybackMode: LottiePlaybackMode? {
615
+ lottieAnimationLayer.currentPlaybackMode
616
+ }
617
+
618
+ /// Whether or not the Main Thread rendering engine should use `forceDisplayUpdate()`
619
+ /// when rendering each individual frame.
620
+ /// - The main thread rendering engine implements optimizations to decrease the amount
621
+ /// of properties that have to be re-rendered on each frame. There are some cases
622
+ /// where this can result in bugs / incorrect behavior, so we allow it to be disabled.
623
+ /// - Forcing a full render on every frame will decrease performance, and is not recommended
624
+ /// except as a workaround to a bug in the main thread rendering engine.
625
+ /// - Has no effect when using the Core Animation rendering engine.
626
+ public var mainThreadRenderingEngineShouldForceDisplayUpdateOnEachFrame: Bool {
627
+ get { lottieAnimationLayer.mainThreadRenderingEngineShouldForceDisplayUpdateOnEachFrame }
628
+ set { lottieAnimationLayer.mainThreadRenderingEngineShouldForceDisplayUpdateOnEachFrame = newValue }
629
+ }
630
+
631
+ /// Sets the lottie file backing the animation view. Setting this will clear the
632
+ /// view's contents, completion blocks and current state. The new animation will
633
+ /// be loaded up and set to the beginning of its timeline.
634
+ /// The loopMode, animationSpeed and imageProvider will be set according
635
+ /// to lottie file settings
636
+ /// - Parameters:
637
+ /// - animationId: Internal animation id to play. Optional
638
+ /// Defaults to play first animation in file.
639
+ /// - dotLottieFile: Lottie file to play
640
+ public func loadAnimation(
641
+ _ animationId: String? = nil,
642
+ from dotLottieFile: DotLottieFile
643
+ ) {
644
+ lottieAnimationLayer.loadAnimation(animationId, from: dotLottieFile)
645
+ }
646
+
647
+ /// Sets the lottie file backing the animation view. Setting this will clear the
648
+ /// view's contents, completion blocks and current state. The new animation will
649
+ /// be loaded up and set to the beginning of its timeline.
650
+ /// The loopMode, animationSpeed and imageProvider will be set according
651
+ /// to lottie file settings
652
+ /// - Parameters:
653
+ /// - atIndex: Internal animation index to play. Optional
654
+ /// Defaults to play first animation in file.
655
+ /// - dotLottieFile: Lottie file to play
656
+ public func loadAnimation(
657
+ atIndex index: Int,
658
+ from dotLottieFile: DotLottieFile
659
+ ) {
660
+ lottieAnimationLayer.loadAnimation(atIndex: index, from: dotLottieFile)
661
+ }
662
+
663
+ /// Reloads the images supplied to the animation from the `imageProvider`
664
+ public func reloadImages() {
665
+ lottieAnimationLayer.reloadImages()
666
+ }
667
+
668
+ /// Forces the LottieAnimationView to redraw its contents.
669
+ public func forceDisplayUpdate() {
670
+ lottieAnimationLayer.forceDisplayUpdate()
671
+ }
672
+
673
+ /// Sets a ValueProvider for the specified keypath. The value provider will be set
674
+ /// on all properties that match the keypath.
675
+ ///
676
+ /// Nearly all properties of a Lottie animation can be changed at runtime using a
677
+ /// combination of `Animation Keypaths` and `Value Providers`.
678
+ /// Setting a ValueProvider on a keypath will cause the animation to update its
679
+ /// contents and read the new Value Provider.
680
+ ///
681
+ /// A value provider provides a typed value on a frame by frame basis.
682
+ ///
683
+ /// - Parameter valueProvider: The new value provider for the properties.
684
+ /// - Parameter keypath: The keypath used to search for properties.
685
+ ///
686
+ /// Example:
687
+ /// ```
688
+ /// /// A keypath that finds the color value for all `Fill 1` nodes.
689
+ /// let fillKeypath = AnimationKeypath(keypath: "**.Fill 1.Color")
690
+ /// /// A Color Value provider that returns a reddish color.
691
+ /// let redValueProvider = ColorValueProvider(Color(r: 1, g: 0.2, b: 0.3, a: 1))
692
+ /// /// Set the provider on the animationView.
693
+ /// animationView.setValueProvider(redValueProvider, keypath: fillKeypath)
694
+ /// ```
695
+ public func setValueProvider(_ valueProvider: AnyValueProvider, keypath: AnimationKeypath) {
696
+ lottieAnimationLayer.setValueProvider(valueProvider, keypath: keypath)
697
+ }
698
+
699
+ /// Sets a ValueProvider for the specified keypath. The value provider will be removed
700
+ /// on all properties that match the keypath.
701
+ public func removeValueProvider(for keypath: AnimationKeypath) {
702
+ lottieAnimationLayer.removeValueProvider(for: keypath)
703
+ }
704
+
705
+ /// Reads the value of a property specified by the Keypath.
706
+ /// Returns nil if no property is found.
707
+ ///
708
+ /// Note: This method isn't supported by the Core Animation rendering engine and will always return `nil` if used.
709
+ /// It is still supported by the Main Thread rendering engine.
710
+ ///
711
+ /// - Parameter for: The keypath used to search for the property.
712
+ /// - Parameter atFrame: The Frame Time of the value to query. If nil then the current frame is used.
713
+ public func getValue(for keypath: AnimationKeypath, atFrame: AnimationFrameTime?) -> Any? {
714
+ lottieAnimationLayer.getValue(for: keypath, atFrame: atFrame)
715
+ }
716
+
717
+ /// Reads the original value of a property specified by the Keypath.
718
+ /// This will ignore any value providers and can be useful when implementing a value providers that makes change to the original value from the animation.
719
+ /// Returns nil if no property is found.
720
+ ///
721
+ /// - Parameter for: The keypath used to search for the property.
722
+ /// - Parameter atFrame: The Frame Time of the value to query. If nil then the current frame is used.
723
+ public func getOriginalValue(for keypath: AnimationKeypath, atFrame: AnimationFrameTime?) -> Any? {
724
+ lottieAnimationLayer.getOriginalValue(for: keypath, atFrame: atFrame)
725
+ }
726
+
727
+ /// Logs all child keypaths.
728
+ /// Logs the result of `allHierarchyKeypaths()` to the `LottieLogger`.
729
+ public func logHierarchyKeypaths() {
730
+ lottieAnimationLayer.logHierarchyKeypaths()
731
+ }
732
+
733
+ /// Computes and returns a list of all child keypaths in the current animation.
734
+ /// The returned list is the same as the log output of `logHierarchyKeypaths()`
735
+ public func allHierarchyKeypaths() -> [String] {
736
+ lottieAnimationLayer.allHierarchyKeypaths()
737
+ }
738
+
739
+ /// Searches for the nearest child layer to the first Keypath and adds the subview
740
+ /// to that layer. The subview will move and animate with the child layer.
741
+ /// Furthermore the subview will be in the child layers coordinate space.
742
+ ///
743
+ /// Note: if no layer is found for the keypath, then nothing happens.
744
+ ///
745
+ /// - Parameter subview: The subview to add to the found animation layer.
746
+ /// - Parameter keypath: The keypath used to find the animation layer.
747
+ ///
748
+ /// Example:
749
+ /// ```
750
+ /// /// A keypath that finds `Layer 1`
751
+ /// let layerKeypath = AnimationKeypath(keypath: "Layer 1")
752
+ ///
753
+ /// /// Wrap the custom view in an `AnimationSubview`
754
+ /// let subview = AnimationSubview()
755
+ /// subview.addSubview(customView)
756
+ ///
757
+ /// /// Set the provider on the animationView.
758
+ /// animationView.addSubview(subview, forLayerAt: layerKeypath)
759
+ /// ```
760
+ public func addSubview(_ subview: AnimationSubview, forLayerAt keypath: AnimationKeypath) {
761
+ guard let sublayer = lottieAnimationLayer.rootAnimationLayer?.layer(for: keypath) else {
762
+ return
763
+ }
764
+ setNeedsLayout()
765
+ layoutIfNeeded()
766
+ lottieAnimationLayer.forceDisplayUpdate()
767
+ addSubview(subview)
768
+ if let subViewLayer = subview.viewLayer {
769
+ sublayer.addSublayer(subViewLayer)
770
+ }
771
+ }
772
+
773
+ /// Converts a CGRect from the LottieAnimationView's coordinate space into the
774
+ /// coordinate space of the layer found at Keypath.
775
+ ///
776
+ /// If no layer is found, nil is returned
777
+ ///
778
+ /// - Parameter rect: The CGRect to convert.
779
+ /// - Parameter toLayerAt: The keypath used to find the layer.
780
+ public func convert(_ rect: CGRect, toLayerAt keypath: AnimationKeypath?) -> CGRect? {
781
+ let convertedRect = lottieAnimationLayer.convert(rect, toLayerAt: keypath)
782
+ setNeedsLayout()
783
+ layoutIfNeeded()
784
+ return convertedRect
785
+ }
786
+
787
+ /// Converts a CGPoint from the LottieAnimationView's coordinate space into the
788
+ /// coordinate space of the layer found at Keypath.
789
+ ///
790
+ /// If no layer is found, nil is returned
791
+ ///
792
+ /// - Parameter point: The CGPoint to convert.
793
+ /// - Parameter toLayerAt: The keypath used to find the layer.
794
+ public func convert(_ point: CGPoint, toLayerAt keypath: AnimationKeypath?) -> CGPoint? {
795
+ let convertedRect = lottieAnimationLayer.convert(point, toLayerAt: keypath)
796
+ setNeedsLayout()
797
+ layoutIfNeeded()
798
+ return convertedRect
799
+ }
800
+
801
+ /// Sets the enabled state of all animator nodes found with the keypath search.
802
+ /// This can be used to interactively enable / disable parts of the animation.
803
+ ///
804
+ /// - Parameter isEnabled: When true the animator nodes affect the rendering tree. When false the node is removed from the tree.
805
+ /// - Parameter keypath: The keypath used to find the node(s).
806
+ public func setNodeIsEnabled(isEnabled: Bool, keypath: AnimationKeypath) {
807
+ lottieAnimationLayer.setNodeIsEnabled(isEnabled: isEnabled, keypath: keypath)
808
+ }
809
+
810
+ /// Markers are a way to describe a point in time by a key name.
811
+ ///
812
+ /// Markers are encoded into animation JSON. By using markers a designer can mark
813
+ /// playback points for a developer to use without having to worry about keeping
814
+ /// track of animation frames. If the animation file is updated, the developer
815
+ /// does not need to update playback code.
816
+ ///
817
+ /// Returns the Progress Time for the marker named. Returns nil if no marker found.
818
+ public func progressTime(forMarker named: String) -> AnimationProgressTime? {
819
+ lottieAnimationLayer.progressTime(forMarker: named)
820
+ }
821
+
822
+ /// Markers are a way to describe a point in time by a key name.
823
+ ///
824
+ /// Markers are encoded into animation JSON. By using markers a designer can mark
825
+ /// playback points for a developer to use without having to worry about keeping
826
+ /// track of animation frames. If the animation file is updated, the developer
827
+ /// does not need to update playback code.
828
+ ///
829
+ /// Returns the Frame Time for the marker named. Returns nil if no marker found.
830
+ public func frameTime(forMarker named: String) -> AnimationFrameTime? {
831
+ lottieAnimationLayer.frameTime(forMarker: named)
832
+ }
833
+
834
+ /// Markers are a way to describe a point in time and a duration by a key name.
835
+ ///
836
+ /// Markers are encoded into animation JSON. By using markers a designer can mark
837
+ /// playback points for a developer to use without having to worry about keeping
838
+ /// track of animation frames. If the animation file is updated, the developer
839
+ /// does not need to update playback code.
840
+ ///
841
+ /// - Returns: The duration frame time for the marker, or `nil` if no marker found.
842
+ public func durationFrameTime(forMarker named: String) -> AnimationFrameTime? {
843
+ lottieAnimationLayer.durationFrameTime(forMarker: named)
844
+ }
845
+
846
+ // MARK: Internal
847
+
848
+ /// The backing CALayer for this animation view.
849
+ let lottieAnimationLayer: LottieAnimationLayer
850
+
851
+ var animationLayer: RootAnimationLayer? {
852
+ lottieAnimationLayer.rootAnimationLayer
853
+ }
854
+
855
+ /// Set animation name from Interface Builder
856
+ @IBInspectable var animationName: String? {
857
+ didSet {
858
+ lottieAnimationLayer.animation = animationName.flatMap { LottieAnimation.named($0, animationCache: nil)
859
+ }
860
+ }
861
+ }
862
+
863
+ override func commonInit() {
864
+ super.commonInit()
865
+ lottieAnimationLayer.screenScale = screenScale
866
+ viewLayer?.addSublayer(lottieAnimationLayer)
867
+
868
+ lottieAnimationLayer.animationLoaded = { [weak self] _, animation in
869
+ guard let self else { return }
870
+ animationLoaded?(self, animation)
871
+ invalidateIntrinsicContentSize()
872
+ setNeedsLayout()
873
+ }
874
+
875
+ lottieAnimationLayer.animationLayerDidLoad = { [weak self] _, _ in
876
+ guard let self else { return }
877
+ invalidateIntrinsicContentSize()
878
+ setNeedsLayout()
879
+ }
880
+ }
881
+
882
+ override func layoutAnimation() {
883
+ guard let animation = lottieAnimationLayer.animation, let animationLayer = lottieAnimationLayer.animationLayer else { return }
884
+
885
+ var position = animation.bounds.center
886
+ let xform: CATransform3D
887
+ var shouldForceUpdates = false
888
+
889
+ if let viewportFrame {
890
+ shouldForceUpdates = contentMode == .redraw
891
+
892
+ let compAspect = viewportFrame.size.width / viewportFrame.size.height
893
+ let viewAspect = bounds.size.width / bounds.size.height
894
+ let dominantDimension = compAspect > viewAspect ? bounds.size.width : bounds.size.height
895
+ let compDimension = compAspect > viewAspect ? viewportFrame.size.width : viewportFrame.size.height
896
+ let scale = dominantDimension / compDimension
897
+
898
+ let viewportOffset = animation.bounds.center - viewportFrame.center
899
+ xform = CATransform3DTranslate(CATransform3DMakeScale(scale, scale, 1), viewportOffset.x, viewportOffset.y, 0)
900
+ position = bounds.center
901
+ } else {
902
+ switch contentMode {
903
+ case .scaleToFill:
904
+ position = bounds.center
905
+ xform = CATransform3DMakeScale(
906
+ bounds.size.width / animation.size.width,
907
+ bounds.size.height / animation.size.height,
908
+ 1
909
+ )
910
+ case .scaleAspectFit:
911
+ position = bounds.center
912
+ let compAspect = animation.size.width / animation.size.height
913
+ let viewAspect = bounds.size.width / bounds.size.height
914
+ let dominantDimension = compAspect > viewAspect ? bounds.size.width : bounds.size.height
915
+ let compDimension = compAspect > viewAspect ? animation.size.width : animation.size.height
916
+ let scale = dominantDimension / compDimension
917
+ xform = CATransform3DMakeScale(scale, scale, 1)
918
+ case .scaleAspectFill:
919
+ position = bounds.center
920
+ let compAspect = animation.size.width / animation.size.height
921
+ let viewAspect = bounds.size.width / bounds.size.height
922
+ let scaleWidth = compAspect < viewAspect
923
+ let dominantDimension = scaleWidth ? bounds.size.width : bounds.size.height
924
+ let compDimension = scaleWidth ? animation.size.width : animation.size.height
925
+ let scale = dominantDimension / compDimension
926
+ xform = CATransform3DMakeScale(scale, scale, 1)
927
+ case .redraw:
928
+ shouldForceUpdates = true
929
+ xform = CATransform3DIdentity
930
+ case .center:
931
+ position = bounds.center
932
+ xform = CATransform3DIdentity
933
+ case .top:
934
+ position.x = bounds.center.x
935
+ xform = CATransform3DIdentity
936
+ case .bottom:
937
+ position.x = bounds.center.x
938
+ position.y = bounds.maxY - animation.bounds.midY
939
+ xform = CATransform3DIdentity
940
+ case .left:
941
+ position.y = bounds.center.y
942
+ xform = CATransform3DIdentity
943
+ case .right:
944
+ position.y = bounds.center.y
945
+ position.x = bounds.maxX - animation.bounds.midX
946
+ xform = CATransform3DIdentity
947
+ case .topLeft:
948
+ xform = CATransform3DIdentity
949
+ case .topRight:
950
+ position.x = bounds.maxX - animation.bounds.midX
951
+ xform = CATransform3DIdentity
952
+ case .bottomLeft:
953
+ position.y = bounds.maxY - animation.bounds.midY
954
+ xform = CATransform3DIdentity
955
+ case .bottomRight:
956
+ position.x = bounds.maxX - animation.bounds.midX
957
+ position.y = bounds.maxY - animation.bounds.midY
958
+ xform = CATransform3DIdentity
959
+
960
+ #if canImport(UIKit)
961
+ @unknown default:
962
+ logger.assertionFailure("unsupported contentMode: \(contentMode.rawValue)")
963
+ xform = CATransform3DIdentity
964
+ #endif
965
+ }
966
+ }
967
+
968
+ // UIView Animation does not implicitly set CAAnimation time or timing functions.
969
+ // If layout is changed in an animation we must get the current animation duration
970
+ // and timing function and then manually create a CAAnimation to match the UIView animation.
971
+ // If layout is changed without animation, explicitly set animation duration to 0.0
972
+ // inside CATransaction to avoid unwanted artifacts.
973
+ /// Check if any animation exist on the view's layer, and match it.
974
+ if
975
+ let key = lottieAnimationLayer.animationKeys()?.first,
976
+ let animation = lottieAnimationLayer.animation(forKey: key),
977
+ animateLayoutChangesWithCurrentCoreAnimationContext
978
+ {
979
+ // The layout is happening within an animation block. Grab the animation data.
980
+
981
+ let positionKey = "LayoutPositionAnimation"
982
+ let transformKey = "LayoutTransformAnimation"
983
+ animationLayer.removeAnimation(forKey: positionKey)
984
+ animationLayer.removeAnimation(forKey: transformKey)
985
+
986
+ let positionAnimation = animation.copy() as? CABasicAnimation ?? CABasicAnimation(keyPath: "position")
987
+ positionAnimation.keyPath = "position"
988
+ positionAnimation.isAdditive = false
989
+ positionAnimation.fromValue = (animationLayer.presentation() ?? animationLayer).position
990
+ positionAnimation.toValue = position
991
+ positionAnimation.isRemovedOnCompletion = true
992
+
993
+ let xformAnimation = animation.copy() as? CABasicAnimation ?? CABasicAnimation(keyPath: "transform")
994
+ xformAnimation.keyPath = "transform"
995
+ xformAnimation.isAdditive = false
996
+ xformAnimation.fromValue = (animationLayer.presentation() ?? animationLayer).transform
997
+ xformAnimation.toValue = xform
998
+ xformAnimation.isRemovedOnCompletion = true
999
+
1000
+ animationLayer.position = position
1001
+ animationLayer.transform = xform
1002
+ animationLayer.anchorPoint = lottieAnimationLayer.anchorPoint
1003
+ animationLayer.add(positionAnimation, forKey: positionKey)
1004
+ animationLayer.add(xformAnimation, forKey: transformKey)
1005
+ } else {
1006
+ // In performance tests, we have to wrap the animation view setup
1007
+ // in a `CATransaction` in order for the layers to be deallocated at
1008
+ // the correct time. The `CATransaction`s in this method interfere
1009
+ // with the ones managed by the performance test, and aren't actually
1010
+ // necessary in a headless environment, so we disable them.
1011
+ if TestHelpers.performanceTestsAreRunning {
1012
+ animationLayer.position = position
1013
+ animationLayer.transform = xform
1014
+ } else {
1015
+ CATransaction.begin()
1016
+ CATransaction.setAnimationDuration(0.0)
1017
+ CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: .linear))
1018
+ animationLayer.position = position
1019
+ animationLayer.transform = xform
1020
+ CATransaction.commit()
1021
+ }
1022
+ }
1023
+
1024
+ if shouldForceUpdates {
1025
+ lottieAnimationLayer.forceDisplayUpdate()
1026
+ }
1027
+ }
1028
+
1029
+ func updateRasterizationState() {
1030
+ lottieAnimationLayer.updateRasterizationState()
1031
+ }
1032
+
1033
+ /// Updates the animation frame. Does not affect any current animations
1034
+ func updateAnimationFrame(_ newFrame: CGFloat) {
1035
+ lottieAnimationLayer.updateAnimationFrame(newFrame)
1036
+ }
1037
+
1038
+ @objc
1039
+ override func animationWillMoveToBackground() {
1040
+ updateAnimationForBackgroundState()
1041
+ }
1042
+
1043
+ @objc
1044
+ override func animationWillEnterForeground() {
1045
+ updateAnimationForForegroundState()
1046
+ }
1047
+
1048
+ override func animationMovedToWindow() {
1049
+ /// Don't update any state if the `superview` is `nil`
1050
+ /// When A viewA owns superViewB, it removes the superViewB from the window. At this point, viewA still owns superViewB and triggers the viewA method: -didmovetowindow
1051
+ guard superview != nil else { return }
1052
+
1053
+ if window != nil {
1054
+ updateAnimationForForegroundState(backgroundBehavior: windowBackgroundBehavior)
1055
+ } else {
1056
+ updateAnimationForBackgroundState(backgroundBehavior: windowBackgroundBehavior)
1057
+ }
1058
+ }
1059
+
1060
+ func updateInFlightAnimation() {
1061
+ lottieAnimationLayer.updateInFlightAnimation()
1062
+ }
1063
+
1064
+ func loadAnimation(_ animationSource: LottieAnimationSource?) {
1065
+ lottieAnimationLayer.loadAnimation(animationSource)
1066
+ }
1067
+
1068
+ // MARK: Fileprivate
1069
+
1070
+ fileprivate var waitingToPlayAnimation = false
1071
+
1072
+ fileprivate func updateAnimationForBackgroundState(backgroundBehavior: LottieBackgroundBehavior? = nil) {
1073
+ lottieAnimationLayer.updateAnimationForBackgroundState(backgroundBehavior: backgroundBehavior)
1074
+ }
1075
+
1076
+ fileprivate func updateAnimationForForegroundState(backgroundBehavior: LottieBackgroundBehavior? = nil) {
1077
+ let wasWaitingToPlayAnimation = waitingToPlayAnimation
1078
+ if waitingToPlayAnimation {
1079
+ waitingToPlayAnimation = false
1080
+ }
1081
+ lottieAnimationLayer.updateAnimationForForegroundState(
1082
+ wasWaitingToPlayAnimation: wasWaitingToPlayAnimation,
1083
+ backgroundBehavior: backgroundBehavior
1084
+ )
1085
+ }
1086
+
1087
+ // MARK: Private
1088
+
1089
+ private let logger: LottieLogger
1090
+ }