lottie-ios 4.3.4 → 4.4.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 (182) hide show
  1. package/.github/workflows/main.yml +51 -58
  2. package/Lottie.xcodeproj/project.pbxproj +20 -0
  3. package/Lottie.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +4 -17
  4. package/Lottie.xcworkspace/xcshareddata/swiftpm/Package.resolved +37 -40
  5. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  6. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +9 -680
  7. package/Package.resolved +20 -22
  8. package/Package.swift +3 -2
  9. package/README.md +21 -3
  10. package/Rakefile +52 -28
  11. package/Sources/PrivacyInfo.xcprivacy +23 -0
  12. package/Sources/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +1 -1
  13. package/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +23 -13
  14. package/Sources/Private/CoreAnimation/Animations/CustomPathAnimation.swift +8 -2
  15. package/Sources/Private/CoreAnimation/Animations/EllipseAnimation.swift +7 -1
  16. package/Sources/Private/CoreAnimation/Animations/GradientAnimations.swift +15 -2
  17. package/Sources/Private/CoreAnimation/Animations/LayerProperty.swift +8 -1
  18. package/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift +8 -1
  19. package/Sources/Private/CoreAnimation/Animations/StarAnimation.swift +12 -1
  20. package/Sources/Private/CoreAnimation/Animations/StrokeAnimation.swift +0 -1
  21. package/Sources/Private/CoreAnimation/Animations/TransformAnimations.swift +19 -11
  22. package/Sources/Private/CoreAnimation/Animations/VisibilityAnimation.swift +45 -19
  23. package/Sources/Private/CoreAnimation/CoreAnimationLayer.swift +38 -3
  24. package/Sources/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +1 -1
  25. package/Sources/Private/CoreAnimation/Extensions/Keyframes+combined.swift +9 -2
  26. package/Sources/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
  27. package/Sources/Private/CoreAnimation/Layers/AnimationLayer.swift +77 -13
  28. package/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +1 -1
  29. package/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +2 -2
  30. package/Sources/Private/CoreAnimation/Layers/ImageLayer.swift +1 -1
  31. package/Sources/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +1 -7
  32. package/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift +19 -53
  33. package/Sources/Private/CoreAnimation/Layers/ShapeItemLayer.swift +2 -2
  34. package/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +2 -4
  35. package/Sources/Private/CoreAnimation/Layers/SolidLayer.swift +5 -2
  36. package/Sources/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +1 -1
  37. package/Sources/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +10 -10
  38. package/Sources/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +3 -3
  39. package/Sources/Private/EmbeddedLibraries/README.md +2 -0
  40. package/Sources/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +2 -2
  41. package/Sources/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +7 -7
  42. package/Sources/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +2 -2
  43. package/Sources/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +5 -5
  44. package/Sources/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +1 -2
  45. package/Sources/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +1 -3
  46. package/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +1 -2
  47. package/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +2 -3
  48. package/Sources/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +2 -3
  49. package/Sources/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +5 -12
  50. package/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +0 -1
  51. package/Sources/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +0 -2
  52. package/Sources/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +3 -3
  53. package/Sources/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +12 -12
  54. package/Sources/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +1 -2
  55. package/Sources/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +0 -2
  56. package/Sources/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +1 -3
  57. package/Sources/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +0 -2
  58. package/Sources/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +0 -2
  59. package/Sources/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +1 -3
  60. package/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +0 -1
  61. package/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +0 -1
  62. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +1 -3
  63. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +1 -2
  64. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +0 -1
  65. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +0 -2
  66. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +0 -1
  67. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +0 -1
  68. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +0 -1
  69. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +2 -3
  70. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +1 -3
  71. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +2 -2
  72. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +0 -2
  73. package/Sources/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +0 -1
  74. package/Sources/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +0 -2
  75. package/Sources/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +0 -2
  76. package/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +0 -1
  77. package/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +0 -1
  78. package/Sources/Private/Model/Assets/Asset.swift +2 -3
  79. package/Sources/Private/Model/Assets/AssetLibrary.swift +11 -11
  80. package/Sources/Private/Model/Assets/ImageAsset.swift +20 -0
  81. package/Sources/Private/Model/Assets/PrecompAsset.swift +0 -2
  82. package/Sources/Private/Model/DictionaryInitializable.swift +18 -10
  83. package/Sources/Private/Model/DotLottie/DotLottieImageProvider.swift +9 -6
  84. package/Sources/Private/Model/DotLottie/DotLottieUtils.swift +1 -1
  85. package/Sources/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +0 -2
  86. package/Sources/Private/Model/Keyframes/KeyframeData.swift +1 -4
  87. package/Sources/Private/Model/Keyframes/KeyframeGroup.swift +1 -3
  88. package/Sources/Private/Model/LayerEffects/DropShadowEffect.swift +0 -2
  89. package/Sources/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +0 -2
  90. package/Sources/Private/Model/LayerEffects/EffectValues/EffectValue.swift +2 -3
  91. package/Sources/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +0 -2
  92. package/Sources/Private/Model/LayerEffects/LayerEffect.swift +2 -3
  93. package/Sources/Private/Model/LayerStyles/DropShadowStyle.swift +0 -2
  94. package/Sources/Private/Model/LayerStyles/LayerStyle.swift +2 -3
  95. package/Sources/Private/Model/Layers/ImageLayerModel.swift +0 -2
  96. package/Sources/Private/Model/Layers/LayerModel.swift +11 -5
  97. package/Sources/Private/Model/Layers/PreCompLayerModel.swift +0 -2
  98. package/Sources/Private/Model/Layers/ShapeLayerModel.swift +0 -2
  99. package/Sources/Private/Model/Layers/SolidLayerModel.swift +0 -2
  100. package/Sources/Private/Model/Layers/TextLayerModel.swift +0 -2
  101. package/Sources/Private/Model/Objects/DashPattern.swift +1 -3
  102. package/Sources/Private/Model/Objects/Marker.swift +0 -2
  103. package/Sources/Private/Model/Objects/Mask.swift +0 -2
  104. package/Sources/Private/Model/Objects/Transform.swift +46 -9
  105. package/Sources/Private/Model/ShapeItems/Ellipse.swift +0 -2
  106. package/Sources/Private/Model/ShapeItems/Fill.swift +0 -2
  107. package/Sources/Private/Model/ShapeItems/GradientFill.swift +1 -3
  108. package/Sources/Private/Model/ShapeItems/GradientStroke.swift +1 -3
  109. package/Sources/Private/Model/ShapeItems/Group.swift +0 -2
  110. package/Sources/Private/Model/ShapeItems/Merge.swift +1 -3
  111. package/Sources/Private/Model/ShapeItems/Rectangle.swift +0 -2
  112. package/Sources/Private/Model/ShapeItems/Repeater.swift +0 -2
  113. package/Sources/Private/Model/ShapeItems/RoundedCorners.swift +0 -2
  114. package/Sources/Private/Model/ShapeItems/Shape.swift +0 -2
  115. package/Sources/Private/Model/ShapeItems/ShapeItem.swift +2 -3
  116. package/Sources/Private/Model/ShapeItems/ShapeTransform.swift +0 -2
  117. package/Sources/Private/Model/ShapeItems/Star.swift +1 -3
  118. package/Sources/Private/Model/ShapeItems/Stroke.swift +0 -2
  119. package/Sources/Private/Model/ShapeItems/Trim.swift +1 -3
  120. package/Sources/Private/Model/Text/Font.swift +0 -2
  121. package/Sources/Private/Model/Text/Glyph.swift +0 -2
  122. package/Sources/Private/Model/Text/TextAnimator.swift +0 -2
  123. package/Sources/Private/Model/Text/TextDocument.swift +2 -4
  124. package/Sources/Private/Utility/Debugging/AnimatorNodeDebugging.swift +0 -2
  125. package/Sources/Private/Utility/Debugging/LayerDebugging.swift +4 -5
  126. package/Sources/Private/Utility/Extensions/AnimationKeypathExtension.swift +2 -3
  127. package/Sources/Private/Utility/Extensions/DataExtension.swift +0 -1
  128. package/Sources/Private/Utility/Extensions/StringExtensions.swift +5 -0
  129. package/Sources/Private/Utility/Helpers/AnimationContext.swift +2 -3
  130. package/Sources/Private/Utility/Helpers/AnyEquatable.swift +0 -2
  131. package/Sources/Private/Utility/LottieAnimationSource.swift +11 -1
  132. package/Sources/Private/Utility/Primitives/BezierPath.swift +2 -3
  133. package/Sources/Private/Utility/Primitives/CGPointExtension.swift +1 -1
  134. package/Sources/Private/Utility/Primitives/ColorExtension.swift +1 -2
  135. package/Sources/Private/Utility/Primitives/VectorsExtensions.swift +6 -6
  136. package/Sources/Public/Animation/LottieAnimation.swift +2 -2
  137. package/Sources/Public/Animation/LottieAnimationHelpers.swift +7 -5
  138. package/Sources/Public/Animation/LottieAnimationLayer.swift +29 -43
  139. package/Sources/Public/Animation/LottieAnimationView.swift +6 -7
  140. package/Sources/Public/Animation/LottieAnimationViewInitializers.swift +3 -3
  141. package/Sources/Public/Animation/LottiePlaybackMode.swift +53 -0
  142. package/Sources/Public/Animation/LottieView.swift +143 -48
  143. package/Sources/Public/AnimationCache/AnimationCacheProvider.swift +0 -2
  144. package/Sources/Public/AnimationCache/DefaultAnimationCache.swift +11 -1
  145. package/Sources/Public/AnimationCache/LRUAnimationCache.swift +0 -2
  146. package/Sources/Public/Controls/AnimatedButton.swift +4 -6
  147. package/Sources/Public/Controls/AnimatedControl.swift +1 -3
  148. package/Sources/Public/Controls/AnimatedSwitch.swift +1 -3
  149. package/Sources/Public/DotLottie/Cache/DotLottieCache.swift +9 -0
  150. package/Sources/Public/DotLottie/Cache/DotLottieCacheProvider.swift +1 -3
  151. package/Sources/Public/DotLottie/DotLottieConfiguration.swift +53 -5
  152. package/Sources/Public/DotLottie/DotLottieFile.swift +4 -3
  153. package/Sources/Public/DotLottie/DotLottieFileHelpers.swift +6 -6
  154. package/Sources/Public/DynamicProperties/AnimationKeypath.swift +0 -2
  155. package/Sources/Public/DynamicProperties/AnyValueProvider.swift +0 -1
  156. package/Sources/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +2 -2
  157. package/Sources/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +1 -1
  158. package/Sources/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +1 -1
  159. package/Sources/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +1 -1
  160. package/Sources/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +1 -1
  161. package/Sources/Public/FontProvider/AnimationFontProvider.swift +0 -2
  162. package/Sources/Public/ImageProvider/AnimationImageProvider.swift +0 -2
  163. package/Sources/Public/Keyframes/Interpolatable.swift +26 -0
  164. package/Sources/Public/Primitives/LottieColor.swift +0 -2
  165. package/Sources/Public/Primitives/Vectors.swift +0 -2
  166. package/Sources/Public/TextProvider/AnimationTextProvider.swift +0 -2
  167. package/Sources/Public/iOS/AnimationSubview.swift +0 -1
  168. package/Sources/Public/iOS/BundleImageProvider.swift +3 -8
  169. package/Sources/Public/iOS/Compatibility/CompatibleAnimationView.swift +4 -8
  170. package/Sources/Public/iOS/UIColorExtension.swift +1 -2
  171. package/Sources/Public/macOS/BundleImageProvider.macOS.swift +3 -6
  172. package/lottie-ios.podspec +5 -2
  173. package/package.json +1 -1
  174. package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  175. package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  176. package/Lottie.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +0 -37
  177. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  178. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
  179. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/xcdebugger/Expressions.xcexplist +0 -153
  180. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/IDEFindNavigatorScopes.plist +0 -5
  181. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Expressions.xcexplist +0 -231
  182. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +0 -37
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/7/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  /// The animatable transform for a layer. Controls position, rotation, scale, and opacity.
11
9
  final class Transform: Codable, DictionaryInitializable {
12
10
 
@@ -86,7 +84,7 @@ final class Transform: Codable, DictionaryInitializable {
86
84
  {
87
85
  self.anchorPoint = anchorPoint
88
86
  } else {
89
- anchorPoint = KeyframeGroup(LottieVector3D(x: Double(0), y: 0, z: 0))
87
+ anchorPoint = Transform.default.anchorPoint
90
88
  }
91
89
 
92
90
  if
@@ -112,7 +110,7 @@ final class Transform: Codable, DictionaryInitializable {
112
110
  positionY = try KeyframeGroup<LottieVector1D>(dictionary: yDictionary)
113
111
  position = nil
114
112
  } else {
115
- position = KeyframeGroup(LottieVector3D(x: Double(0), y: 0, z: 0))
113
+ position = Transform.default.position
116
114
  positionX = nil
117
115
  positionY = nil
118
116
  }
@@ -123,7 +121,7 @@ final class Transform: Codable, DictionaryInitializable {
123
121
  {
124
122
  self.scale = scale
125
123
  } else {
126
- scale = KeyframeGroup(LottieVector3D(x: Double(100), y: 100, z: 100))
124
+ scale = Transform.default.scale
127
125
  }
128
126
 
129
127
  if
@@ -132,7 +130,7 @@ final class Transform: Codable, DictionaryInitializable {
132
130
  {
133
131
  rotationX = rotation
134
132
  } else {
135
- rotationX = KeyframeGroup(LottieVector1D(0))
133
+ rotationX = Transform.default.rotationX
136
134
  }
137
135
 
138
136
  if
@@ -141,7 +139,7 @@ final class Transform: Codable, DictionaryInitializable {
141
139
  {
142
140
  rotationY = rotation
143
141
  } else {
144
- rotationY = KeyframeGroup(LottieVector1D(0))
142
+ rotationY = Transform.default.rotationY
145
143
  }
146
144
 
147
145
  if
@@ -155,7 +153,7 @@ final class Transform: Codable, DictionaryInitializable {
155
153
  {
156
154
  rotationZ = rotation
157
155
  } else {
158
- rotationZ = KeyframeGroup(LottieVector1D(0))
156
+ rotationZ = Transform.default.rotationZ
159
157
  }
160
158
  rotation = nil
161
159
  if
@@ -164,10 +162,34 @@ final class Transform: Codable, DictionaryInitializable {
164
162
  {
165
163
  self.opacity = opacity
166
164
  } else {
167
- opacity = KeyframeGroup(LottieVector1D(100))
165
+ opacity = Transform.default.opacity
168
166
  }
169
167
  }
170
168
 
169
+ init(
170
+ anchorPoint: KeyframeGroup<LottieVector3D>,
171
+ position: KeyframeGroup<LottieVector3D>?,
172
+ positionX: KeyframeGroup<LottieVector1D>?,
173
+ positionY: KeyframeGroup<LottieVector1D>?,
174
+ scale: KeyframeGroup<LottieVector3D>,
175
+ rotationX: KeyframeGroup<LottieVector1D>,
176
+ rotationY: KeyframeGroup<LottieVector1D>,
177
+ rotationZ: KeyframeGroup<LottieVector1D>,
178
+ opacity: KeyframeGroup<LottieVector1D>,
179
+ rotation: KeyframeGroup<LottieVector1D>?)
180
+ {
181
+ self.anchorPoint = anchorPoint
182
+ self.position = position
183
+ self.positionX = positionX
184
+ self.positionY = positionY
185
+ self.scale = scale
186
+ self.rotationX = rotationX
187
+ self.rotationY = rotationY
188
+ self.rotationZ = rotationZ
189
+ self.opacity = opacity
190
+ self.rotation = rotation
191
+ }
192
+
171
193
  // MARK: Internal
172
194
 
173
195
  enum CodingKeys: String, CodingKey {
@@ -189,6 +211,21 @@ final class Transform: Codable, DictionaryInitializable {
189
211
  case positionY = "y"
190
212
  }
191
213
 
214
+ /// Default transform values to use if no transform is provided
215
+ static var `default`: Transform {
216
+ Transform(
217
+ anchorPoint: KeyframeGroup(LottieVector3D(x: Double(0), y: 0, z: 0)),
218
+ position: KeyframeGroup(LottieVector3D(x: Double(0), y: 0, z: 0)),
219
+ positionX: nil,
220
+ positionY: nil,
221
+ scale: KeyframeGroup(LottieVector3D(x: Double(100), y: 100, z: 100)),
222
+ rotationX: KeyframeGroup(LottieVector1D(0)),
223
+ rotationY: KeyframeGroup(LottieVector1D(0)),
224
+ rotationZ: KeyframeGroup(LottieVector1D(0)),
225
+ opacity: KeyframeGroup(LottieVector1D(100)),
226
+ rotation: nil)
227
+ }
228
+
192
229
  /// The anchor point of the transform.
193
230
  let anchorPoint: KeyframeGroup<LottieVector3D>
194
231
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - PathDirection
11
9
 
12
10
  enum PathDirection: Int, Codable {
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - FillRule
11
9
 
12
10
  enum FillRule: Int, Codable {
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - GradientType
11
9
 
12
10
  enum GradientType: Int, Codable, Sendable {
@@ -45,7 +43,7 @@ final class GradientFill: ShapeItem {
45
43
  endPoint = try KeyframeGroup<LottieVector3D>(dictionary: endPointDictionary)
46
44
  let gradientRawType: Int = try dictionary.value(for: CodingKeys.gradientType)
47
45
  guard let gradient = GradientType(rawValue: gradientRawType) else {
48
- throw InitializableError.invalidInput
46
+ throw InitializableError.invalidInput()
49
47
  }
50
48
  gradientType = gradient
51
49
  if let highlightLengthDictionary = dictionary[CodingKeys.highlightLength.rawValue] as? [String: Any] {
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - LineCap
11
9
 
12
10
  enum LineCap: Int, Codable, Sendable {
@@ -60,7 +58,7 @@ final class GradientStroke: ShapeItem {
60
58
  endPoint = try KeyframeGroup<LottieVector3D>(dictionary: endPointDictionary)
61
59
  let gradientRawType: Int = try dictionary.value(for: CodingKeys.gradientType)
62
60
  guard let gradient = GradientType(rawValue: gradientRawType) else {
63
- throw InitializableError.invalidInput
61
+ throw InitializableError.invalidInput()
64
62
  }
65
63
  gradientType = gradient
66
64
  if let highlightLengthDictionary = dictionary[CodingKeys.highlightLength.rawValue] as? [String: Any] {
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  /// An item that define a a group of shape items
11
9
  final class Group: ShapeItem {
12
10
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - MergeMode
11
9
 
12
10
  enum MergeMode: Int, Codable, Sendable {
@@ -33,7 +31,7 @@ final class Merge: ShapeItem {
33
31
  required init(dictionary: [String: Any]) throws {
34
32
  let modeRawType: Int = try dictionary.value(for: CodingKeys.mode)
35
33
  guard let mode = MergeMode(rawValue: modeRawType) else {
36
- throw InitializableError.invalidInput
34
+ throw InitializableError.invalidInput()
37
35
  }
38
36
  self.mode = mode
39
37
  try super.init(dictionary: dictionary)
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  final class Rectangle: ShapeItem {
11
9
 
12
10
  // MARK: Lifecycle
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  final class Repeater: ShapeItem {
11
9
 
12
10
  // MARK: Lifecycle
@@ -5,8 +5,6 @@
5
5
  // Created by Duolingo on 10/31/22.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - RoundedCorners
11
9
 
12
10
  final class RoundedCorners: ShapeItem {
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  /// An item that defines an custom shape
11
9
  final class Shape: ShapeItem {
12
10
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - ShapeType
11
9
 
12
10
  enum ShapeType: String, Codable, Sendable {
@@ -122,7 +120,7 @@ class ShapeItem: Codable, DictionaryInitializable {
122
120
  }
123
121
  }
124
122
 
125
- extension Array where Element == ShapeItem {
123
+ extension [ShapeItem] {
126
124
 
127
125
  static func fromDictionaries(_ dictionaries: [[String: Any]]) throws -> [ShapeItem] {
128
126
  try dictionaries.compactMap { dictionary in
@@ -169,4 +167,5 @@ extension Array where Element == ShapeItem {
169
167
 
170
168
  /// Since `ShapeItem` isn't `final`, we have to use `@unchecked Sendable` instead of `Sendable.`
171
169
  /// All `ShapeItem` subclasses are immutable `Sendable` values.
170
+ // swiftlint:disable:next no_unchecked_sendable
172
171
  extension ShapeItem: @unchecked Sendable { }
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  final class ShapeTransform: ShapeItem {
11
9
 
12
10
  // MARK: Lifecycle
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - StarType
11
9
 
12
10
  enum StarType: Int, Codable, Sendable {
@@ -66,7 +64,7 @@ final class Star: ShapeItem {
66
64
  points = try KeyframeGroup<LottieVector1D>(dictionary: pointsDictionary)
67
65
  let starTypeRawValue: Int = try dictionary.value(for: CodingKeys.starType)
68
66
  guard let starType = StarType(rawValue: starTypeRawValue) else {
69
- throw InitializableError.invalidInput
67
+ throw InitializableError.invalidInput()
70
68
  }
71
69
  self.starType = starType
72
70
  try super.init(dictionary: dictionary)
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  final class Stroke: ShapeItem {
11
9
 
12
10
  // MARK: Lifecycle
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - TrimType
11
9
 
12
10
  enum TrimType: Int, Codable {
@@ -38,7 +36,7 @@ final class Trim: ShapeItem {
38
36
  offset = try KeyframeGroup<LottieVector1D>(dictionary: offsetDictionary)
39
37
  let trimTypeRawValue: Int = try dictionary.value(for: CodingKeys.trimType)
40
38
  guard let trimType = TrimType(rawValue: trimTypeRawValue) else {
41
- throw InitializableError.invalidInput
39
+ throw InitializableError.invalidInput()
42
40
  }
43
41
  self.trimType = trimType
44
42
  try super.init(dictionary: dictionary)
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/9/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - Font
11
9
 
12
10
  final class Font: Codable, Sendable, DictionaryInitializable {
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/9/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  /// A model that holds a vector character
11
9
  final class Glyph: Codable, Sendable, DictionaryInitializable {
12
10
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/9/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  final class TextAnimator: Codable, DictionaryInitializable {
11
9
 
12
10
  // MARK: Lifecycle
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/9/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - TextJustification
11
9
 
12
10
  enum TextJustification: Int, Codable {
@@ -27,7 +25,7 @@ final class TextDocument: Codable, DictionaryInitializable, AnyInitializable {
27
25
  fontFamily = try dictionary.value(for: CodingKeys.fontFamily)
28
26
  let justificationValue: Int = try dictionary.value(for: CodingKeys.justification)
29
27
  guard let justification = TextJustification(rawValue: justificationValue) else {
30
- throw InitializableError.invalidInput
28
+ throw InitializableError.invalidInput()
31
29
  }
32
30
  self.justification = justification
33
31
  tracking = try dictionary.value(for: CodingKeys.tracking)
@@ -59,7 +57,7 @@ final class TextDocument: Codable, DictionaryInitializable, AnyInitializable {
59
57
 
60
58
  convenience init(value: Any) throws {
61
59
  guard let dictionary = value as? [String: Any] else {
62
- throw InitializableError.invalidInput
60
+ throw InitializableError.invalidInput()
63
61
  }
64
62
  try self.init(dictionary: dictionary)
65
63
  }
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/18/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  extension AnimatorNode {
11
9
 
12
10
  func printNodeTree() {
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/24/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  // MARK: - LayerDebugStyle
@@ -54,7 +53,7 @@ extension CALayer {
54
53
  }
55
54
  string = string + "|_" + String(describing: self)
56
55
  LottieLogger.shared.info(string)
57
- if let sublayers = sublayers {
56
+ if let sublayers {
58
57
  for sublayer in sublayers {
59
58
  sublayer.logLayerTree(withIndent: withIndent + 1)
60
59
  }
@@ -80,7 +79,7 @@ extension CALayer {
80
79
  sublayers = cust.layerForDebugging().sublayers
81
80
  }
82
81
 
83
- if let sublayers = sublayers {
82
+ if let sublayers {
84
83
  for i in 0..<sublayers.count {
85
84
  if let debugLayer = sublayers[i] as? DebugLayer {
86
85
  debugLayer.removeFromSuperlayer()
@@ -89,7 +88,7 @@ extension CALayer {
89
88
  }
90
89
  }
91
90
 
92
- if let sublayers = sublayers {
91
+ if let sublayers {
93
92
  for sublayer in sublayers {
94
93
  sublayer.setDebuggingState(visible: visible)
95
94
  }
@@ -206,7 +205,7 @@ extension LayerDebugStyle {
206
205
  }
207
206
  }
208
207
 
209
- extension Array where Element == LayerModel {
208
+ extension [LayerModel] {
210
209
 
211
210
  var parents: [Int] {
212
211
  var array = [Int]()
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 2/4/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  extension KeypathSearchable {
@@ -201,7 +200,7 @@ extension AnimationKeypath {
201
200
  // Pops the top keypath from the stack if the keyname matches.
202
201
  func popKey(_ keyname: String) -> AnimationKeypath? {
203
202
  guard
204
- let currentKey = currentKey,
203
+ let currentKey,
205
204
  currentKey.equalsKeypath(keyname),
206
205
  keys.count > 1
207
206
  else {
@@ -215,7 +214,7 @@ extension AnimationKeypath {
215
214
  if currentKey.keyPathType == .fuzzyWildcard {
216
215
  /// Dont remove if current key is a fuzzy wildcard, and if the next keypath doesnt equal keypathname
217
216
  if
218
- let nextKeypath = nextKeypath,
217
+ let nextKeypath,
219
218
  nextKeypath.equalsKeypath(keyname)
220
219
  {
221
220
  /// Remove next two keypaths. This keypath breaks the wildcard.
@@ -5,7 +5,6 @@
5
5
  // Created by René Fouquet on 03.05.21.
6
6
  //
7
7
 
8
- import Foundation
9
8
  #if canImport(UIKit)
10
9
  import UIKit
11
10
  #elseif canImport(AppKit)
@@ -15,6 +15,11 @@ extension String {
15
15
  return .rgb(red, green, blue)
16
16
  }
17
17
 
18
+ var lottieColor: LottieColor {
19
+ let (red, green, blue) = hexColorComponents()
20
+ return .init(r: red, g: green, b: blue, a: 1.0)
21
+ }
22
+
18
23
  func hexColorComponents() -> (red: CGFloat, green: CGFloat, blue: CGFloat) {
19
24
  var cString: String = trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
20
25
 
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 2/1/19.
6
6
  //
7
7
 
8
- import CoreGraphics
9
8
  import Foundation
10
9
  import QuartzCore
11
10
 
@@ -71,13 +70,13 @@ class AnimationCompletionDelegate: NSObject, CAAnimationDelegate {
71
70
  public func animationDidStop(_ anim: CAAnimation, finished flag: Bool) {
72
71
  guard ignoreDelegate == false else { return }
73
72
  animationState = flag ? .complete : .cancelled
74
- if let animationLayer = animationLayer, let key = animationKey {
73
+ if let animationLayer, let key = animationKey {
75
74
  animationLayer.removeAnimation(forKey: key)
76
75
  if flag {
77
76
  animationLayer.currentFrame = (anim as! CABasicAnimation).toValue as! CGFloat
78
77
  }
79
78
  }
80
- if let completionBlock = completionBlock {
79
+ if let completionBlock {
81
80
  completionBlock(flag)
82
81
  }
83
82
  }
@@ -1,8 +1,6 @@
1
1
  // Created by miguel_jimenez on 8/2/23.
2
2
  // Copyright © 2023 Airbnb Inc. All rights reserved.
3
3
 
4
- import Foundation
5
-
6
4
  // MARK: - AnyEquatable
7
5
 
8
6
  struct AnyEquatable {
@@ -20,8 +20,18 @@ extension LottieAnimationSource {
20
20
  switch self {
21
21
  case .lottieAnimation(let animation):
22
22
  return animation
23
+ case .dotLottieFile:
24
+ return dotLottieAnimation?.animation
25
+ }
26
+ }
27
+
28
+ /// The `DotLottieFile.Animation`, if this is a dotLottie animation
29
+ var dotLottieAnimation: DotLottieFile.Animation? {
30
+ switch self {
31
+ case .lottieAnimation:
32
+ return nil
23
33
  case .dotLottieFile(let dotLottieFile):
24
- return dotLottieFile.animation()?.animation
34
+ return dotLottieFile.animation()
25
35
  }
26
36
  }
27
37
  }
@@ -6,7 +6,6 @@
6
6
  //
7
7
 
8
8
  import CoreGraphics
9
- import Foundation
10
9
 
11
10
  // MARK: - BezierPath
12
11
 
@@ -405,7 +404,7 @@ extension BezierPath: AnyInitializable {
405
404
  } else if let dictionary = value as? [String: Any] {
406
405
  pathDictionary = dictionary
407
406
  } else {
408
- throw InitializableError.invalidInput
407
+ throw InitializableError.invalidInput()
409
408
  }
410
409
  closed = (try? pathDictionary.value(for: CodingKeys.closed)) ?? true
411
410
  var vertexDictionaries: [Any] = try pathDictionary.value(for: CodingKeys.vertices)
@@ -415,7 +414,7 @@ extension BezierPath: AnyInitializable {
415
414
  vertexDictionaries.count == inPointsDictionaries.count,
416
415
  inPointsDictionaries.count == outPointsDictionaries.count
417
416
  else {
418
- throw InitializableError.invalidInput
417
+ throw InitializableError.invalidInput()
419
418
  }
420
419
  guard vertexDictionaries.count > 0 else {
421
420
  length = 0
@@ -22,7 +22,7 @@ extension CGPoint: AnyInitializable {
22
22
  {
23
23
  self.init(x: array[0], y: array[1])
24
24
  } else {
25
- throw InitializableError.invalidInput
25
+ throw InitializableError.invalidInput()
26
26
  }
27
27
  }
28
28
 
@@ -6,7 +6,6 @@
6
6
  //
7
7
 
8
8
  import CoreGraphics
9
- import Foundation
10
9
 
11
10
  // MARK: - LottieColor + Codable
12
11
 
@@ -70,7 +69,7 @@ extension LottieColor: AnyInitializable {
70
69
 
71
70
  init(value: Any) throws {
72
71
  guard var array = value as? [Double] else {
73
- throw InitializableError.invalidInput
72
+ throw InitializableError.invalidInput()
74
73
  }
75
74
  var r: Double = array.count > 0 ? array.removeFirst() : 0
76
75
  var g: Double = array.count > 0 ? array.removeFirst() : 0
@@ -54,7 +54,7 @@ extension LottieVector1D: AnyInitializable {
54
54
  } else if let double = value as? Double {
55
55
  self.value = double
56
56
  } else {
57
- throw InitializableError.invalidInput
57
+ throw InitializableError.invalidInput()
58
58
  }
59
59
  }
60
60
 
@@ -127,7 +127,7 @@ extension LottieVector2D: AnyInitializable {
127
127
 
128
128
  init(value: Any) throws {
129
129
  guard let dictionary = value as? [String: Any] else {
130
- throw InitializableError.invalidInput
130
+ throw InitializableError.invalidInput()
131
131
  }
132
132
 
133
133
  if
@@ -138,7 +138,7 @@ extension LottieVector2D: AnyInitializable {
138
138
  } else if let double = dictionary[CodingKeys.x.rawValue] as? Double {
139
139
  x = double
140
140
  } else {
141
- throw InitializableError.invalidInput
141
+ throw InitializableError.invalidInput()
142
142
  }
143
143
  if
144
144
  let array = dictionary[CodingKeys.y.rawValue] as? [Double],
@@ -148,7 +148,7 @@ extension LottieVector2D: AnyInitializable {
148
148
  } else if let double = dictionary[CodingKeys.y.rawValue] as? Double {
149
149
  y = double
150
150
  } else {
151
- throw InitializableError.invalidInput
151
+ throw InitializableError.invalidInput()
152
152
  }
153
153
  }
154
154
  }
@@ -213,7 +213,7 @@ extension LottieVector3D: AnyInitializable {
213
213
 
214
214
  init(value: Any) throws {
215
215
  guard var array = value as? [Double] else {
216
- throw InitializableError.invalidInput
216
+ throw InitializableError.invalidInput()
217
217
  }
218
218
  x = array.count > 0 ? array.removeFirst() : 0
219
219
  y = array.count > 0 ? array.removeFirst() : 0
@@ -322,7 +322,7 @@ extension CATransform3D {
322
322
  skewAxis: CGFloat?)
323
323
  -> CATransform3D
324
324
  {
325
- if let skew = skew, let skewAxis = skewAxis {
325
+ if let skew, let skewAxis {
326
326
  return CATransform3DMakeTranslation(position.x, position.y, 0)
327
327
  .rotated(rotationX, axis: .x)
328
328
  .rotated(rotationY, axis: .y)
@@ -39,7 +39,7 @@ public final class LottieAnimation: Codable, Sendable, DictionaryInitializable {
39
39
  assetLibrary = try container.decodeIfPresent(AssetLibrary.self, forKey: .assetLibrary)
40
40
  markers = try container.decodeIfPresent([Marker].self, forKey: .markers)
41
41
 
42
- if let markers = markers {
42
+ if let markers {
43
43
  var markerMap: [String: Marker] = [:]
44
44
  for marker in markers {
45
45
  markerMap[marker.name] = marker
@@ -109,7 +109,7 @@ public final class LottieAnimation: Codable, Sendable, DictionaryInitializable {
109
109
 
110
110
  /// Return all marker names, in order, or an empty list if none are specified
111
111
  public var markerNames: [String] {
112
- guard let markers = markers else { return [] }
112
+ guard let markers else { return [] }
113
113
  return markers.map { $0.name }
114
114
  }
115
115