@octane-xplat/lottie 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/README.md +36 -16
  2. package/dist/native/index.js +10 -9
  3. package/dist/native/octane-client-build.json +1 -1
  4. package/dist/web/index.js +39 -25
  5. package/dist/web/octane-client-build.json +1 -1
  6. package/package.json +25 -3
  7. package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
  8. package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
  9. package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
  10. package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
  11. package/platforms/macos/UPSTREAM.md +13 -0
  12. package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
  13. package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
  14. package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
  15. package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
  16. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
  17. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
  18. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
  19. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
  20. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
  21. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
  22. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
  23. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
  24. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
  25. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
  26. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
  27. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
  28. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
  29. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
  30. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
  31. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
  32. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
  33. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
  34. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
  35. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
  36. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
  37. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
  38. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
  39. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
  40. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
  41. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
  42. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
  43. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
  44. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
  45. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
  46. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
  47. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
  48. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
  49. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
  50. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
  51. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
  52. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
  53. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
  54. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
  55. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
  56. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
  57. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
  58. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
  59. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
  60. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
  61. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
  62. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
  63. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
  64. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
  65. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
  66. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
  67. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
  68. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
  69. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
  70. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
  71. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
  72. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
  73. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
  74. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
  75. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
  76. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
  77. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
  78. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
  79. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
  80. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
  81. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
  82. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
  83. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
  84. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
  85. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
  86. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
  87. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
  88. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
  89. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
  90. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
  91. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
  92. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
  93. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
  94. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
  95. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
  96. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
  97. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
  98. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
  99. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
  100. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
  101. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
  102. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
  103. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
  104. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
  105. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
  106. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
  107. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
  108. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
  109. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
  110. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
  111. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
  112. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
  113. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
  114. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
  115. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
  116. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
  117. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
  118. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
  119. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
  120. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
  121. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
  122. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
  123. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
  124. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
  125. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
  126. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
  127. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
  128. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
  129. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
  130. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
  131. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
  132. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
  133. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
  134. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
  135. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
  136. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
  137. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
  138. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
  139. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
  140. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
  141. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
  142. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
  143. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
  144. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
  145. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
  146. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
  147. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
  148. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
  149. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
  150. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
  151. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
  152. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
  153. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
  154. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
  155. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
  156. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
  157. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
  158. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
  159. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
  160. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
  161. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
  162. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
  163. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
  164. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
  165. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
  166. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
  167. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
  168. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
  169. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
  170. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
  171. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
  172. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
  173. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
  174. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
  175. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
  176. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
  177. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
  178. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
  179. package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
  180. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
  181. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
  182. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
  183. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
  184. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
  185. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
  186. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
  187. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
  188. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
  189. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
  190. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
  191. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
  192. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
  193. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
  194. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
  195. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
  196. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
  197. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
  198. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
  199. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
  200. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
  201. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
  202. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
  203. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
  204. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
  205. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
  206. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
  207. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
  208. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
  209. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
  210. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
  211. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
  212. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
  213. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
  214. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
  215. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
  216. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
  217. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
  218. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
  219. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
  220. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
  221. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
  222. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
  223. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
  224. package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
  225. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
  226. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
  227. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
  228. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
  229. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
  230. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
  231. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
  232. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
  233. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
  234. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
  235. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
  236. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
  237. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
  238. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
  239. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
  240. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
  241. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
  242. package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
  243. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
  244. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
  245. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
  246. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
  247. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
  248. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
  249. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
  250. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
  251. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
  252. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
  253. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
  254. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
  255. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
  256. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
  257. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
  258. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
  259. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
  260. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
  261. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
  262. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
  263. package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
  264. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
  265. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
  266. package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
  267. package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
  268. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
  269. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
  270. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
  271. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
  272. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
  273. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
  274. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
  275. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
  276. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
  277. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
  278. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
  279. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
  280. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
  281. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
  282. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
  283. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
  284. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
  285. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
  286. package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
  287. package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
  288. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
  289. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
  290. package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
  291. package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
  292. package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
  293. package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
  294. package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
  295. package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
  296. package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
  297. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
  298. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
  299. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
  300. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
  301. package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
  302. package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
  303. package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
  304. package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
  305. package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
  306. package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
  307. package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
  308. package/src/Lottie.macos.tsrx +129 -0
  309. package/src/Lottie.tsrx +3 -2
  310. package/src/Lottie.web.tsrx +28 -11
  311. package/src/index.macos.ts +2 -0
  312. package/src/props.ts +6 -1
  313. package/types/generated/props.d.ts +5 -1
