@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
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Data+Compression.swift
|
|
3
|
+
// ZIPFoundation
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2017-2025 Thomas Zoechling, https://www.peakstep.com and the ZIP Foundation project authors.
|
|
6
|
+
// Released under the MIT License.
|
|
7
|
+
//
|
|
8
|
+
// See https://github.com/weichsel/ZIPFoundation/blob/master/LICENSE for license information.
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
import Foundation
|
|
12
|
+
|
|
13
|
+
#if canImport(zlib)
|
|
14
|
+
import zlib
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
// MARK: - CompressionMethod
|
|
18
|
+
|
|
19
|
+
/// The compression method of an `Entry` in a ZIP `Archive`.
|
|
20
|
+
enum CompressionMethod: UInt16 {
|
|
21
|
+
/// Indicates that an `Entry` has no compression applied to its contents.
|
|
22
|
+
case none = 0
|
|
23
|
+
/// Indicates that contents of an `Entry` have been compressed with a zlib compatible Deflate algorithm.
|
|
24
|
+
case deflate = 8
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// An unsigned 32-Bit Integer representing a checksum.
|
|
28
|
+
typealias CRC32 = UInt32
|
|
29
|
+
/// A custom handler that consumes a `Data` object containing partial entry data.
|
|
30
|
+
/// - Parameters:
|
|
31
|
+
/// - data: A chunk of `Data` to consume.
|
|
32
|
+
/// - Throws: Can throw to indicate errors during data consumption.
|
|
33
|
+
typealias Consumer = (_ data: Data) throws -> Void
|
|
34
|
+
/// A custom handler that receives a position and a size that can be used to provide data from an arbitrary source.
|
|
35
|
+
/// - Parameters:
|
|
36
|
+
/// - position: The current read position.
|
|
37
|
+
/// - size: The size of the chunk to provide.
|
|
38
|
+
/// - Returns: A chunk of `Data`.
|
|
39
|
+
/// - Throws: Can throw to indicate errors in the data source.
|
|
40
|
+
typealias Provider = (_ position: Int64, _ size: Int) throws -> Data
|
|
41
|
+
|
|
42
|
+
extension Data {
|
|
43
|
+
enum CompressionError: Error {
|
|
44
|
+
case invalidStream
|
|
45
|
+
case corruptedData
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// Compress the output of `provider` and pass it to `consumer`.
|
|
49
|
+
/// - Parameters:
|
|
50
|
+
/// - size: The uncompressed size of the data to be compressed.
|
|
51
|
+
/// - bufferSize: The maximum size of the compression buffer.
|
|
52
|
+
/// - provider: A closure that accepts a position and a chunk size. Returns a `Data` chunk.
|
|
53
|
+
/// - consumer: A closure that processes the result of the compress operation.
|
|
54
|
+
/// - Returns: The checksum of the processed content.
|
|
55
|
+
static func compress(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) throws -> CRC32 {
|
|
56
|
+
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS)
|
|
57
|
+
return try process(
|
|
58
|
+
operation: COMPRESSION_STREAM_ENCODE,
|
|
59
|
+
size: size,
|
|
60
|
+
bufferSize: bufferSize,
|
|
61
|
+
provider: provider,
|
|
62
|
+
consumer: consumer
|
|
63
|
+
)
|
|
64
|
+
#else
|
|
65
|
+
return try encode(size: size, bufferSize: bufferSize, provider: provider, consumer: consumer)
|
|
66
|
+
#endif
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Decompress the output of `provider` and pass it to `consumer`.
|
|
70
|
+
/// - Parameters:
|
|
71
|
+
/// - size: The compressed size of the data to be decompressed.
|
|
72
|
+
/// - bufferSize: The maximum size of the decompression buffer.
|
|
73
|
+
/// - skipCRC32: Optional flag to skip calculation of the CRC32 checksum to improve performance.
|
|
74
|
+
/// - provider: A closure that accepts a position and a chunk size. Returns a `Data` chunk.
|
|
75
|
+
/// - consumer: A closure that processes the result of the decompress operation.
|
|
76
|
+
/// - Returns: The checksum of the processed content.
|
|
77
|
+
static func decompress(
|
|
78
|
+
size: Int64,
|
|
79
|
+
bufferSize: Int,
|
|
80
|
+
skipCRC32: Bool,
|
|
81
|
+
provider: Provider,
|
|
82
|
+
consumer: Consumer
|
|
83
|
+
) throws -> CRC32 {
|
|
84
|
+
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS)
|
|
85
|
+
return try process(
|
|
86
|
+
operation: COMPRESSION_STREAM_DECODE,
|
|
87
|
+
size: size,
|
|
88
|
+
bufferSize: bufferSize,
|
|
89
|
+
skipCRC32: skipCRC32,
|
|
90
|
+
provider: provider,
|
|
91
|
+
consumer: consumer
|
|
92
|
+
)
|
|
93
|
+
#else
|
|
94
|
+
return try decode(bufferSize: bufferSize, skipCRC32: skipCRC32, provider: provider, consumer: consumer)
|
|
95
|
+
#endif
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// Calculate the `CRC32` checksum of the receiver.
|
|
99
|
+
///
|
|
100
|
+
/// - Parameter checksum: The starting seed.
|
|
101
|
+
/// - Returns: The checksum calculated from the bytes of the receiver and the starting seed.
|
|
102
|
+
func crc32(checksum: CRC32) -> CRC32 {
|
|
103
|
+
#if canImport(zlib)
|
|
104
|
+
return withUnsafeBytes { bufferPointer in
|
|
105
|
+
let length = UInt32(count)
|
|
106
|
+
return CRC32(zlib.crc32(UInt(checksum), bufferPointer.bindMemory(to: UInt8.self).baseAddress, length))
|
|
107
|
+
}
|
|
108
|
+
#else
|
|
109
|
+
return builtInCRC32(checksum: checksum)
|
|
110
|
+
#endif
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// MARK: - Apple Platforms
|
|
116
|
+
|
|
117
|
+
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS)
|
|
118
|
+
import Compression
|
|
119
|
+
|
|
120
|
+
extension Data {
|
|
121
|
+
|
|
122
|
+
static func process(
|
|
123
|
+
operation: compression_stream_operation,
|
|
124
|
+
size: Int64,
|
|
125
|
+
bufferSize: Int,
|
|
126
|
+
skipCRC32: Bool = false,
|
|
127
|
+
provider: Provider,
|
|
128
|
+
consumer: Consumer
|
|
129
|
+
) throws -> CRC32 {
|
|
130
|
+
var crc32 = CRC32(0)
|
|
131
|
+
let destPointer = UnsafeMutablePointer<UInt8>.allocate(capacity: bufferSize)
|
|
132
|
+
defer { destPointer.deallocate() }
|
|
133
|
+
let streamPointer = UnsafeMutablePointer<compression_stream>.allocate(capacity: 1)
|
|
134
|
+
defer { streamPointer.deallocate() }
|
|
135
|
+
var stream = streamPointer.pointee
|
|
136
|
+
var status = compression_stream_init(&stream, operation, COMPRESSION_ZLIB)
|
|
137
|
+
guard status != COMPRESSION_STATUS_ERROR else { throw CompressionError.invalidStream }
|
|
138
|
+
defer { compression_stream_destroy(&stream) }
|
|
139
|
+
stream.src_size = 0
|
|
140
|
+
stream.dst_ptr = destPointer
|
|
141
|
+
stream.dst_size = bufferSize
|
|
142
|
+
var position: Int64 = 0
|
|
143
|
+
var sourceData: Data?
|
|
144
|
+
repeat {
|
|
145
|
+
let isExhausted = stream.src_size == 0
|
|
146
|
+
if isExhausted {
|
|
147
|
+
do {
|
|
148
|
+
sourceData = try provider(position, Int(Swift.min(size - position, Int64(bufferSize))))
|
|
149
|
+
position += Int64(stream.prepare(for: sourceData))
|
|
150
|
+
} catch { throw error }
|
|
151
|
+
}
|
|
152
|
+
if let sourceData {
|
|
153
|
+
sourceData.withUnsafeBytes { rawBufferPointer in
|
|
154
|
+
if let baseAddress = rawBufferPointer.baseAddress {
|
|
155
|
+
let pointer = baseAddress.assumingMemoryBound(to: UInt8.self)
|
|
156
|
+
stream.src_ptr = pointer.advanced(by: sourceData.count - stream.src_size)
|
|
157
|
+
let flags = sourceData.count < bufferSize ? Int32(COMPRESSION_STREAM_FINALIZE.rawValue) : 0
|
|
158
|
+
status = compression_stream_process(&stream, flags)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if
|
|
162
|
+
operation == COMPRESSION_STREAM_ENCODE,
|
|
163
|
+
isExhausted, skipCRC32 == false { crc32 = sourceData.crc32(checksum: crc32) }
|
|
164
|
+
}
|
|
165
|
+
switch status {
|
|
166
|
+
case COMPRESSION_STATUS_OK, COMPRESSION_STATUS_END:
|
|
167
|
+
let outputData = Data(bytesNoCopy: destPointer, count: bufferSize - stream.dst_size, deallocator: .none)
|
|
168
|
+
try consumer(outputData)
|
|
169
|
+
if operation == COMPRESSION_STREAM_DECODE, !skipCRC32 { crc32 = outputData.crc32(checksum: crc32) }
|
|
170
|
+
stream.dst_ptr = destPointer
|
|
171
|
+
stream.dst_size = bufferSize
|
|
172
|
+
|
|
173
|
+
default: throw CompressionError.corruptedData
|
|
174
|
+
}
|
|
175
|
+
} while status == COMPRESSION_STATUS_OK
|
|
176
|
+
return crc32
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
extension compression_stream {
|
|
181
|
+
|
|
182
|
+
fileprivate mutating func prepare(for sourceData: Data?) -> Int {
|
|
183
|
+
guard let sourceData else { return 0 }
|
|
184
|
+
|
|
185
|
+
src_size = sourceData.count
|
|
186
|
+
return sourceData.count
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// MARK: - Linux
|
|
191
|
+
|
|
192
|
+
#else
|
|
193
|
+
import CZlib
|
|
194
|
+
|
|
195
|
+
extension Data {
|
|
196
|
+
static func encode(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) throws -> CRC32 {
|
|
197
|
+
var stream = z_stream()
|
|
198
|
+
let streamSize = Int32(MemoryLayout<z_stream>.size)
|
|
199
|
+
var result = deflateInit2_(
|
|
200
|
+
&stream,
|
|
201
|
+
Z_DEFAULT_COMPRESSION,
|
|
202
|
+
Z_DEFLATED,
|
|
203
|
+
-MAX_WBITS,
|
|
204
|
+
9,
|
|
205
|
+
Z_DEFAULT_STRATEGY,
|
|
206
|
+
ZLIB_VERSION,
|
|
207
|
+
streamSize
|
|
208
|
+
)
|
|
209
|
+
defer { deflateEnd(&stream) }
|
|
210
|
+
guard result == Z_OK else { throw CompressionError.invalidStream }
|
|
211
|
+
var flush = Z_NO_FLUSH
|
|
212
|
+
var position: Int64 = 0
|
|
213
|
+
var zipCRC32 = CRC32(0)
|
|
214
|
+
repeat {
|
|
215
|
+
let readSize = Int(Swift.min(size - position, Int64(bufferSize)))
|
|
216
|
+
var inputChunk = try provider(position, readSize)
|
|
217
|
+
zipCRC32 = inputChunk.crc32(checksum: zipCRC32)
|
|
218
|
+
stream.avail_in = UInt32(inputChunk.count)
|
|
219
|
+
try inputChunk.withUnsafeMutableBytes { rawBufferPointer in
|
|
220
|
+
if let baseAddress = rawBufferPointer.baseAddress {
|
|
221
|
+
let pointer = baseAddress.assumingMemoryBound(to: UInt8.self)
|
|
222
|
+
stream.next_in = pointer
|
|
223
|
+
flush = position + Int64(bufferSize) >= size ? Z_FINISH : Z_NO_FLUSH
|
|
224
|
+
} else if rawBufferPointer.count > 0 {
|
|
225
|
+
throw CompressionError.corruptedData
|
|
226
|
+
} else {
|
|
227
|
+
stream.next_in = nil
|
|
228
|
+
flush = Z_FINISH
|
|
229
|
+
}
|
|
230
|
+
var outputChunk = Data(count: bufferSize)
|
|
231
|
+
repeat {
|
|
232
|
+
stream.avail_out = UInt32(bufferSize)
|
|
233
|
+
try outputChunk.withUnsafeMutableBytes { rawBufferPointer in
|
|
234
|
+
guard let baseAddress = rawBufferPointer.baseAddress, rawBufferPointer.count > 0 else {
|
|
235
|
+
throw CompressionError.corruptedData
|
|
236
|
+
}
|
|
237
|
+
let pointer = baseAddress.assumingMemoryBound(to: UInt8.self)
|
|
238
|
+
stream.next_out = pointer
|
|
239
|
+
result = deflate(&stream, flush)
|
|
240
|
+
}
|
|
241
|
+
guard result >= Z_OK else { throw CompressionError.corruptedData }
|
|
242
|
+
|
|
243
|
+
outputChunk.count = bufferSize - Int(stream.avail_out)
|
|
244
|
+
try consumer(outputChunk)
|
|
245
|
+
} while stream.avail_out == 0
|
|
246
|
+
}
|
|
247
|
+
position += Int64(readSize)
|
|
248
|
+
} while flush != Z_FINISH
|
|
249
|
+
return zipCRC32
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
static func decode(bufferSize: Int, skipCRC32: Bool, provider: Provider, consumer: Consumer) throws -> CRC32 {
|
|
253
|
+
var stream = z_stream()
|
|
254
|
+
let streamSize = Int32(MemoryLayout<z_stream>.size)
|
|
255
|
+
var result = inflateInit2_(&stream, -MAX_WBITS, ZLIB_VERSION, streamSize)
|
|
256
|
+
defer { inflateEnd(&stream) }
|
|
257
|
+
guard result == Z_OK else { throw CompressionError.invalidStream }
|
|
258
|
+
var unzipCRC32 = CRC32(0)
|
|
259
|
+
var position: Int64 = 0
|
|
260
|
+
repeat {
|
|
261
|
+
stream.avail_in = UInt32(bufferSize)
|
|
262
|
+
var chunk = try provider(position, bufferSize)
|
|
263
|
+
position += Int64(chunk.count)
|
|
264
|
+
try chunk.withUnsafeMutableBytes { rawBufferPointer in
|
|
265
|
+
if let baseAddress = rawBufferPointer.baseAddress, rawBufferPointer.count > 0 {
|
|
266
|
+
let pointer = baseAddress.assumingMemoryBound(to: UInt8.self)
|
|
267
|
+
stream.next_in = pointer
|
|
268
|
+
repeat {
|
|
269
|
+
var outputData = Data(count: bufferSize)
|
|
270
|
+
stream.avail_out = UInt32(bufferSize)
|
|
271
|
+
try outputData.withUnsafeMutableBytes { rawBufferPointer in
|
|
272
|
+
if let baseAddress = rawBufferPointer.baseAddress, rawBufferPointer.count > 0 {
|
|
273
|
+
let pointer = baseAddress.assumingMemoryBound(to: UInt8.self)
|
|
274
|
+
stream.next_out = pointer
|
|
275
|
+
} else {
|
|
276
|
+
throw CompressionError.corruptedData
|
|
277
|
+
}
|
|
278
|
+
result = inflate(&stream, Z_NO_FLUSH)
|
|
279
|
+
guard
|
|
280
|
+
result != Z_NEED_DICT,
|
|
281
|
+
result != Z_DATA_ERROR,
|
|
282
|
+
result != Z_MEM_ERROR
|
|
283
|
+
else {
|
|
284
|
+
throw CompressionError.corruptedData
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
let remainingLength = UInt32(bufferSize) - stream.avail_out
|
|
288
|
+
outputData.count = Int(remainingLength)
|
|
289
|
+
try consumer(outputData)
|
|
290
|
+
if !skipCRC32 { unzipCRC32 = outputData.crc32(checksum: unzipCRC32) }
|
|
291
|
+
} while stream.avail_out == 0
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
} while result != Z_STREAM_END
|
|
295
|
+
return unzipCRC32
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
#endif
|
|
300
|
+
|
|
301
|
+
/// The lookup table used to calculate `CRC32` checksums when using the built-in
|
|
302
|
+
/// CRC32 implementation.
|
|
303
|
+
private let crcTable: [CRC32] = [
|
|
304
|
+
0x00000000,
|
|
305
|
+
0x77073096,
|
|
306
|
+
0xee0e612c,
|
|
307
|
+
0x990951ba,
|
|
308
|
+
0x076dc419,
|
|
309
|
+
0x706af48f,
|
|
310
|
+
0xe963a535,
|
|
311
|
+
0x9e6495a3,
|
|
312
|
+
0x0edb8832,
|
|
313
|
+
0x79dcb8a4,
|
|
314
|
+
0xe0d5e91e,
|
|
315
|
+
0x97d2d988,
|
|
316
|
+
0x09b64c2b,
|
|
317
|
+
0x7eb17cbd,
|
|
318
|
+
0xe7b82d07,
|
|
319
|
+
0x90bf1d91,
|
|
320
|
+
0x1db71064,
|
|
321
|
+
0x6ab020f2,
|
|
322
|
+
0xf3b97148,
|
|
323
|
+
0x84be41de,
|
|
324
|
+
0x1adad47d,
|
|
325
|
+
0x6ddde4eb,
|
|
326
|
+
0xf4d4b551,
|
|
327
|
+
0x83d385c7,
|
|
328
|
+
0x136c9856,
|
|
329
|
+
0x646ba8c0,
|
|
330
|
+
0xfd62f97a,
|
|
331
|
+
0x8a65c9ec,
|
|
332
|
+
0x14015c4f,
|
|
333
|
+
0x63066cd9,
|
|
334
|
+
0xfa0f3d63,
|
|
335
|
+
0x8d080df5,
|
|
336
|
+
0x3b6e20c8,
|
|
337
|
+
0x4c69105e,
|
|
338
|
+
0xd56041e4,
|
|
339
|
+
0xa2677172,
|
|
340
|
+
0x3c03e4d1,
|
|
341
|
+
0x4b04d447,
|
|
342
|
+
0xd20d85fd,
|
|
343
|
+
0xa50ab56b,
|
|
344
|
+
0x35b5a8fa,
|
|
345
|
+
0x42b2986c,
|
|
346
|
+
0xdbbbc9d6,
|
|
347
|
+
0xacbcf940,
|
|
348
|
+
0x32d86ce3,
|
|
349
|
+
0x45df5c75,
|
|
350
|
+
0xdcd60dcf,
|
|
351
|
+
0xabd13d59,
|
|
352
|
+
0x26d930ac,
|
|
353
|
+
0x51de003a,
|
|
354
|
+
0xc8d75180,
|
|
355
|
+
0xbfd06116,
|
|
356
|
+
0x21b4f4b5,
|
|
357
|
+
0x56b3c423,
|
|
358
|
+
0xcfba9599,
|
|
359
|
+
0xb8bda50f,
|
|
360
|
+
0x2802b89e,
|
|
361
|
+
0x5f058808,
|
|
362
|
+
0xc60cd9b2,
|
|
363
|
+
0xb10be924,
|
|
364
|
+
0x2f6f7c87,
|
|
365
|
+
0x58684c11,
|
|
366
|
+
0xc1611dab,
|
|
367
|
+
0xb6662d3d,
|
|
368
|
+
0x76dc4190,
|
|
369
|
+
0x01db7106,
|
|
370
|
+
0x98d220bc,
|
|
371
|
+
0xefd5102a,
|
|
372
|
+
0x71b18589,
|
|
373
|
+
0x06b6b51f,
|
|
374
|
+
0x9fbfe4a5,
|
|
375
|
+
0xe8b8d433,
|
|
376
|
+
0x7807c9a2,
|
|
377
|
+
0x0f00f934,
|
|
378
|
+
0x9609a88e,
|
|
379
|
+
0xe10e9818,
|
|
380
|
+
0x7f6a0dbb,
|
|
381
|
+
0x086d3d2d,
|
|
382
|
+
0x91646c97,
|
|
383
|
+
0xe6635c01,
|
|
384
|
+
0x6b6b51f4,
|
|
385
|
+
0x1c6c6162,
|
|
386
|
+
0x856530d8,
|
|
387
|
+
0xf262004e,
|
|
388
|
+
0x6c0695ed,
|
|
389
|
+
0x1b01a57b,
|
|
390
|
+
0x8208f4c1,
|
|
391
|
+
0xf50fc457,
|
|
392
|
+
0x65b0d9c6,
|
|
393
|
+
0x12b7e950,
|
|
394
|
+
0x8bbeb8ea,
|
|
395
|
+
0xfcb9887c,
|
|
396
|
+
0x62dd1ddf,
|
|
397
|
+
0x15da2d49,
|
|
398
|
+
0x8cd37cf3,
|
|
399
|
+
0xfbd44c65,
|
|
400
|
+
0x4db26158,
|
|
401
|
+
0x3ab551ce,
|
|
402
|
+
0xa3bc0074,
|
|
403
|
+
0xd4bb30e2,
|
|
404
|
+
0x4adfa541,
|
|
405
|
+
0x3dd895d7,
|
|
406
|
+
0xa4d1c46d,
|
|
407
|
+
0xd3d6f4fb,
|
|
408
|
+
0x4369e96a,
|
|
409
|
+
0x346ed9fc,
|
|
410
|
+
0xad678846,
|
|
411
|
+
0xda60b8d0,
|
|
412
|
+
0x44042d73,
|
|
413
|
+
0x33031de5,
|
|
414
|
+
0xaa0a4c5f,
|
|
415
|
+
0xdd0d7cc9,
|
|
416
|
+
0x5005713c,
|
|
417
|
+
0x270241aa,
|
|
418
|
+
0xbe0b1010,
|
|
419
|
+
0xc90c2086,
|
|
420
|
+
0x5768b525,
|
|
421
|
+
0x206f85b3,
|
|
422
|
+
0xb966d409,
|
|
423
|
+
0xce61e49f,
|
|
424
|
+
0x5edef90e,
|
|
425
|
+
0x29d9c998,
|
|
426
|
+
0xb0d09822,
|
|
427
|
+
0xc7d7a8b4,
|
|
428
|
+
0x59b33d17,
|
|
429
|
+
0x2eb40d81,
|
|
430
|
+
0xb7bd5c3b,
|
|
431
|
+
0xc0ba6cad,
|
|
432
|
+
0xedb88320,
|
|
433
|
+
0x9abfb3b6,
|
|
434
|
+
0x03b6e20c,
|
|
435
|
+
0x74b1d29a,
|
|
436
|
+
0xead54739,
|
|
437
|
+
0x9dd277af,
|
|
438
|
+
0x04db2615,
|
|
439
|
+
0x73dc1683,
|
|
440
|
+
0xe3630b12,
|
|
441
|
+
0x94643b84,
|
|
442
|
+
0x0d6d6a3e,
|
|
443
|
+
0x7a6a5aa8,
|
|
444
|
+
0xe40ecf0b,
|
|
445
|
+
0x9309ff9d,
|
|
446
|
+
0x0a00ae27,
|
|
447
|
+
0x7d079eb1,
|
|
448
|
+
0xf00f9344,
|
|
449
|
+
0x8708a3d2,
|
|
450
|
+
0x1e01f268,
|
|
451
|
+
0x6906c2fe,
|
|
452
|
+
0xf762575d,
|
|
453
|
+
0x806567cb,
|
|
454
|
+
0x196c3671,
|
|
455
|
+
0x6e6b06e7,
|
|
456
|
+
0xfed41b76,
|
|
457
|
+
0x89d32be0,
|
|
458
|
+
0x10da7a5a,
|
|
459
|
+
0x67dd4acc,
|
|
460
|
+
0xf9b9df6f,
|
|
461
|
+
0x8ebeeff9,
|
|
462
|
+
0x17b7be43,
|
|
463
|
+
0x60b08ed5,
|
|
464
|
+
0xd6d6a3e8,
|
|
465
|
+
0xa1d1937e,
|
|
466
|
+
0x38d8c2c4,
|
|
467
|
+
0x4fdff252,
|
|
468
|
+
0xd1bb67f1,
|
|
469
|
+
0xa6bc5767,
|
|
470
|
+
0x3fb506dd,
|
|
471
|
+
0x48b2364b,
|
|
472
|
+
0xd80d2bda,
|
|
473
|
+
0xaf0a1b4c,
|
|
474
|
+
0x36034af6,
|
|
475
|
+
0x41047a60,
|
|
476
|
+
0xdf60efc3,
|
|
477
|
+
0xa867df55,
|
|
478
|
+
0x316e8eef,
|
|
479
|
+
0x4669be79,
|
|
480
|
+
0xcb61b38c,
|
|
481
|
+
0xbc66831a,
|
|
482
|
+
0x256fd2a0,
|
|
483
|
+
0x5268e236,
|
|
484
|
+
0xcc0c7795,
|
|
485
|
+
0xbb0b4703,
|
|
486
|
+
0x220216b9,
|
|
487
|
+
0x5505262f,
|
|
488
|
+
0xc5ba3bbe,
|
|
489
|
+
0xb2bd0b28,
|
|
490
|
+
0x2bb45a92,
|
|
491
|
+
0x5cb36a04,
|
|
492
|
+
0xc2d7ffa7,
|
|
493
|
+
0xb5d0cf31,
|
|
494
|
+
0x2cd99e8b,
|
|
495
|
+
0x5bdeae1d,
|
|
496
|
+
0x9b64c2b0,
|
|
497
|
+
0xec63f226,
|
|
498
|
+
0x756aa39c,
|
|
499
|
+
0x026d930a,
|
|
500
|
+
0x9c0906a9,
|
|
501
|
+
0xeb0e363f,
|
|
502
|
+
0x72076785,
|
|
503
|
+
0x05005713,
|
|
504
|
+
0x95bf4a82,
|
|
505
|
+
0xe2b87a14,
|
|
506
|
+
0x7bb12bae,
|
|
507
|
+
0x0cb61b38,
|
|
508
|
+
0x92d28e9b,
|
|
509
|
+
0xe5d5be0d,
|
|
510
|
+
0x7cdcefb7,
|
|
511
|
+
0x0bdbdf21,
|
|
512
|
+
0x86d3d2d4,
|
|
513
|
+
0xf1d4e242,
|
|
514
|
+
0x68ddb3f8,
|
|
515
|
+
0x1fda836e,
|
|
516
|
+
0x81be16cd,
|
|
517
|
+
0xf6b9265b,
|
|
518
|
+
0x6fb077e1,
|
|
519
|
+
0x18b74777,
|
|
520
|
+
0x88085ae6,
|
|
521
|
+
0xff0f6a70,
|
|
522
|
+
0x66063bca,
|
|
523
|
+
0x11010b5c,
|
|
524
|
+
0x8f659eff,
|
|
525
|
+
0xf862ae69,
|
|
526
|
+
0x616bffd3,
|
|
527
|
+
0x166ccf45,
|
|
528
|
+
0xa00ae278,
|
|
529
|
+
0xd70dd2ee,
|
|
530
|
+
0x4e048354,
|
|
531
|
+
0x3903b3c2,
|
|
532
|
+
0xa7672661,
|
|
533
|
+
0xd06016f7,
|
|
534
|
+
0x4969474d,
|
|
535
|
+
0x3e6e77db,
|
|
536
|
+
0xaed16a4a,
|
|
537
|
+
0xd9d65adc,
|
|
538
|
+
0x40df0b66,
|
|
539
|
+
0x37d83bf0,
|
|
540
|
+
0xa9bcae53,
|
|
541
|
+
0xdebb9ec5,
|
|
542
|
+
0x47b2cf7f,
|
|
543
|
+
0x30b5ffe9,
|
|
544
|
+
0xbdbdf21c,
|
|
545
|
+
0xcabac28a,
|
|
546
|
+
0x53b39330,
|
|
547
|
+
0x24b4a3a6,
|
|
548
|
+
0xbad03605,
|
|
549
|
+
0xcdd70693,
|
|
550
|
+
0x54de5729,
|
|
551
|
+
0x23d967bf,
|
|
552
|
+
0xb3667a2e,
|
|
553
|
+
0xc4614ab8,
|
|
554
|
+
0x5d681b02,
|
|
555
|
+
0x2a6f2b94,
|
|
556
|
+
0xb40bbe37,
|
|
557
|
+
0xc30c8ea1,
|
|
558
|
+
0x5a05df1b,
|
|
559
|
+
0x2d02ef8d,
|
|
560
|
+
]
|
|
561
|
+
|
|
562
|
+
extension Data {
|
|
563
|
+
|
|
564
|
+
/// Lookup table-based CRC32 implenetation that is used
|
|
565
|
+
/// if `zlib` isn't available.
|
|
566
|
+
/// - Parameter checksum: Running checksum or `0` for the initial run.
|
|
567
|
+
/// - Returns: The calculated checksum of the receiver.
|
|
568
|
+
func builtInCRC32(checksum: CRC32) -> CRC32 {
|
|
569
|
+
// The typecast is necessary on 32-bit platforms because of
|
|
570
|
+
// https://bugs.swift.org/browse/SR-1774
|
|
571
|
+
let mask = 0xffffffff as CRC32
|
|
572
|
+
var result = checksum ^ mask
|
|
573
|
+
#if swift(>=5.0)
|
|
574
|
+
crcTable.withUnsafeBufferPointer { crcTablePointer in
|
|
575
|
+
self.withUnsafeBytes { bufferPointer in
|
|
576
|
+
var bufferIndex = 0
|
|
577
|
+
while bufferIndex < self.count {
|
|
578
|
+
let byte = bufferPointer[bufferIndex]
|
|
579
|
+
let index = Int((result ^ CRC32(byte)) & 0xff)
|
|
580
|
+
result = (result >> 8) ^ crcTablePointer[index]
|
|
581
|
+
bufferIndex += 1
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
#else
|
|
586
|
+
withUnsafeBytes { bytes in
|
|
587
|
+
let bins = stride(from: 0, to: self.count, by: 256)
|
|
588
|
+
for bin in bins {
|
|
589
|
+
for binIndex in 0..<256 {
|
|
590
|
+
let byteIndex = bin + binIndex
|
|
591
|
+
guard byteIndex < self.count else { break }
|
|
592
|
+
|
|
593
|
+
let byte = bytes[byteIndex]
|
|
594
|
+
let index = Int((result ^ CRC32(byte)) & 0xff)
|
|
595
|
+
result = (result >> 8) ^ crcTable[index]
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
#endif
|
|
600
|
+
return result ^ mask
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
#if !swift(>=5.0)
|
|
605
|
+
|
|
606
|
+
// Since Swift 5.0, `Data.withUnsafeBytes()` passes an `UnsafeRawBufferPointer` instead of an `UnsafePointer<UInt8>`
|
|
607
|
+
// into `body`.
|
|
608
|
+
// We provide a compatible method for targets that use Swift 4.x so that we can use the new version
|
|
609
|
+
// across all language versions.
|
|
610
|
+
|
|
611
|
+
extension Data {
|
|
612
|
+
func withUnsafeBytes<T>(_ body: (UnsafeRawBufferPointer) throws -> T) rethrows -> T {
|
|
613
|
+
let count = count
|
|
614
|
+
return try withUnsafeBytes { (pointer: UnsafePointer<UInt8>) throws -> T in
|
|
615
|
+
try body(UnsafeRawBufferPointer(start: pointer, count: count))
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS)
|
|
620
|
+
#else
|
|
621
|
+
mutating func withUnsafeMutableBytes<T>(_ body: (UnsafeMutableRawBufferPointer) throws -> T) rethrows -> T {
|
|
622
|
+
let count = count
|
|
623
|
+
guard count > 0 else {
|
|
624
|
+
return try body(UnsafeMutableRawBufferPointer(start: nil, count: count))
|
|
625
|
+
}
|
|
626
|
+
return try withUnsafeMutableBytes { (pointer: UnsafeMutablePointer<UInt8>) throws -> T in
|
|
627
|
+
try body(UnsafeMutableRawBufferPointer(start: pointer, count: count))
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
#endif
|
|
631
|
+
}
|
|
632
|
+
#endif
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Data+CompressionDeprecated.swift
|
|
3
|
+
// ZIPFoundation
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2017-2025 Thomas Zoechling, https://www.peakstep.com and the ZIP Foundation project authors.
|
|
6
|
+
// Released under the MIT License.
|
|
7
|
+
//
|
|
8
|
+
// See https://github.com/weichsel/ZIPFoundation/blob/master/LICENSE for license information.
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
import Foundation
|
|
12
|
+
|
|
13
|
+
extension Data {
|
|
14
|
+
|
|
15
|
+
@available(*, deprecated, message: "Please use `Int64` for `size` and provider `position`.")
|
|
16
|
+
static func compress(
|
|
17
|
+
size: Int,
|
|
18
|
+
bufferSize: Int,
|
|
19
|
+
provider: (_ position: Int, _ size: Int) throws -> Data,
|
|
20
|
+
consumer: Consumer
|
|
21
|
+
) throws -> CRC32 {
|
|
22
|
+
let newProvider: Provider = { try provider(Int($0), $1) }
|
|
23
|
+
return try compress(size: Int64(size), bufferSize: bufferSize, provider: newProvider, consumer: consumer)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@available(*, deprecated, message: "Please use `Int64` for `size` and provider `position`.")
|
|
27
|
+
static func decompress(
|
|
28
|
+
size: Int,
|
|
29
|
+
bufferSize: Int,
|
|
30
|
+
skipCRC32: Bool,
|
|
31
|
+
provider: (_ position: Int, _ size: Int) throws -> Data,
|
|
32
|
+
consumer: Consumer
|
|
33
|
+
) throws -> CRC32 {
|
|
34
|
+
let newProvider: Provider = { try provider(Int($0), $1) }
|
|
35
|
+
return try decompress(
|
|
36
|
+
size: Int64(size),
|
|
37
|
+
bufferSize: bufferSize,
|
|
38
|
+
skipCRC32: skipCRC32,
|
|
39
|
+
provider: newProvider,
|
|
40
|
+
consumer: consumer
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
}
|