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
@@ -33,7 +33,7 @@
33
33
 
34
34
  import Foundation
35
35
 
36
- #if os(iOS) || os(tvOS)
36
+ #if canImport(UIKit)
37
37
  import UIKit
38
38
 
39
39
  /// Notification that cache should be cleared
@@ -74,7 +74,7 @@ final class LRUCache<Key: Hashable, Value> {
74
74
  }
75
75
 
76
76
  deinit {
77
- if let token = token {
77
+ if let token {
78
78
  notificationCenter.removeObserver(token)
79
79
  }
80
80
  }
@@ -131,7 +131,7 @@ extension LRUCache {
131
131
 
132
132
  /// Insert a value into the cache with optional `cost`
133
133
  func setValue(_ value: Value?, forKey key: Key, cost: Int = 0) {
134
- guard let value = value else {
134
+ guard let value else {
135
135
  removeValue(forKey: key)
136
136
  return
137
137
  }
@@ -39,3 +39,5 @@ When doing this, follow these steps:
39
39
 
40
40
  5. Change all of the `public` symbols defined in the module to instead be `internal`
41
41
  to prevent Lottie from exposing any APIs from other libraries.
42
+
43
+ 6. If the dependency provides a privacy manifest, incorporate content from that dependency's privacy manifest into Lottie's privacy manifest.
@@ -92,13 +92,13 @@ extension Archive {
92
92
  }
93
93
  case .directory:
94
94
  _ = try provider(0, 0)
95
- if let progress = progress { progress.completedUnitCount = progress.totalUnitCount }
95
+ if let progress { progress.completedUnitCount = progress.totalUnitCount }
96
96
  case .symlink:
97
97
  let (linkSizeWritten, linkChecksum) = try writeSymbolicLink(
98
98
  size: Int(uncompressedSize),
99
99
  provider: provider)
100
100
  (sizeWritten, checksum) = (Int64(linkSizeWritten), linkChecksum)
101
- if let progress = progress { progress.completedUnitCount = progress.totalUnitCount }
101
+ if let progress { progress.completedUnitCount = progress.totalUnitCount }
102
102
  }
103
103
  return (sizeWritten, checksum)
104
104
  }
@@ -102,7 +102,7 @@ private func fileFromCookie(cookie: UnsafeRawPointer) -> MemoryFile {
102
102
  }
103
103
 
104
104
  private func closeStub(_ cookie: UnsafeMutableRawPointer?) -> Int32 {
105
- if let cookie = cookie {
105
+ if let cookie {
106
106
  Unmanaged<MemoryFile>.fromOpaque(cookie).release()
107
107
  }
108
108
  return 0
@@ -115,7 +115,7 @@ private func readStub(
115
115
  _ count: Int32)
116
116
  -> Int32
117
117
  {
118
- guard let cookie = cookie, let bytePtr = bytePtr else { return 0 }
118
+ guard let cookie, let bytePtr else { return 0 }
119
119
  return Int32(fileFromCookie(cookie: cookie).readData(
120
120
  buffer: UnsafeMutableRawBufferPointer(start: bytePtr, count: Int(count))))
121
121
  }
@@ -126,7 +126,7 @@ private func writeStub(
126
126
  _ count: Int32)
127
127
  -> Int32
128
128
  {
129
- guard let cookie = cookie, let bytePtr = bytePtr else { return 0 }
129
+ guard let cookie, let bytePtr else { return 0 }
130
130
  return Int32(fileFromCookie(cookie: cookie).writeData(
131
131
  buffer: UnsafeRawBufferPointer(start: bytePtr, count: Int(count))))
132
132
  }
@@ -137,7 +137,7 @@ private func seekStub(
137
137
  _ whence: Int32)
138
138
  -> fpos_t
139
139
  {
140
- guard let cookie = cookie else { return 0 }
140
+ guard let cookie else { return 0 }
141
141
  return fpos_t(fileFromCookie(cookie: cookie).seek(offset: Int(offset), whence: whence))
142
142
  }
143
143
 
@@ -148,7 +148,7 @@ private func readStub(
148
148
  _ count: Int)
149
149
  -> Int
150
150
  {
151
- guard let cookie = cookie, let bytePtr = bytePtr else { return 0 }
151
+ guard let cookie, let bytePtr else { return 0 }
152
152
  return fileFromCookie(cookie: cookie).readData(
153
153
  buffer: UnsafeMutableRawBufferPointer(start: bytePtr, count: count))
154
154
  }
@@ -159,7 +159,7 @@ private func writeStub(
159
159
  _ count: Int)
160
160
  -> Int
161
161
  {
162
- guard let cookie = cookie, let bytePtr = bytePtr else { return 0 }
162
+ guard let cookie, let bytePtr else { return 0 }
163
163
  return fileFromCookie(cookie: cookie).writeData(
164
164
  buffer: UnsafeRawBufferPointer(start: bytePtr, count: count))
165
165
  }
@@ -170,7 +170,7 @@ private func seekStub(
170
170
  _ whence: Int32)
171
171
  -> Int32
172
172
  {
173
- guard let cookie = cookie, let offset = offset else { return 0 }
173
+ guard let cookie, let offset else { return 0 }
174
174
  let result = fileFromCookie(cookie: cookie).seek(offset: Int(offset.pointee), whence: whence)
175
175
  if result >= 0 {
176
176
  offset.pointee = result
@@ -149,7 +149,7 @@ extension Data {
149
149
  position += Int64(stream.prepare(for: sourceData))
150
150
  } catch { throw error }
151
151
  }
152
- if let sourceData = sourceData {
152
+ if let sourceData {
153
153
  sourceData.withUnsafeBytes { rawBufferPointer in
154
154
  if let baseAddress = rawBufferPointer.baseAddress {
155
155
  let pointer = baseAddress.assumingMemoryBound(to: UInt8.self)
@@ -179,7 +179,7 @@ extension Data {
179
179
  extension compression_stream {
180
180
 
181
181
  fileprivate mutating func prepare(for sourceData: Data?) -> Int {
182
- guard let sourceData = sourceData else { return 0 }
182
+ guard let sourceData else { return 0 }
183
183
 
184
184
  src_size = sourceData.count
185
185
  return sourceData.count
@@ -156,7 +156,7 @@ extension FileManager {
156
156
  if isDirectory {
157
157
  let subPaths = try subpathsOfDirectory(atPath: sourceURL.path)
158
158
  var totalUnitCount = Int64(0)
159
- if let progress = progress {
159
+ if let progress {
160
160
  totalUnitCount = subPaths.reduce(Int64(0)) {
161
161
  let itemURL = sourceURL.appendingPathComponent($1)
162
162
  let itemSize = archive.totalUnitCountForAddingItem(at: itemURL)
@@ -171,7 +171,7 @@ extension FileManager {
171
171
  for entryPath in subPaths {
172
172
  let finalEntryPath = shouldKeepParent ? directoryPrefix + "/" + entryPath : entryPath
173
173
  let finalBaseURL = shouldKeepParent ? sourceURL.deletingLastPathComponent() : sourceURL
174
- if let progress = progress {
174
+ if let progress {
175
175
  let itemURL = sourceURL.appendingPathComponent(entryPath)
176
176
  let entryProgress = archive.makeProgressForAddingItem(at: itemURL)
177
177
  progress.addChild(entryProgress, withPendingUnitCount: entryProgress.totalUnitCount)
@@ -233,7 +233,7 @@ extension FileManager {
233
233
  }
234
234
  }
235
235
  var totalUnitCount = Int64(0)
236
- if let progress = progress {
236
+ if let progress {
237
237
  totalUnitCount = sortedEntries.reduce(0) { $0 + archive.totalUnitCountForReading($1) }
238
238
  progress.totalUnitCount = totalUnitCount
239
239
  }
@@ -247,7 +247,7 @@ extension FileManager {
247
247
  userInfo: [NSFilePathErrorKey: entryURL.path])
248
248
  }
249
249
  let crc32: CRC32
250
- if let progress = progress {
250
+ if let progress {
251
251
  let entryProgress = archive.makeProgressForReading(entry)
252
252
  progress.addChild(entryProgress, withPendingUnitCount: entryProgress.totalUnitCount)
253
253
  crc32 = try archive.extract(entry, to: entryURL, skipCRC32: skipCRC32, progress: entryProgress)
@@ -349,7 +349,7 @@ extension Date {
349
349
  extension CocoaError {
350
350
  static func error(_ code: CocoaError.Code, userInfo: [AnyHashable: Any]? = nil, url: URL? = nil) -> Error {
351
351
  var info: [String: Any] = userInfo as? [String: Any] ?? [:]
352
- if let url = url {
352
+ if let url {
353
353
  info[NSURLErrorKey] = url
354
354
  }
355
355
  return NSError(domain: NSCocoaErrorDomain, code: code.rawValue, userInfo: info)
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/22/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  // MARK: - CompositionLayer
@@ -52,7 +51,7 @@ class CompositionLayer: CALayer, KeypathSearchable {
52
51
  compositingFilter = layer.blendMode.filterName
53
52
  addSublayer(contentsLayer)
54
53
 
55
- if let maskLayer = maskLayer {
54
+ if let maskLayer {
56
55
  contentsLayer.mask = maskLayer
57
56
  }
58
57
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import CoreGraphics
9
- import Foundation
10
8
  import QuartzCore
11
9
 
12
10
  final class ImageCompositionLayer: CompositionLayer {
@@ -40,7 +38,7 @@ final class ImageCompositionLayer: CompositionLayer {
40
38
 
41
39
  var image: CGImage? = nil {
42
40
  didSet {
43
- if let image = image {
41
+ if let image {
44
42
  contentsLayer.contents = image
45
43
  } else {
46
44
  contentsLayer.contents = nil
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  extension MaskMode {
@@ -129,7 +128,7 @@ private class MaskLayer: CALayer {
129
128
  let maskLayer = CAShapeLayer()
130
129
 
131
130
  func updateWithFrame(frame: CGFloat, forceUpdates: Bool) {
132
- guard let properties = properties else { return }
131
+ guard let properties else { return }
133
132
  if properties.opacity.needsUpdate(frame: frame) || forceUpdates {
134
133
  properties.opacity.update(frame: frame)
135
134
  opacity = Float(properties.opacity.value.cgFloatValue)
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  final class PreCompositionLayer: CompositionLayer {
@@ -102,7 +101,7 @@ final class PreCompositionLayer: CompositionLayer {
102
101
  let remappingNode: NodeProperty<LottieVector1D>?
103
102
 
104
103
  override var keypathProperties: [String: AnyNodeProperty] {
105
- guard let remappingNode = remappingNode else {
104
+ guard let remappingNode else {
106
105
  return super.keypathProperties
107
106
  }
108
107
  return ["Time Remap" : remappingNode]
@@ -110,7 +109,7 @@ final class PreCompositionLayer: CompositionLayer {
110
109
 
111
110
  override func displayContentsWithFrame(frame: CGFloat, forceUpdates: Bool) {
112
111
  let localFrame: CGFloat
113
- if let remappingNode = remappingNode {
112
+ if let remappingNode {
114
113
  remappingNode.update(frame: frame)
115
114
  localFrame = remappingNode.value.cgFloatValue * frameRate
116
115
  } else {
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  final class SolidCompositionLayer: CompositionLayer {
@@ -45,12 +44,12 @@ final class SolidCompositionLayer: CompositionLayer {
45
44
  let solidShape = CAShapeLayer()
46
45
 
47
46
  override var keypathProperties: [String: AnyNodeProperty] {
48
- guard let colorProperty = colorProperty else { return super.keypathProperties }
47
+ guard let colorProperty else { return super.keypathProperties }
49
48
  return [PropertyName.color.rawValue : colorProperty]
50
49
  }
51
50
 
52
51
  override func displayContentsWithFrame(frame: CGFloat, forceUpdates _: Bool) {
53
- guard let colorProperty = colorProperty else { return }
52
+ guard let colorProperty else { return }
54
53
  colorProperty.update(frame: frame)
55
54
  solidShape.fillColor = colorProperty.value.cgColorValue
56
55
  }
@@ -5,11 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import CoreGraphics
9
- import CoreText
10
- import Foundation
11
- import QuartzCore
12
-
13
8
  /// Needed for NSMutableParagraphStyle...
14
9
  #if os(OSX)
15
10
  import AppKit
@@ -69,7 +64,7 @@ final class TextCompositionLayer: CompositionLayer {
69
64
  self.textLayer.masksToBounds = false
70
65
  self.textLayer.isGeometryFlipped = true
71
66
 
72
- if let rootNode = rootNode {
67
+ if let rootNode {
73
68
  childKeypaths.append(rootNode)
74
69
  }
75
70
  }
@@ -102,17 +97,15 @@ final class TextCompositionLayer: CompositionLayer {
102
97
  var fontProvider: AnimationFontProvider
103
98
  weak var rootAnimationLayer: MainThreadAnimationLayer?
104
99
 
105
- lazy var fullAnimationKeypath: AnimationKeypath = {
106
- // Individual layers don't know their full keypaths, so we have to delegate
100
+ lazy var fullAnimationKeypath: AnimationKeypath = // Individual layers don't know their full keypaths, so we have to delegate
107
101
  // to the `MainThreadAnimationLayer` to search the layer hierarchy and find
108
102
  // the full keypath (which includes this layer's parent layers)
109
103
  rootAnimationLayer?.keypath(for: self)
110
- // If that failed for some reason, just use the last path component (which we do have here)
111
- ?? AnimationKeypath(keypath: keypathName)
112
- }()
104
+ // If that failed for some reason, just use the last path component (which we do have here)
105
+ ?? AnimationKeypath(keypath: keypathName)
113
106
 
114
107
  override func displayContentsWithFrame(frame: CGFloat, forceUpdates: Bool) {
115
- guard let textDocument = textDocument else { return }
108
+ guard let textDocument else { return }
116
109
 
117
110
  textLayer.contentsScale = renderScale
118
111
 
@@ -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: - MainThreadAnimationLayer
@@ -1,8 +1,6 @@
1
1
  // Created by Jianjun Wu on 2022/5/12.
2
2
  // Copyright © 2022 Airbnb Inc. All rights reserved.
3
3
 
4
- import CoreGraphics
5
- import Foundation
6
4
  import QuartzCore
7
5
 
8
6
  // MARK: - CachedImageProvider
@@ -8,7 +8,7 @@
8
8
  import CoreGraphics
9
9
  import Foundation
10
10
 
11
- extension Array where Element == LayerModel {
11
+ extension [LayerModel] {
12
12
 
13
13
  func initializeCompositionLayers(
14
14
  assetLibrary: AssetLibrary?,
@@ -41,7 +41,7 @@ extension Array where Element == LayerModel {
41
41
  layerMap[layer.index] = solidContainer
42
42
  } else if
43
43
  let precompLayer = layer as? PreCompLayerModel,
44
- let assetLibrary = assetLibrary,
44
+ let assetLibrary,
45
45
  let precompAsset = assetLibrary.precompAssets[precompLayer.referenceID]
46
46
  {
47
47
  let precompContainer = PreCompositionLayer(
@@ -58,7 +58,7 @@ extension Array where Element == LayerModel {
58
58
  layerMap[layer.index] = precompContainer
59
59
  } else if
60
60
  let imageLayer = layer as? ImageLayerModel,
61
- let assetLibrary = assetLibrary,
61
+ let assetLibrary,
62
62
  let imageAsset = assetLibrary.imageAssets[imageLayer.referenceID]
63
63
  {
64
64
  let imageContainer = ImageCompositionLayer(
@@ -117,7 +117,7 @@ final class CoreTextRenderLayer: CALayer {
117
117
  }
118
118
 
119
119
  override func draw(in ctx: CGContext) {
120
- guard let attributedString = attributedString else { return }
120
+ guard let attributedString else { return }
121
121
  updateTextContent()
122
122
  guard fillFrameSetter != nil || strokeFrameSetter != nil else { return }
123
123
 
@@ -155,21 +155,21 @@ final class CoreTextRenderLayer: CALayer {
155
155
  // For some reason some fonts, such as Helvetica draw with and ascender that is greater than the one reported by CTFontGetAscender.
156
156
  // I suspect this is actually an issue with the Attributed string, but cannot reproduce.
157
157
 
158
- if let fillFrame = fillFrame {
158
+ if let fillFrame {
159
159
  ctx.adjustWithLineOrigins(in: fillFrame, with: font)
160
- } else if let strokeFrame = strokeFrame {
160
+ } else if let strokeFrame {
161
161
  ctx.adjustWithLineOrigins(in: strokeFrame, with: font)
162
162
  }
163
163
 
164
- if !strokeOnTop, let strokeFrame = strokeFrame {
164
+ if !strokeOnTop, let strokeFrame {
165
165
  CTFrameDraw(strokeFrame, ctx)
166
166
  }
167
167
 
168
- if let fillFrame = fillFrame {
168
+ if let fillFrame {
169
169
  CTFrameDraw(fillFrame, ctx)
170
170
  }
171
171
 
172
- if strokeOnTop, let strokeFrame = strokeFrame {
172
+ if strokeOnTop, let strokeFrame {
173
173
  CTFrameDraw(strokeFrame, ctx)
174
174
  }
175
175
  }
@@ -186,7 +186,7 @@ final class CoreTextRenderLayer: CALayer {
186
186
  // Draws Debug colors for the font alignment.
187
187
  @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
188
188
  private func drawDebug(_ ctx: CGContext) {
189
- if let font = font {
189
+ if let font {
190
190
  let ascent = CTFontGetAscent(font)
191
191
  let descent = CTFontGetDescent(font)
192
192
  let capHeight = CTFontGetCapHeight(font)
@@ -224,7 +224,7 @@ final class CoreTextRenderLayer: CALayer {
224
224
  private func updateTextContent() {
225
225
  guard needsContentUpdate else { return }
226
226
  needsContentUpdate = false
227
- guard let font = font, let text = text, text.count > 0, fillColor != nil || strokeColor != nil else {
227
+ guard let font, let text, text.count > 0, fillColor != nil || strokeColor != nil else {
228
228
  drawingRect = .zero
229
229
  drawingAnchor = .zero
230
230
  attributedString = nil
@@ -256,7 +256,7 @@ final class CoreTextRenderLayer: CALayer {
256
256
  NSAttributedString.Key.paragraphStyle: paragraphStyle,
257
257
  ]
258
258
 
259
- if let fillColor = fillColor {
259
+ if let fillColor {
260
260
  attributes[NSAttributedString.Key.foregroundColor] = fillColor
261
261
  }
262
262
 
@@ -270,7 +270,7 @@ final class CoreTextRenderLayer: CALayer {
270
270
  fillFrameSetter = nil
271
271
  }
272
272
 
273
- if let strokeColor = strokeColor {
273
+ if let strokeColor {
274
274
  attributes[NSAttributedString.Key.foregroundColor] = nil
275
275
  attributes[NSAttributedString.Key.strokeWidth] = strokeWidth
276
276
  attributes[NSAttributedString.Key.strokeColor] = strokeColor
@@ -287,7 +287,7 @@ final class CoreTextRenderLayer: CALayer {
287
287
 
288
288
  // Calculate drawing size and anchor offset
289
289
  let textAnchor: CGPoint
290
- if let preferredSize = preferredSize {
290
+ if let preferredSize {
291
291
  drawingRect = CGRect(origin: .zero, size: preferredSize)
292
292
  drawingRect.size.height += (ascent - capHeight)
293
293
  drawingRect.size.height += descent
@@ -332,7 +332,7 @@ final class CoreTextRenderLayer: CALayer {
332
332
  extension CGContext {
333
333
 
334
334
  fileprivate func adjustWithLineOrigins(in frame: CTFrame, with font: CTFont?) {
335
- guard let font = font else { return }
335
+ guard let font else { return }
336
336
 
337
337
  let count = CFArrayGetCount(CTFrameGetLines(frame))
338
338
 
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/28/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  /// A layer that inverses the alpha output of its input layer.
@@ -46,7 +45,7 @@ final class InvertedMatteLayer: CALayer, CompositionLayerDelegate {
46
45
  }
47
46
 
48
47
  override func draw(in ctx: CGContext) {
49
- guard let inputMatte = inputMatte else { return }
48
+ guard let inputMatte else { return }
50
49
  ctx.setFillColor(.rgb(0, 0, 0))
51
50
  ctx.fill(bounds)
52
51
  ctx.setBlendMode(.destinationOut)
@@ -6,8 +6,6 @@
6
6
  // Copyright © 2020 YurtvilleProds. All rights reserved.
7
7
  //
8
8
 
9
- import Foundation
10
-
11
9
  /// Connects a LottieFontProvider to a group of text layers
12
10
  final class LayerFontProvider {
13
11
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/25/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  /// Connects a LottieImageProvider to a group of image layers
11
9
  final class LayerImageProvider {
12
10
 
@@ -15,7 +13,7 @@ final class LayerImageProvider {
15
13
  init(imageProvider: AnimationImageProvider, assets: [String: ImageAsset]?) {
16
14
  self.imageProvider = imageProvider
17
15
  imageLayers = [ImageCompositionLayer]()
18
- if let assets = assets {
16
+ if let assets {
19
17
  imageAssets = assets
20
18
  } else {
21
19
  imageAssets = [:]
@@ -5,8 +5,6 @@
5
5
  // Created by Alexandr Goncharov on 07/06/2019.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  /// Connects a LottieTextProvider to a group of text layers
11
9
  final class LayerTextProvider {
12
10
 
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 2/4/19.
6
6
  //
7
7
 
8
- import CoreGraphics
9
- import Foundation
10
8
  import QuartzCore
11
9
 
12
10
  // MARK: - LayerTransformProperties
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/18/19.
6
6
  //
7
7
 
8
- import Foundation
9
-
10
8
  // MARK: - NodeTree
11
9
 
12
10
  final class NodeTree {
@@ -17,7 +15,7 @@ final class NodeTree {
17
15
  var childrenNodes: [AnimatorNode] = []
18
16
  }
19
17
 
20
- extension Array where Element == ShapeItem {
18
+ extension [ShapeItem] {
21
19
  func initializeNodeTree() -> NodeTree {
22
20
  let nodeTree = NodeTree()
23
21
 
@@ -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
  /// Protocol that provides keypath search functionality. Returns all node properties associated with a keypath.
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/21/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  // MARK: - NodePropertyMap
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/30/19.
6
6
  //
7
7
 
8
- import CoreGraphics
9
- import Foundation
10
8
  import QuartzCore
11
9
 
12
10
  class GroupOutputNode: NodeOutput {
@@ -59,7 +57,7 @@ class GroupOutputNode: NodeOutput {
59
57
  }
60
58
  var xform = CATransform3DGetAffineTransform(transform)
61
59
  if
62
- let rootNode = rootNode,
60
+ let rootNode,
63
61
  let rootPath = rootNode.outputPath,
64
62
  let xformedPath = rootPath.copy(using: &xform)
65
63
  {
@@ -6,7 +6,6 @@
6
6
  //
7
7
 
8
8
  import CoreGraphics
9
- import Foundation
10
9
 
11
10
  class PassThroughOutputNode: NodeOutput {
12
11
 
@@ -24,7 +23,7 @@ class PassThroughOutputNode: NodeOutput {
24
23
  var isEnabled = true
25
24
 
26
25
  var outputPath: CGPath? {
27
- if let parent = parent {
26
+ if let parent {
28
27
  return parent.outputPath
29
28
  }
30
29
  return nil
@@ -6,7 +6,6 @@
6
6
  //
7
7
 
8
8
  import CoreGraphics
9
- import Foundation
10
9
 
11
10
  /// A node that has an output of a BezierPath
12
11
  class PathOutputNode: NodeOutput {
@@ -5,8 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/30/19.
6
6
  //
7
7
 
8
- import CoreGraphics
9
- import Foundation
10
8
  import QuartzCore
11
9
 
12
10
  extension FillRule {
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/30/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  // MARK: - GradientFillLayer
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/30/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  // MARK: - Renderer
@@ -5,7 +5,6 @@
5
5
  // Created by Brandon Withrow on 1/30/19.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import QuartzCore
10
9
 
11
10
  /// A rendered for a Path Fill