@@ -0,0 +1,247 @@
1
+ //
2
+ // TextCompositionLayer.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/25/19.
6
+ //
7
+
8
+ /// Needed for NSMutableParagraphStyle...
9
+ #if os(OSX)
10
+ import AppKit
11
+ #else
12
+ import UIKit
13
+ #endif
14
+
15
+ extension TextJustification {
16
+ var textAlignment: NSTextAlignment {
17
+ switch self {
18
+ case .left:
19
+ .left
20
+ case .right:
21
+ .right
22
+ case .center:
23
+ .center
24
+ case .justifyLastLineLeft, .justifyLastLineRight, .justifyLastLineCenter, .justifyLastLineFull:
25
+ .justified
26
+ }
27
+ }
28
+
29
+ var caTextAlignement: CATextLayerAlignmentMode {
30
+ switch self {
31
+ case .left:
32
+ .left
33
+ case .right:
34
+ .right
35
+ case .center:
36
+ .center
37
+ case .justifyLastLineLeft, .justifyLastLineRight, .justifyLastLineCenter, .justifyLastLineFull:
38
+ .justified
39
+ }
40
+ }
41
+ }
42
+
43
+ // MARK: - TextCompositionLayer
44
+
45
+ final class TextCompositionLayer: CompositionLayer {
46
+
47
+ // MARK: Lifecycle
48
+
49
+ init(
50
+ textLayer: TextLayerModel,
51
+ textProvider: AnimationKeypathTextProvider,
52
+ fontProvider: AnimationFontProvider,
53
+ rootAnimationLayer: MainThreadAnimationLayer?
54
+ ) {
55
+ var rootNode: TextAnimatorNode?
56
+ for animator in textLayer.animators {
57
+ rootNode = TextAnimatorNode(parentNode: rootNode, textAnimator: animator)
58
+ }
59
+ self.rootNode = rootNode
60
+ textDocument = KeyframeInterpolator(keyframes: textLayer.text.keyframes)
61
+
62
+ let transparent = LottieColor(r: 0, g: 0, b: 0, a: 0)
63
+ let black = LottieColor(r: 0, g: 0, b: 0, a: 1)
64
+
65
+ let fillKeyframes = textLayer.text.keyframes.map { keyframe in
66
+ keyframe.withValue(keyframe.value.fillColorData ?? black)
67
+ }
68
+ fillColorNode = NodeProperty(provider: KeyframeInterpolator(keyframes: ContiguousArray(fillKeyframes)))
69
+
70
+ let strokeKeyframes = textLayer.text.keyframes.map { keyframe in
71
+ keyframe.withValue(keyframe.value.strokeColorData ?? transparent)
72
+ }
73
+ strokeColorNode = NodeProperty(provider: KeyframeInterpolator(keyframes: ContiguousArray(strokeKeyframes)))
74
+
75
+ self.textProvider = textProvider
76
+ self.fontProvider = fontProvider
77
+ self.rootAnimationLayer = rootAnimationLayer
78
+
79
+ super.init(layer: textLayer, size: .zero)
80
+ contentsLayer.addSublayer(self.textLayer)
81
+ self.textLayer.masksToBounds = false
82
+ self.textLayer.isGeometryFlipped = true
83
+
84
+ if let rootNode {
85
+ childKeypaths.append(rootNode)
86
+ }
87
+ }
88
+
89
+ required init?(coder _: NSCoder) {
90
+ fatalError("init(coder:) has not been implemented")
91
+ }
92
+
93
+ override init(layer: Any) {
94
+ /// Used for creating shadow model layers. Read More here: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
95
+ guard let layer = layer as? TextCompositionLayer else {
96
+ fatalError("init(layer:) Wrong Layer Class")
97
+ }
98
+ rootNode = nil
99
+ textDocument = nil
100
+
101
+ fillColorNode = layer.fillColorNode
102
+ strokeColorNode = layer.strokeColorNode
103
+
104
+ textProvider = DefaultTextProvider()
105
+ fontProvider = DefaultFontProvider()
106
+
107
+ super.init(layer: layer)
108
+ }
109
+
110
+ // MARK: Internal
111
+
112
+ let rootNode: TextAnimatorNode?
113
+ let textDocument: KeyframeInterpolator<TextDocument>?
114
+
115
+ let fillColorNode: NodeProperty<LottieColor>
116
+ let strokeColorNode: NodeProperty<LottieColor>
117
+
118
+ let textLayer = CoreTextRenderLayer()
119
+ var textProvider: AnimationKeypathTextProvider
120
+ var fontProvider: AnimationFontProvider
121
+ weak var rootAnimationLayer: MainThreadAnimationLayer?
122
+
123
+ lazy var fullAnimationKeypath: AnimationKeypath = // Individual layers don't know their full keypaths, so we have to delegate
124
+ // to the `MainThreadAnimationLayer` to search the layer hierarchy and find
125
+ // the full keypath (which includes this layer's parent layers)
126
+ rootAnimationLayer?.keypath(for: self)
127
+ // If that failed for some reason, just use the last path component (which we do have here)
128
+ ?? AnimationKeypath(keypath: keypathName)
129
+
130
+ override var keypathProperties: [String: AnyNodeProperty] {
131
+ guard rootNode != nil else {
132
+ return [
133
+ PropertyName.color.rawValue: fillColorNode,
134
+ PropertyName.strokeColor.rawValue: strokeColorNode,
135
+ ]
136
+ }
137
+ var properties = super.keypathProperties
138
+ properties[PropertyName.color.rawValue] = fillColorNode
139
+ properties[PropertyName.strokeColor.rawValue] = strokeColorNode
140
+ return properties
141
+ }
142
+
143
+ override func displayContentsWithFrame(frame: CGFloat, forceUpdates: Bool) {
144
+ guard let textDocument else { return }
145
+
146
+ textLayer.contentsScale = renderScale
147
+
148
+ fillColorNode.update(frame: frame)
149
+ strokeColorNode.update(frame: frame)
150
+
151
+ let documentUpdate = textDocument.hasUpdate(frame: frame)
152
+ let animatorUpdate = rootNode?.updateContents(frame, forceLocalUpdate: forceUpdates) ?? false
153
+ guard
154
+ documentUpdate == true ||
155
+ animatorUpdate == true ||
156
+ fillColorNode.needsUpdate(frame: frame) ||
157
+ strokeColorNode.needsUpdate(frame: frame)
158
+ else { return }
159
+
160
+ rootNode?.rebuildOutputs(frame: frame)
161
+
162
+ // Get Text Attributes
163
+ let text = textDocument.value(frame: frame) as! TextDocument
164
+
165
+ // Prior to Lottie 4.3.0 the Main Thread rendering engine always just used `LegacyAnimationTextProvider`
166
+ // and called it with the `keypathName` (only the last path component of the full keypath).
167
+ // Starting in Lottie 4.3.0 we use `AnimationKeypathTextProvider` instead if implemented.
168
+ let textString: String =
169
+ if let keypathTextValue = textProvider.text(for: fullAnimationKeypath, sourceText: text.text) {
170
+ keypathTextValue
171
+ } else if let legacyTextProvider = textProvider as? LegacyAnimationTextProvider {
172
+ legacyTextProvider.textFor(keypathName: keypathName, sourceText: text.text)
173
+ } else {
174
+ text.text
175
+ }
176
+
177
+ let isStrokeOverridden =
178
+ (strokeColorNode.valueProvider as AnyObject) !== (strokeColorNode.originalValueProvider as AnyObject)
179
+
180
+ let strokeColor: CGColor? =
181
+ if let animatorStroke = rootNode?.textOutputNode.strokeColor {
182
+ animatorStroke
183
+ } else if isStrokeOverridden {
184
+ strokeColorNode.value.cgColorValue
185
+ } else {
186
+ text.strokeColorData?.cgColorValue
187
+ }
188
+
189
+ let strokeWidth = rootNode?.textOutputNode.strokeWidth ?? CGFloat(text.strokeWidth ?? 0)
190
+ let tracking = (CGFloat(text.fontSize) * (rootNode?.textOutputNode.tracking ?? CGFloat(text.tracking))) / 1000.0
191
+ let matrix = rootNode?.textOutputNode.xform ?? CATransform3DIdentity
192
+ let ctFont = fontProvider.fontFor(family: text.fontFamily, size: CGFloat(text.fontSize))
193
+ let start = rootNode?.textOutputNode.start.flatMap { Int($0) }
194
+ let end = rootNode?.textOutputNode.end.flatMap { Int($0) }
195
+ let selectedRangeOpacity = rootNode?.textOutputNode.selectedRangeOpacity
196
+ let textRangeUnit = rootNode?.textAnimatorProperties.textRangeUnit
197
+
198
+ // Set all of the text layer options
199
+ textLayer.text = textString
200
+ textLayer.font = ctFont
201
+ textLayer.alignment = text.justification.textAlignment
202
+ textLayer.lineHeight = CGFloat(text.lineHeight)
203
+ textLayer.tracking = tracking
204
+
205
+ // Configure the text animators
206
+ textLayer.start = start
207
+ textLayer.end = end
208
+ textLayer.textRangeUnit = textRangeUnit
209
+ textLayer.selectedRangeOpacity = selectedRangeOpacity
210
+
211
+ // Check for an explicit override. If not overridden, we default to `TextDocument`
212
+ // to support transparency (avoiding the default black color of the value provider).
213
+ // `fillColorNode` is non-optional and defaults to black if the color was not overridden.
214
+ // If the color has been overridden, we use the new color: `fillColorNode.value.cgColorValue`.
215
+ // Otherwise, we use the default color from the text: `text.fillColorData?.cgColorValue`.
216
+ //
217
+ // We cannot remove the cast since `AnyValueProvider` is not a class-bound protocol,
218
+ // so we must cast to `AnyObject` to perform an identity comparison.
219
+ let isFillOverridden =
220
+ (fillColorNode.valueProvider as AnyObject) !== (fillColorNode.originalValueProvider as AnyObject)
221
+
222
+ textLayer.fillColor =
223
+ if let fillColor = rootNode?.textOutputNode.fillColor {
224
+ fillColor
225
+ } else if isFillOverridden {
226
+ fillColorNode.value.cgColorValue
227
+ } else {
228
+ text.fillColorData?.cgColorValue
229
+ }
230
+
231
+ textLayer.preferredSize = text.textFrameSize?.sizeValue
232
+ textLayer.strokeOnTop = text.strokeOverFill ?? false
233
+ textLayer.strokeWidth = strokeWidth
234
+ textLayer.strokeColor = strokeColor
235
+ textLayer.sizeToFit()
236
+
237
+ textLayer.opacity = Float(rootNode?.textOutputNode.opacity ?? 1)
238
+ textLayer.transform = CATransform3DIdentity
239
+ textLayer.position = text.textFramePosition?.pointValue ?? CGPoint.zero
240
+ textLayer.transform = matrix
241
+ }
242
+
243
+ override func updateRenderScale() {
244
+ super.updateRenderScale()
245
+ textLayer.contentsScale = renderScale
246
+ }
247
+ }
@@ -0,0 +1,321 @@
1
+ //
2
+ // MainThreadAnimationLayer.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/24/19.
6
+ //
7
+
8
+ import QuartzCore
9
+
10
+ // MARK: - MainThreadAnimationLayer
11
+
12
+ /// The base `CALayer` for the Main Thread rendering engine
13
+ ///
14
+ /// This layer holds a single composition container and allows for animation of
15
+ /// the currentFrame property.
16
+ final class MainThreadAnimationLayer: CALayer, RootAnimationLayer {
17
+
18
+ // MARK: Lifecycle
19
+
20
+ init(
21
+ animation: LottieAnimation,
22
+ imageProvider: AnimationImageProvider,
23
+ textProvider: AnimationKeypathTextProvider,
24
+ fontProvider: AnimationFontProvider,
25
+ maskAnimationToBounds: Bool,
26
+ logger: LottieLogger
27
+ ) {
28
+ layerImageProvider = LayerImageProvider(imageProvider: imageProvider, assets: animation.assetLibrary?.imageAssets)
29
+ layerTextProvider = LayerTextProvider(textProvider: textProvider)
30
+ layerFontProvider = LayerFontProvider(fontProvider: fontProvider)
31
+ animationLayers = []
32
+ self.logger = logger
33
+ super.init()
34
+ masksToBounds = maskAnimationToBounds
35
+ bounds = animation.bounds
36
+ let layers = animation.layers.initializeCompositionLayers(
37
+ assetLibrary: animation.assetLibrary,
38
+ layerImageProvider: layerImageProvider,
39
+ layerTextProvider: layerTextProvider,
40
+ layerFontProvider: layerFontProvider,
41
+ textProvider: textProvider,
42
+ fontProvider: fontProvider,
43
+ frameRate: CGFloat(animation.framerate),
44
+ rootAnimationLayer: self
45
+ )
46
+
47
+ var imageLayers = [ImageCompositionLayer]()
48
+ var textLayers = [TextCompositionLayer]()
49
+
50
+ var mattedLayer: CompositionLayer? = nil
51
+
52
+ for layer in layers.reversed() {
53
+ layer.bounds = bounds
54
+ animationLayers.append(layer)
55
+ if let imageLayer = layer as? ImageCompositionLayer {
56
+ imageLayers.append(imageLayer)
57
+ }
58
+ if let textLayer = layer as? TextCompositionLayer {
59
+ textLayers.append(textLayer)
60
+ }
61
+ if let matte = mattedLayer {
62
+ /// The previous layer requires this layer to be its matte
63
+ matte.matteLayer = layer
64
+ mattedLayer = nil
65
+ continue
66
+ }
67
+ if
68
+ let matte = layer.matteType,
69
+ matte == .add || matte == .invert
70
+ {
71
+ /// We have a layer that requires a matte.
72
+ mattedLayer = layer
73
+ }
74
+ addSublayer(layer)
75
+ }
76
+
77
+ layerImageProvider.addImageLayers(imageLayers)
78
+ layerImageProvider.reloadImages()
79
+ layerTextProvider.addTextLayers(textLayers)
80
+ layerTextProvider.reloadTexts()
81
+ layerFontProvider.addTextLayers(textLayers)
82
+ layerFontProvider.reloadTexts()
83
+ setNeedsDisplay()
84
+ }
85
+
86
+ /// Called by CoreAnimation to create a shadow copy of this layer
87
+ /// More details: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
88
+ override init(layer: Any) {
89
+ guard let typedLayer = layer as? Self else {
90
+ fatalError("\(Self.self).init(layer:) incorrectly called with \(type(of: layer))")
91
+ }
92
+
93
+ animationLayers = []
94
+ layerImageProvider = LayerImageProvider(imageProvider: BlankImageProvider(), assets: nil)
95
+ layerTextProvider = LayerTextProvider(textProvider: DefaultTextProvider())
96
+ layerFontProvider = LayerFontProvider(fontProvider: DefaultFontProvider())
97
+ logger = typedLayer.logger
98
+ super.init(layer: layer)
99
+
100
+ currentFrame = typedLayer.currentFrame
101
+ }
102
+
103
+ required init?(coder _: NSCoder) {
104
+ fatalError("init(coder:) has not been implemented")
105
+ }
106
+
107
+ // MARK: Internal
108
+
109
+ var respectAnimationFrameRate = false
110
+
111
+ /// The animatable Current Frame Property
112
+ @NSManaged var currentFrame: CGFloat
113
+
114
+ /// The parent `LottieAnimationLayer` that manages this layer
115
+ weak var lottieAnimationLayer: LottieAnimationLayer?
116
+
117
+ /// Whether or not to use `forceDisplayUpdate()` when rendering each individual frame.
118
+ /// - The main thread rendering engine implements optimizations to decrease the amount
119
+ /// of properties that have to be re-rendered on each frame. There are some cases
120
+ /// where this can result in bugs / incorrect behavior, so we allow it to be disabled.
121
+ /// - Forcing a full render on every frame will decrease performance, and is not recommended
122
+ /// except as a workaround to a bug in the main thread rendering engine.
123
+ var forceDisplayUpdateOnEachFrame = false
124
+
125
+ var animationLayers: ContiguousArray<CompositionLayer>
126
+
127
+ var primaryAnimationKey: AnimationKey {
128
+ .managed
129
+ }
130
+
131
+ var isAnimationPlaying: Bool? {
132
+ nil // this state is managed by `LottieAnimationView`
133
+ }
134
+
135
+ var _animationLayers: [CALayer] {
136
+ Array(animationLayers)
137
+ }
138
+
139
+ var imageProvider: AnimationImageProvider {
140
+ get {
141
+ layerImageProvider.imageProvider
142
+ }
143
+ set {
144
+ layerImageProvider.imageProvider = newValue
145
+ }
146
+ }
147
+
148
+ var renderScale: CGFloat = 1 {
149
+ didSet {
150
+ for animationLayer in animationLayers {
151
+ animationLayer.renderScale = renderScale
152
+ }
153
+ }
154
+ }
155
+
156
+ var textProvider: AnimationKeypathTextProvider {
157
+ get { layerTextProvider.textProvider }
158
+ set { layerTextProvider.textProvider = newValue }
159
+ }
160
+
161
+ var fontProvider: AnimationFontProvider {
162
+ get { layerFontProvider.fontProvider }
163
+ set { layerFontProvider.fontProvider = newValue }
164
+ }
165
+
166
+ override class func needsDisplay(forKey key: String) -> Bool {
167
+ if key == "currentFrame" {
168
+ return true
169
+ }
170
+ return super.needsDisplay(forKey: key)
171
+ }
172
+
173
+ override func action(forKey event: String) -> CAAction? {
174
+ if event == "currentFrame" {
175
+ let animation = CABasicAnimation(keyPath: event)
176
+ animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
177
+ animation.fromValue = presentation()?.currentFrame
178
+ return animation
179
+ }
180
+ return super.action(forKey: event)
181
+ }
182
+
183
+ override func display() {
184
+ guard Thread.isMainThread else { return }
185
+ var newFrame: CGFloat =
186
+ if
187
+ let animationKeys = animationKeys(),
188
+ !animationKeys.isEmpty
189
+ {
190
+ presentation()?.currentFrame ?? currentFrame
191
+ } else {
192
+ // We ignore the presentation's frame if there's no animation in the layer.
193
+ currentFrame
194
+ }
195
+ if respectAnimationFrameRate {
196
+ newFrame = floor(newFrame)
197
+ }
198
+ for animationLayer in animationLayers {
199
+ animationLayer.displayWithFrame(frame: newFrame, forceUpdates: forceDisplayUpdateOnEachFrame)
200
+ }
201
+ }
202
+
203
+ func reloadImages() {
204
+ layerImageProvider.reloadImages()
205
+ }
206
+
207
+ func removeAnimations() {
208
+ // no-op, since the primary animation is managed by the `LottieAnimationView`.
209
+ }
210
+
211
+ /// Forces the view to update its drawing.
212
+ func forceDisplayUpdate() {
213
+ for animationLayer in animationLayers {
214
+ animationLayer.displayWithFrame(frame: currentFrame, forceUpdates: true)
215
+ }
216
+ }
217
+
218
+ func logHierarchyKeypaths() {
219
+ logger.info("Lottie: Logging Animation Keypaths")
220
+
221
+ for keypath in allHierarchyKeypaths() {
222
+ logger.info(keypath)
223
+ }
224
+ }
225
+
226
+ func allHierarchyKeypaths() -> [String] {
227
+ animationLayers.flatMap { $0.allKeypaths() }
228
+ }
229
+
230
+ func setValueProvider(_ valueProvider: AnyValueProvider, keypath: AnimationKeypath) {
231
+ for layer in animationLayers {
232
+ if let foundProperties = layer.nodeProperties(for: keypath) {
233
+ for property in foundProperties {
234
+ property.setProvider(provider: valueProvider)
235
+ }
236
+ layer.displayWithFrame(frame: presentation()?.currentFrame ?? currentFrame, forceUpdates: true)
237
+ }
238
+ }
239
+ }
240
+
241
+ func removeValueProvider(for keypath: AnimationKeypath) {
242
+ for layer in animationLayers {
243
+ if let foundProperties = layer.nodeProperties(for: keypath) {
244
+ for property in foundProperties {
245
+ property.removeProvider()
246
+ }
247
+ layer.displayWithFrame(frame: presentation()?.currentFrame ?? currentFrame, forceUpdates: true)
248
+ }
249
+ }
250
+ }
251
+
252
+ func getValue(for keypath: AnimationKeypath, atFrame: CGFloat?) -> Any? {
253
+ for layer in animationLayers {
254
+ if
255
+ let foundProperties = layer.nodeProperties(for: keypath),
256
+ let first = foundProperties.first
257
+ {
258
+ return first.valueProvider.value(frame: atFrame ?? currentFrame)
259
+ }
260
+ }
261
+ return nil
262
+ }
263
+
264
+ func getOriginalValue(for keypath: AnimationKeypath, atFrame: AnimationFrameTime?) -> Any? {
265
+ for layer in animationLayers {
266
+ if
267
+ let foundProperties = layer.nodeProperties(for: keypath),
268
+ let first = foundProperties.first
269
+ {
270
+ return first.originalValueProvider.value(frame: atFrame ?? currentFrame)
271
+ }
272
+ }
273
+ return nil
274
+ }
275
+
276
+ func layer(for keypath: AnimationKeypath) -> CALayer? {
277
+ for layer in animationLayers {
278
+ if let foundLayer = layer.layer(for: keypath) {
279
+ return foundLayer
280
+ }
281
+ }
282
+ return nil
283
+ }
284
+
285
+ func keypath(for layerToFind: CALayer) -> AnimationKeypath? {
286
+ for layer in animationLayers {
287
+ if let foundKeypath = layer.keypath(for: layerToFind) {
288
+ return foundKeypath
289
+ }
290
+ }
291
+ return nil
292
+ }
293
+
294
+ func animatorNodes(for keypath: AnimationKeypath) -> [AnimatorNode]? {
295
+ var results = [AnimatorNode]()
296
+ for layer in animationLayers {
297
+ if let nodes = layer.animatorNodes(for: keypath) {
298
+ results.append(contentsOf: nodes)
299
+ }
300
+ }
301
+ if results.count == 0 {
302
+ return nil
303
+ }
304
+ return results
305
+ }
306
+
307
+ // MARK: Fileprivate
308
+
309
+ fileprivate let layerImageProvider: LayerImageProvider
310
+ fileprivate let layerTextProvider: LayerTextProvider
311
+ fileprivate let layerFontProvider: LayerFontProvider
312
+ fileprivate let logger: LottieLogger
313
+ }
314
+
315
+ // MARK: - BlankImageProvider
316
+
317
+ private final class BlankImageProvider: AnimationImageProvider {
318
+ func imageForAsset(asset _: ImageAsset) -> CGImage? {
319
+ nil
320
+ }
321
+ }
@@ -0,0 +1,56 @@
1
+ // Created by Jianjun Wu on 2022/5/12.
2
+ // Copyright © 2022 Airbnb Inc. All rights reserved.
3
+
4
+ import QuartzCore
5
+
6
+ // MARK: - CachedImageProvider
7
+
8
+ private final class CachedImageProvider: AnimationImageProvider {
9
+
10
+ // MARK: Lifecycle
11
+
12
+ /// Initializes an image provider with an image provider
13
+ ///
14
+ /// - Parameter imageProvider: The provider to load image from asset
15
+ ///
16
+ init(imageProvider: AnimationImageProvider) {
17
+ self.imageProvider = imageProvider
18
+ }
19
+
20
+ // MARK: Internal
21
+
22
+ func imageForAsset(asset: ImageAsset) -> CGImage? {
23
+ if let image = imageCache.value(forKey: asset.id) {
24
+ return image
25
+ }
26
+ if let image = imageProvider.imageForAsset(asset: asset) {
27
+ imageCache.setValue(image, forKey: asset.id)
28
+ return image
29
+ }
30
+ return nil
31
+ }
32
+
33
+ func contentsGravity(for asset: ImageAsset) -> CALayerContentsGravity {
34
+ imageProvider.contentsGravity(for: asset)
35
+ }
36
+
37
+ // MARK: Private
38
+
39
+ /// The underlying storage of this cache.
40
+ /// - We use the `LRUCache` library instead of `NSCache`, because `NSCache`
41
+ /// clears all cached values when the app is backgrounded instead of
42
+ /// only when the app receives a memory warning notification.
43
+ private var imageCache = LRUCache<String, CGImage>()
44
+ private let imageProvider: AnimationImageProvider
45
+
46
+ }
47
+
48
+ extension AnimationImageProvider {
49
+ /// Create a cache enabled image provider which will reuse the asset image with the same asset id
50
+ /// It wraps the current provider as image loader, and uses `NSCache` to cache the images for resue.
51
+ /// The cache will be reset when the `animation` is reset.
52
+ var cachedImageProvider: AnimationImageProvider {
53
+ guard cacheEligible else { return self }
54
+ return CachedImageProvider(imageProvider: self)
55
+ }
56
+ }