@octane-xplat/lottie 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -16
- package/dist/native/index.js +10 -9
- package/dist/native/octane-client-build.json +1 -1
- package/dist/web/index.js +39 -25
- package/dist/web/octane-client-build.json +1 -1
- package/package.json +25 -3
- 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 +3 -2
- package/src/Lottie.web.tsrx +28 -11
- package/src/index.macos.ts +2 -0
- package/src/props.ts +6 -1
- package/types/generated/props.d.ts +5 -1
package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Created by Cal Stephens on 1/6/22.
|
|
2
|
+
// Copyright © 2022 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
import QuartzCore
|
|
5
|
+
|
|
6
|
+
// MARK: - MaskCompositionLayer
|
|
7
|
+
|
|
8
|
+
/// The CALayer type responsible for rendering the `Mask` of a `BaseCompositionLayer`
|
|
9
|
+
final class MaskCompositionLayer: CALayer {
|
|
10
|
+
|
|
11
|
+
// MARK: Lifecycle
|
|
12
|
+
|
|
13
|
+
init(masks: [Mask]) {
|
|
14
|
+
maskLayers = masks.map(MaskLayer.init(mask:))
|
|
15
|
+
super.init()
|
|
16
|
+
|
|
17
|
+
var containerLayer = BaseAnimationLayer()
|
|
18
|
+
var firstObject = true
|
|
19
|
+
for maskLayer in maskLayers {
|
|
20
|
+
if maskLayer.maskModel.mode.usableMode == .none {
|
|
21
|
+
continue
|
|
22
|
+
} else if maskLayer.maskModel.mode.usableMode == .add || firstObject {
|
|
23
|
+
firstObject = false
|
|
24
|
+
containerLayer.addSublayer(maskLayer)
|
|
25
|
+
} else {
|
|
26
|
+
containerLayer.mask = maskLayer
|
|
27
|
+
let newContainer = BaseAnimationLayer()
|
|
28
|
+
newContainer.addSublayer(containerLayer)
|
|
29
|
+
containerLayer = newContainer
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addSublayer(containerLayer)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
required init?(coder _: NSCoder) {
|
|
37
|
+
fatalError("init(coder:) has not been implemented")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// Called by CoreAnimation to create a shadow copy of this layer
|
|
41
|
+
/// More details: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
|
|
42
|
+
override init(layer: Any) {
|
|
43
|
+
guard let typedLayer = layer as? Self else {
|
|
44
|
+
fatalError("\(Self.self).init(layer:) incorrectly called with \(type(of: layer))")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
maskLayers = typedLayer.maskLayers
|
|
48
|
+
super.init(layer: typedLayer)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// MARK: Internal
|
|
52
|
+
|
|
53
|
+
override func layoutSublayers() {
|
|
54
|
+
super.layoutSublayers()
|
|
55
|
+
|
|
56
|
+
for sublayer in sublayers ?? [] {
|
|
57
|
+
sublayer.fillBoundsOfSuperlayer()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// MARK: Private
|
|
62
|
+
|
|
63
|
+
private let maskLayers: [MaskLayer]
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// MARK: AnimationLayer
|
|
68
|
+
|
|
69
|
+
extension MaskCompositionLayer: AnimationLayer {
|
|
70
|
+
func setupAnimations(context: LayerAnimationContext) throws {
|
|
71
|
+
for maskLayer in maskLayers {
|
|
72
|
+
try maskLayer.setupAnimations(context: context)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// MARK: MaskCompositionLayer.MaskLayer
|
|
78
|
+
|
|
79
|
+
extension MaskCompositionLayer {
|
|
80
|
+
final class MaskLayer: CAShapeLayer {
|
|
81
|
+
|
|
82
|
+
// MARK: Lifecycle
|
|
83
|
+
|
|
84
|
+
init(mask: Mask) {
|
|
85
|
+
maskModel = mask
|
|
86
|
+
super.init()
|
|
87
|
+
|
|
88
|
+
fillRule = .evenOdd
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
required init?(coder _: NSCoder) {
|
|
92
|
+
fatalError("init(coder:) has not been implemented")
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// Called by CoreAnimation to create a shadow copy of this layer
|
|
96
|
+
/// More details: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
|
|
97
|
+
override init(layer: Any) {
|
|
98
|
+
guard let typedLayer = layer as? Self else {
|
|
99
|
+
fatalError("\(Self.self).init(layer:) incorrectly called with \(type(of: layer))")
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
maskModel = typedLayer.maskModel
|
|
103
|
+
super.init(layer: typedLayer)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// MARK: Internal
|
|
107
|
+
|
|
108
|
+
let maskModel: Mask
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// MARK: - MaskCompositionLayer.MaskLayer + AnimationLayer
|
|
114
|
+
|
|
115
|
+
extension MaskCompositionLayer.MaskLayer: AnimationLayer {
|
|
116
|
+
func setupAnimations(context: LayerAnimationContext) throws {
|
|
117
|
+
let shouldInvertMask = (maskModel.mode.usableMode == .subtract && !maskModel.inverted)
|
|
118
|
+
|| (maskModel.mode.usableMode == .add && maskModel.inverted)
|
|
119
|
+
|
|
120
|
+
try addAnimations(
|
|
121
|
+
for: maskModel.shape,
|
|
122
|
+
context: context,
|
|
123
|
+
transformPath: { maskPath in
|
|
124
|
+
// If the mask is using `MaskMode.subtract` or has `inverted: true`,
|
|
125
|
+
// we have to invert the area filled by the path. We can do that by
|
|
126
|
+
// drawing a rectangle, and then adding a path (which is subtracted
|
|
127
|
+
// from the rectangle based on the .evenOdd fill mode).
|
|
128
|
+
if shouldInvertMask {
|
|
129
|
+
let path = CGMutablePath()
|
|
130
|
+
path.addRect(.veryLargeRect)
|
|
131
|
+
path.addPath(maskPath)
|
|
132
|
+
return path
|
|
133
|
+
} else {
|
|
134
|
+
return maskPath
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Created by Cal Stephens on 12/14/21.
|
|
2
|
+
// Copyright © 2021 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
import QuartzCore
|
|
5
|
+
|
|
6
|
+
// MARK: - PreCompLayer
|
|
7
|
+
|
|
8
|
+
/// The `CALayer` type responsible for rendering `PreCompLayerModel`s
|
|
9
|
+
final class PreCompLayer: BaseCompositionLayer {
|
|
10
|
+
|
|
11
|
+
// MARK: Lifecycle
|
|
12
|
+
|
|
13
|
+
init(preCompLayer: PreCompLayerModel) {
|
|
14
|
+
self.preCompLayer = preCompLayer
|
|
15
|
+
super.init(layerModel: preCompLayer)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
required init?(coder _: NSCoder) {
|
|
19
|
+
fatalError("init(coder:) has not been implemented")
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// Called by CoreAnimation to create a shadow copy of this layer
|
|
23
|
+
/// More details: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
|
|
24
|
+
override init(layer: Any) {
|
|
25
|
+
guard let typedLayer = layer as? Self else {
|
|
26
|
+
fatalError("\(Self.self).init(layer:) incorrectly called with \(type(of: layer))")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
preCompLayer = typedLayer.preCompLayer
|
|
30
|
+
super.init(layer: typedLayer)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// MARK: Internal
|
|
34
|
+
|
|
35
|
+
let preCompLayer: PreCompLayerModel
|
|
36
|
+
|
|
37
|
+
/// Post-init setup for `PreCompLayer`s.
|
|
38
|
+
/// Should always be called after `PreCompLayer.init(preCompLayer:)`.
|
|
39
|
+
///
|
|
40
|
+
/// This is a workaround for a hard-to-reproduce crash that was
|
|
41
|
+
/// triggered when `PreCompLayer.init` was called reentantly. We didn't
|
|
42
|
+
/// have any consistent repro steps for this crash (it happened 100% of
|
|
43
|
+
/// the time for some testers, and 0% of the time for other testers),
|
|
44
|
+
/// but moving this code out of `PreCompLayer.init` does seem to fix it.
|
|
45
|
+
///
|
|
46
|
+
/// The stack trace looked like:
|
|
47
|
+
/// - `_os_unfair_lock_recursive_abort`
|
|
48
|
+
/// - `-[CALayerAccessibility__UIKit__QuartzCore dealloc]`
|
|
49
|
+
/// - `PreCompLayer.__allocating_init(preCompLayer:context:)` <- reentrant init call
|
|
50
|
+
/// - ...
|
|
51
|
+
/// - `CALayer.setupLayerHierarchy(for:context:)`
|
|
52
|
+
/// - `PreCompLayer.init(preCompLayer:context:)`
|
|
53
|
+
///
|
|
54
|
+
func setup(context: LayerContext) throws {
|
|
55
|
+
try setupLayerHierarchy(
|
|
56
|
+
for: context.animation.assetLibrary?.precompAssets[preCompLayer.referenceID]?.layers ?? [],
|
|
57
|
+
context: context
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override func setupAnimations(context: LayerAnimationContext) throws {
|
|
62
|
+
var context = context
|
|
63
|
+
context = context.addingKeypathComponent(preCompLayer.name)
|
|
64
|
+
try setupLayerAnimations(context: context)
|
|
65
|
+
|
|
66
|
+
let timeRemappingInterpolator = preCompLayer.timeRemapping.flatMap { KeyframeInterpolator(keyframes: $0.keyframes) }
|
|
67
|
+
|
|
68
|
+
let contextForChildren = context
|
|
69
|
+
// `timeStretch` and `startTime` are a simple linear function so can be inverted from a
|
|
70
|
+
// "global time to local time" function into the simpler "local time to global time".
|
|
71
|
+
.withSimpleTimeRemapping { [preCompLayer] layerLocalFrame in
|
|
72
|
+
(layerLocalFrame * AnimationFrameTime(preCompLayer.timeStretch)) + AnimationFrameTime(preCompLayer.startTime)
|
|
73
|
+
}
|
|
74
|
+
// `timeRemappingInterpolator` is arbitrarily complex and cannot be inverted,
|
|
75
|
+
// so can only be applied via `complexTimeRemapping` from global time to local time.
|
|
76
|
+
.withComplexTimeRemapping(required: preCompLayer.timeRemapping != nil) { [preCompLayer] globalTime in
|
|
77
|
+
if let timeRemappingInterpolator {
|
|
78
|
+
let remappedLocalTime = timeRemappingInterpolator.value(frame: globalTime) as! LottieVector1D
|
|
79
|
+
return remappedLocalTime.cgFloatValue * context.animation.framerate
|
|
80
|
+
} else {
|
|
81
|
+
return (globalTime - preCompLayer.startTime) / preCompLayer.timeStretch
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
try setupChildAnimations(context: contextForChildren)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// MARK: CustomLayoutLayer
|
|
91
|
+
|
|
92
|
+
extension PreCompLayer: CustomLayoutLayer {
|
|
93
|
+
func layout(superlayerBounds: CGRect) {
|
|
94
|
+
anchorPoint = .zero
|
|
95
|
+
|
|
96
|
+
// Pre-comp layers use a size specified in the layer model,
|
|
97
|
+
// and clip the composition to that bounds
|
|
98
|
+
bounds = CGRect(
|
|
99
|
+
x: superlayerBounds.origin.x,
|
|
100
|
+
y: superlayerBounds.origin.y,
|
|
101
|
+
width: CGFloat(preCompLayer.width),
|
|
102
|
+
height: CGFloat(preCompLayer.height)
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
contentsLayer.masksToBounds = true
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Created by Cal Stephens on 8/1/22.
|
|
2
|
+
// Copyright © 2022 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
import QuartzCore
|
|
5
|
+
|
|
6
|
+
// MARK: - RepeaterLayer
|
|
7
|
+
|
|
8
|
+
/// A layer that renders a child layer at some offset using a `Repeater`
|
|
9
|
+
final class RepeaterLayer: BaseAnimationLayer {
|
|
10
|
+
|
|
11
|
+
// MARK: Lifecycle
|
|
12
|
+
|
|
13
|
+
init(repeater: Repeater, childLayer: CALayer, index: Int) {
|
|
14
|
+
repeaterTransform = RepeaterTransform(repeater: repeater, index: index)
|
|
15
|
+
super.init()
|
|
16
|
+
addSublayer(childLayer)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
required init?(coder _: NSCoder) {
|
|
20
|
+
fatalError("init(coder:) has not been implemented")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// Called by CoreAnimation to create a shadow copy of this layer
|
|
24
|
+
/// More details: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
|
|
25
|
+
override init(layer: Any) {
|
|
26
|
+
guard let typedLayer = layer as? Self else {
|
|
27
|
+
fatalError("\(Self.self).init(layer:) incorrectly called with \(type(of: layer))")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
repeaterTransform = typedLayer.repeaterTransform
|
|
31
|
+
super.init(layer: typedLayer)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// MARK: Internal
|
|
35
|
+
|
|
36
|
+
override func setupAnimations(context: LayerAnimationContext) throws {
|
|
37
|
+
try super.setupAnimations(context: context)
|
|
38
|
+
try addTransformAnimations(for: repeaterTransform, context: context)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// MARK: Private
|
|
42
|
+
|
|
43
|
+
private let repeaterTransform: RepeaterTransform
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// MARK: - RepeaterTransform
|
|
48
|
+
|
|
49
|
+
/// A transform model created from a `Repeater`
|
|
50
|
+
private struct RepeaterTransform {
|
|
51
|
+
|
|
52
|
+
// MARK: Lifecycle
|
|
53
|
+
|
|
54
|
+
init(repeater: Repeater, index: Int) {
|
|
55
|
+
anchorPoint = repeater.anchorPoint
|
|
56
|
+
scale = repeater.scale
|
|
57
|
+
|
|
58
|
+
rotationX = repeater.rotationX.map { rotation in
|
|
59
|
+
LottieVector1D(rotation.value * Double(index))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
rotationY = repeater.rotationY.map { rotation in
|
|
63
|
+
LottieVector1D(rotation.value * Double(index))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
rotationZ = repeater.rotationZ.map { rotation in
|
|
67
|
+
LottieVector1D(rotation.value * Double(index))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
position = repeater.position.map { position in
|
|
71
|
+
LottieVector3D(
|
|
72
|
+
x: position.x * Double(index),
|
|
73
|
+
y: position.y * Double(index),
|
|
74
|
+
z: position.z * Double(index)
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// MARK: Internal
|
|
80
|
+
|
|
81
|
+
let anchorPoint: KeyframeGroup<LottieVector3D>
|
|
82
|
+
let position: KeyframeGroup<LottieVector3D>
|
|
83
|
+
let rotationX: KeyframeGroup<LottieVector1D>
|
|
84
|
+
let rotationY: KeyframeGroup<LottieVector1D>
|
|
85
|
+
let rotationZ: KeyframeGroup<LottieVector1D>
|
|
86
|
+
|
|
87
|
+
let scale: KeyframeGroup<LottieVector3D>
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// MARK: TransformModel
|
|
92
|
+
|
|
93
|
+
extension RepeaterTransform: TransformModel {
|
|
94
|
+
var _position: KeyframeGroup<LottieVector3D>? {
|
|
95
|
+
position
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var _positionX: KeyframeGroup<LottieVector1D>? {
|
|
99
|
+
nil
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var _positionY: KeyframeGroup<LottieVector1D>? {
|
|
103
|
+
nil
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var _skew: KeyframeGroup<LottieVector1D>? {
|
|
107
|
+
nil
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
var _skewAxis: KeyframeGroup<LottieVector1D>? {
|
|
111
|
+
nil
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
// Created by Cal Stephens on 12/13/21.
|
|
2
|
+
// Copyright © 2021 Airbnb Inc. All rights reserved.
|
|
3
|
+
|
|
4
|
+
import QuartzCore
|
|
5
|
+
|
|
6
|
+
// MARK: - ShapeItemLayer
|
|
7
|
+
|
|
8
|
+
/// A CALayer type that renders an array of `[ShapeItem]`s,
|
|
9
|
+
/// from a `Group` in a `ShapeLayerModel`.
|
|
10
|
+
final class ShapeItemLayer: BaseAnimationLayer {
|
|
11
|
+
|
|
12
|
+
// MARK: Lifecycle
|
|
13
|
+
|
|
14
|
+
/// Initializes a `ShapeItemLayer` that renders a `Group` from a `ShapeLayerModel`
|
|
15
|
+
/// - Parameters:
|
|
16
|
+
/// - shape: The `ShapeItem` in this group that renders a `GGPath`
|
|
17
|
+
/// - otherItems: Other items in this group that affect the appearance of the shape
|
|
18
|
+
init(shape: Item, otherItems: [Item], context: LayerContext) throws {
|
|
19
|
+
self.shape = shape
|
|
20
|
+
self.otherItems = otherItems
|
|
21
|
+
|
|
22
|
+
try context.compatibilityAssert(
|
|
23
|
+
shape.item.drawsCGPath,
|
|
24
|
+
"`ShapeItemLayer` must contain exactly one `ShapeItem` that draws a `GPPath`"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
try context.compatibilityAssert(
|
|
28
|
+
!otherItems.contains(where: { $0.item.drawsCGPath }),
|
|
29
|
+
"`ShapeItemLayer` must contain exactly one `ShapeItem` that draws a `GPPath`"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
super.init()
|
|
33
|
+
|
|
34
|
+
setupLayerHierarchy()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
required init?(coder _: NSCoder) {
|
|
38
|
+
fatalError("init(coder:) has not been implemented")
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// Called by CoreAnimation to create a shadow copy of this layer
|
|
42
|
+
/// More details: https://developer.apple.com/documentation/quartzcore/calayer/1410842-init
|
|
43
|
+
override init(layer: Any) {
|
|
44
|
+
guard let typedLayer = layer as? Self else {
|
|
45
|
+
fatalError("\(Self.self).init(layer:) incorrectly called with \(type(of: layer))")
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
shape = typedLayer.shape
|
|
49
|
+
otherItems = typedLayer.otherItems
|
|
50
|
+
super.init(layer: typedLayer)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: Internal
|
|
54
|
+
|
|
55
|
+
/// An item that can be displayed by this layer
|
|
56
|
+
struct Item {
|
|
57
|
+
/// A `ShapeItem` that should be rendered by this layer
|
|
58
|
+
let item: ShapeItem
|
|
59
|
+
|
|
60
|
+
/// The set of groups that this item descends from
|
|
61
|
+
/// - Due to the way `GroupLayer`s are setup, the original `ShapeItem`
|
|
62
|
+
/// hierarchy from the `ShapeLayer` data model may no longer exactly
|
|
63
|
+
/// match the hierarchy of `GroupLayer` / `ShapeItemLayer`s constructed
|
|
64
|
+
/// at runtime. Since animation keypaths need to match the original
|
|
65
|
+
/// structure of the `ShapeLayer` data model, we track that info here.
|
|
66
|
+
let groupPath: [String]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override func setupAnimations(context: LayerAnimationContext) throws {
|
|
70
|
+
try super.setupAnimations(context: context)
|
|
71
|
+
|
|
72
|
+
guard let sublayerConfiguration else { return }
|
|
73
|
+
|
|
74
|
+
switch sublayerConfiguration.fill {
|
|
75
|
+
case .solidFill(let shapeLayer):
|
|
76
|
+
try setupSolidFillAnimations(shapeLayer: shapeLayer, context: context)
|
|
77
|
+
|
|
78
|
+
case .gradientFill(let gradientLayers):
|
|
79
|
+
try setupGradientFillAnimations(layers: gradientLayers, context: context)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if let gradientStrokeConfiguration = sublayerConfiguration.gradientStroke {
|
|
83
|
+
try setupGradientStrokeAnimations(layers: gradientStrokeConfiguration, context: context)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// MARK: Private
|
|
88
|
+
|
|
89
|
+
private struct GradientLayers {
|
|
90
|
+
/// The `CALayer` that renders the RGB components of the gradient
|
|
91
|
+
let gradientColorLayer: GradientRenderLayer
|
|
92
|
+
/// The `CALayer` that renders the alpha components of the gradient,
|
|
93
|
+
/// masking the `gradientColorLayer`
|
|
94
|
+
let gradientAlphaLayer: GradientRenderLayer?
|
|
95
|
+
/// The `CAShapeLayer` that clips the gradient layers to the expected shape
|
|
96
|
+
let shapeMaskLayer: CAShapeLayer
|
|
97
|
+
/// The top-most `CAShapeLayer` used to render `Stroke`s over the gradient if necessary
|
|
98
|
+
let overlayLayer: CAShapeLayer?
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// The configuration of this layer's `fill` sublayers
|
|
102
|
+
private enum FillLayerConfiguration {
|
|
103
|
+
/// This layer displays a single `CAShapeLayer`
|
|
104
|
+
case solidFill(CAShapeLayer)
|
|
105
|
+
|
|
106
|
+
/// This layer displays a `GradientRenderLayer` masked by a `CAShapeLayer`.
|
|
107
|
+
case gradientFill(GradientLayers)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// The `ShapeItem` in this group that renders a `GGPath`
|
|
111
|
+
private let shape: Item
|
|
112
|
+
|
|
113
|
+
/// Other items in this group that affect the appearance of the shape
|
|
114
|
+
private let otherItems: [Item]
|
|
115
|
+
|
|
116
|
+
/// The current configuration of this layer's sublayer(s)
|
|
117
|
+
private var sublayerConfiguration: (fill: FillLayerConfiguration, gradientStroke: GradientLayers?)?
|
|
118
|
+
|
|
119
|
+
private func setupLayerHierarchy() {
|
|
120
|
+
// We have to build a different layer hierarchy depending on if
|
|
121
|
+
// we're rendering a gradient (a `CAGradientLayer` masked by a `CAShapeLayer`)
|
|
122
|
+
// or a solid shape (a simple `CAShapeLayer`).
|
|
123
|
+
let fillLayerConfiguration: FillLayerConfiguration =
|
|
124
|
+
if let gradientFill = otherItems.first(GradientFill.self) {
|
|
125
|
+
setupGradientFillLayerHierarchy(for: gradientFill)
|
|
126
|
+
} else {
|
|
127
|
+
setupSolidFillLayerHierarchy()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let gradientStrokeConfiguration: GradientLayers? =
|
|
131
|
+
if let gradientStroke = otherItems.first(GradientStroke.self) {
|
|
132
|
+
setupGradientStrokeLayerHierarchy(for: gradientStroke)
|
|
133
|
+
} else {
|
|
134
|
+
nil
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
sublayerConfiguration = (fillLayerConfiguration, gradientStrokeConfiguration)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private func setupSolidFillLayerHierarchy() -> FillLayerConfiguration {
|
|
141
|
+
let shapeLayer = CAShapeLayer()
|
|
142
|
+
addSublayer(shapeLayer)
|
|
143
|
+
|
|
144
|
+
// `CAShapeLayer.fillColor` defaults to black, so we have to
|
|
145
|
+
// nil out the background color if there isn't an expected fill color
|
|
146
|
+
if !otherItems.contains(where: { $0.item is Fill }) {
|
|
147
|
+
shapeLayer.fillColor = nil
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return .solidFill(shapeLayer)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private func setupGradientFillLayerHierarchy(
|
|
154
|
+
for gradientFill: GradientFill
|
|
155
|
+
) -> FillLayerConfiguration {
|
|
156
|
+
let container = BaseAnimationLayer()
|
|
157
|
+
let pathContainer = BaseAnimationLayer()
|
|
158
|
+
|
|
159
|
+
let pathMask = CAShapeLayer()
|
|
160
|
+
pathMask.fillColor = .rgb(0, 0, 0)
|
|
161
|
+
pathContainer.mask = pathMask
|
|
162
|
+
|
|
163
|
+
let rgbGradientLayer = GradientRenderLayer()
|
|
164
|
+
pathContainer.addSublayer(rgbGradientLayer)
|
|
165
|
+
container.addSublayer(pathContainer)
|
|
166
|
+
|
|
167
|
+
let overlayLayer = CAShapeLayer()
|
|
168
|
+
overlayLayer.fillColor = nil
|
|
169
|
+
container.addSublayer(overlayLayer)
|
|
170
|
+
|
|
171
|
+
addSublayer(container)
|
|
172
|
+
|
|
173
|
+
let alphaGradientLayer: GradientRenderLayer?
|
|
174
|
+
if gradientFill.hasAlphaComponent {
|
|
175
|
+
alphaGradientLayer = GradientRenderLayer()
|
|
176
|
+
rgbGradientLayer.mask = alphaGradientLayer
|
|
177
|
+
} else {
|
|
178
|
+
alphaGradientLayer = nil
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return .gradientFill(GradientLayers(
|
|
182
|
+
gradientColorLayer: rgbGradientLayer,
|
|
183
|
+
gradientAlphaLayer: alphaGradientLayer,
|
|
184
|
+
shapeMaskLayer: pathMask,
|
|
185
|
+
overlayLayer: overlayLayer
|
|
186
|
+
))
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
private func setupGradientStrokeLayerHierarchy(
|
|
190
|
+
for gradientStroke: GradientStroke
|
|
191
|
+
) -> GradientLayers {
|
|
192
|
+
let container = BaseAnimationLayer()
|
|
193
|
+
|
|
194
|
+
let pathMask = CAShapeLayer()
|
|
195
|
+
pathMask.fillColor = nil
|
|
196
|
+
pathMask.strokeColor = .rgb(0, 0, 0)
|
|
197
|
+
container.mask = pathMask
|
|
198
|
+
|
|
199
|
+
let rgbGradientLayer = GradientRenderLayer()
|
|
200
|
+
container.addSublayer(rgbGradientLayer)
|
|
201
|
+
addSublayer(container)
|
|
202
|
+
|
|
203
|
+
let alphaGradientLayer: GradientRenderLayer?
|
|
204
|
+
if gradientStroke.hasAlphaComponent {
|
|
205
|
+
alphaGradientLayer = GradientRenderLayer()
|
|
206
|
+
rgbGradientLayer.mask = alphaGradientLayer
|
|
207
|
+
} else {
|
|
208
|
+
alphaGradientLayer = nil
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return GradientLayers(
|
|
212
|
+
gradientColorLayer: rgbGradientLayer,
|
|
213
|
+
gradientAlphaLayer: alphaGradientLayer,
|
|
214
|
+
shapeMaskLayer: pathMask,
|
|
215
|
+
overlayLayer: nil
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private func setupSolidFillAnimations(
|
|
220
|
+
shapeLayer: CAShapeLayer,
|
|
221
|
+
context: LayerAnimationContext
|
|
222
|
+
) throws {
|
|
223
|
+
var trimPathMultiplier: PathMultiplier? = nil
|
|
224
|
+
if let (trim, context) = otherItems.first(Trim.self, where: { !$0.isEmpty }, context: context) {
|
|
225
|
+
trimPathMultiplier = try shapeLayer.addAnimations(for: trim, context: context)
|
|
226
|
+
|
|
227
|
+
try context.compatibilityAssert(
|
|
228
|
+
otherItems.first(Fill.self) == nil,
|
|
229
|
+
"""
|
|
230
|
+
The Core Animation rendering engine doesn't currently support applying
|
|
231
|
+
trims to filled shapes (only stroked shapes).
|
|
232
|
+
"""
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
try shapeLayer.addAnimations(
|
|
237
|
+
for: shape.item,
|
|
238
|
+
context: context.for(shape),
|
|
239
|
+
pathMultiplier: trimPathMultiplier ?? 1,
|
|
240
|
+
roundedCorners: otherItems.first(RoundedCorners.self)
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
if let (fill, context) = otherItems.first(Fill.self, context: context) {
|
|
244
|
+
try shapeLayer.addAnimations(for: fill, context: context)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if let (stroke, context) = otherItems.first(Stroke.self, context: context) {
|
|
248
|
+
try shapeLayer.addStrokeAnimations(for: stroke, context: context)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private func setupGradientFillAnimations(
|
|
253
|
+
layers: GradientLayers,
|
|
254
|
+
context: LayerAnimationContext
|
|
255
|
+
) throws {
|
|
256
|
+
let pathLayers = [layers.shapeMaskLayer, layers.overlayLayer]
|
|
257
|
+
for pathLayer in pathLayers {
|
|
258
|
+
try pathLayer?.addAnimations(
|
|
259
|
+
for: shape.item,
|
|
260
|
+
context: context.for(shape),
|
|
261
|
+
pathMultiplier: 1,
|
|
262
|
+
roundedCorners: otherItems.first(RoundedCorners.self)
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if let (gradientFill, context) = otherItems.first(GradientFill.self, context: context) {
|
|
267
|
+
layers.shapeMaskLayer.fillRule = gradientFill.fillRule.caFillRule
|
|
268
|
+
try layers.gradientColorLayer.addGradientAnimations(for: gradientFill, type: .rgb, context: context)
|
|
269
|
+
try layers.gradientAlphaLayer?.addGradientAnimations(for: gradientFill, type: .alpha, context: context)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if let (stroke, context) = otherItems.first(Stroke.self, context: context) {
|
|
273
|
+
try layers.overlayLayer?.addStrokeAnimations(for: stroke, context: context)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private func setupGradientStrokeAnimations(
|
|
278
|
+
layers: GradientLayers,
|
|
279
|
+
context: LayerAnimationContext
|
|
280
|
+
) throws {
|
|
281
|
+
var trimPathMultiplier: PathMultiplier? = nil
|
|
282
|
+
if let (trim, context) = otherItems.first(Trim.self, context: context) {
|
|
283
|
+
trimPathMultiplier = try layers.shapeMaskLayer.addAnimations(for: trim, context: context)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
try layers.shapeMaskLayer.addAnimations(
|
|
287
|
+
for: shape.item,
|
|
288
|
+
context: context.for(shape),
|
|
289
|
+
pathMultiplier: trimPathMultiplier ?? 1,
|
|
290
|
+
roundedCorners: otherItems.first(RoundedCorners.self)
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
if let (gradientStroke, context) = otherItems.first(GradientStroke.self, context: context) {
|
|
294
|
+
try layers.gradientColorLayer.addGradientAnimations(for: gradientStroke, type: .rgb, context: context)
|
|
295
|
+
try layers.gradientAlphaLayer?.addGradientAnimations(for: gradientStroke, type: .alpha, context: context)
|
|
296
|
+
|
|
297
|
+
try layers.shapeMaskLayer.addStrokeAnimations(for: gradientStroke, context: context)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// MARK: - [ShapeItem] helpers
|
|
304
|
+
|
|
305
|
+
extension [ShapeItemLayer.Item] {
|
|
306
|
+
/// The first `ShapeItem` in this array of the given type
|
|
307
|
+
func first<ItemType: ShapeItem>(
|
|
308
|
+
_: ItemType.Type,
|
|
309
|
+
where condition: (ItemType) -> Bool = { _ in true },
|
|
310
|
+
context: LayerAnimationContext
|
|
311
|
+
) -> (item: ItemType, context: LayerAnimationContext)? {
|
|
312
|
+
for item in self {
|
|
313
|
+
if let match = item.item as? ItemType, condition(match) {
|
|
314
|
+
return (match, context.for(item))
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return nil
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/// The first `ShapeItem` in this array of the given type
|
|
322
|
+
func first<ItemType: ShapeItem>(_: ItemType.Type) -> ItemType? {
|
|
323
|
+
for item in self {
|
|
324
|
+
if let match = item.item as? ItemType {
|
|
325
|
+
return match
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return nil
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
extension LayerAnimationContext {
|
|
334
|
+
/// An updated `LayerAnimationContext` with the`AnimationKeypath`
|
|
335
|
+
/// that refers to this specific `ShapeItem`.
|
|
336
|
+
func `for`(_ item: ShapeItemLayer.Item) -> LayerAnimationContext {
|
|
337
|
+
var context = self
|
|
338
|
+
|
|
339
|
+
for parentGroupName in item.groupPath {
|
|
340
|
+
context.currentKeypath.keys.append(parentGroupName)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
context.currentKeypath.keys.append(item.item.name)
|
|
344
|
+
return context
|
|
345
|
+
}
|
|
346
|
+
}
|