@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,141 @@
1
+ //
2
+ // ImageAsset.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/9/19.
6
+ //
7
+
8
+ import CoreGraphics
9
+ import Foundation
10
+
11
+ #if canImport(UIKit)
12
+ import UIKit
13
+ #elseif canImport(AppKit)
14
+ import AppKit
15
+ #endif
16
+
17
+ // MARK: - ImageAsset
18
+
19
+ public final class ImageAsset: Asset {
20
+
21
+ // MARK: Lifecycle
22
+
23
+ required init(from decoder: Decoder) throws {
24
+ let container = try decoder.container(keyedBy: ImageAsset.CodingKeys.self)
25
+ name = try container.decode(String.self, forKey: .name)
26
+ directory = try container.decode(String.self, forKey: .directory)
27
+ width = try container.decode(Double.self, forKey: .width)
28
+ height = try container.decode(Double.self, forKey: .height)
29
+ try super.init(from: decoder)
30
+ }
31
+
32
+ required init(dictionary: [String: Any]) throws {
33
+ name = try dictionary.value(for: CodingKeys.name)
34
+ directory = try dictionary.value(for: CodingKeys.directory)
35
+ width = try dictionary.value(for: CodingKeys.width)
36
+ height = try dictionary.value(for: CodingKeys.height)
37
+ try super.init(dictionary: dictionary)
38
+ }
39
+
40
+ // MARK: Public
41
+
42
+ /// Image name
43
+ public let name: String
44
+
45
+ /// Image Directory
46
+ public let directory: String
47
+
48
+ /// Image Size
49
+ public let width: Double
50
+
51
+ public let height: Double
52
+
53
+ override public func encode(to encoder: Encoder) throws {
54
+ try super.encode(to: encoder)
55
+ var container = encoder.container(keyedBy: CodingKeys.self)
56
+ try container.encode(name, forKey: .name)
57
+ try container.encode(directory, forKey: .directory)
58
+ try container.encode(width, forKey: .width)
59
+ try container.encode(height, forKey: .height)
60
+ }
61
+
62
+ // MARK: Internal
63
+
64
+ enum CodingKeys: String, CodingKey {
65
+ case name = "p"
66
+ case directory = "u"
67
+ case width = "w"
68
+ case height = "h"
69
+ }
70
+ }
71
+
72
+ extension Data {
73
+
74
+ // MARK: Lifecycle
75
+
76
+ /// Initializes `Data` from an `ImageAsset`.
77
+ ///
78
+ /// Returns nil when the input is not recognized as valid Data URL.
79
+ /// - parameter imageAsset: The image asset that contains Data URL.
80
+ init?(imageAsset: ImageAsset) {
81
+ self.init(dataString: imageAsset.name)
82
+ }
83
+
84
+ /// Initializes `Data` from a [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) String.
85
+ ///
86
+ /// Returns nil when the input is not recognized as valid Data URL.
87
+ /// - parameter dataString: The data string to parse.
88
+ /// - parameter options: Options for the string parsing. Default value is `[]`.
89
+ init?(dataString: String, options: DataURLReadOptions = []) {
90
+ let trimmedDataString = dataString.trimmingCharacters(in: .whitespacesAndNewlines)
91
+ guard
92
+ dataString.hasPrefix("data:"),
93
+ let url = URL(string: trimmedDataString)
94
+ else {
95
+ return nil
96
+ }
97
+ // The code below is needed because Data(contentsOf:) floods logs
98
+ // with messages since url doesn't have a host. This only fixes flooding logs
99
+ // when data inside Data URL is base64 encoded.
100
+ if
101
+ let base64Range = trimmedDataString.range(of: ";base64,"),
102
+ !options.contains(DataURLReadOptions.legacy)
103
+ {
104
+ let encodedString = String(trimmedDataString[base64Range.upperBound...])
105
+ self.init(base64Encoded: encodedString)
106
+ } else {
107
+ try? self.init(contentsOf: url)
108
+ }
109
+ }
110
+
111
+ // MARK: Internal
112
+
113
+ struct DataURLReadOptions: OptionSet {
114
+ /// Will read Data URL using Data(contentsOf:)
115
+ static let legacy = DataURLReadOptions(rawValue: 1 << 0)
116
+
117
+ let rawValue: Int
118
+
119
+ }
120
+
121
+ }
122
+
123
+ extension ImageAsset {
124
+ /// A `CGImage` loaded from this asset if represented using a Base 64 encoding
125
+ var base64Image: CGImage? {
126
+ guard let data = Data(imageAsset: self) else { return nil }
127
+
128
+ #if canImport(UIKit)
129
+ return UIImage(data: data)?.cgImage
130
+ #elseif canImport(AppKit)
131
+ return NSImage(data: data)?.lottie_CGImage
132
+ #endif
133
+ }
134
+ }
135
+
136
+ // MARK: - ImageAsset + @unchecked Sendable
137
+
138
+ /// `ImageAsset` inherits `@unchecked Sendable` from `Asset` and
139
+ /// we need to restate that here to avoid a warning in Xcode 16
140
+ // swiftlint:disable:next no_unchecked_sendable
141
+ extension ImageAsset: @unchecked Sendable { }
@@ -0,0 +1,47 @@
1
+ //
2
+ // PrecompAsset.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/9/19.
6
+ //
7
+
8
+ // MARK: - PrecompAsset
9
+
10
+ final class PrecompAsset: Asset {
11
+
12
+ // MARK: Lifecycle
13
+
14
+ required init(from decoder: Decoder) throws {
15
+ let container = try decoder.container(keyedBy: PrecompAsset.CodingKeys.self)
16
+ layers = try container.decode([LayerModel].self, ofFamily: LayerType.self, forKey: .layers)
17
+ try super.init(from: decoder)
18
+ }
19
+
20
+ required init(dictionary: [String: Any]) throws {
21
+ let layerDictionaries: [[String: Any]] = try dictionary.value(for: CodingKeys.layers)
22
+ layers = try [LayerModel].fromDictionaries(layerDictionaries)
23
+ try super.init(dictionary: dictionary)
24
+ }
25
+
26
+ // MARK: Internal
27
+
28
+ enum CodingKeys: String, CodingKey {
29
+ case layers
30
+ }
31
+
32
+ /// Layers of the precomp
33
+ let layers: [LayerModel]
34
+
35
+ override func encode(to encoder: Encoder) throws {
36
+ try super.encode(to: encoder)
37
+ var container = encoder.container(keyedBy: CodingKeys.self)
38
+ try container.encode(layers, forKey: .layers)
39
+ }
40
+ }
41
+
42
+ // MARK: @unchecked Sendable
43
+
44
+ /// `PrecompAsset` inherits `@unchecked Sendable` from `Asset` and
45
+ /// we need to restate that here to avoid a warning in Xcode 16
46
+ // swiftlint:disable:next no_unchecked_sendable
47
+ extension PrecompAsset: @unchecked Sendable { }
@@ -0,0 +1,73 @@
1
+ //
2
+ // DictionaryInitializable.swift
3
+ // Lottie
4
+ //
5
+ // Created by Marcelo Fabri on 5/5/22.
6
+ //
7
+
8
+ // MARK: - InitializableError
9
+
10
+ enum InitializableError: Error {
11
+ case invalidInput(file: StaticString = #fileID, line: UInt = #line)
12
+ }
13
+
14
+ // MARK: - DictionaryInitializable
15
+
16
+ protocol DictionaryInitializable {
17
+
18
+ init(dictionary: [String: Any]) throws
19
+
20
+ }
21
+
22
+ // MARK: - AnyInitializable
23
+
24
+ protocol AnyInitializable {
25
+
26
+ init(value: Any) throws
27
+
28
+ }
29
+
30
+ extension Dictionary {
31
+
32
+ @_disfavoredOverload
33
+ func value<T, KeyType: RawRepresentable>(
34
+ for key: KeyType,
35
+ file: StaticString = #fileID,
36
+ line: UInt = #line
37
+ ) throws -> T where KeyType.RawValue == Key {
38
+ guard let value = self[key.rawValue] as? T else {
39
+ throw InitializableError.invalidInput(file: file, line: line)
40
+ }
41
+ return value
42
+ }
43
+
44
+ func value<T: AnyInitializable, KeyType: RawRepresentable>(
45
+ for key: KeyType,
46
+ file: StaticString = #fileID,
47
+ line: UInt = #line
48
+ ) throws -> T where KeyType.RawValue == Key {
49
+ if let value = self[key.rawValue] as? T {
50
+ return value
51
+ }
52
+
53
+ if let value = self[key.rawValue] {
54
+ return try T(value: value)
55
+ }
56
+
57
+ throw InitializableError.invalidInput(file: file, line: line)
58
+ }
59
+
60
+ }
61
+
62
+ // MARK: - [Double] + AnyInitializable
63
+
64
+ extension [Double]: AnyInitializable {
65
+
66
+ init(value: Any) throws {
67
+ guard let array = value as? [Double] else {
68
+ throw InitializableError.invalidInput()
69
+ }
70
+ self = array
71
+ }
72
+
73
+ }
@@ -0,0 +1,57 @@
1
+ //
2
+ // DotLottieAnimation.swift
3
+ // Pods
4
+ //
5
+ // Created by Evandro Harrison Hoffmann on 28/06/2021.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ // MARK: - DotLottieAnimation
11
+
12
+ struct DotLottieAnimation: Codable {
13
+ /// Id of Animation
14
+ var id: String
15
+
16
+ /// Loop enabled
17
+ var loop: Bool? = false
18
+
19
+ /// Animation Playback Speed
20
+ var speed: Double? = 1
21
+
22
+ /// 1 or -1
23
+ var direction: Int? = 1
24
+
25
+ /// mode - "bounce" | "normal"
26
+ var mode: DotLottieAnimationMode? = .normal
27
+
28
+ /// Loop mode for animation
29
+ var loopMode: LottieLoopMode {
30
+ switch mode {
31
+ case .bounce:
32
+ .autoReverse
33
+ case .normal, nil:
34
+ (loop ?? false) ? .loop : .playOnce
35
+ }
36
+ }
37
+
38
+ /// Animation speed
39
+ var animationSpeed: Double {
40
+ (speed ?? 1) * Double(direction ?? 1)
41
+ }
42
+
43
+ /// Loads `LottieAnimation` from `animationUrl`
44
+ /// - Returns: Deserialized `LottieAnimation`. Optional.
45
+ func animation(url: URL) throws -> LottieAnimation {
46
+ let animationUrl = url.appendingPathComponent("\(id).json")
47
+ let data = try Data(contentsOf: animationUrl)
48
+ return try LottieAnimation.from(data: data)
49
+ }
50
+ }
51
+
52
+ // MARK: - DotLottieAnimationMode
53
+
54
+ enum DotLottieAnimationMode: String, Codable {
55
+ case normal
56
+ case bounce
57
+ }
@@ -0,0 +1,89 @@
1
+ //
2
+ // DotLottieImageProvider.swift
3
+ // Lottie
4
+ //
5
+ // Created by Evandro Hoffmann on 20/10/22.
6
+ //
7
+
8
+ #if canImport(UIKit)
9
+ import UIKit
10
+ #elseif canImport(AppKit)
11
+ import AppKit
12
+ #endif
13
+
14
+ // MARK: - DotLottieImageProvider
15
+
16
+ /// An image provider that loads the images from a DotLottieFile into memory
17
+ final class DotLottieImageProvider: AnimationImageProvider {
18
+
19
+ // MARK: Lifecycle
20
+
21
+ /// Initializes an image provider with a specific filepath.
22
+ ///
23
+ /// - Parameter filepath: The absolute filepath containing the images.
24
+ ///
25
+ convenience init?(filepath: String) {
26
+ self.init(filepath: URL(fileURLWithPath: filepath))
27
+ }
28
+
29
+ init?(filepath: URL) {
30
+ guard filepath.urls.count > 0 else { return nil }
31
+ self.filepath = filepath
32
+ loadImages()
33
+ }
34
+
35
+ // MARK: Internal
36
+
37
+ let filepath: URL
38
+
39
+ func imageForAsset(asset: ImageAsset) -> CGImage? {
40
+ if let base64Image = asset.base64Image {
41
+ return base64Image
42
+ }
43
+
44
+ return images[asset.name]
45
+ }
46
+
47
+ // MARK: Private
48
+
49
+ /// This is intentionally a Dictionary instead of an NSCache. Files from a decompressed dotLottie zip archive
50
+ /// are only valid are deleted after being read into memory. If we used an NSCache then the OS could evict
51
+ /// the cache entries when under memory pressure, and we would have no way to reload them later.
52
+ /// - Ideally we would have a way to remove image data when under memory pressure, but this would require
53
+ /// re-decompressing the dotLottie file when requesting an image that has been loaded but then removed.
54
+ private var images = [String: CGImage]()
55
+
56
+ private func loadImages() {
57
+ for url in filepath.urls {
58
+ #if canImport(UIKit)
59
+ if
60
+ let data = try? Data(contentsOf: url),
61
+ let image = UIImage(data: data)?.cgImage
62
+ {
63
+ images[url.lastPathComponent] = image
64
+ }
65
+ #elseif canImport(AppKit)
66
+ if
67
+ let data = try? Data(contentsOf: url),
68
+ let image = NSImage(data: data)?.lottie_CGImage
69
+ {
70
+ images[url.lastPathComponent] = image
71
+ }
72
+ #endif
73
+ }
74
+ }
75
+
76
+ }
77
+
78
+ // MARK: Hashable
79
+
80
+ extension DotLottieImageProvider: Hashable {
81
+ static func ==(_ lhs: DotLottieImageProvider, _ rhs: DotLottieImageProvider) -> Bool {
82
+ lhs.filepath == rhs.filepath
83
+ }
84
+
85
+ func hash(into hasher: inout Hasher) {
86
+ hasher.combine(filepath)
87
+ }
88
+
89
+ }
@@ -0,0 +1,42 @@
1
+ //
2
+ // DotLottieManifest.swift
3
+ // Lottie
4
+ //
5
+ // Created by Evandro Harrison Hoffmann on 27/06/2020.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ /// Manifest model for .lottie File
11
+ struct DotLottieManifest: Codable {
12
+
13
+ var animations: [DotLottieAnimation]
14
+ var version: String?
15
+ var author: String?
16
+ var generator: String?
17
+
18
+ /// Decodes data to Manifest model
19
+ /// - Parameter data: Data to decode
20
+ /// - Throws: Error
21
+ /// - Returns: .lottie Manifest model
22
+ static func decode(from data: Data) throws -> DotLottieManifest {
23
+ try JSONDecoder().decode(DotLottieManifest.self, from: data)
24
+ }
25
+
26
+ /// Loads manifest from given URL
27
+ /// - Parameter path: URL path to Manifest
28
+ /// - Returns: Manifest Model
29
+ static func load(from url: URL) throws -> DotLottieManifest {
30
+ let data = try Data(contentsOf: url)
31
+ return try decode(from: data)
32
+ }
33
+
34
+ /// Encodes to data
35
+ /// - Parameter encoder: JSONEncoder
36
+ /// - Throws: Error
37
+ /// - Returns: encoded Data
38
+ func encode(with encoder: JSONEncoder = JSONEncoder()) throws -> Data {
39
+ try encoder.encode(self)
40
+ }
41
+
42
+ }
@@ -0,0 +1,71 @@
1
+ //
2
+ // DotLottieUtils.swift
3
+ // Lottie
4
+ //
5
+ // Created by Evandro Harrison Hoffmann on 27/06/2020.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ // MARK: - DotLottieUtils
11
+
12
+ enum DotLottieUtils {
13
+ static let dotLottieExtension = "lottie"
14
+ static let jsonExtension = "json"
15
+ /// IANA-approved short extension for the `video/lottie+json` media type.
16
+ /// See https://www.iana.org/assignments/media-types/video/lottie+json
17
+ /// Treated as an alias for `.json` everywhere a Lottie JSON animation is loaded.
18
+ static let lotExtension = "lot"
19
+
20
+ /// Temp folder to app directory
21
+ static var tempDirectoryURL: URL {
22
+ FileManager.default.temporaryDirectory
23
+ }
24
+ }
25
+
26
+ extension URL {
27
+ /// Checks if url is a lottie file
28
+ var isDotLottie: Bool {
29
+ pathExtension == DotLottieUtils.dotLottieExtension
30
+ }
31
+
32
+ /// Checks if url is a json file (`.json` or its IANA-registered alias `.lot`)
33
+ var isJsonFile: Bool {
34
+ pathExtension == DotLottieUtils.jsonExtension
35
+ || pathExtension == DotLottieUtils.lotExtension
36
+ }
37
+
38
+ var urls: [URL] {
39
+ FileManager.default.urls(for: self) ?? []
40
+ }
41
+ }
42
+
43
+ extension FileManager {
44
+ /// Lists urls for all files in a directory
45
+ /// - Parameters:
46
+ /// - url: URL of directory to search
47
+ /// - skipsHiddenFiles: If should or not show hidden files
48
+ /// - Returns: Returns urls of all files matching criteria in the directory
49
+ func urls(for url: URL, skipsHiddenFiles: Bool = true) -> [URL]? {
50
+ try? contentsOfDirectory(at: url, includingPropertiesForKeys: nil, options: skipsHiddenFiles ? .skipsHiddenFiles : [])
51
+ }
52
+ }
53
+
54
+ // MARK: - DotLottieError
55
+
56
+ public enum DotLottieError: Error {
57
+ /// URL response has no data.
58
+ case noDataLoaded
59
+ /// Asset with this name was not found in the provided bundle.
60
+ case assetNotFound(name: String, bundle: Bundle?)
61
+ /// Animation loading from asset was not supported on macOS 10.10,
62
+ /// but this error is no longer used.
63
+ case loadingFromAssetNotSupported
64
+
65
+ @available(*, deprecated, message: "Unused")
66
+ case invalidFileFormat
67
+ @available(*, deprecated, message: "Unused")
68
+ case invalidData
69
+ @available(*, deprecated, message: "Unused")
70
+ case animationNotAvailable
71
+ }
@@ -0,0 +1,58 @@
1
+ import Foundation
2
+ #if canImport(UIKit)
3
+ import UIKit
4
+ #endif
5
+
6
+ extension Bundle {
7
+ func getAnimationData(_ name: String, subdirectory: String? = nil) throws -> Data {
8
+ // Check for files in the bundle at the given path
9
+ let name = name.removingJSONSuffix()
10
+ if let url = url(forResource: name, withExtension: "json", subdirectory: subdirectory) {
11
+ return try Data(contentsOf: url)
12
+ }
13
+ // `.lot` is the IANA-registered short extension for `video/lottie+json` and is
14
+ // treated as a synonym for `.json` when loading Lottie animations.
15
+ if let url = url(forResource: name, withExtension: "lot", subdirectory: subdirectory) {
16
+ return try Data(contentsOf: url)
17
+ }
18
+
19
+ // Check for data assets
20
+ let assetKey = subdirectory != nil ? "\(subdirectory ?? "")/\(name)" : name
21
+ return try Data(assetName: assetKey, in: self)
22
+ }
23
+
24
+ func dotLottieData(_ name: String, subdirectory: String? = nil) throws -> Data {
25
+ // Check for files in the bundle at the given path
26
+ let name = name.removingDotLottieSuffix()
27
+ if let url = url(forResource: name, withExtension: "lottie", subdirectory: subdirectory) {
28
+ return try Data(contentsOf: url)
29
+ }
30
+
31
+ let assetKey = subdirectory != nil ? "\(subdirectory ?? "")/\(name)" : name
32
+ return try Data(assetName: assetKey, in: self)
33
+ }
34
+ }
35
+
36
+ extension String {
37
+ fileprivate func removingJSONSuffix() -> String {
38
+ // Allow filenames to be passed with a ".json" extension (or its IANA-registered
39
+ // synonym ".lot") so the bundle lookup still works when the caller passes the
40
+ // extension as part of the name. Keeps the behavior from Lottie 2.x for .json
41
+ // and extends it to .lot per the `video/lottie+json` media type spec.
42
+ guard hasSuffix(".json") || hasSuffix(".lot") else {
43
+ return self
44
+ }
45
+
46
+ return (self as NSString).deletingPathExtension
47
+ }
48
+
49
+ fileprivate func removingDotLottieSuffix() -> String {
50
+ // Allow filenames to be passed with a ".lottie" extension (but not other extensions)
51
+ // to keep the behavior from Lottie 2.x - instead of failing to load the file
52
+ guard hasSuffix(".lottie") else {
53
+ return self
54
+ }
55
+
56
+ return (self as NSString).deletingPathExtension
57
+ }
58
+ }
@@ -0,0 +1,71 @@
1
+ // From: https://medium.com/@kewindannerfjordremeczki/swift-4-0-decodable-heterogeneous-collections-ecc0e6b468cf
2
+
3
+ // MARK: - ClassFamily
4
+
5
+ /// To support a new class family, create an enum that conforms to this protocol and contains the different types.
6
+ protocol ClassFamily: Decodable {
7
+ /// The discriminator key.
8
+ static var discriminator: Discriminator { get }
9
+
10
+ /// The "unknown" fallback case if the type discriminator could not be parsed successfully.
11
+ static var unknown: Self { get }
12
+
13
+ /// Returns the class type of the object corresponding to the value.
14
+ func getType() -> AnyObject.Type
15
+ }
16
+
17
+ // MARK: - Discriminator
18
+
19
+ /// Discriminator key enum used to retrieve discriminator fields in JSON payloads.
20
+ enum Discriminator: String, CodingKey {
21
+ case type = "ty"
22
+ }
23
+
24
+ extension KeyedDecodingContainer {
25
+
26
+ /// Decode a heterogeneous list of objects for a given family.
27
+ /// - Parameters:
28
+ /// - heterogeneousType: The decodable type of the list.
29
+ /// - family: The ClassFamily enum for the type family.
30
+ /// - key: The CodingKey to look up the list in the current container.
31
+ /// - Returns: The resulting list of heterogeneousType elements.
32
+ func decode<T: Decodable, U: ClassFamily>(_: [T].Type, ofFamily family: U.Type, forKey key: K) throws -> [T] {
33
+ var container = try nestedUnkeyedContainer(forKey: key)
34
+ var list = [T]()
35
+ var tmpContainer = container
36
+ while !container.isAtEnd {
37
+ let typeContainer = try container.nestedContainer(keyedBy: Discriminator.self)
38
+ let family: U = (try? typeContainer.decodeIfPresent(U.self, forKey: U.discriminator)) ?? .unknown
39
+ if let type = family.getType() as? T.Type {
40
+ list.append(try tmpContainer.decode(type))
41
+ }
42
+ }
43
+ return list
44
+ }
45
+
46
+ /// Decode a heterogeneous list of objects for a given family if the given key is present.
47
+ /// - Parameters:
48
+ /// - heterogeneousType: The decodable type of the list.
49
+ /// - family: The ClassFamily enum for the type family.
50
+ /// - key: The CodingKey to look up the list in the current container.
51
+ /// - Returns: The resulting list of heterogeneousType elements.
52
+ func decodeIfPresent<T: Decodable, U: ClassFamily>(_: [T].Type, ofFamily family: U.Type, forKey key: K) throws -> [T]? {
53
+ var container: UnkeyedDecodingContainer
54
+ do {
55
+ container = try nestedUnkeyedContainer(forKey: key)
56
+ } catch {
57
+ return nil
58
+ }
59
+
60
+ var list = [T]()
61
+ var tmpContainer = container
62
+ while !container.isAtEnd {
63
+ let typeContainer = try container.nestedContainer(keyedBy: Discriminator.self)
64
+ let family: U = (try? typeContainer.decodeIfPresent(U.self, forKey: U.discriminator)) ?? .unknown
65
+ if let type = family.getType() as? T.Type {
66
+ list.append(try tmpContainer.decode(type))
67
+ }
68
+ }
69
+ return list
70
+ }
71
+ }