@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,643 @@
1
+ // Created by Bryn Bodayle on 1/20/22.
2
+ // Copyright © 2022 Airbnb Inc. All rights reserved.
3
+
4
+ #if canImport(SwiftUI)
5
+ import SwiftUI
6
+
7
+ // MARK: - LottieView
8
+
9
+ /// A wrapper which exposes Lottie's `LottieAnimationView` to SwiftUI
10
+ public struct LottieView<Placeholder: View>: UIViewConfiguringSwiftUIView {
11
+
12
+ // MARK: Lifecycle
13
+
14
+ /// Creates a `LottieView` that displays the given animation
15
+ public init(animation: LottieAnimation?) where Placeholder == EmptyView {
16
+ localAnimation = animation.map(LottieAnimationSource.lottieAnimation)
17
+ placeholder = nil
18
+ }
19
+
20
+ /// Initializes a `LottieView` with the provided `DotLottieFile` for display.
21
+ ///
22
+ /// - Important: Avoid using this initializer with the `SynchronouslyBlockingCurrentThread` APIs.
23
+ /// If decompression of a `.lottie` file is necessary, prefer using the `.init(_ loadAnimation:)`
24
+ /// initializer, which takes an asynchronous closure:
25
+ /// ```
26
+ /// LottieView {
27
+ /// try await DotLottieFile.named(name)
28
+ /// }
29
+ /// ```
30
+ public init(dotLottieFile: DotLottieFile?) where Placeholder == EmptyView {
31
+ localAnimation = dotLottieFile.map(LottieAnimationSource.dotLottieFile)
32
+ placeholder = nil
33
+ }
34
+
35
+ /// Creates a `LottieView` that asynchronously loads and displays the given `LottieAnimation`.
36
+ /// The `loadAnimation` closure is called exactly once in `onAppear`.
37
+ /// If you wish to call `loadAnimation` again at a different time, you can use `.reloadAnimationTrigger(...)`.
38
+ public init(_ loadAnimation: @escaping () async throws -> LottieAnimation?) where Placeholder == EmptyView {
39
+ self.init(loadAnimation, placeholder: EmptyView.init)
40
+ }
41
+
42
+ /// Creates a `LottieView` that asynchronously loads and displays the given `LottieAnimation`.
43
+ /// The `loadAnimation` closure is called exactly once in `onAppear`.
44
+ /// If you wish to call `loadAnimation` again at a different time, you can use `.reloadAnimationTrigger(...)`.
45
+ /// While the animation is loading, the `placeholder` view is shown in place of the `LottieAnimationView`.
46
+ public init(
47
+ _ loadAnimation: @escaping () async throws -> LottieAnimation?,
48
+ @ViewBuilder placeholder: @escaping (() -> Placeholder)
49
+ ) {
50
+ self.init {
51
+ try await loadAnimation().map(LottieAnimationSource.lottieAnimation)
52
+ } placeholder: {
53
+ placeholder()
54
+ }
55
+ }
56
+
57
+ /// Creates a `LottieView` that asynchronously loads and displays the given `DotLottieFile`.
58
+ /// The `loadDotLottieFile` closure is called exactly once in `onAppear`.
59
+ /// If you wish to call `loadAnimation` again at a different time, you can use `.reloadAnimationTrigger(...)`.
60
+ /// You can use the `DotLottieFile` static methods API which use Swift concurrency to load your `.lottie` files:
61
+ /// ```
62
+ /// LottieView {
63
+ /// try await DotLottieFile.named(name)
64
+ /// }
65
+ /// ```
66
+ public init(_ loadDotLottieFile: @escaping () async throws -> DotLottieFile?) where Placeholder == EmptyView {
67
+ self.init(loadDotLottieFile, placeholder: EmptyView.init)
68
+ }
69
+
70
+ /// Creates a `LottieView` that asynchronously loads and displays the given `DotLottieFile`.
71
+ /// The `loadDotLottieFile` closure is called exactly once in `onAppear`.
72
+ /// If you wish to call `loadAnimation` again at a different time, you can use `.reloadAnimationTrigger(...)`.
73
+ /// While the animation is loading, the `placeholder` view is shown in place of the `LottieAnimationView`.
74
+ /// You can use the `DotLottieFile` static methods API which use Swift concurrency to load your `.lottie` files:
75
+ /// ```
76
+ /// LottieView {
77
+ /// try await DotLottieFile.named(name)
78
+ /// } placeholder: {
79
+ /// LoadingView()
80
+ /// }
81
+ /// ```
82
+ public init(
83
+ _ loadDotLottieFile: @escaping () async throws -> DotLottieFile?,
84
+ @ViewBuilder placeholder: @escaping (() -> Placeholder)
85
+ ) {
86
+ self.init {
87
+ try await loadDotLottieFile().map(LottieAnimationSource.dotLottieFile)
88
+ } placeholder: {
89
+ placeholder()
90
+ }
91
+ }
92
+
93
+ /// Creates a `LottieView` that asynchronously loads and displays the given `LottieAnimationSource`.
94
+ /// The `loadAnimation` closure is called exactly once in `onAppear`.
95
+ /// If you wish to call `loadAnimation` again at a different time, you can use `.reloadAnimationTrigger(...)`.
96
+ /// While the animation is loading, the `placeholder` view is shown in place of the `LottieAnimationView`.
97
+ public init(_ loadAnimation: @escaping () async throws -> LottieAnimationSource?) where Placeholder == EmptyView {
98
+ self.init(loadAnimation, placeholder: EmptyView.init)
99
+ }
100
+
101
+ /// Creates a `LottieView` that asynchronously loads and displays the given `LottieAnimationSource`.
102
+ /// The `loadAnimation` closure is called exactly once in `onAppear`.
103
+ /// If you wish to call `loadAnimation` again at a different time, you can use `.reloadAnimationTrigger(...)`.
104
+ /// While the animation is loading, the `placeholder` view is shown in place of the `LottieAnimationView`.
105
+ public init(
106
+ _ loadAnimation: @escaping () async throws -> LottieAnimationSource?,
107
+ @ViewBuilder placeholder: @escaping () -> Placeholder
108
+ ) {
109
+ localAnimation = nil
110
+ self.loadAnimation = loadAnimation
111
+ self.placeholder = placeholder
112
+ }
113
+
114
+ // MARK: Public
115
+
116
+ public var body: some View {
117
+ LottieAnimationView.swiftUIView {
118
+ LottieAnimationView(
119
+ animationSource: animationSource,
120
+ imageProvider: imageProviderConfiguration?.imageProvider,
121
+ textProvider: textProvider,
122
+ fontProvider: fontProvider,
123
+ configuration: configuration,
124
+ logger: logger
125
+ )
126
+ }
127
+ .sizing(sizing)
128
+ .configure { context in
129
+ applyCurrentAnimationConfiguration(to: context.view, in: context.container)
130
+ }
131
+ .configurations(configurations)
132
+ .opacity(animationSource == nil ? 0 : 1)
133
+ .overlay {
134
+ placeholder?()
135
+ .opacity(animationSource == nil ? 1 : 0)
136
+ }
137
+ .onAppear {
138
+ loadAnimationIfNecessary()
139
+ }
140
+ .valueChanged(value: reloadAnimationTrigger) { _ in
141
+ reloadAnimationTriggerDidChange()
142
+ }
143
+ }
144
+
145
+ /// Returns a copy of this `LottieView` updated to have the specific configuration property
146
+ /// applied to its represented `LottieAnimationView` whenever it is updated via the `updateUIView(...)`
147
+ /// or `updateNSView(...)` methods.
148
+ ///
149
+ /// - note: This configuration will be applied on every SwiftUI render pass.
150
+ /// Be wary of applying heavy side-effects as configuration values.
151
+ public func configure<Property>(
152
+ _ property: ReferenceWritableKeyPath<LottieAnimationView, Property>,
153
+ to value: Property
154
+ ) -> Self {
155
+ configure { $0[keyPath: property] = value }
156
+ }
157
+
158
+ /// Returns a copy of this `LottieView` updated to have the specific configuration property
159
+ /// applied to its represented `LottieAnimationView` whenever it is updated via the `updateUIView(...)`
160
+ /// or `updateNSView(...)` methods.
161
+ ///
162
+ /// - note: If the `value` is already the currently-applied configuration value, it won't be applied
163
+ public func configure<Property: Equatable>(
164
+ _ property: ReferenceWritableKeyPath<LottieAnimationView, Property>,
165
+ to value: Property
166
+ ) -> Self {
167
+ configure {
168
+ guard $0[keyPath: property] != value else { return }
169
+ $0[keyPath: property] = value
170
+ }
171
+ }
172
+
173
+ /// Returns a copy of this `LottieView` updated to have the given closure applied to its
174
+ /// represented `LottieAnimationView` whenever it is updated via the `updateUIView(…)`
175
+ /// or `updateNSView(…)` method.
176
+ ///
177
+ /// - note: This configuration closure will be executed on every SwiftUI render pass.
178
+ /// Be wary of applying heavy side-effects inside it.
179
+ public func configure(_ configure: @escaping (LottieAnimationView) -> Void) -> Self {
180
+ var copy = self
181
+ copy.configurations.append { context in
182
+ configure(context.view)
183
+ }
184
+ return copy
185
+ }
186
+
187
+ /// Returns a copy of this view that can be resized by scaling its animation
188
+ /// to always fit the size offered by its parent.
189
+ public func resizable() -> Self {
190
+ var copy = self
191
+ copy.sizing = .proposed
192
+ return copy
193
+ }
194
+
195
+ /// Returns a copy of this view that adopts the intrinsic size of the animation,
196
+ /// up to the proposed size.
197
+ public func intrinsicSize() -> Self {
198
+ var copy = self
199
+ copy.sizing = .intrinsic
200
+ return copy
201
+ }
202
+
203
+ @available(*, deprecated, renamed: "playing()", message: "Will be removed in a future major release.")
204
+ public func play() -> Self {
205
+ playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: .playOnce)))
206
+ }
207
+
208
+ /// Returns a copy of this view that loops its animation from the start to end whenever visible
209
+ public func looping() -> Self {
210
+ playbackMode(.playing(.fromProgress(0, toProgress: 1, loopMode: .loop)))
211
+ }
212
+
213
+ @available(*, deprecated, renamed: "playing(_:)", message: "Will be removed in a future major release.")
214
+ public func play(loopMode: LottieLoopMode = .playOnce) -> Self {
215
+ playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: loopMode)))
216
+ }
217
+
218
+ @available(*, deprecated, renamed: "playbackMode(_:)", message: "Will be removed in a future major release.")
219
+ public func play(_ playbackMode: LottiePlaybackMode) -> Self {
220
+ self.playbackMode(playbackMode)
221
+ }
222
+
223
+ /// Returns a copy of this view playing with the given playback mode
224
+ public func playing(_ mode: LottiePlaybackMode.PlaybackMode) -> Self {
225
+ playbackMode(.playing(mode))
226
+ }
227
+
228
+ /// Returns a copy of this view playing from the current frame to the end frame,
229
+ /// with the given `LottiePlaybackMode`.
230
+ public func playing(loopMode: LottieLoopMode) -> Self {
231
+ playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: loopMode)))
232
+ }
233
+
234
+ /// Returns a copy of this view playing once from the current frame to the end frame
235
+ public func playing() -> Self {
236
+ playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: .playOnce)))
237
+ }
238
+
239
+ /// Returns a copy of this view paused with the given state
240
+ public func paused(at state: LottiePlaybackMode.PausedState = .currentFrame) -> Self {
241
+ playbackMode(.paused(at: state))
242
+ }
243
+
244
+ /// Returns a copy of this view using the given `LottiePlaybackMode`
245
+ public func playbackMode(_ playbackMode: LottiePlaybackMode) -> Self {
246
+ var copy = self
247
+ copy.playbackMode = playbackMode
248
+ return copy
249
+ }
250
+
251
+ /// Returns a copy of this view playing its animation at the given speed
252
+ public func animationSpeed(_ animationSpeed: Double) -> Self {
253
+ var copy = self
254
+ copy.animationSpeed = animationSpeed
255
+ return copy
256
+ }
257
+
258
+ /// Returns a copy of this view with the given closure that is called whenever the
259
+ /// `LottieAnimationSource` provided via `init` is loaded and applied to the underlying `LottieAnimationView`.
260
+ public func animationDidLoad(_ animationDidLoad: @escaping (LottieAnimationSource) -> Void) -> Self {
261
+ var copy = self
262
+ copy.animationDidLoad = animationDidLoad
263
+ return copy
264
+ }
265
+
266
+ /// Returns a copy of this view with the given `LottieCompletionBlock` that is called
267
+ /// when an animation finishes playing.
268
+ public func animationDidFinish(_ animationCompletionHandler: LottieCompletionBlock?) -> Self {
269
+ var copy = self
270
+ copy.animationCompletionHandler = { [previousCompletionHandler = self.animationCompletionHandler] completed in
271
+ previousCompletionHandler?(completed)
272
+ animationCompletionHandler?(completed)
273
+ }
274
+ return copy
275
+ }
276
+
277
+ /// Returns a copy of this view updated to have the provided background behavior.
278
+ public func backgroundBehavior(_ value: LottieBackgroundBehavior) -> Self {
279
+ configure { view in
280
+ view.backgroundBehavior = value
281
+ }
282
+ }
283
+
284
+ /// Returns a copy of this view updated to have the provided window background behavior.
285
+ public func windowBackgroundBehavior(_ value: LottieBackgroundBehavior?) -> Self {
286
+ configure { view in
287
+ view.windowBackgroundBehavior = value
288
+ }
289
+ }
290
+
291
+ /// Returns a copy of this view with its accessibility label updated to the given value.
292
+ public func accessibilityLabel(_ accessibilityLabel: String?) -> Self {
293
+ configure { view in
294
+ #if os(macOS)
295
+ view.setAccessibilityElement(accessibilityLabel != nil)
296
+ view.setAccessibilityLabel(accessibilityLabel)
297
+ #else
298
+ view.isAccessibilityElement = accessibilityLabel != nil
299
+ view.accessibilityLabel = accessibilityLabel
300
+ #endif
301
+ }
302
+ }
303
+
304
+ /// Returns a copy of this view with its `LottieConfiguration` updated to the given value.
305
+ public func configuration(_ configuration: LottieConfiguration) -> Self {
306
+ var copy = self
307
+ copy.configuration = configuration
308
+
309
+ copy = copy.configure { view in
310
+ if view.configuration != configuration {
311
+ view.configuration = configuration
312
+ }
313
+ }
314
+
315
+ return copy
316
+ }
317
+
318
+ /// Returns a copy of this view with its `LottieLogger` updated to the given value.
319
+ /// - The underlying `LottieAnimationView`'s `LottieLogger` is immutable after configured,
320
+ /// so this value is only used when initializing the `LottieAnimationView` for the first time.
321
+ public func logger(_ logger: LottieLogger) -> Self {
322
+ var copy = self
323
+ copy.logger = logger
324
+ return copy
325
+ }
326
+
327
+ /// Returns a copy of this view with its image provider updated to the given value.
328
+ /// The image provider must be `Equatable` to avoid unnecessary state updates / re-renders.
329
+ public func imageProvider<ImageProvider: AnimationImageProvider & Equatable>(_ imageProvider: ImageProvider) -> Self {
330
+ var copy = self
331
+
332
+ copy.imageProviderConfiguration = (
333
+ imageProvider: imageProvider,
334
+ imageProvidersAreEqual: { untypedLHS, untypedRHS in
335
+ guard
336
+ let lhs = untypedLHS as? ImageProvider,
337
+ let rhs = untypedRHS as? ImageProvider
338
+ else { return false }
339
+
340
+ return lhs == rhs
341
+ }
342
+ )
343
+
344
+ return copy
345
+ }
346
+
347
+ /// Returns a copy of this view with its text provider updated to the given value.
348
+ /// The image provider must be `Equatable` to avoid unnecessary state updates / re-renders.
349
+ public func textProvider<TextProvider: AnimationKeypathTextProvider & Equatable>(_ textProvider: TextProvider) -> Self {
350
+ var copy = self
351
+ copy.textProvider = textProvider
352
+
353
+ copy = copy.configure { view in
354
+ if (view.textProvider as? TextProvider) != textProvider {
355
+ view.textProvider = textProvider
356
+ }
357
+ }
358
+
359
+ return copy
360
+ }
361
+
362
+ /// Returns a copy of this view with its image provider updated to the given value.
363
+ /// The image provider must be `Equatable` to avoid unnecessary state updates / re-renders.
364
+ public func fontProvider<FontProvider: AnimationFontProvider & Equatable>(_ fontProvider: FontProvider) -> Self {
365
+ var copy = self
366
+ copy.fontProvider = fontProvider
367
+
368
+ copy = configure { view in
369
+ if (view.fontProvider as? FontProvider) != fontProvider {
370
+ view.fontProvider = fontProvider
371
+ }
372
+ }
373
+
374
+ return copy
375
+ }
376
+
377
+ /// Returns a copy of this view using the given value provider for the given keypath.
378
+ /// The value provider must be `Equatable` to avoid unnecessary state updates / re-renders.
379
+ public func valueProvider<ValueProvider: AnyValueProvider & Equatable>(
380
+ _ valueProvider: ValueProvider,
381
+ for keypath: AnimationKeypath
382
+ ) -> Self {
383
+ configure { view in
384
+ if (view.valueProviders[keypath] as? ValueProvider) != valueProvider {
385
+ view.setValueProvider(valueProvider, keypath: keypath)
386
+ }
387
+ }
388
+ }
389
+
390
+ /// Returns a copy of this view updated to display the given `AnimationProgressTime`.
391
+ /// - If the `currentProgress` value is provided, the `currentProgress` of the
392
+ /// underlying `LottieAnimationView` is updated. This will pause any existing animations.
393
+ /// - If the `animationProgress` is `nil`, no changes will be made and any existing animations
394
+ /// will continue playing uninterrupted.
395
+ public func currentProgress(_ currentProgress: AnimationProgressTime?) -> Self {
396
+ guard let currentProgress else { return self }
397
+ var copy = self
398
+ copy.playbackMode = .paused(at: .progress(currentProgress))
399
+ return copy
400
+ }
401
+
402
+ /// Returns a copy of this view updated to display the given `AnimationFrameTime`.
403
+ /// - If the `currentFrame` value is provided, the `currentFrame` of the
404
+ /// underlying `LottieAnimationView` is updated. This will pause any existing animations.
405
+ /// - If the `currentFrame` is `nil`, no changes will be made and any existing animations
406
+ /// will continue playing uninterrupted.
407
+ public func currentFrame(_ currentFrame: AnimationFrameTime?) -> Self {
408
+ guard let currentFrame else { return self }
409
+ var copy = self
410
+ copy.playbackMode = .paused(at: .frame(currentFrame))
411
+ return copy
412
+ }
413
+
414
+ /// Returns a copy of this view updated to display the given time value.
415
+ /// - If the `currentTime` value is provided, the `currentTime` of the
416
+ /// underlying `LottieAnimationView` is updated. This will pause any existing animations.
417
+ /// - If the `currentTime` is `nil`, no changes will be made and any existing animations
418
+ /// will continue playing uninterrupted.
419
+ public func currentTime(_ currentTime: TimeInterval?) -> Self {
420
+ guard let currentTime else { return self }
421
+ var copy = self
422
+ copy.playbackMode = .paused(at: .time(currentTime))
423
+ return copy
424
+ }
425
+
426
+ /// Returns a new instance of this view, which will invoke the provided `loadAnimation` closure
427
+ /// whenever the `binding` value is updated.
428
+ ///
429
+ /// - Note: This function requires a valid `loadAnimation` closure provided during view initialization,
430
+ /// otherwise `reloadAnimationTrigger` will have no effect.
431
+ /// - Parameters:
432
+ /// - binding: The binding that triggers the reloading when its value changes.
433
+ /// - showPlaceholder: When `true`, the current animation will be removed before invoking `loadAnimation`,
434
+ /// displaying the `Placeholder` until the new animation loads.
435
+ /// When `false`, the previous animation remains visible while the new one loads.
436
+ public func reloadAnimationTrigger(_ value: some Equatable, showPlaceholder: Bool = true) -> Self {
437
+ var copy = self
438
+ copy.reloadAnimationTrigger = AnyEquatable(value)
439
+ copy.showPlaceholderWhileReloading = showPlaceholder
440
+ return copy
441
+ }
442
+
443
+ /// Returns a view that updates the given binding each frame with the animation's `realtimeAnimationProgress`.
444
+ /// The `LottieView` is wrapped in a `TimelineView` with the `.animation` schedule.
445
+ /// - This is a one-way binding. Its value is updated but never read.
446
+ /// - If provided, the binding will be updated each frame with the `realtimeAnimationProgress`
447
+ /// of the underlying `LottieAnimationView`. This is potentially expensive since it triggers
448
+ /// a state update every frame.
449
+ /// - If the binding is `nil`, the `TimelineView` will be paused and no updates will occur to the binding.
450
+ @available(iOS 15.0, tvOS 15.0, macOS 12.0, *)
451
+ public func getRealtimeAnimationProgress(_ realtimeAnimationProgress: Binding<AnimationProgressTime>?) -> some View {
452
+ TimelineView(.animation(paused: realtimeAnimationProgress == nil)) { _ in
453
+ configure { view in
454
+ if let realtimeAnimationProgress {
455
+ DispatchQueue.main.async {
456
+ realtimeAnimationProgress.wrappedValue = view.realtimeAnimationProgress
457
+ }
458
+ }
459
+ }
460
+ }
461
+ }
462
+
463
+ /// Returns a view that updates the given binding each frame with the animation's `realtimeAnimationProgress`.
464
+ /// The `LottieView` is wrapped in a `TimelineView` with the `.animation` schedule.
465
+ /// - This is a one-way binding. Its value is updated but never read.
466
+ /// - If provided, the binding will be updated each frame with the `realtimeAnimationProgress`
467
+ /// of the underlying `LottieAnimationView`. This is potentially expensive since it triggers
468
+ /// a state update every frame.
469
+ /// - If the binding is `nil`, the `TimelineView` will be paused and no updates will occur to the binding.
470
+ @available(iOS 15.0, tvOS 15.0, macOS 12.0, *)
471
+ public func getRealtimeAnimationFrame(_ realtimeAnimationFrame: Binding<AnimationFrameTime>?) -> some View {
472
+ TimelineView(.animation(paused: realtimeAnimationFrame == nil)) { _ in
473
+ configure { view in
474
+ if let realtimeAnimationFrame {
475
+ DispatchQueue.main.async {
476
+ realtimeAnimationFrame.wrappedValue = view.realtimeAnimationFrame
477
+ }
478
+ }
479
+ }
480
+ }
481
+ }
482
+
483
+ /// Returns a copy of this view with the `DotLottieConfigurationComponents`
484
+ /// updated to the given value.
485
+ /// - Defaults to `[.imageProvider]`
486
+ /// - If a component is specified here, that value in the `DotLottieConfiguration`
487
+ /// of an active dotLottie animation will override any value provided via other methods.
488
+ public func dotLottieConfigurationComponents(
489
+ _ dotLottieConfigurationComponents: DotLottieConfigurationComponents
490
+ ) -> Self {
491
+ var copy = self
492
+ copy.dotLottieConfigurationComponents = dotLottieConfigurationComponents
493
+ return copy
494
+ }
495
+
496
+ // MARK: Internal
497
+
498
+ var configurations = [SwiftUIView<LottieAnimationView, Void>.Configuration]()
499
+
500
+ // MARK: Private
501
+
502
+ @State private var remoteAnimation: LottieAnimationSource?
503
+
504
+ private let localAnimation: LottieAnimationSource?
505
+ private var playbackMode: LottiePlaybackMode?
506
+ private var animationSpeed: Double?
507
+ private var reloadAnimationTrigger: AnyEquatable?
508
+ private var loadAnimation: (() async throws -> LottieAnimationSource?)?
509
+ private var animationDidLoad: ((LottieAnimationSource) -> Void)?
510
+ private var animationCompletionHandler: LottieCompletionBlock?
511
+ private var showPlaceholderWhileReloading = false
512
+ private var textProvider: AnimationKeypathTextProvider = DefaultTextProvider()
513
+ private var fontProvider: AnimationFontProvider = DefaultFontProvider()
514
+ private var configuration = LottieConfiguration.shared
515
+ private var dotLottieConfigurationComponents = DotLottieConfigurationComponents.imageProvider
516
+ private var logger = LottieLogger.shared
517
+ private var sizing = SwiftUIMeasurementContainerStrategy.automatic
518
+ private let placeholder: (() -> Placeholder)?
519
+
520
+ private var imageProviderConfiguration: (
521
+ imageProvider: AnimationImageProvider,
522
+ imageProvidersAreEqual: (AnimationImageProvider, AnimationImageProvider) -> Bool
523
+ )?
524
+
525
+ private var animationSource: LottieAnimationSource? {
526
+ localAnimation ?? remoteAnimation
527
+ }
528
+
529
+ private func loadAnimationIfNecessary() {
530
+ guard let loadAnimation else { return }
531
+
532
+ Task {
533
+ do {
534
+ remoteAnimation = try await loadAnimation()
535
+ } catch {
536
+ logger.warn("Failed to load asynchronous Lottie animation with error: \(error)")
537
+ }
538
+ }
539
+ }
540
+
541
+ private func reloadAnimationTriggerDidChange() {
542
+ guard loadAnimation != nil else { return }
543
+
544
+ if showPlaceholderWhileReloading {
545
+ remoteAnimation = nil
546
+ }
547
+
548
+ loadAnimationIfNecessary()
549
+ }
550
+
551
+ /// Applies playback configuration for the current animation to the `LottieAnimationView`
552
+ private func applyCurrentAnimationConfiguration(
553
+ to view: LottieAnimationView,
554
+ in container: SwiftUIMeasurementContainer<LottieAnimationView>
555
+ ) {
556
+ guard let animationSource else { return }
557
+ var imageProviderConfiguration = imageProviderConfiguration
558
+ var playbackMode = playbackMode
559
+ var animationSpeed = animationSpeed
560
+
561
+ // When playing a dotLottie animation, its `DotLottieConfiguration`
562
+ // can override some behavior of the animation.
563
+ if let dotLottieConfiguration = animationSource.dotLottieAnimation?.configuration {
564
+ // Only use the value from the `DotLottieConfiguration` is that component
565
+ // is specified in the list of `dotLottieConfigurationComponents`.
566
+ if dotLottieConfigurationComponents.contains(.loopMode) {
567
+ playbackMode = playbackMode?.loopMode(dotLottieConfiguration.loopMode)
568
+ }
569
+
570
+ if dotLottieConfigurationComponents.contains(.animationSpeed) {
571
+ animationSpeed = dotLottieConfiguration.speed
572
+ }
573
+
574
+ if
575
+ dotLottieConfigurationComponents.contains(.imageProvider),
576
+ let dotLottieImageProvider = dotLottieConfiguration.dotLottieImageProvider
577
+ {
578
+ imageProviderConfiguration = (
579
+ imageProvider: dotLottieImageProvider,
580
+ imageProvidersAreEqual: { untypedLHS, untypedRHS in
581
+ guard
582
+ let lhs = untypedLHS as? DotLottieImageProvider,
583
+ let rhs = untypedRHS as? DotLottieImageProvider
584
+ else { return false }
585
+
586
+ return lhs == rhs
587
+ }
588
+ )
589
+ }
590
+ }
591
+
592
+ // We check referential equality of the animation before updating as updating the
593
+ // animation has a side-effect of rebuilding the animation layer, and it would be
594
+ // prohibitive to do so on every state update.
595
+ if animationSource.animation !== view.animation {
596
+ view.loadAnimation(animationSource)
597
+
598
+ // Invalidate the intrinsic size of the SwiftUI measurement container,
599
+ // since any cached measurements will be out of date after updating the animation.
600
+ container.invalidateIntrinsicContentSize()
601
+
602
+ // Call the `animationDidLoad` asynchronously
603
+ // to prevent consumers that update state in that callback from
604
+ // causing SwiftUI to emit warnings about modifying state during view updates.
605
+ DispatchQueue.main.async {
606
+ animationDidLoad?(animationSource)
607
+ }
608
+ }
609
+
610
+ if
611
+ let playbackMode,
612
+ playbackMode != view.currentPlaybackMode
613
+ {
614
+ view.setPlaybackMode(playbackMode, completion: animationCompletionHandler)
615
+ }
616
+
617
+ if
618
+ let (imageProvider, imageProvidersAreEqual) = imageProviderConfiguration,
619
+ !imageProvidersAreEqual(imageProvider, view.imageProvider)
620
+ {
621
+ view.imageProvider = imageProvider
622
+ }
623
+
624
+ if
625
+ let animationSpeed,
626
+ animationSpeed != view.animationSpeed
627
+ {
628
+ view.animationSpeed = animationSpeed
629
+ }
630
+ }
631
+ }
632
+
633
+ extension View {
634
+
635
+ /// The `.overlay` modifier that uses a `ViewBuilder` is available in iOS 15+, this helper function helps us to use the same API in older OSs
636
+ fileprivate func overlay(
637
+ @ViewBuilder content: () -> some View
638
+ ) -> some View {
639
+ overlay(content(), alignment: .center)
640
+ }
641
+ }
642
+
643
+ #endif
@@ -0,0 +1,21 @@
1
+ //
2
+ // AnimationCacheProvider.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 2/5/19.
6
+ //
7
+
8
+ /// `AnimationCacheProvider` is a protocol that describes an Animation Cache.
9
+ /// Animation Cache is used when loading `LottieAnimation` models. Using an Animation Cache
10
+ /// can increase performance when loading an animation multiple times.
11
+ ///
12
+ /// Lottie comes with a prebuilt LRU Animation Cache.
13
+ public protocol AnimationCacheProvider: AnyObject, Sendable {
14
+
15
+ func animation(forKey: String) -> LottieAnimation?
16
+
17
+ func setAnimation(_ animation: LottieAnimation, forKey: String)
18
+
19
+ func clearCache()
20
+
21
+ }