@octane-xplat/lottie 0.0.1 → 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 (361) hide show
  1. package/README.md +56 -2
  2. package/dist/native/cx.mobile.js +11 -0
  3. package/dist/native/escape-props.js +39 -0
  4. package/dist/native/index.js +183 -0
  5. package/dist/native/layout-child.js +38 -0
  6. package/dist/native/octane-client-build.json +8 -0
  7. package/dist/native/vendor/ui-lottie/index.android.js +286 -0
  8. package/dist/native/vendor/ui-lottie/index.ios.js +214 -0
  9. package/dist/native/vendor/ui-lottie/src/lottie/index.common.js +50 -0
  10. package/dist/native/vendor/ui-lottie/src/lottie/utils.js +6 -0
  11. package/dist/web/escape-props.web.js +17 -0
  12. package/dist/web/index.js +346 -0
  13. package/dist/web/layout-child.web.js +47 -0
  14. package/dist/web/octane-client-build.json +8 -0
  15. package/package.json +104 -11
  16. package/platforms/android/include.gradle +7 -0
  17. package/platforms/android/java/com/nativescript/lottie/LottieAnimationView.java +92 -0
  18. package/platforms/android/lottie.aar +0 -0
  19. package/platforms/android/native-api-usage.json +16 -0
  20. package/platforms/ios/Podfile +5 -0
  21. package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
  22. package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
  23. package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
  24. package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
  25. package/platforms/macos/UPSTREAM.md +13 -0
  26. package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
  27. package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
  28. package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
  29. package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
  30. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
  31. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
  32. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
  33. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
  34. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
  35. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
  36. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
  37. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
  38. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
  39. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
  40. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
  41. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
  42. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
  43. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
  44. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
  45. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
  46. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
  47. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
  48. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
  49. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
  50. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
  51. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
  52. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
  53. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
  54. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
  55. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
  56. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
  57. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
  58. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
  59. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
  60. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
  61. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
  62. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
  63. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
  64. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
  65. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
  66. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
  67. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
  68. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
  69. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
  70. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
  71. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
  72. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
  73. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
  74. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
  75. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
  76. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
  77. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
  78. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
  79. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
  80. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
  81. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
  82. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
  83. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
  84. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
  85. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
  86. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
  87. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
  88. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
  89. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
  90. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
  91. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
  92. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
  93. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
  94. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
  95. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
  96. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
  97. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
  98. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
  99. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
  100. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
  101. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
  102. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
  103. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
  104. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
  105. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
  106. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
  107. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
  108. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
  109. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
  110. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
  111. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
  112. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
  113. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
  114. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
  115. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
  116. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
  117. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
  118. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
  119. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
  120. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
  121. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
  122. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
  123. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
  124. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
  125. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
  126. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
  127. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
  128. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
  129. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
  130. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
  131. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
  132. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
  133. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
  134. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
  135. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
  136. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
  137. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
  138. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
  139. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
  140. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
  141. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
  142. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
  143. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
  144. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
  145. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
  146. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
  147. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
  148. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
  149. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
  150. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
  151. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
  152. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
  153. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
  154. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
  155. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
  156. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
  157. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
  158. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
  159. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
  160. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
  161. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
  162. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
  163. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
  164. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
  165. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
  166. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
  167. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
  168. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
  169. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
  170. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
  171. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
  172. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
  173. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
  174. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
  175. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
  176. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
  177. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
  178. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
  179. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
  180. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
  181. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
  182. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
  183. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
  184. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
  185. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
  186. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
  187. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
  188. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
  189. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
  190. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
  191. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
  192. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
  193. package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
  194. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
  195. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
  196. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
  197. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
  198. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
  199. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
  200. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
  201. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
  202. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
  203. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
  204. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
  205. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
  206. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
  207. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
  208. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
  209. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
  210. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
  211. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
  212. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
  213. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
  214. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
  215. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
  216. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
  217. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
  218. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
  219. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
  220. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
  221. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
  222. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
  223. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
  224. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
  225. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
  226. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
  227. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
  228. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
  229. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
  230. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
  231. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
  232. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
  233. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
  234. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
  235. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
  236. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
  237. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
  238. package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
  239. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
  240. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
  241. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
  242. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
  243. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
  244. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
  245. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
  246. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
  247. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
  248. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
  249. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
  250. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
  251. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
  252. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
  253. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
  254. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
  255. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
  256. package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
  257. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
  258. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
  259. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
  260. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
  261. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
  262. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
  263. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
  264. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
  265. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
  266. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
  267. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
  268. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
  269. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
  270. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
  271. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
  272. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
  273. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
  274. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
  275. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
  276. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
  277. package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
  278. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
  279. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
  280. package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
  281. package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
  282. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
  283. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
  284. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
  285. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
  286. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
  287. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
  288. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
  289. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
  290. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
  291. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
  292. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
  293. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
  294. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
  295. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
  296. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
  297. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
  298. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
  299. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
  300. package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
  301. package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
  302. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
  303. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
  304. package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
  305. package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
  306. package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
  307. package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
  308. package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
  309. package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
  310. package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
  311. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
  312. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
  313. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
  314. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
  315. package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
  316. package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
  317. package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
  318. package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
  319. package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
  320. package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
  321. package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
  322. package/src/Lottie.macos.tsrx +129 -0
  323. package/src/Lottie.tsrx +162 -0
  324. package/src/Lottie.web.tsrx +152 -0
  325. package/src/cx.mobile.ts +8 -0
  326. package/src/escape-props.ts +65 -0
  327. package/src/escape-props.web.ts +25 -0
  328. package/src/index.macos.ts +2 -0
  329. package/src/index.ts +2 -0
  330. package/src/index.web.ts +2 -0
  331. package/src/layout-child.ts +57 -0
  332. package/src/layout-child.web.ts +108 -0
  333. package/src/native-elements.d.ts +8 -0
  334. package/src/props.ts +133 -0
  335. package/src/references.d.ts +3 -0
  336. package/src/vendor/ui-lottie/LICENSE.md +21 -0
  337. package/src/vendor/ui-lottie/src/lottie/index.android.ts +447 -0
  338. package/src/vendor/ui-lottie/src/lottie/index.common.ts +84 -0
  339. package/src/vendor/ui-lottie/src/lottie/index.d.ts +133 -0
  340. package/src/vendor/ui-lottie/src/lottie/index.ios.ts +345 -0
  341. package/src/vendor/ui-lottie/src/lottie/typings/android.d.ts +4149 -0
  342. package/src/vendor/ui-lottie/src/lottie/typings/android.nativescript.d.ts +12 -0
  343. package/src/vendor/ui-lottie/src/lottie/typings/dotlottie.ios.d.ts +14 -0
  344. package/src/vendor/ui-lottie/src/lottie/typings/ios.d.ts +384 -0
  345. package/src/vendor/ui-lottie/src/lottie/utils.ts +9 -0
  346. package/types/generated/.tsrx-typegen-manifest.json +18 -0
  347. package/types/generated/Lottie.d.ts +7 -0
  348. package/types/generated/Lottie.web.d.ts +7 -0
  349. package/types/generated/cx.mobile.d.ts +6 -0
  350. package/types/generated/escape-props.d.ts +15 -0
  351. package/types/generated/escape-props.web.d.ts +5 -0
  352. package/types/generated/index.d.ts +2 -0
  353. package/types/generated/index.web.d.ts +2 -0
  354. package/types/generated/layout-child.d.ts +6 -0
  355. package/types/generated/layout-child.web.d.ts +15 -0
  356. package/types/generated/props.d.ts +110 -0
  357. package/types/generated/vendor/ui-lottie/src/lottie/index.common.d.ts +30 -0
  358. package/types/generated/vendor/ui-lottie/src/lottie/index.ios.d.ts +35 -0
  359. package/types/generated/vendor/ui-lottie/src/lottie/utils.d.ts +1 -0
  360. package/index.d.ts +0 -1
  361. package/index.js +0 -2
