@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.
- package/README.md +56 -2
- package/dist/native/cx.mobile.js +11 -0
- package/dist/native/escape-props.js +39 -0
- package/dist/native/index.js +183 -0
- package/dist/native/layout-child.js +38 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/native/vendor/ui-lottie/index.android.js +286 -0
- package/dist/native/vendor/ui-lottie/index.ios.js +214 -0
- package/dist/native/vendor/ui-lottie/src/lottie/index.common.js +50 -0
- package/dist/native/vendor/ui-lottie/src/lottie/utils.js +6 -0
- package/dist/web/escape-props.web.js +17 -0
- package/dist/web/index.js +346 -0
- package/dist/web/layout-child.web.js +47 -0
- package/dist/web/octane-client-build.json +8 -0
- package/package.json +104 -11
- package/platforms/android/include.gradle +7 -0
- package/platforms/android/java/com/nativescript/lottie/LottieAnimationView.java +92 -0
- package/platforms/android/lottie.aar +0 -0
- package/platforms/android/native-api-usage.json +16 -0
- package/platforms/ios/Podfile +5 -0
- package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
- package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
- package/platforms/macos/UPSTREAM.md +13 -0
- package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
- package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
- package/src/Lottie.macos.tsrx +129 -0
- package/src/Lottie.tsrx +162 -0
- package/src/Lottie.web.tsrx +152 -0
- package/src/cx.mobile.ts +8 -0
- package/src/escape-props.ts +65 -0
- package/src/escape-props.web.ts +25 -0
- package/src/index.macos.ts +2 -0
- package/src/index.ts +2 -0
- package/src/index.web.ts +2 -0
- package/src/layout-child.ts +57 -0
- package/src/layout-child.web.ts +108 -0
- package/src/native-elements.d.ts +8 -0
- package/src/props.ts +133 -0
- package/src/references.d.ts +3 -0
- package/src/vendor/ui-lottie/LICENSE.md +21 -0
- package/src/vendor/ui-lottie/src/lottie/index.android.ts +447 -0
- package/src/vendor/ui-lottie/src/lottie/index.common.ts +84 -0
- package/src/vendor/ui-lottie/src/lottie/index.d.ts +133 -0
- package/src/vendor/ui-lottie/src/lottie/index.ios.ts +345 -0
- package/src/vendor/ui-lottie/src/lottie/typings/android.d.ts +4149 -0
- package/src/vendor/ui-lottie/src/lottie/typings/android.nativescript.d.ts +12 -0
- package/src/vendor/ui-lottie/src/lottie/typings/dotlottie.ios.d.ts +14 -0
- package/src/vendor/ui-lottie/src/lottie/typings/ios.d.ts +384 -0
- package/src/vendor/ui-lottie/src/lottie/utils.ts +9 -0
- package/types/generated/.tsrx-typegen-manifest.json +18 -0
- package/types/generated/Lottie.d.ts +7 -0
- package/types/generated/Lottie.web.d.ts +7 -0
- package/types/generated/cx.mobile.d.ts +6 -0
- package/types/generated/escape-props.d.ts +15 -0
- package/types/generated/escape-props.web.d.ts +5 -0
- package/types/generated/index.d.ts +2 -0
- package/types/generated/index.web.d.ts +2 -0
- package/types/generated/layout-child.d.ts +6 -0
- package/types/generated/layout-child.web.d.ts +15 -0
- package/types/generated/props.d.ts +110 -0
- package/types/generated/vendor/ui-lottie/src/lottie/index.common.d.ts +30 -0
- package/types/generated/vendor/ui-lottie/src/lottie/index.ios.d.ts +35 -0
- package/types/generated/vendor/ui-lottie/src/lottie/utils.d.ts +1 -0
- package/index.d.ts +0 -1
- package/index.js +0 -2
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
// Created by Cal Stephens on 12/13/21.
|
|
2
|
+
// Copyright © 2021 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
import QuartzCore
|
|
5
|
+
|
|
6
|
+
// MARK: - CoreAnimationLayer
|
|
7
|
+
|
|
8
|
+
/// The root `CALayer` of the Core Animation rendering engine
|
|
9
|
+
final class CoreAnimationLayer: BaseAnimationLayer {
|
|
10
|
+
|
|
11
|
+
// MARK: Lifecycle
|
|
12
|
+
|
|
13
|
+
/// Initializes a `CALayer` that renders the given animation using `CAAnimation`s.
|
|
14
|
+
/// - This initializer is throwing, but will only throw when using
|
|
15
|
+
/// `CompatibilityTracker.Mode.abort`.
|
|
16
|
+
init(
|
|
17
|
+
animation: LottieAnimation,
|
|
18
|
+
imageProvider: AnimationImageProvider,
|
|
19
|
+
textProvider: AnimationKeypathTextProvider,
|
|
20
|
+
fontProvider: AnimationFontProvider,
|
|
21
|
+
maskAnimationToBounds: Bool,
|
|
22
|
+
compatibilityTrackerMode: CompatibilityTracker.Mode,
|
|
23
|
+
logger: LottieLogger
|
|
24
|
+
) throws {
|
|
25
|
+
self.animation = animation
|
|
26
|
+
self.imageProvider = imageProvider
|
|
27
|
+
self.textProvider = textProvider
|
|
28
|
+
self.fontProvider = fontProvider
|
|
29
|
+
self.logger = logger
|
|
30
|
+
compatibilityTracker = CompatibilityTracker(mode: compatibilityTrackerMode, logger: logger)
|
|
31
|
+
valueProviderStore = ValueProviderStore(logger: logger)
|
|
32
|
+
super.init()
|
|
33
|
+
masksToBounds = maskAnimationToBounds
|
|
34
|
+
setup()
|
|
35
|
+
try setupChildLayers()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// Called by CoreAnimation to create a shadow copy of this layer
|
|
39
|
+
/// More details: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
|
|
40
|
+
override init(layer: Any) {
|
|
41
|
+
guard let typedLayer = layer as? Self else {
|
|
42
|
+
fatalError("init(layer:) incorrectly called with \(type(of: layer))")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
animation = typedLayer.animation
|
|
46
|
+
currentAnimationConfiguration = typedLayer.currentAnimationConfiguration
|
|
47
|
+
imageProvider = typedLayer.imageProvider
|
|
48
|
+
textProvider = typedLayer.textProvider
|
|
49
|
+
fontProvider = typedLayer.fontProvider
|
|
50
|
+
didSetUpAnimation = typedLayer.didSetUpAnimation
|
|
51
|
+
compatibilityTracker = typedLayer.compatibilityTracker
|
|
52
|
+
logger = typedLayer.logger
|
|
53
|
+
valueProviderStore = typedLayer.valueProviderStore
|
|
54
|
+
super.init(layer: typedLayer)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
required init?(coder _: NSCoder) {
|
|
58
|
+
fatalError("init(coder:) has not been implemented")
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// MARK: Internal
|
|
62
|
+
|
|
63
|
+
/// Timing-related configuration to apply to this layer's child `CAAnimation`s
|
|
64
|
+
/// - This is effectively a configurable subset of `CAMediaTiming`
|
|
65
|
+
struct CAMediaTimingConfiguration: Equatable {
|
|
66
|
+
var autoreverses = false
|
|
67
|
+
var repeatCount: Float = 0
|
|
68
|
+
var speed: Float = 1
|
|
69
|
+
var timeOffset: TimeInterval = 0
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
enum PlaybackState: Equatable {
|
|
73
|
+
/// The animation is has started playing, and may still be playing.
|
|
74
|
+
/// - When animating with a finite duration (e.g. `playOnce`), playback
|
|
75
|
+
/// state will still be `playing` when the animation completes.
|
|
76
|
+
/// To check if the animation is currently playing, prefer `isAnimationPlaying`.
|
|
77
|
+
case playing
|
|
78
|
+
/// The animation is statically displaying a specific frame
|
|
79
|
+
case paused(frame: AnimationFrameTime)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Configuration used by the `playAnimation` method
|
|
83
|
+
struct AnimationConfiguration: Equatable {
|
|
84
|
+
var animationContext: AnimationContext
|
|
85
|
+
var timingConfiguration: CAMediaTimingConfiguration
|
|
86
|
+
var recordHierarchyKeypath: ((String) -> Void)?
|
|
87
|
+
|
|
88
|
+
var expectedAnimationDuration: TimeInterval {
|
|
89
|
+
let animationDuration = Double(animationContext.playTo - animationContext.playFrom) / animationContext.framerate
|
|
90
|
+
let durationMultiplier = timingConfiguration.autoreverses ? 2.0 : 1.0
|
|
91
|
+
let speed = Double(timingConfiguration.speed)
|
|
92
|
+
let repeatCount = Double(timingConfiguration.repeatCount)
|
|
93
|
+
let timeOffset = timingConfiguration.timeOffset
|
|
94
|
+
return animationDuration * durationMultiplier / speed * repeatCount - timeOffset
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static func ==(_ lhs: AnimationConfiguration, _ rhs: AnimationConfiguration) -> Bool {
|
|
98
|
+
lhs.animationContext == rhs.animationContext
|
|
99
|
+
&& lhs.timingConfiguration == rhs.timingConfiguration
|
|
100
|
+
&& ((lhs.recordHierarchyKeypath == nil) == (rhs.recordHierarchyKeypath == nil))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// The parent `LottieAnimationLayer` that manages this layer
|
|
105
|
+
weak var lottieAnimationLayer: LottieAnimationLayer?
|
|
106
|
+
|
|
107
|
+
/// A closure that is called after this layer sets up its animation.
|
|
108
|
+
/// If the animation setup was unsuccessful and encountered compatibility issues,
|
|
109
|
+
/// those issues are included in this call.
|
|
110
|
+
var didSetUpAnimation: (([CompatibilityIssue]) -> Void)?
|
|
111
|
+
|
|
112
|
+
/// The `AnimationImageProvider` that `ImageLayer`s use to retrieve images,
|
|
113
|
+
/// referenced by name in the animation json.
|
|
114
|
+
var imageProvider: AnimationImageProvider {
|
|
115
|
+
didSet { reloadImages() }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// The `AnimationKeypathTextProvider` that `TextLayer`'s use to retrieve texts,
|
|
119
|
+
/// that they should use to render their text context
|
|
120
|
+
var textProvider: AnimationKeypathTextProvider {
|
|
121
|
+
didSet {
|
|
122
|
+
// We need to rebuild the current animation after updating the text provider,
|
|
123
|
+
// since this is used in `TextLayer.setupAnimations(context:)`
|
|
124
|
+
rebuildCurrentAnimation()
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// The `FontProvider` that `TextLayer`s use to retrieve the `CTFont`
|
|
129
|
+
/// that they should use to render their text content
|
|
130
|
+
var fontProvider: AnimationFontProvider {
|
|
131
|
+
didSet { reloadFonts() }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// Queues the animation with the given timing configuration
|
|
135
|
+
/// to begin playing at the next `display()` call.
|
|
136
|
+
/// - This batches together animations so that even if `playAnimation`
|
|
137
|
+
/// is called multiple times in the same run loop cycle, the animation
|
|
138
|
+
/// will only be set up a single time.
|
|
139
|
+
func playAnimation(
|
|
140
|
+
configuration: AnimationConfiguration,
|
|
141
|
+
playbackState: PlaybackState = .playing
|
|
142
|
+
) {
|
|
143
|
+
pendingAnimationConfiguration = (
|
|
144
|
+
animationConfiguration: configuration,
|
|
145
|
+
playbackState: playbackState
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
setNeedsDisplay()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
override func layoutSublayers() {
|
|
152
|
+
super.layoutSublayers()
|
|
153
|
+
|
|
154
|
+
// If no animation has been set up yet, display the first frame
|
|
155
|
+
// now that the layer hierarchy has been setup and laid out
|
|
156
|
+
if
|
|
157
|
+
pendingAnimationConfiguration == nil,
|
|
158
|
+
currentAnimationConfiguration == nil,
|
|
159
|
+
bounds.size != .zero
|
|
160
|
+
{
|
|
161
|
+
currentFrame = animation.frameTime(forProgress: animationProgress)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
override func display() {
|
|
166
|
+
// We intentionally don't call `super.display()`, since this layer
|
|
167
|
+
// doesn't directly render any content.
|
|
168
|
+
// - This fixes an issue where certain animations would unexpectedly
|
|
169
|
+
// allocate a very large amount of memory (400mb+).
|
|
170
|
+
// - Alternatively this layer could subclass `CATransformLayer`,
|
|
171
|
+
// but this causes Core Animation to emit unnecessary logs.
|
|
172
|
+
if var pendingAnimationConfiguration {
|
|
173
|
+
pendingAnimationConfigurationModification?(&pendingAnimationConfiguration.animationConfiguration)
|
|
174
|
+
pendingAnimationConfigurationModification = nil
|
|
175
|
+
self.pendingAnimationConfiguration = nil
|
|
176
|
+
|
|
177
|
+
do {
|
|
178
|
+
try setupAnimation(for: pendingAnimationConfiguration.animationConfiguration)
|
|
179
|
+
} catch {
|
|
180
|
+
if case CompatibilityTracker.Error.encounteredCompatibilityIssue(let compatibilityIssue) = error {
|
|
181
|
+
// Even though the animation setup failed, we still update the layer's playback state
|
|
182
|
+
// so it can be read by the parent `LottieAnimationView` when handling this error
|
|
183
|
+
currentPlaybackState = pendingAnimationConfiguration.playbackState
|
|
184
|
+
|
|
185
|
+
didSetUpAnimation?([compatibilityIssue])
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
currentPlaybackState = pendingAnimationConfiguration.playbackState
|
|
191
|
+
|
|
192
|
+
compatibilityTracker.reportCompatibilityIssues { compatibilityIssues in
|
|
193
|
+
didSetUpAnimation?(compatibilityIssues)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// MARK: Private
|
|
199
|
+
|
|
200
|
+
/// The configuration for the most recent animation which has been
|
|
201
|
+
/// queued by calling `playAnimation` but not yet actually set up
|
|
202
|
+
private var pendingAnimationConfiguration: (
|
|
203
|
+
animationConfiguration: AnimationConfiguration,
|
|
204
|
+
playbackState: PlaybackState
|
|
205
|
+
)?
|
|
206
|
+
|
|
207
|
+
/// A modification that should be applied to the next animation configuration
|
|
208
|
+
private var pendingAnimationConfigurationModification: ((inout AnimationConfiguration) -> Void)?
|
|
209
|
+
|
|
210
|
+
/// Configuration for the animation that is currently setup in this layer
|
|
211
|
+
private var currentAnimationConfiguration: AnimationConfiguration?
|
|
212
|
+
|
|
213
|
+
/// The real-world time at which the animation playback was started.
|
|
214
|
+
/// Used to calculate the animation's current progress, including time spent in the background.
|
|
215
|
+
private var animationStartedAt: Date?
|
|
216
|
+
|
|
217
|
+
/// The current progress of the placeholder `CAAnimation`,
|
|
218
|
+
/// which is also the realtime animation progress of this layer's animation
|
|
219
|
+
@objc private var animationProgress: CGFloat = 0
|
|
220
|
+
|
|
221
|
+
private let animation: LottieAnimation
|
|
222
|
+
private let valueProviderStore: ValueProviderStore
|
|
223
|
+
private let compatibilityTracker: CompatibilityTracker
|
|
224
|
+
private let logger: LottieLogger
|
|
225
|
+
private let loggingState = LoggingState()
|
|
226
|
+
|
|
227
|
+
/// The current playback state of the animation that is displayed in this layer
|
|
228
|
+
private var currentPlaybackState: PlaybackState? {
|
|
229
|
+
didSet {
|
|
230
|
+
guard playbackState != oldValue else { return }
|
|
231
|
+
|
|
232
|
+
switch playbackState {
|
|
233
|
+
case .playing, nil:
|
|
234
|
+
timeOffset = 0
|
|
235
|
+
case .paused(let frame):
|
|
236
|
+
timeOffset = animation.time(forFrame: frame)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/// The current or pending playback state of the animation displayed in this layer
|
|
242
|
+
private var playbackState: PlaybackState? {
|
|
243
|
+
pendingAnimationConfiguration?.playbackState ?? currentPlaybackState
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/// Context used when setting up and configuring sublayers
|
|
247
|
+
private var layerContext: LayerContext {
|
|
248
|
+
LayerContext(
|
|
249
|
+
animation: animation,
|
|
250
|
+
imageProvider: imageProvider,
|
|
251
|
+
textProvider: textProvider,
|
|
252
|
+
fontProvider: fontProvider,
|
|
253
|
+
compatibilityTracker: compatibilityTracker,
|
|
254
|
+
layerName: "root layer"
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private func setup() {
|
|
259
|
+
bounds = animation.bounds
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private func setupChildLayers() throws {
|
|
263
|
+
try setupLayerHierarchy(
|
|
264
|
+
for: animation.layers,
|
|
265
|
+
context: layerContext
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
try validateReasonableNumberOfTimeRemappingLayers()
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/// Immediately builds and begins playing `CAAnimation`s for each sublayer
|
|
272
|
+
private func setupAnimation(for configuration: AnimationConfiguration) throws {
|
|
273
|
+
// Remove any existing animations from the layer hierarchy
|
|
274
|
+
removeAnimations()
|
|
275
|
+
|
|
276
|
+
currentAnimationConfiguration = configuration
|
|
277
|
+
|
|
278
|
+
let layerContext = LayerAnimationContext(
|
|
279
|
+
animation: animation,
|
|
280
|
+
timingConfiguration: configuration.timingConfiguration,
|
|
281
|
+
startFrame: configuration.animationContext.playFrom,
|
|
282
|
+
endFrame: configuration.animationContext.playTo,
|
|
283
|
+
valueProviderStore: valueProviderStore,
|
|
284
|
+
compatibilityTracker: compatibilityTracker,
|
|
285
|
+
logger: logger,
|
|
286
|
+
loggingState: loggingState,
|
|
287
|
+
currentKeypath: AnimationKeypath(keys: []),
|
|
288
|
+
textProvider: textProvider,
|
|
289
|
+
recordHierarchyKeypath: configuration.recordHierarchyKeypath
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
// Perform a layout pass if necessary so all of the sublayers
|
|
293
|
+
// have the most up-to-date sizing information
|
|
294
|
+
layoutIfNeeded()
|
|
295
|
+
|
|
296
|
+
// Set the speed of this layer, which will be inherited
|
|
297
|
+
// by all sublayers and their animations.
|
|
298
|
+
// - This is required to support scrubbing with a speed of 0
|
|
299
|
+
speed = configuration.timingConfiguration.speed
|
|
300
|
+
|
|
301
|
+
// Setup a placeholder animation to let us track the realtime animation progress
|
|
302
|
+
setupPlaceholderAnimation(context: layerContext)
|
|
303
|
+
animationStartedAt = Date()
|
|
304
|
+
|
|
305
|
+
// Set up the new animations with the current `TimingConfiguration`
|
|
306
|
+
for animationLayer in sublayers ?? [] {
|
|
307
|
+
try (animationLayer as? AnimationLayer)?.setupAnimations(context: layerContext)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/// Sets up a placeholder `CABasicAnimation` that tracks the current
|
|
312
|
+
/// progress of this animation (between 0 and 1). This lets us provide
|
|
313
|
+
/// realtime animation progress via `self.currentFrame`.
|
|
314
|
+
private func setupPlaceholderAnimation(context: LayerAnimationContext) {
|
|
315
|
+
let animationProgressTracker = CABasicAnimation(keyPath: #keyPath(animationProgress))
|
|
316
|
+
animationProgressTracker.fromValue = 0
|
|
317
|
+
animationProgressTracker.toValue = 1
|
|
318
|
+
|
|
319
|
+
let timedProgressAnimation = animationProgressTracker.timed(with: context, for: self)
|
|
320
|
+
timedProgressAnimation.delegate = currentAnimationConfiguration?.animationContext.closure
|
|
321
|
+
|
|
322
|
+
// Remove the progress animation once complete so we know when the animation
|
|
323
|
+
// has finished playing (if it doesn't loop infinitely)
|
|
324
|
+
timedProgressAnimation.isRemovedOnCompletion = true
|
|
325
|
+
|
|
326
|
+
add(timedProgressAnimation, forKey: #keyPath(animationProgress))
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/// Removes the current `CAAnimation`s, and rebuilds new animations
|
|
330
|
+
/// using the same configuration as the previous animations.
|
|
331
|
+
private func rebuildCurrentAnimation() {
|
|
332
|
+
guard
|
|
333
|
+
// Don't replace any pending animations that are queued to begin
|
|
334
|
+
// on the next run loop cycle, since an existing pending animation
|
|
335
|
+
// will cause the animation to be rebuilt anyway.
|
|
336
|
+
pendingAnimationConfiguration == nil
|
|
337
|
+
else { return }
|
|
338
|
+
|
|
339
|
+
if isAnimationPlaying == true {
|
|
340
|
+
lottieAnimationLayer?.updateInFlightAnimation()
|
|
341
|
+
} else {
|
|
342
|
+
let currentFrame = currentFrame
|
|
343
|
+
removeAnimations()
|
|
344
|
+
self.currentFrame = currentFrame
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// MARK: RootAnimationLayer
|
|
351
|
+
|
|
352
|
+
extension CoreAnimationLayer: RootAnimationLayer {
|
|
353
|
+
|
|
354
|
+
var primaryAnimationKey: AnimationKey {
|
|
355
|
+
.specific(#keyPath(animationProgress))
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/// Whether or not the animation is currently playing.
|
|
359
|
+
/// - Handles case where CAAnimations with a finite duration animation (e.g. `playOnce`)
|
|
360
|
+
/// have finished playing but still present on this layer.
|
|
361
|
+
var isAnimationPlaying: Bool? {
|
|
362
|
+
switch pendingAnimationConfiguration?.playbackState {
|
|
363
|
+
case .playing:
|
|
364
|
+
return true
|
|
365
|
+
|
|
366
|
+
case .paused:
|
|
367
|
+
return false
|
|
368
|
+
|
|
369
|
+
case nil:
|
|
370
|
+
switch playbackState {
|
|
371
|
+
case .playing:
|
|
372
|
+
if animation(forKey: #keyPath(animationProgress)) != nil {
|
|
373
|
+
return true
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
guard let animationStartedAt, let currentAnimationConfiguration else { return false }
|
|
377
|
+
if currentAnimationConfiguration.timingConfiguration.repeatCount == .greatestFiniteMagnitude {
|
|
378
|
+
return true
|
|
379
|
+
} else {
|
|
380
|
+
return animationStartedAt.distance(to: Date()) < currentAnimationConfiguration.expectedAnimationDuration
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
case nil, .paused:
|
|
384
|
+
return false
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/// The current frame of the animation being displayed,
|
|
390
|
+
/// accounting for the realtime progress of any active CAAnimations.
|
|
391
|
+
var currentFrame: AnimationFrameTime {
|
|
392
|
+
get {
|
|
393
|
+
switch playbackState {
|
|
394
|
+
case .paused(let frame):
|
|
395
|
+
return frame
|
|
396
|
+
|
|
397
|
+
case .playing, nil:
|
|
398
|
+
// When in the `playing` state, the animation is either actively playing
|
|
399
|
+
// or is completed on the final frame of a non-repeating animation.
|
|
400
|
+
// When a non-repeating animation is complete, `animation(forKey: #keyPath(animationProgress))`
|
|
401
|
+
// is no longer present and the Core-Animation-managed `animationProgress` value is just 0.
|
|
402
|
+
// In that case, since the animation is complete, we just return the final frame that was played to.
|
|
403
|
+
let animationCurrentlyPlaying = animation(forKey: #keyPath(animationProgress)) != nil
|
|
404
|
+
|
|
405
|
+
if !animationCurrentlyPlaying, let configuration = currentAnimationConfiguration {
|
|
406
|
+
return configuration.animationContext.playTo
|
|
407
|
+
} else {
|
|
408
|
+
return animation.frameTime(forProgress: (presentation() ?? self).animationProgress)
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
set {
|
|
413
|
+
// We can display a specific frame of the animation by setting
|
|
414
|
+
// `timeOffset` of this layer. This requires setting up the layer hierarchy
|
|
415
|
+
// with a specific configuration (speed=0, etc) at least once. But if
|
|
416
|
+
// the layer hierarchy is already set up correctly, we can update the
|
|
417
|
+
// `timeOffset` very cheaply.
|
|
418
|
+
let requiredAnimationConfiguration = AnimationConfiguration(
|
|
419
|
+
animationContext: AnimationContext(
|
|
420
|
+
playFrom: animation.startFrame,
|
|
421
|
+
// Normal animation playback (like when looping) skips the last frame.
|
|
422
|
+
// However when the animation is paused, we need to be able to render the final frame.
|
|
423
|
+
// To allow this we have to extend the length of the animation by one frame.
|
|
424
|
+
playTo: animation.endFrame + 1,
|
|
425
|
+
framerate: animation.framerate,
|
|
426
|
+
closure: nil
|
|
427
|
+
),
|
|
428
|
+
timingConfiguration: CAMediaTimingConfiguration(speed: 0)
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
if
|
|
432
|
+
pendingAnimationConfiguration == nil,
|
|
433
|
+
currentAnimationConfiguration == requiredAnimationConfiguration
|
|
434
|
+
{
|
|
435
|
+
currentPlaybackState = .paused(frame: newValue)
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
else {
|
|
439
|
+
playAnimation(
|
|
440
|
+
configuration: requiredAnimationConfiguration,
|
|
441
|
+
playbackState: .paused(frame: newValue)
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
var renderScale: CGFloat {
|
|
448
|
+
get { contentsScale }
|
|
449
|
+
set {
|
|
450
|
+
contentsScale = newValue
|
|
451
|
+
|
|
452
|
+
for sublayer in allSublayers {
|
|
453
|
+
sublayer.contentsScale = newValue
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
var respectAnimationFrameRate: Bool {
|
|
459
|
+
get { false }
|
|
460
|
+
set {
|
|
461
|
+
if newValue {
|
|
462
|
+
logger.assertionFailure("""
|
|
463
|
+
The Core Animation rendering engine currently doesn't support `respectAnimationFrameRate`)
|
|
464
|
+
""")
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
var _animationLayers: [CALayer] {
|
|
470
|
+
(sublayers ?? []).filter { $0 is AnimationLayer }
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
func reloadImages() {
|
|
474
|
+
// When the image provider changes, we have to update all `ImageLayer`s
|
|
475
|
+
// so they can query the most up-to-date image from the new image provider.
|
|
476
|
+
for sublayer in allSublayers {
|
|
477
|
+
if let imageLayer = sublayer as? ImageLayer {
|
|
478
|
+
imageLayer.setupImage(context: layerContext)
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
func reloadFonts() {
|
|
484
|
+
// When the text provider changes, we have to update all `TextLayer`s
|
|
485
|
+
// so they can query the most up-to-date font from the new font provider.
|
|
486
|
+
for sublayer in allSublayers {
|
|
487
|
+
if let textLayer = sublayer as? TextLayer {
|
|
488
|
+
try? textLayer.configureRenderLayer(with: layerContext)
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
func forceDisplayUpdate() {
|
|
494
|
+
// Unimplemented
|
|
495
|
+
// - We can't call `display()` here, because it would cause unexpected frame animations:
|
|
496
|
+
// https://github.com/airbnb/lottie-ios/issues/2193
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
func logHierarchyKeypaths() {
|
|
500
|
+
for keypath in allHierarchyKeypaths() {
|
|
501
|
+
logger.info(keypath)
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
func allHierarchyKeypaths() -> [String] {
|
|
506
|
+
guard pendingAnimationConfiguration?.animationConfiguration ?? currentAnimationConfiguration != nil else {
|
|
507
|
+
logger.info("Cannot log hierarchy keypaths until animation has been set up at least once")
|
|
508
|
+
return []
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
logger.info("Lottie: Rebuilding animation with hierarchy keypath logging enabled")
|
|
512
|
+
|
|
513
|
+
var allAnimationKeypaths = [String]()
|
|
514
|
+
pendingAnimationConfigurationModification = { configuration in
|
|
515
|
+
configuration.recordHierarchyKeypath = { keypath in
|
|
516
|
+
allAnimationKeypaths.append(keypath)
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
rebuildCurrentAnimation()
|
|
521
|
+
displayIfNeeded()
|
|
522
|
+
|
|
523
|
+
return allAnimationKeypaths
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
func setValueProvider(_ valueProvider: AnyValueProvider, keypath: AnimationKeypath) {
|
|
527
|
+
valueProviderStore.setValueProvider(valueProvider, keypath: keypath)
|
|
528
|
+
|
|
529
|
+
// We need to rebuild the current animation after registering a value provider,
|
|
530
|
+
// since any existing `CAAnimation`s could now be out of date.
|
|
531
|
+
rebuildCurrentAnimation()
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
func removeValueProvider(for keypath: AnimationKeypath) {
|
|
535
|
+
valueProviderStore.removeValueProvider(for: keypath)
|
|
536
|
+
|
|
537
|
+
// We need to rebuild the current animation after removing a value provider,
|
|
538
|
+
// since any existing `CAAnimation`s could now be out of date.
|
|
539
|
+
rebuildCurrentAnimation()
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
func getValue(for _: AnimationKeypath, atFrame _: AnimationFrameTime?) -> Any? {
|
|
543
|
+
logger.assertionFailure("""
|
|
544
|
+
The Core Animation rendering engine doesn't support querying values for individual frames
|
|
545
|
+
""")
|
|
546
|
+
return nil
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
func getOriginalValue(for _: AnimationKeypath, atFrame _: AnimationFrameTime?) -> Any? {
|
|
550
|
+
logger.assertionFailure("""
|
|
551
|
+
The Core Animation rendering engine doesn't support querying values for individual frames
|
|
552
|
+
""")
|
|
553
|
+
return nil
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
func layer(for _: AnimationKeypath) -> CALayer? {
|
|
557
|
+
logger.assertionFailure("""
|
|
558
|
+
The Core Animation rendering engine doesn't support retrieving `CALayer`s by keypath
|
|
559
|
+
""")
|
|
560
|
+
return nil
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
func animatorNodes(for _: AnimationKeypath) -> [AnimatorNode]? {
|
|
564
|
+
logger.assertionFailure("""
|
|
565
|
+
The Core Animation rendering engine does not use `AnimatorNode`s
|
|
566
|
+
""")
|
|
567
|
+
return nil
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
func removeAnimations() {
|
|
571
|
+
currentAnimationConfiguration = nil
|
|
572
|
+
currentPlaybackState = nil
|
|
573
|
+
animationStartedAt = nil
|
|
574
|
+
removeAllAnimations()
|
|
575
|
+
|
|
576
|
+
for sublayer in allSublayers {
|
|
577
|
+
sublayer.removeAllAnimations()
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/// Time remapping in the Core Animation rendering engine requires manually interpolating
|
|
582
|
+
/// every frame of every animation. For very large animations with a huge number of layers,
|
|
583
|
+
/// this can be prohibitively expensive.
|
|
584
|
+
func validateReasonableNumberOfTimeRemappingLayers() throws {
|
|
585
|
+
let numberOfLayersWithTimeRemapping = numberOfLayersWithTimeRemapping
|
|
586
|
+
let numberOfFrames = Int(animation.framerate * animation.duration)
|
|
587
|
+
let totalCost = numberOfLayersWithTimeRemapping * numberOfFrames
|
|
588
|
+
|
|
589
|
+
/// Cap the cost / complexity of animations that use Core Animation time remapping.
|
|
590
|
+
/// - Short, simple animations perform well, but long and complex animations perform poorly.
|
|
591
|
+
/// - We count the total number of frames that will need to be manually interpolated, which is
|
|
592
|
+
/// the number of layers with time remapping enabled times the total number of frames.
|
|
593
|
+
/// - The cap is arbitrary, and is currently:
|
|
594
|
+
/// - 1000 layers for a one second animation at 60fp
|
|
595
|
+
/// - 500 layers for a two second animation at 60fps, etc
|
|
596
|
+
/// - All of the sample animations in the lottie-ios repo below this cap perform well.
|
|
597
|
+
/// If users report animations below this cap that perform poorly, we can lower the cap.
|
|
598
|
+
let maximumAllowedCost = 1000 * 60
|
|
599
|
+
|
|
600
|
+
try layerContext.compatibilityAssert(
|
|
601
|
+
totalCost < maximumAllowedCost,
|
|
602
|
+
"""
|
|
603
|
+
This animation has a very large number of layers with time remapping (\(numberOfLayersWithTimeRemapping) \
|
|
604
|
+
layers over \(numberOfFrames) frames) so will perform poorly with the Core Animation rendering engine.
|
|
605
|
+
"""
|
|
606
|
+
)
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// MARK: - CALayer + allSublayers
|
|
612
|
+
|
|
613
|
+
extension CALayer {
|
|
614
|
+
/// All of the layers in the layer tree that are descendants from this later
|
|
615
|
+
@nonobjc
|
|
616
|
+
var allSublayers: [CALayer] {
|
|
617
|
+
var allSublayers = [CALayer]()
|
|
618
|
+
|
|
619
|
+
for sublayer in sublayers ?? [] {
|
|
620
|
+
allSublayers.append(sublayer)
|
|
621
|
+
allSublayers.append(contentsOf: sublayer.allSublayers)
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return allSublayers
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/// The number of layers in this layer hierarchy that have a time remapping applied
|
|
628
|
+
@nonobjc
|
|
629
|
+
var numberOfLayersWithTimeRemapping: Int {
|
|
630
|
+
var numberOfSublayersWithTimeRemapping = 0
|
|
631
|
+
|
|
632
|
+
for sublayer in sublayers ?? [] {
|
|
633
|
+
if
|
|
634
|
+
let preCompLayer = sublayer as? PreCompLayer,
|
|
635
|
+
preCompLayer.preCompLayer.timeRemapping != nil
|
|
636
|
+
{
|
|
637
|
+
numberOfSublayersWithTimeRemapping += preCompLayer.allSublayers.count
|
|
638
|
+
} else {
|
|
639
|
+
numberOfSublayersWithTimeRemapping += sublayer.numberOfLayersWithTimeRemapping
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
return numberOfSublayersWithTimeRemapping
|
|
644
|
+
}
|
|
645
|
+
}
|
package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Created by Cal Stephens on 12/15/21.
|
|
2
|
+
// Copyright © 2021 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
import QuartzCore
|
|
5
|
+
|
|
6
|
+
// MARK: - CALayer + fillBoundsOfSuperlayer
|
|
7
|
+
|
|
8
|
+
extension CALayer {
|
|
9
|
+
/// Updates the `bounds` of this layer to fill the bounds of its `superlayer`
|
|
10
|
+
/// without setting `frame` (which is not permitted if the layer can rotate)
|
|
11
|
+
@nonobjc
|
|
12
|
+
func fillBoundsOfSuperlayer() {
|
|
13
|
+
guard let superlayer else { return }
|
|
14
|
+
|
|
15
|
+
if let customLayerLayer = self as? CustomLayoutLayer {
|
|
16
|
+
customLayerLayer.layout(superlayerBounds: superlayer.bounds)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
else {
|
|
20
|
+
// By default the `anchorPoint` of a layer is `CGPoint(x: 0.5, y: 0.5)`.
|
|
21
|
+
// Setting it to `.zero` makes the layer have the same coordinate space
|
|
22
|
+
// as its superlayer, which lets use use `superlayer.bounds` directly.
|
|
23
|
+
anchorPoint = .zero
|
|
24
|
+
|
|
25
|
+
bounds = superlayer.bounds
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// MARK: - CustomLayoutLayer
|
|
31
|
+
|
|
32
|
+
/// A `CALayer` that sets a custom `bounds` and `anchorPoint` relative to its superlayer
|
|
33
|
+
protocol CustomLayoutLayer: CALayer {
|
|
34
|
+
func layout(superlayerBounds: CGRect)
|
|
35
|
+
}
|