lottie-ios 4.3.3 → 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 (199) hide show
  1. package/.github/workflows/main.yml +51 -58
  2. package/Lottie.xcodeproj/project.pbxproj +40 -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 -666
  7. package/Package.resolved +20 -22
  8. package/Package.swift +4 -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 +97 -31
  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/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift +1 -1
  39. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift +1 -3
  40. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +2 -0
  41. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +2 -0
  42. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +2 -0
  43. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +2 -0
  44. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +2 -0
  45. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +2 -0
  46. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +2 -0
  47. package/Sources/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +2 -0
  48. package/Sources/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +2 -1
  49. package/Sources/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +256 -0
  50. package/Sources/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
  51. package/Sources/Private/EmbeddedLibraries/README.md +16 -0
  52. package/Sources/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +2 -2
  53. package/Sources/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +7 -7
  54. package/Sources/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +2 -2
  55. package/Sources/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +5 -5
  56. package/Sources/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +1 -2
  57. package/Sources/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +1 -3
  58. package/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +1 -2
  59. package/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +2 -3
  60. package/Sources/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +2 -3
  61. package/Sources/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +5 -12
  62. package/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +0 -1
  63. package/Sources/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +11 -7
  64. package/Sources/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +3 -3
  65. package/Sources/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +12 -12
  66. package/Sources/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +1 -3
  67. package/Sources/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +0 -2
  68. package/Sources/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +1 -3
  69. package/Sources/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +0 -2
  70. package/Sources/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +0 -2
  71. package/Sources/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +1 -3
  72. package/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +0 -1
  73. package/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +0 -1
  74. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +1 -3
  75. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +1 -2
  76. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +0 -1
  77. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +0 -2
  78. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +0 -1
  79. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +0 -1
  80. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +0 -1
  81. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +2 -3
  82. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +1 -3
  83. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +2 -2
  84. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +0 -2
  85. package/Sources/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +0 -1
  86. package/Sources/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +0 -2
  87. package/Sources/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +0 -2
  88. package/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +0 -1
  89. package/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +0 -1
  90. package/Sources/Private/Model/Assets/Asset.swift +2 -3
  91. package/Sources/Private/Model/Assets/AssetLibrary.swift +11 -11
  92. package/Sources/Private/Model/Assets/ImageAsset.swift +20 -0
  93. package/Sources/Private/Model/Assets/PrecompAsset.swift +0 -2
  94. package/Sources/Private/Model/DictionaryInitializable.swift +18 -10
  95. package/Sources/Private/Model/DotLottie/DotLottieImageProvider.swift +9 -6
  96. package/Sources/Private/Model/DotLottie/DotLottieUtils.swift +1 -1
  97. package/Sources/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +5 -4
  98. package/Sources/Private/Model/Keyframes/KeyframeData.swift +1 -4
  99. package/Sources/Private/Model/Keyframes/KeyframeGroup.swift +1 -3
  100. package/Sources/Private/Model/LayerEffects/DropShadowEffect.swift +0 -2
  101. package/Sources/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +0 -2
  102. package/Sources/Private/Model/LayerEffects/EffectValues/EffectValue.swift +4 -5
  103. package/Sources/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +0 -2
  104. package/Sources/Private/Model/LayerEffects/LayerEffect.swift +2 -3
  105. package/Sources/Private/Model/LayerStyles/DropShadowStyle.swift +0 -2
  106. package/Sources/Private/Model/LayerStyles/LayerStyle.swift +2 -3
  107. package/Sources/Private/Model/Layers/ImageLayerModel.swift +0 -2
  108. package/Sources/Private/Model/Layers/LayerModel.swift +16 -5
  109. package/Sources/Private/Model/Layers/PreCompLayerModel.swift +0 -2
  110. package/Sources/Private/Model/Layers/ShapeLayerModel.swift +0 -2
  111. package/Sources/Private/Model/Layers/SolidLayerModel.swift +0 -2
  112. package/Sources/Private/Model/Layers/TextLayerModel.swift +0 -2
  113. package/Sources/Private/Model/Objects/DashPattern.swift +1 -3
  114. package/Sources/Private/Model/Objects/Marker.swift +0 -2
  115. package/Sources/Private/Model/Objects/Mask.swift +0 -2
  116. package/Sources/Private/Model/Objects/Transform.swift +46 -9
  117. package/Sources/Private/Model/ShapeItems/Ellipse.swift +0 -2
  118. package/Sources/Private/Model/ShapeItems/Fill.swift +0 -2
  119. package/Sources/Private/Model/ShapeItems/GradientFill.swift +1 -3
  120. package/Sources/Private/Model/ShapeItems/GradientStroke.swift +1 -3
  121. package/Sources/Private/Model/ShapeItems/Group.swift +0 -2
  122. package/Sources/Private/Model/ShapeItems/Merge.swift +1 -3
  123. package/Sources/Private/Model/ShapeItems/Rectangle.swift +0 -2
  124. package/Sources/Private/Model/ShapeItems/Repeater.swift +0 -2
  125. package/Sources/Private/Model/ShapeItems/RoundedCorners.swift +0 -2
  126. package/Sources/Private/Model/ShapeItems/Shape.swift +0 -2
  127. package/Sources/Private/Model/ShapeItems/ShapeItem.swift +2 -3
  128. package/Sources/Private/Model/ShapeItems/ShapeTransform.swift +0 -2
  129. package/Sources/Private/Model/ShapeItems/Star.swift +1 -3
  130. package/Sources/Private/Model/ShapeItems/Stroke.swift +0 -2
  131. package/Sources/Private/Model/ShapeItems/Trim.swift +1 -3
  132. package/Sources/Private/Model/Text/Font.swift +0 -2
  133. package/Sources/Private/Model/Text/Glyph.swift +0 -2
  134. package/Sources/Private/Model/Text/TextAnimator.swift +0 -2
  135. package/Sources/Private/Model/Text/TextDocument.swift +2 -4
  136. package/Sources/Private/Utility/Debugging/AnimatorNodeDebugging.swift +0 -2
  137. package/Sources/Private/Utility/Debugging/LayerDebugging.swift +4 -5
  138. package/Sources/Private/Utility/Extensions/AnimationKeypathExtension.swift +2 -3
  139. package/Sources/Private/Utility/Extensions/DataExtension.swift +0 -1
  140. package/Sources/Private/Utility/Extensions/StringExtensions.swift +5 -0
  141. package/Sources/Private/Utility/Helpers/AnimationContext.swift +2 -3
  142. package/Sources/Private/Utility/Helpers/AnyEquatable.swift +0 -2
  143. package/Sources/Private/Utility/Helpers/Binding+Map.swift +2 -0
  144. package/Sources/Private/Utility/Helpers/View+ValueChanged.swift +2 -0
  145. package/Sources/Private/Utility/LottieAnimationSource.swift +11 -1
  146. package/Sources/Private/Utility/Primitives/BezierPath.swift +2 -3
  147. package/Sources/Private/Utility/Primitives/CGPointExtension.swift +1 -1
  148. package/Sources/Private/Utility/Primitives/ColorExtension.swift +1 -2
  149. package/Sources/Private/Utility/Primitives/VectorsExtensions.swift +6 -6
  150. package/Sources/Public/Animation/LottieAnimation.swift +2 -2
  151. package/Sources/Public/Animation/LottieAnimationHelpers.swift +7 -5
  152. package/Sources/Public/Animation/LottieAnimationLayer.swift +30 -43
  153. package/Sources/Public/Animation/LottieAnimationView.swift +18 -8
  154. package/Sources/Public/Animation/LottieAnimationViewInitializers.swift +3 -3
  155. package/Sources/Public/Animation/LottiePlaybackMode.swift +53 -0
  156. package/Sources/Public/Animation/LottieView.swift +145 -48
  157. package/Sources/Public/AnimationCache/AnimationCacheProvider.swift +0 -2
  158. package/Sources/Public/AnimationCache/DefaultAnimationCache.swift +21 -7
  159. package/Sources/Public/AnimationCache/LRUAnimationCache.swift +0 -2
  160. package/Sources/Public/Controls/AnimatedButton.swift +4 -6
  161. package/Sources/Public/Controls/AnimatedControl.swift +1 -3
  162. package/Sources/Public/Controls/AnimatedSwitch.swift +1 -3
  163. package/Sources/Public/Controls/LottieButton.swift +2 -1
  164. package/Sources/Public/Controls/LottieSwitch.swift +2 -0
  165. package/Sources/Public/DotLottie/Cache/DotLottieCache.swift +17 -4
  166. package/Sources/Public/DotLottie/Cache/DotLottieCacheProvider.swift +1 -3
  167. package/Sources/Public/DotLottie/DotLottieConfiguration.swift +53 -5
  168. package/Sources/Public/DotLottie/DotLottieFile.swift +4 -3
  169. package/Sources/Public/DotLottie/DotLottieFileHelpers.swift +18 -11
  170. package/Sources/Public/DynamicProperties/AnimationKeypath.swift +0 -2
  171. package/Sources/Public/DynamicProperties/AnyValueProvider.swift +0 -1
  172. package/Sources/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +2 -2
  173. package/Sources/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +1 -1
  174. package/Sources/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +1 -1
  175. package/Sources/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +1 -1
  176. package/Sources/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +1 -1
  177. package/Sources/Public/FontProvider/AnimationFontProvider.swift +0 -2
  178. package/Sources/Public/ImageProvider/AnimationImageProvider.swift +0 -2
  179. package/Sources/Public/Keyframes/Interpolatable.swift +26 -0
  180. package/Sources/Public/Primitives/LottieColor.swift +0 -2
  181. package/Sources/Public/Primitives/Vectors.swift +0 -2
  182. package/Sources/Public/TextProvider/AnimationTextProvider.swift +0 -2
  183. package/Sources/Public/iOS/AnimationSubview.swift +0 -1
  184. package/Sources/Public/iOS/BundleImageProvider.swift +3 -8
  185. package/Sources/Public/iOS/Compatibility/CompatibleAnimationView.swift +4 -8
  186. package/Sources/Public/iOS/LottieAnimationViewBase.swift +5 -2
  187. package/Sources/Public/iOS/UIColorExtension.swift +1 -2
  188. package/Sources/Public/macOS/BundleImageProvider.macOS.swift +3 -6
  189. package/lottie-ios.podspec +6 -2
  190. package/package.json +1 -1
  191. package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  192. package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  193. package/Lottie.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +0 -37
  194. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  195. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
  196. package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/xcdebugger/Expressions.xcexplist +0 -153
  197. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/IDEFindNavigatorScopes.plist +0 -5
  198. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Expressions.xcexplist +0 -231
  199. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +0 -37
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/8/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  /// A layer that holds vector shape objects.
11
9
  final class ShapeLayerModel: LayerModel {
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
  /// A layer that holds a solid color.
11
9
  final class SolidLayerModel: LayerModel {
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
  /// A layer that holds text.
11
9
  final class TextLayerModel: LayerModel {
12
10
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/22/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - DashElementType
11
9
 
12
10
  enum DashElementType: String, Codable {
@@ -24,7 +22,7 @@ final class DashElement: Codable, DictionaryInitializable {
24
22
  init(dictionary: [String: Any]) throws {
25
23
  let typeRawValue: String = try dictionary.value(for: CodingKeys.type)
26
24
  guard let type = DashElementType(rawValue: typeRawValue) else {
27
- throw InitializableError.invalidInput
25
+ throw InitializableError.invalidInput()
28
26
  }
29
27
  self.type = type
30
28
  let valueDictionary: [String: Any] = try dictionary.value(for: CodingKeys.value)
@@ -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 time marker
11
9
  final class Marker: Codable, Sendable, DictionaryInitializable {
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: - MaskMode
11
9
 
12
10
  enum MaskMode: String, Codable {
@@ -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 {
@@ -1,6 +1,7 @@
1
1
  // Created by miguel_jimenez on 7/27/23.
2
2
  // Copyright © 2023 Airbnb Inc. All rights reserved.
3
3
 
4
+ #if canImport(SwiftUI)
4
5
  import SwiftUI
5
6
 
6
7
  @available(iOS 13.0, tvOS 13.0, macOS 10.15, *)
@@ -16,3 +17,4 @@ extension Binding {
16
17
  }
17
18
  }
18
19
  }
20
+ #endif
@@ -1,6 +1,7 @@
1
1
  // Created by miguel_jimenez on 7/26/23.
2
2
  // Copyright © 2023 Airbnb Inc. All rights reserved.
3
3
 
4
+ #if canImport(Combine) && canImport(SwiftUI)
4
5
  import Combine
5
6
  import SwiftUI
6
7
 
@@ -18,3 +19,4 @@ extension View {
18
19
  }
19
20
  }
20
21
  }
22
+ #endif
@@ -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