@@ -0,0 +1,509 @@
1
+ //
2
+ // Shape.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/8/19.
6
+ //
7
+
8
+ import CoreGraphics
9
+
10
+ // MARK: - BezierPath
11
+
12
+ /// A container that holds instructions for creating a single, unbroken Bezier Path.
13
+ struct BezierPath {
14
+
15
+ // MARK: Lifecycle
16
+
17
+ /// Initializes a new Bezier Path.
18
+ init(startPoint: CurveVertex) {
19
+ elements = [PathElement(vertex: startPoint)]
20
+ length = 0
21
+ closed = false
22
+ }
23
+
24
+ init() {
25
+ elements = []
26
+ length = 0
27
+ closed = false
28
+ }
29
+
30
+ // MARK: Internal
31
+
32
+ /// The elements of the path
33
+ private(set) var elements: [PathElement]
34
+
35
+ /// If the path is closed or not.
36
+ private(set) var closed: Bool
37
+
38
+ /// The total length of the path.
39
+ private(set) var length: CGFloat
40
+
41
+ mutating func moveToStartPoint(_ vertex: CurveVertex) {
42
+ elements = [PathElement(vertex: vertex)]
43
+ length = 0
44
+ }
45
+
46
+ mutating func addVertex(_ vertex: CurveVertex) {
47
+ guard let previous = elements.last else {
48
+ addElement(PathElement(vertex: vertex))
49
+ return
50
+ }
51
+ addElement(previous.pathElementTo(vertex))
52
+ }
53
+
54
+ mutating func addCurve(toPoint: CGPoint, outTangent: CGPoint, inTangent: CGPoint) {
55
+ guard let previous = elements.last else { return }
56
+ let newVertex = CurveVertex(inTangent, toPoint, toPoint)
57
+ updateVertex(
58
+ CurveVertex(previous.vertex.inTangent, previous.vertex.point, outTangent),
59
+ atIndex: elements.endIndex - 1,
60
+ remeasure: false
61
+ )
62
+ addVertex(newVertex)
63
+ }
64
+
65
+ mutating func addLine(toPoint: CGPoint) {
66
+ guard let previous = elements.last else { return }
67
+ let newVertex = CurveVertex(point: toPoint, inTangentRelative: .zero, outTangentRelative: .zero)
68
+ updateVertex(
69
+ CurveVertex(previous.vertex.inTangent, previous.vertex.point, previous.vertex.point),
70
+ atIndex: elements.endIndex - 1,
71
+ remeasure: false
72
+ )
73
+ addVertex(newVertex)
74
+ }
75
+
76
+ mutating func close() {
77
+ closed = true
78
+ }
79
+
80
+ mutating func addElement(_ pathElement: PathElement) {
81
+ elements.append(pathElement)
82
+ length = length + pathElement.length
83
+ }
84
+
85
+ mutating func updateVertex(_ vertex: CurveVertex, atIndex: Int, remeasure: Bool) {
86
+ if remeasure {
87
+ var newElement: PathElement
88
+ if atIndex > 0 {
89
+ let previousElement = elements[atIndex - 1]
90
+ newElement = previousElement.pathElementTo(vertex)
91
+ } else {
92
+ newElement = PathElement(vertex: vertex)
93
+ }
94
+ elements[atIndex] = newElement
95
+
96
+ if atIndex + 1 < elements.count {
97
+ let nextElement = elements[atIndex + 1]
98
+ elements[atIndex + 1] = newElement.pathElementTo(nextElement.vertex)
99
+ }
100
+
101
+ } else {
102
+ let oldElement = elements[atIndex]
103
+ elements[atIndex] = oldElement.updateVertex(newVertex: vertex)
104
+ }
105
+ }
106
+
107
+ /// Trims a path fromLength toLength with an offset.
108
+ ///
109
+ /// Length and offset are defined in the length coordinate space.
110
+ /// If any argument is outside the range of this path, then it will be looped over the path from finish to start.
111
+ ///
112
+ /// Cutting the curve when fromLength is less than toLength
113
+ /// x x x x
114
+ /// ~~~~~~~~~~~~~~~ooooooooooooooooooooooooooooooooooooooooooooooooo-------------------
115
+ /// |Offset |fromLength toLength| |
116
+ ///
117
+ /// Cutting the curve when from Length is greater than toLength
118
+ /// x x x x x
119
+ /// oooooooooooooooooo--------------------~~~~~~~~~~~~~~~~ooooooooooooooooooooooooooooo
120
+ /// | toLength| |Offset |fromLength |
121
+ ///
122
+ func trim(fromLength: CGFloat, toLength: CGFloat, offsetLength: CGFloat) -> [BezierPath] {
123
+ guard elements.count > 1 else {
124
+ return []
125
+ }
126
+
127
+ if fromLength == toLength {
128
+ return []
129
+ }
130
+
131
+ /// Normalize lengths to the curve length.
132
+ var start = (fromLength + offsetLength).truncatingRemainder(dividingBy: length)
133
+ var end = (toLength + offsetLength).truncatingRemainder(dividingBy: length)
134
+
135
+ if start < 0 {
136
+ start = length + start
137
+ }
138
+
139
+ if end < 0 {
140
+ end = length + end
141
+ }
142
+
143
+ if start == length {
144
+ start = 0
145
+ }
146
+ if end == 0 {
147
+ end = length
148
+ }
149
+
150
+ if
151
+ start == 0 && end == length ||
152
+ start == end ||
153
+ start == length && end == 0
154
+ {
155
+ /// The trim encompasses the entire path. Return.
156
+ return [self]
157
+ }
158
+
159
+ if start > end {
160
+ // Start is greater than end. Two paths are returned.
161
+ return trimPathAtLengths(positions: [(start: 0, end: end), (start: start, end: length)])
162
+ }
163
+
164
+ return trimPathAtLengths(positions: [(start: start, end: end)])
165
+ }
166
+
167
+ // MARK: Private
168
+
169
+ private func trimPathAtLengths(positions: [(start: CGFloat, end: CGFloat)]) -> [BezierPath] {
170
+ guard positions.count > 0 else {
171
+ return []
172
+ }
173
+ var remainingPositions = positions
174
+
175
+ var trim = remainingPositions.remove(at: 0)
176
+
177
+ var paths = [BezierPath]()
178
+
179
+ var runningLength: CGFloat = 0
180
+ var finishedTrimming = false
181
+ var pathElements = elements
182
+
183
+ var currentPath = BezierPath()
184
+ var i = 0
185
+
186
+ while !finishedTrimming {
187
+ if pathElements.count <= i {
188
+ /// Do this for rounding errors
189
+ paths.append(currentPath)
190
+ finishedTrimming = true
191
+ continue
192
+ }
193
+ /// Loop through and add elements within start->end range.
194
+ /// Get current element
195
+ let element = pathElements[i]
196
+
197
+ /// Calculate new running length.
198
+ let newLength = runningLength + element.length
199
+
200
+ if newLength < trim.start {
201
+ /// Element is not included in the trim, continue.
202
+ runningLength = newLength
203
+ i = i + 1
204
+ /// Increment index, we are done with this element.
205
+ continue
206
+ }
207
+
208
+ if newLength == trim.start {
209
+ /// Current element IS the start element.
210
+ /// For start we want to add a zero length element.
211
+ currentPath.moveToStartPoint(element.vertex)
212
+ runningLength = newLength
213
+ i = i + 1
214
+ /// Increment index, we are done with this element.
215
+ continue
216
+ }
217
+
218
+ if runningLength < trim.start, trim.start < newLength, currentPath.elements.count == 0 {
219
+ /// The start of the trim is between this element and the previous, trim.
220
+ /// Get previous element.
221
+ let previousElement = pathElements[i - 1]
222
+ /// Trim it
223
+ let trimLength = trim.start - runningLength
224
+ let trimResults = element.splitElementAtPosition(fromElement: previousElement, atLength: trimLength)
225
+ /// Add the right span start.
226
+ currentPath.moveToStartPoint(trimResults.rightSpan.start.vertex)
227
+
228
+ pathElements[i] = trimResults.rightSpan.end
229
+ pathElements[i - 1] = trimResults.rightSpan.start
230
+ runningLength = runningLength + trimResults.leftSpan.end.length
231
+ /// Dont increment index or the current length, the end of this path can be within this span.
232
+ continue
233
+ }
234
+
235
+ if trim.start < newLength, newLength < trim.end {
236
+ /// Element lies within the trim span.
237
+ currentPath.addElement(element)
238
+ runningLength = newLength
239
+ i = i + 1
240
+ continue
241
+ }
242
+
243
+ if newLength == trim.end {
244
+ /// Element is the end element.
245
+ /// The element could have a new length if it's added right after the start node.
246
+ currentPath.addElement(element)
247
+ /// We are done with this span.
248
+ runningLength = newLength
249
+ i = i + 1
250
+ /// Allow the path to be finalized.
251
+ /// Fall through to finalize path and move to next position
252
+ }
253
+
254
+ if runningLength < trim.end, trim.end < newLength {
255
+ /// New element must be cut for end.
256
+ /// Get previous element.
257
+ let previousElement = pathElements[i - 1]
258
+ /// Trim it
259
+ let trimLength = trim.end - runningLength
260
+ let trimResults = element.splitElementAtPosition(fromElement: previousElement, atLength: trimLength)
261
+ /// Add the left span end.
262
+
263
+ currentPath.updateVertex(trimResults.leftSpan.start.vertex, atIndex: currentPath.elements.count - 1, remeasure: false)
264
+ currentPath.addElement(trimResults.leftSpan.end)
265
+
266
+ pathElements[i] = trimResults.rightSpan.end
267
+ pathElements[i - 1] = trimResults.rightSpan.start
268
+ runningLength = runningLength + trimResults.leftSpan.end.length
269
+ /// Dont increment index or the current length, the start of the next path can be within this span.
270
+ /// We are done with this span.
271
+ /// Allow the path to be finalized.
272
+ /// Fall through to finalize path and move to next position
273
+ }
274
+
275
+ paths.append(currentPath)
276
+ currentPath = BezierPath()
277
+ if remainingPositions.count > 0 {
278
+ trim = remainingPositions.remove(at: 0)
279
+ } else {
280
+ finishedTrimming = true
281
+ }
282
+ }
283
+ return paths
284
+ }
285
+
286
+ }
287
+
288
+ // MARK: Codable
289
+
290
+ extension BezierPath: Codable {
291
+
292
+ // MARK: Lifecycle
293
+
294
+ init(from decoder: Decoder) throws {
295
+ let container: KeyedDecodingContainer<BezierPath.CodingKeys>
296
+
297
+ if let keyedContainer = try? decoder.container(keyedBy: BezierPath.CodingKeys.self) {
298
+ container = keyedContainer
299
+ } else {
300
+ var unkeyedContainer = try decoder.unkeyedContainer()
301
+ container = try unkeyedContainer.nestedContainer(keyedBy: BezierPath.CodingKeys.self)
302
+ }
303
+
304
+ closed = try container.decodeIfPresent(Bool.self, forKey: .closed) ?? true
305
+
306
+ var vertexContainer = try container.nestedUnkeyedContainer(forKey: .vertices)
307
+ var inPointsContainer = try container.nestedUnkeyedContainer(forKey: .inPoints)
308
+ var outPointsContainer = try container.nestedUnkeyedContainer(forKey: .outPoints)
309
+
310
+ guard vertexContainer.count == inPointsContainer.count, inPointsContainer.count == outPointsContainer.count else {
311
+ /// Will throw an error if vertex, inpoints, and outpoints are not the same length.
312
+ /// This error is to be expected.
313
+ throw DecodingError.dataCorruptedError(
314
+ forKey: CodingKeys.vertices,
315
+ in: container,
316
+ debugDescription: "Vertex data does not match In Tangents and Out Tangents"
317
+ )
318
+ }
319
+
320
+ guard let count = vertexContainer.count, count > 0 else {
321
+ length = 0
322
+ elements = []
323
+ return
324
+ }
325
+
326
+ var decodedElements = [PathElement]()
327
+
328
+ /// Create first point
329
+ let firstVertex = CurveVertex(
330
+ point: try vertexContainer.decode(CGPoint.self),
331
+ inTangentRelative: try inPointsContainer.decode(CGPoint.self),
332
+ outTangentRelative: try outPointsContainer.decode(CGPoint.self)
333
+ )
334
+ var previousElement = PathElement(vertex: firstVertex)
335
+ decodedElements.append(previousElement)
336
+
337
+ var totalLength: CGFloat = 0
338
+ while !vertexContainer.isAtEnd {
339
+ /// Get the next vertex data.
340
+ let vertex = CurveVertex(
341
+ point: try vertexContainer.decode(CGPoint.self),
342
+ inTangentRelative: try inPointsContainer.decode(CGPoint.self),
343
+ outTangentRelative: try outPointsContainer.decode(CGPoint.self)
344
+ )
345
+ let pathElement = previousElement.pathElementTo(vertex)
346
+ decodedElements.append(pathElement)
347
+ previousElement = pathElement
348
+ totalLength = totalLength + pathElement.length
349
+ }
350
+ if closed {
351
+ // Don't use an out tangent for the closing point, since the
352
+ // closing point is exactly equal to the starting point.
353
+ let closeVertex = CurveVertex(
354
+ point: firstVertex.point,
355
+ inTangentRelative: firstVertex.inTangentRelative,
356
+ outTangentRelative: .zero
357
+ )
358
+
359
+ let closeElement = previousElement.pathElementTo(closeVertex)
360
+ decodedElements.append(closeElement)
361
+ totalLength = totalLength + closeElement.length
362
+ }
363
+ length = totalLength
364
+ elements = decodedElements
365
+ }
366
+
367
+ // MARK: Internal
368
+
369
+ /// The BezierPath container is encoded and decoded from the JSON format
370
+ /// that defines points for a lottie animation.
371
+ ///
372
+ /// {
373
+ /// "c" = Bool
374
+ /// "i" = [[Double]],
375
+ /// "o" = [[Double]],
376
+ /// "v" = [[Double]]
377
+ /// }
378
+ ///
379
+
380
+ enum CodingKeys: String, CodingKey {
381
+ case closed = "c"
382
+ case inPoints = "i"
383
+ case outPoints = "o"
384
+ case vertices = "v"
385
+ }
386
+
387
+ func encode(to encoder: Encoder) throws {
388
+ var container = encoder.container(keyedBy: BezierPath.CodingKeys.self)
389
+ try container.encode(closed, forKey: .closed)
390
+
391
+ var vertexContainer = container.nestedUnkeyedContainer(forKey: .vertices)
392
+ var inPointsContainer = container.nestedUnkeyedContainer(forKey: .inPoints)
393
+ var outPointsContainer = container.nestedUnkeyedContainer(forKey: .outPoints)
394
+
395
+ /// If closed path, ignore the final element.
396
+ let finalIndex = closed ? elements.endIndex - 1 : elements.endIndex
397
+ for i in 0..<finalIndex {
398
+ let element = elements[i]
399
+ try vertexContainer.encode(element.vertex.point)
400
+ try inPointsContainer.encode(element.vertex.inTangentRelative)
401
+ try outPointsContainer.encode(element.vertex.outTangentRelative)
402
+ }
403
+ }
404
+ }
405
+
406
+ // MARK: AnyInitializable
407
+
408
+ extension BezierPath: AnyInitializable {
409
+
410
+ init(value: Any) throws {
411
+ var pathDictionary: [String: Any]
412
+ if
413
+ let array = value as? [[String: Any]],
414
+ let firstDictionary = array.first
415
+ {
416
+ pathDictionary = firstDictionary
417
+ } else if let dictionary = value as? [String: Any] {
418
+ pathDictionary = dictionary
419
+ } else {
420
+ throw InitializableError.invalidInput()
421
+ }
422
+ closed = (try? pathDictionary.value(for: CodingKeys.closed)) ?? true
423
+ var vertexDictionaries: [Any] = try pathDictionary.value(for: CodingKeys.vertices)
424
+ var inPointsDictionaries: [Any] = try pathDictionary.value(for: CodingKeys.inPoints)
425
+ var outPointsDictionaries: [Any] = try pathDictionary.value(for: CodingKeys.outPoints)
426
+ guard
427
+ vertexDictionaries.count == inPointsDictionaries.count,
428
+ inPointsDictionaries.count == outPointsDictionaries.count
429
+ else {
430
+ throw InitializableError.invalidInput()
431
+ }
432
+ guard vertexDictionaries.count > 0 else {
433
+ length = 0
434
+ elements = []
435
+ return
436
+ }
437
+
438
+ var decodedElements = [PathElement]()
439
+ let firstVertexDictionary = vertexDictionaries.removeFirst()
440
+ let firstInPointsDictionary = inPointsDictionaries.removeFirst()
441
+ let firstOutPointsDictionary = outPointsDictionaries.removeFirst()
442
+ let firstVertex = CurveVertex(
443
+ point: try CGPoint(value: firstVertexDictionary),
444
+ inTangentRelative: try CGPoint(value: firstInPointsDictionary),
445
+ outTangentRelative: try CGPoint(value: firstOutPointsDictionary)
446
+ )
447
+ var previousElement = PathElement(vertex: firstVertex)
448
+ decodedElements.append(previousElement)
449
+
450
+ var totalLength: CGFloat = 0
451
+ while vertexDictionaries.count > 0 {
452
+ let vertexDictionary = vertexDictionaries.removeFirst()
453
+ let inPointsDictionary = inPointsDictionaries.removeFirst()
454
+ let outPointsDictionary = outPointsDictionaries.removeFirst()
455
+ let vertex = CurveVertex(
456
+ point: try CGPoint(value: vertexDictionary),
457
+ inTangentRelative: try CGPoint(value: inPointsDictionary),
458
+ outTangentRelative: try CGPoint(value: outPointsDictionary)
459
+ )
460
+ let pathElement = previousElement.pathElementTo(vertex)
461
+ decodedElements.append(pathElement)
462
+ previousElement = pathElement
463
+ totalLength = totalLength + pathElement.length
464
+ }
465
+ if closed {
466
+ // Don't use an out tangent for the closing point, since the
467
+ // closing point is exactly equal to the starting point.
468
+ let closeVertex = CurveVertex(
469
+ point: firstVertex.point,
470
+ inTangentRelative: firstVertex.inTangentRelative,
471
+ outTangentRelative: .zero
472
+ )
473
+
474
+ let closeElement = previousElement.pathElementTo(closeVertex)
475
+ decodedElements.append(closeElement)
476
+ totalLength = totalLength + closeElement.length
477
+ }
478
+
479
+ length = totalLength
480
+ elements = decodedElements
481
+ }
482
+
483
+ }
484
+
485
+ extension BezierPath {
486
+
487
+ func cgPath() -> CGPath {
488
+ let cgPath = CGMutablePath()
489
+
490
+ var previousElement: PathElement?
491
+ for element in elements {
492
+ if let previous = previousElement {
493
+ if previous.vertex.outTangentRelative.isZero, element.vertex.inTangentRelative.isZero {
494
+ cgPath.addLine(to: element.vertex.point)
495
+ } else {
496
+ cgPath.addCurve(to: element.vertex.point, control1: previous.vertex.outTangent, control2: element.vertex.inTangent)
497
+ }
498
+ } else {
499
+ cgPath.move(to: element.vertex.point)
500
+ }
501
+ previousElement = element
502
+ }
503
+ if closed {
504
+ cgPath.closeSubpath()
505
+ }
506
+ return cgPath
507
+ }
508
+
509
+ }
@@ -0,0 +1,163 @@
1
+ //
2
+ // BezierPathRoundExtension.swift
3
+ // Lottie
4
+ //
5
+ // Created by Duolingo on 11/1/22.
6
+ //
7
+
8
+ import CoreGraphics
9
+ import Foundation
10
+
11
+ // Adapted to Swift from lottie-web & lottie-android:
12
+
13
+ // Rounded corner algorithm:
14
+ // Iterate through each vertex.
15
+ // If a vertex is a sharp corner, it rounds it.
16
+ // If a vertex has control points, it is already rounded, so it does nothing.
17
+ //
18
+ // To round a vertex:
19
+ // Split the vertex into two.
20
+ // Move vertex 1 directly towards the previous vertex.
21
+ // Set vertex 1's in control point to itself so it is not rounded on that side.
22
+ // Extend vertex 1's out control point towards the original vertex.
23
+ //
24
+ // Repeat for vertex 2:
25
+ // Move vertex 2 directly towards the next vertex.
26
+ // Set vertex 2's out point to itself so it is not rounded on that side.
27
+ // Extend vertex 2's in control point towards the original vertex.
28
+ //
29
+ // The distance that the vertices and control points are moved are relative to the
30
+ // shape's vertex distances and the roundedness set in the animation.
31
+
32
+ extension CompoundBezierPath {
33
+ /// Round corners of a compound bezier
34
+ func roundCorners(radius: CGFloat) -> CompoundBezierPath {
35
+ var newPaths = [BezierPath]()
36
+ for path in paths {
37
+ newPaths.append(
38
+ path.roundCorners(radius: radius)
39
+ )
40
+ }
41
+
42
+ return CompoundBezierPath(paths: newPaths)
43
+ }
44
+ }
45
+
46
+ extension BezierPath {
47
+ /// Computes a new `BezierPath` with each corner rounded based on the given `radius`
48
+ func roundCorners(radius: CGFloat) -> BezierPath {
49
+ var newPath = BezierPath()
50
+ var uniquePath = BezierPath()
51
+
52
+ var currentVertex: CurveVertex
53
+ var closestVertex: CurveVertex
54
+ var distance: CGFloat
55
+ var newPosPerc: CGFloat
56
+ var closestIndex: Int
57
+
58
+ var iX: CGFloat
59
+ var iY: CGFloat
60
+ var vX: CGFloat
61
+ var vY: CGFloat
62
+ var oX: CGFloat
63
+ var oY: CGFloat
64
+
65
+ var startIndex = 0
66
+
67
+ let TANGENT_LENGTH = 0.5519
68
+
69
+ // If start and end are the same we close the path
70
+ if
71
+ elements[0].vertex.point == elements[elements.count - 1].vertex.point,
72
+ elements[0].vertex.inTangent == elements[elements.count - 1].vertex.inTangent,
73
+ elements[0].vertex.outTangent == elements[elements.count - 1].vertex.outTangent
74
+ {
75
+ startIndex = 1
76
+ newPath.close()
77
+ }
78
+
79
+ guard elements.count - startIndex > 1 else {
80
+ return self
81
+ }
82
+
83
+ for i in startIndex..<elements.count {
84
+ uniquePath.addVertex(elements[i].vertex)
85
+ }
86
+
87
+ var pathHasRoundedCorner = false
88
+
89
+ for elementIndex in 0..<uniquePath.elements.count {
90
+ currentVertex = uniquePath.elements[elementIndex].vertex
91
+
92
+ guard
93
+ currentVertex.point.x == currentVertex.outTangent.x,
94
+ currentVertex.point.y == currentVertex.outTangent.y,
95
+ currentVertex.point.x == currentVertex.inTangent.x,
96
+ currentVertex.point.y == currentVertex.inTangent.y
97
+ else {
98
+ newPath.addVertex(currentVertex)
99
+ continue
100
+ }
101
+
102
+ // Track whether or not this path has at least one rounded corner
103
+ pathHasRoundedCorner = true
104
+
105
+ // Do not round start and end if not closed
106
+ if !newPath.closed, elementIndex == 0 || elementIndex == uniquePath.elements.count - 1 {
107
+ newPath.addVertex(currentVertex)
108
+ } else {
109
+ closestIndex = elementIndex - 1
110
+ if closestIndex < 0 {
111
+ closestIndex = uniquePath.elements.count - 1
112
+ }
113
+
114
+ closestVertex = uniquePath.elements[closestIndex].vertex
115
+ distance = currentVertex.point.distanceTo(closestVertex.point)
116
+ newPosPerc = distance != 0 ? min(distance / 2, radius) / distance : 0
117
+
118
+ iX = currentVertex.point.x + (closestVertex.point.x - currentVertex.point.x) * newPosPerc
119
+ vX = iX
120
+ iY = currentVertex.point.y - (currentVertex.point.y - closestVertex.point.y) * newPosPerc
121
+ vY = iY
122
+ oX = vX - (vX - currentVertex.point.x) * TANGENT_LENGTH
123
+ oY = vY - (vY - currentVertex.point.y) * TANGENT_LENGTH
124
+ newPath.addVertex(
125
+ CurveVertex(
126
+ CGPoint(x: iX, y: iY),
127
+ CGPoint(x: vX, y: vY),
128
+ CGPoint(x: oX, y: oY)
129
+ )
130
+ )
131
+
132
+ closestIndex = (elementIndex + 1) % uniquePath.elements.count
133
+
134
+ closestVertex = uniquePath.elements[closestIndex].vertex
135
+ distance = currentVertex.point.distanceTo(closestVertex.point)
136
+ newPosPerc = distance != 0 ? min(distance / 2, radius) / distance : 0
137
+
138
+ oX = currentVertex.point.x + (closestVertex.point.x - currentVertex.point.x) * newPosPerc
139
+ vX = oX
140
+ oY = currentVertex.point.y + (closestVertex.point.y - currentVertex.point.y) * newPosPerc
141
+ vY = oY
142
+ iX = vX - (vX - currentVertex.point.x) * TANGENT_LENGTH
143
+ iY = vY - (vY - currentVertex.point.y) * TANGENT_LENGTH
144
+
145
+ newPath.addVertex(
146
+ CurveVertex(
147
+ CGPoint(x: iX, y: iY),
148
+ CGPoint(x: vX, y: vY),
149
+ CGPoint(x: oX, y: oY)
150
+ )
151
+ )
152
+ }
153
+ }
154
+
155
+ // If we didn't need to apply the corner radius to any of the corners,
156
+ // just use the original given path instead of modifying it.
157
+ if !pathHasRoundedCorner {
158
+ return self
159
+ }
160
+
161
+ return newPath
162
+ }
163
+ }
@@ -0,0 +1,35 @@
1
+ //
2
+ // CGPointExtension.swift
3
+ // Lottie
4
+ //
5
+ // Created by Marcelo Fabri on 5/5/22.
6
+ //
7
+
8
+ import CoreGraphics
9
+
10
+ extension CGPoint: AnyInitializable {
11
+
12
+ // MARK: Lifecycle
13
+
14
+ init(value: Any) throws {
15
+ if let dictionary = value as? [String: CGFloat] {
16
+ let x: CGFloat = try dictionary.value(for: CodingKeys.x)
17
+ let y: CGFloat = try dictionary.value(for: CodingKeys.y)
18
+ self.init(x: x, y: y)
19
+ } else if
20
+ let array = value as? [CGFloat],
21
+ array.count > 1
22
+ {
23
+ self.init(x: array[0], y: array[1])
24
+ } else {
25
+ throw InitializableError.invalidInput()
26
+ }
27
+ }
28
+
29
+ // MARK: Private
30
+
31
+ private enum CodingKeys: String {
32
+ case x
33
+ case y
34
+ }
35
+ }