@octane-xplat/lottie 0.0.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -2
- package/dist/native/cx.mobile.js +11 -0
- package/dist/native/escape-props.js +39 -0
- package/dist/native/index.js +183 -0
- package/dist/native/layout-child.js +38 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/native/vendor/ui-lottie/index.android.js +286 -0
- package/dist/native/vendor/ui-lottie/index.ios.js +214 -0
- package/dist/native/vendor/ui-lottie/src/lottie/index.common.js +50 -0
- package/dist/native/vendor/ui-lottie/src/lottie/utils.js +6 -0
- package/dist/web/escape-props.web.js +17 -0
- package/dist/web/index.js +346 -0
- package/dist/web/layout-child.web.js +47 -0
- package/dist/web/octane-client-build.json +8 -0
- package/package.json +104 -11
- package/platforms/android/include.gradle +7 -0
- package/platforms/android/java/com/nativescript/lottie/LottieAnimationView.java +92 -0
- package/platforms/android/lottie.aar +0 -0
- package/platforms/android/native-api-usage.json +16 -0
- package/platforms/ios/Podfile +5 -0
- package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
- package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
- package/platforms/macos/UPSTREAM.md +13 -0
- package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
- package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
- package/src/Lottie.macos.tsrx +129 -0
- package/src/Lottie.tsrx +162 -0
- package/src/Lottie.web.tsrx +152 -0
- package/src/cx.mobile.ts +8 -0
- package/src/escape-props.ts +65 -0
- package/src/escape-props.web.ts +25 -0
- package/src/index.macos.ts +2 -0
- package/src/index.ts +2 -0
- package/src/index.web.ts +2 -0
- package/src/layout-child.ts +57 -0
- package/src/layout-child.web.ts +108 -0
- package/src/native-elements.d.ts +8 -0
- package/src/props.ts +133 -0
- package/src/references.d.ts +3 -0
- package/src/vendor/ui-lottie/LICENSE.md +21 -0
- package/src/vendor/ui-lottie/src/lottie/index.android.ts +447 -0
- package/src/vendor/ui-lottie/src/lottie/index.common.ts +84 -0
- package/src/vendor/ui-lottie/src/lottie/index.d.ts +133 -0
- package/src/vendor/ui-lottie/src/lottie/index.ios.ts +345 -0
- package/src/vendor/ui-lottie/src/lottie/typings/android.d.ts +4149 -0
- package/src/vendor/ui-lottie/src/lottie/typings/android.nativescript.d.ts +12 -0
- package/src/vendor/ui-lottie/src/lottie/typings/dotlottie.ios.d.ts +14 -0
- package/src/vendor/ui-lottie/src/lottie/typings/ios.d.ts +384 -0
- package/src/vendor/ui-lottie/src/lottie/utils.ts +9 -0
- package/types/generated/.tsrx-typegen-manifest.json +18 -0
- package/types/generated/Lottie.d.ts +7 -0
- package/types/generated/Lottie.web.d.ts +7 -0
- package/types/generated/cx.mobile.d.ts +6 -0
- package/types/generated/escape-props.d.ts +15 -0
- package/types/generated/escape-props.web.d.ts +5 -0
- package/types/generated/index.d.ts +2 -0
- package/types/generated/index.web.d.ts +2 -0
- package/types/generated/layout-child.d.ts +6 -0
- package/types/generated/layout-child.web.d.ts +15 -0
- package/types/generated/props.d.ts +110 -0
- package/types/generated/vendor/ui-lottie/src/lottie/index.common.d.ts +30 -0
- package/types/generated/vendor/ui-lottie/src/lottie/index.ios.d.ts +35 -0
- package/types/generated/vendor/ui-lottie/src/lottie/utils.d.ts +1 -0
- package/index.d.ts +0 -1
- package/index.js +0 -2
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Archive+Helpers.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 Archive {
|
|
14
|
+
|
|
15
|
+
func readUncompressed(
|
|
16
|
+
entry: Entry,
|
|
17
|
+
bufferSize: Int,
|
|
18
|
+
skipCRC32: Bool,
|
|
19
|
+
progress: Progress? = nil,
|
|
20
|
+
with consumer: Consumer
|
|
21
|
+
) throws -> CRC32 {
|
|
22
|
+
let size = entry.centralDirectoryStructure.effectiveUncompressedSize
|
|
23
|
+
guard size <= .max else { throw ArchiveError.invalidEntrySize }
|
|
24
|
+
return try Data.consumePart(
|
|
25
|
+
of: Int64(size),
|
|
26
|
+
chunkSize: bufferSize,
|
|
27
|
+
skipCRC32: skipCRC32,
|
|
28
|
+
provider: { _, chunkSize -> Data in
|
|
29
|
+
return try Data.readChunk(of: chunkSize, from: self.archiveFile)
|
|
30
|
+
},
|
|
31
|
+
consumer: { data in
|
|
32
|
+
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
|
|
33
|
+
try consumer(data)
|
|
34
|
+
progress?.completedUnitCount += Int64(data.count)
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func readCompressed(
|
|
40
|
+
entry: Entry,
|
|
41
|
+
bufferSize: Int,
|
|
42
|
+
skipCRC32: Bool,
|
|
43
|
+
progress: Progress? = nil,
|
|
44
|
+
with consumer: Consumer
|
|
45
|
+
) throws -> CRC32 {
|
|
46
|
+
let size = entry.centralDirectoryStructure.effectiveCompressedSize
|
|
47
|
+
guard size <= .max else { throw ArchiveError.invalidEntrySize }
|
|
48
|
+
return try Data.decompress(
|
|
49
|
+
size: Int64(size),
|
|
50
|
+
bufferSize: bufferSize,
|
|
51
|
+
skipCRC32: skipCRC32,
|
|
52
|
+
provider: { _, chunkSize -> Data in
|
|
53
|
+
return try Data.readChunk(of: chunkSize, from: self.archiveFile)
|
|
54
|
+
},
|
|
55
|
+
consumer: { data in
|
|
56
|
+
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
|
|
57
|
+
try consumer(data)
|
|
58
|
+
progress?.completedUnitCount += Int64(data.count)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func writeEntry(
|
|
64
|
+
uncompressedSize: Int64,
|
|
65
|
+
type: Entry.EntryType,
|
|
66
|
+
compressionMethod: CompressionMethod,
|
|
67
|
+
bufferSize: Int,
|
|
68
|
+
progress: Progress? = nil,
|
|
69
|
+
provider: Provider
|
|
70
|
+
) throws -> (sizeWritten: Int64, crc32: CRC32) {
|
|
71
|
+
var checksum = CRC32(0)
|
|
72
|
+
var sizeWritten = Int64(0)
|
|
73
|
+
switch type {
|
|
74
|
+
case .file:
|
|
75
|
+
switch compressionMethod {
|
|
76
|
+
case .none:
|
|
77
|
+
(sizeWritten, checksum) = try writeUncompressed(
|
|
78
|
+
size: uncompressedSize,
|
|
79
|
+
bufferSize: bufferSize,
|
|
80
|
+
progress: progress,
|
|
81
|
+
provider: provider
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
case .deflate:
|
|
85
|
+
(sizeWritten, checksum) = try writeCompressed(
|
|
86
|
+
size: uncompressedSize,
|
|
87
|
+
bufferSize: bufferSize,
|
|
88
|
+
progress: progress,
|
|
89
|
+
provider: provider
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
case .directory:
|
|
94
|
+
_ = try provider(0, 0)
|
|
95
|
+
if let progress { progress.completedUnitCount = progress.totalUnitCount }
|
|
96
|
+
|
|
97
|
+
case .symlink:
|
|
98
|
+
let (linkSizeWritten, linkChecksum) = try writeSymbolicLink(
|
|
99
|
+
size: Int(uncompressedSize),
|
|
100
|
+
provider: provider
|
|
101
|
+
)
|
|
102
|
+
(sizeWritten, checksum) = (Int64(linkSizeWritten), linkChecksum)
|
|
103
|
+
if let progress { progress.completedUnitCount = progress.totalUnitCount }
|
|
104
|
+
}
|
|
105
|
+
return (sizeWritten, checksum)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
func writeLocalFileHeader(
|
|
109
|
+
path: String,
|
|
110
|
+
compressionMethod: CompressionMethod,
|
|
111
|
+
size: (uncompressed: UInt64, compressed: UInt64),
|
|
112
|
+
checksum: CRC32,
|
|
113
|
+
modificationDateTime: (UInt16, UInt16)
|
|
114
|
+
) throws -> LocalFileHeader {
|
|
115
|
+
// We always set Bit 11 in generalPurposeBitFlag, which indicates an UTF-8 encoded path.
|
|
116
|
+
let fileNameData = Data(path.utf8)
|
|
117
|
+
var uncompressedSizeOfLFH = UInt32(0)
|
|
118
|
+
var compressedSizeOfLFH = UInt32(0)
|
|
119
|
+
var extraFieldLength = UInt16(0)
|
|
120
|
+
var zip64ExtendedInformation: Entry.ZIP64ExtendedInformation?
|
|
121
|
+
var versionNeededToExtract = Version.v20.rawValue
|
|
122
|
+
// ZIP64 Extended Information in the Local header MUST include BOTH original and compressed file size fields.
|
|
123
|
+
if size.uncompressed >= maxUncompressedSize || size.compressed >= maxCompressedSize {
|
|
124
|
+
uncompressedSizeOfLFH = .max
|
|
125
|
+
compressedSizeOfLFH = .max
|
|
126
|
+
extraFieldLength = UInt16(20) // 2 + 2 + 8 + 8
|
|
127
|
+
versionNeededToExtract = Version.v45.rawValue
|
|
128
|
+
zip64ExtendedInformation = Entry.ZIP64ExtendedInformation(
|
|
129
|
+
dataSize: extraFieldLength - 4,
|
|
130
|
+
uncompressedSize: size.uncompressed,
|
|
131
|
+
compressedSize: size.compressed,
|
|
132
|
+
relativeOffsetOfLocalHeader: 0,
|
|
133
|
+
diskNumberStart: 0
|
|
134
|
+
)
|
|
135
|
+
} else {
|
|
136
|
+
uncompressedSizeOfLFH = UInt32(size.uncompressed)
|
|
137
|
+
compressedSizeOfLFH = UInt32(size.compressed)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let localFileHeader = LocalFileHeader(
|
|
141
|
+
versionNeededToExtract: versionNeededToExtract,
|
|
142
|
+
generalPurposeBitFlag: UInt16(2048),
|
|
143
|
+
compressionMethod: compressionMethod.rawValue,
|
|
144
|
+
lastModFileTime: modificationDateTime.1,
|
|
145
|
+
lastModFileDate: modificationDateTime.0,
|
|
146
|
+
crc32: checksum,
|
|
147
|
+
compressedSize: compressedSizeOfLFH,
|
|
148
|
+
uncompressedSize: uncompressedSizeOfLFH,
|
|
149
|
+
fileNameLength: UInt16(fileNameData.count),
|
|
150
|
+
extraFieldLength: extraFieldLength,
|
|
151
|
+
fileNameData: fileNameData,
|
|
152
|
+
extraFieldData: zip64ExtendedInformation?.data ?? Data()
|
|
153
|
+
)
|
|
154
|
+
_ = try Data.write(chunk: localFileHeader.data, to: archiveFile)
|
|
155
|
+
return localFileHeader
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
func writeCentralDirectoryStructure(
|
|
159
|
+
localFileHeader: LocalFileHeader,
|
|
160
|
+
relativeOffset: UInt64,
|
|
161
|
+
externalFileAttributes: UInt32
|
|
162
|
+
) throws -> CentralDirectoryStructure {
|
|
163
|
+
var extraUncompressedSize: UInt64?
|
|
164
|
+
var extraCompressedSize: UInt64?
|
|
165
|
+
var extraOffset: UInt64?
|
|
166
|
+
var relativeOffsetOfCD = UInt32(0)
|
|
167
|
+
var extraFieldLength = UInt16(0)
|
|
168
|
+
var zip64ExtendedInformation: Entry.ZIP64ExtendedInformation?
|
|
169
|
+
if localFileHeader.uncompressedSize == .max || localFileHeader.compressedSize == .max {
|
|
170
|
+
let zip64Field = Entry.ZIP64ExtendedInformation
|
|
171
|
+
.scanForZIP64Field(in: localFileHeader.extraFieldData, fields: [.uncompressedSize, .compressedSize])
|
|
172
|
+
extraUncompressedSize = zip64Field?.uncompressedSize
|
|
173
|
+
extraCompressedSize = zip64Field?.compressedSize
|
|
174
|
+
}
|
|
175
|
+
if relativeOffset >= maxOffsetOfLocalFileHeader {
|
|
176
|
+
extraOffset = relativeOffset
|
|
177
|
+
relativeOffsetOfCD = .max
|
|
178
|
+
} else {
|
|
179
|
+
relativeOffsetOfCD = UInt32(relativeOffset)
|
|
180
|
+
}
|
|
181
|
+
extraFieldLength = [extraUncompressedSize, extraCompressedSize, extraOffset]
|
|
182
|
+
.compactMap { $0 }
|
|
183
|
+
.reduce(UInt16(0)) { $0 + UInt16(MemoryLayout.size(ofValue: $1)) }
|
|
184
|
+
if extraFieldLength > 0 {
|
|
185
|
+
// Size of extra fields, shouldn't include the leading 4 bytes
|
|
186
|
+
zip64ExtendedInformation = Entry.ZIP64ExtendedInformation(
|
|
187
|
+
dataSize: extraFieldLength,
|
|
188
|
+
uncompressedSize: extraUncompressedSize ?? 0,
|
|
189
|
+
compressedSize: extraCompressedSize ?? 0,
|
|
190
|
+
relativeOffsetOfLocalHeader: extraOffset ?? 0,
|
|
191
|
+
diskNumberStart: 0
|
|
192
|
+
)
|
|
193
|
+
extraFieldLength += Entry.ZIP64ExtendedInformation.headerSize
|
|
194
|
+
}
|
|
195
|
+
let centralDirectory = CentralDirectoryStructure(
|
|
196
|
+
localFileHeader: localFileHeader,
|
|
197
|
+
fileAttributes: externalFileAttributes,
|
|
198
|
+
relativeOffset: relativeOffsetOfCD,
|
|
199
|
+
extraField: (
|
|
200
|
+
extraFieldLength,
|
|
201
|
+
zip64ExtendedInformation?.data ?? Data()
|
|
202
|
+
)
|
|
203
|
+
)
|
|
204
|
+
_ = try Data.write(chunk: centralDirectory.data, to: archiveFile)
|
|
205
|
+
return centralDirectory
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
func writeEndOfCentralDirectory(
|
|
209
|
+
centralDirectoryStructure: CentralDirectoryStructure,
|
|
210
|
+
startOfCentralDirectory: UInt64,
|
|
211
|
+
startOfEndOfCentralDirectory: UInt64,
|
|
212
|
+
operation: ModifyOperation
|
|
213
|
+
) throws -> EndOfCentralDirectoryStructure {
|
|
214
|
+
var record = endOfCentralDirectoryRecord
|
|
215
|
+
let sizeOfCD = sizeOfCentralDirectory
|
|
216
|
+
let numberOfTotalEntries = totalNumberOfEntriesInCentralDirectory
|
|
217
|
+
let countChange = operation.rawValue
|
|
218
|
+
var dataLength = centralDirectoryStructure.extraFieldLength
|
|
219
|
+
dataLength += centralDirectoryStructure.fileNameLength
|
|
220
|
+
dataLength += centralDirectoryStructure.fileCommentLength
|
|
221
|
+
let cdDataLengthChange = countChange * (Int(dataLength) + CentralDirectoryStructure.size)
|
|
222
|
+
let (updatedSizeOfCD, updatedNumberOfEntries): (UInt64, UInt64) = try {
|
|
223
|
+
switch operation {
|
|
224
|
+
case .add:
|
|
225
|
+
guard .max - sizeOfCD >= cdDataLengthChange else {
|
|
226
|
+
throw ArchiveError.invalidCentralDirectorySize
|
|
227
|
+
}
|
|
228
|
+
guard .max - numberOfTotalEntries >= countChange else {
|
|
229
|
+
throw ArchiveError.invalidCentralDirectoryEntryCount
|
|
230
|
+
}
|
|
231
|
+
return (sizeOfCD + UInt64(cdDataLengthChange), numberOfTotalEntries + UInt64(countChange))
|
|
232
|
+
|
|
233
|
+
case .remove:
|
|
234
|
+
return (sizeOfCD - UInt64(-cdDataLengthChange), numberOfTotalEntries - UInt64(-countChange))
|
|
235
|
+
}
|
|
236
|
+
}()
|
|
237
|
+
let sizeOfCDForEOCD = updatedSizeOfCD >= maxSizeOfCentralDirectory
|
|
238
|
+
? UInt32.max
|
|
239
|
+
: UInt32(updatedSizeOfCD)
|
|
240
|
+
let numberOfTotalEntriesForEOCD = updatedNumberOfEntries >= maxTotalNumberOfEntries
|
|
241
|
+
? UInt16.max
|
|
242
|
+
: UInt16(updatedNumberOfEntries)
|
|
243
|
+
let offsetOfCDForEOCD = startOfCentralDirectory >= maxOffsetOfCentralDirectory
|
|
244
|
+
? UInt32.max
|
|
245
|
+
: UInt32(startOfCentralDirectory)
|
|
246
|
+
// ZIP64 End of Central Directory
|
|
247
|
+
var zip64EOCD: ZIP64EndOfCentralDirectory?
|
|
248
|
+
if numberOfTotalEntriesForEOCD == .max || offsetOfCDForEOCD == .max || sizeOfCDForEOCD == .max {
|
|
249
|
+
zip64EOCD = try writeZIP64EOCD(
|
|
250
|
+
totalNumberOfEntries: updatedNumberOfEntries,
|
|
251
|
+
sizeOfCentralDirectory: updatedSizeOfCD,
|
|
252
|
+
offsetOfCentralDirectory: startOfCentralDirectory,
|
|
253
|
+
offsetOfEndOfCentralDirectory: startOfEndOfCentralDirectory
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
record = EndOfCentralDirectoryRecord(
|
|
257
|
+
record: record,
|
|
258
|
+
numberOfEntriesOnDisk: numberOfTotalEntriesForEOCD,
|
|
259
|
+
numberOfEntriesInCentralDirectory: numberOfTotalEntriesForEOCD,
|
|
260
|
+
updatedSizeOfCentralDirectory: sizeOfCDForEOCD,
|
|
261
|
+
startOfCentralDirectory: offsetOfCDForEOCD
|
|
262
|
+
)
|
|
263
|
+
_ = try Data.write(chunk: record.data, to: archiveFile)
|
|
264
|
+
return (record, zip64EOCD)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
func writeUncompressed(
|
|
268
|
+
size: Int64,
|
|
269
|
+
bufferSize: Int,
|
|
270
|
+
progress: Progress? = nil,
|
|
271
|
+
provider: Provider
|
|
272
|
+
) throws -> (sizeWritten: Int64, checksum: CRC32) {
|
|
273
|
+
var position: Int64 = 0
|
|
274
|
+
var sizeWritten: Int64 = 0
|
|
275
|
+
var checksum = CRC32(0)
|
|
276
|
+
while position < size {
|
|
277
|
+
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
|
|
278
|
+
let readSize = (size - position) >= bufferSize ? bufferSize : Int(size - position)
|
|
279
|
+
let entryChunk = try provider(position, readSize)
|
|
280
|
+
checksum = entryChunk.crc32(checksum: checksum)
|
|
281
|
+
sizeWritten += Int64(try Data.write(chunk: entryChunk, to: archiveFile))
|
|
282
|
+
position += Int64(bufferSize)
|
|
283
|
+
progress?.completedUnitCount = sizeWritten
|
|
284
|
+
}
|
|
285
|
+
return (sizeWritten, checksum)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
func writeCompressed(
|
|
289
|
+
size: Int64,
|
|
290
|
+
bufferSize: Int,
|
|
291
|
+
progress: Progress? = nil,
|
|
292
|
+
provider: Provider
|
|
293
|
+
) throws -> (sizeWritten: Int64, checksum: CRC32) {
|
|
294
|
+
var sizeWritten: Int64 = 0
|
|
295
|
+
let consumer: Consumer = { data in sizeWritten += Int64(try Data.write(chunk: data, to: self.archiveFile)) }
|
|
296
|
+
let checksum = try Data.compress(
|
|
297
|
+
size: size,
|
|
298
|
+
bufferSize: bufferSize,
|
|
299
|
+
provider: { position, size -> Data in
|
|
300
|
+
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
|
|
301
|
+
let data = try provider(position, size)
|
|
302
|
+
progress?.completedUnitCount += Int64(data.count)
|
|
303
|
+
return data
|
|
304
|
+
},
|
|
305
|
+
consumer: consumer
|
|
306
|
+
)
|
|
307
|
+
return (sizeWritten, checksum)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
func writeSymbolicLink(size: Int, provider: Provider) throws -> (sizeWritten: Int, checksum: CRC32) {
|
|
311
|
+
// The reported size of a symlink is the number of characters in the path it points to.
|
|
312
|
+
let linkData = try provider(0, size)
|
|
313
|
+
let checksum = linkData.crc32(checksum: 0)
|
|
314
|
+
let sizeWritten = try Data.write(chunk: linkData, to: archiveFile)
|
|
315
|
+
return (sizeWritten, checksum)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
func writeZIP64EOCD(
|
|
319
|
+
totalNumberOfEntries: UInt64,
|
|
320
|
+
sizeOfCentralDirectory: UInt64,
|
|
321
|
+
offsetOfCentralDirectory: UInt64,
|
|
322
|
+
offsetOfEndOfCentralDirectory: UInt64
|
|
323
|
+
) throws -> ZIP64EndOfCentralDirectory {
|
|
324
|
+
var zip64EOCD: ZIP64EndOfCentralDirectory = zip64EndOfCentralDirectory ?? {
|
|
325
|
+
// Shouldn't include the leading 12 bytes: (size - 12 = 44)
|
|
326
|
+
let record = ZIP64EndOfCentralDirectoryRecord(
|
|
327
|
+
sizeOfZIP64EndOfCentralDirectoryRecord: UInt64(44),
|
|
328
|
+
versionMadeBy: UInt16(789),
|
|
329
|
+
versionNeededToExtract: Version.v45.rawValue,
|
|
330
|
+
numberOfDisk: 0,
|
|
331
|
+
numberOfDiskStart: 0,
|
|
332
|
+
totalNumberOfEntriesOnDisk: 0,
|
|
333
|
+
totalNumberOfEntriesInCentralDirectory: 0,
|
|
334
|
+
sizeOfCentralDirectory: 0,
|
|
335
|
+
offsetToStartOfCentralDirectory: 0,
|
|
336
|
+
zip64ExtensibleDataSector: Data()
|
|
337
|
+
)
|
|
338
|
+
let locator = ZIP64EndOfCentralDirectoryLocator(
|
|
339
|
+
numberOfDiskWithZIP64EOCDRecordStart: 0,
|
|
340
|
+
relativeOffsetOfZIP64EOCDRecord: 0,
|
|
341
|
+
totalNumberOfDisk: 1
|
|
342
|
+
)
|
|
343
|
+
return ZIP64EndOfCentralDirectory(record: record, locator: locator)
|
|
344
|
+
}()
|
|
345
|
+
|
|
346
|
+
let updatedRecord = ZIP64EndOfCentralDirectoryRecord(
|
|
347
|
+
record: zip64EOCD.record,
|
|
348
|
+
numberOfEntriesOnDisk: totalNumberOfEntries,
|
|
349
|
+
numberOfEntriesInCD: totalNumberOfEntries,
|
|
350
|
+
sizeOfCentralDirectory: sizeOfCentralDirectory,
|
|
351
|
+
offsetToStartOfCD: offsetOfCentralDirectory
|
|
352
|
+
)
|
|
353
|
+
let updatedLocator = ZIP64EndOfCentralDirectoryLocator(
|
|
354
|
+
locator: zip64EOCD.locator,
|
|
355
|
+
offsetOfZIP64EOCDRecord: offsetOfEndOfCentralDirectory
|
|
356
|
+
)
|
|
357
|
+
zip64EOCD = ZIP64EndOfCentralDirectory(record: updatedRecord, locator: updatedLocator)
|
|
358
|
+
_ = try Data.write(chunk: zip64EOCD.data, to: archiveFile)
|
|
359
|
+
return zip64EOCD
|
|
360
|
+
}
|
|
361
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Archive+MemoryFile.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 Archive {
|
|
14
|
+
var isMemoryArchive: Bool {
|
|
15
|
+
url.scheme == memoryURLScheme
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#if swift(>=5.0)
|
|
20
|
+
|
|
21
|
+
extension Archive {
|
|
22
|
+
|
|
23
|
+
final class MemoryFile {
|
|
24
|
+
|
|
25
|
+
// MARK: Lifecycle
|
|
26
|
+
|
|
27
|
+
init(data: Data = Data()) {
|
|
28
|
+
self.data = data
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// MARK: Internal
|
|
32
|
+
|
|
33
|
+
private(set) var data: Data
|
|
34
|
+
|
|
35
|
+
func open(mode: AccessMode) throws -> FILEPointer {
|
|
36
|
+
let cookie = Unmanaged.passRetained(self)
|
|
37
|
+
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) || os(Android)
|
|
38
|
+
guard
|
|
39
|
+
let result = mode.isWritable
|
|
40
|
+
? funopen(cookie.toOpaque(), readStub, writeStub, seekStub, closeStub)
|
|
41
|
+
: funopen(cookie.toOpaque(), readStub, nil, seekStub, closeStub)
|
|
42
|
+
else { throw MemoryFileError.invalidMemoryFile }
|
|
43
|
+
#else
|
|
44
|
+
let stubs = cookie_io_functions_t(read: readStub, write: writeStub, seek: seekStub, close: closeStub)
|
|
45
|
+
guard let result = fopencookie(cookie.toOpaque(), mode.posixMode, stubs)
|
|
46
|
+
else { throw MemoryFileError.invalidMemoryFile }
|
|
47
|
+
#endif
|
|
48
|
+
return result
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// MARK: Private
|
|
52
|
+
|
|
53
|
+
private var offset = 0
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Returns a `Data` object containing a representation of the receiver.
|
|
58
|
+
var data: Data? {
|
|
59
|
+
memoryFile?.data
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
enum MemoryFileError: Error {
|
|
64
|
+
case invalidMemoryFile
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
extension Archive.MemoryFile {
|
|
68
|
+
|
|
69
|
+
fileprivate func readData(buffer: UnsafeMutableRawBufferPointer) -> Int {
|
|
70
|
+
let size = min(buffer.count, data.count - offset)
|
|
71
|
+
let start = data.startIndex
|
|
72
|
+
data.copyBytes(to: buffer.bindMemory(to: UInt8.self), from: start + offset..<start + offset + size)
|
|
73
|
+
offset += size
|
|
74
|
+
return size
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fileprivate func writeData(buffer: UnsafeRawBufferPointer) -> Int {
|
|
78
|
+
let start = data.startIndex
|
|
79
|
+
if offset < data.count, offset + buffer.count > data.count {
|
|
80
|
+
data.removeSubrange(start + offset..<start + data.count)
|
|
81
|
+
} else if offset > data.count {
|
|
82
|
+
data.append(Data(count: offset - data.count))
|
|
83
|
+
}
|
|
84
|
+
if offset == data.count {
|
|
85
|
+
data.append(buffer.bindMemory(to: UInt8.self))
|
|
86
|
+
} else {
|
|
87
|
+
let start = data.startIndex // May have changed in earlier mutation
|
|
88
|
+
data.replaceSubrange(
|
|
89
|
+
start + offset..<start + offset + buffer.count,
|
|
90
|
+
with: buffer.bindMemory(to: UInt8.self)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
offset += buffer.count
|
|
94
|
+
return buffer.count
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fileprivate func seek(offset: Int, whence: Int32) -> Int {
|
|
98
|
+
var result = -1
|
|
99
|
+
if whence == SEEK_SET {
|
|
100
|
+
result = offset
|
|
101
|
+
} else if whence == SEEK_CUR {
|
|
102
|
+
result = self.offset + offset
|
|
103
|
+
} else if whence == SEEK_END {
|
|
104
|
+
result = data.count + offset
|
|
105
|
+
}
|
|
106
|
+
self.offset = result
|
|
107
|
+
return self.offset
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private func fileFromCookie(cookie: UnsafeRawPointer) -> Archive.MemoryFile {
|
|
112
|
+
Unmanaged<Archive.MemoryFile>.fromOpaque(cookie).takeUnretainedValue()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private func closeStub(_ cookie: UnsafeMutableRawPointer?) -> Int32 {
|
|
116
|
+
if let cookie {
|
|
117
|
+
Unmanaged<Archive.MemoryFile>.fromOpaque(cookie).release()
|
|
118
|
+
}
|
|
119
|
+
return 0
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) || os(Android)
|
|
123
|
+
|
|
124
|
+
private func readStub(
|
|
125
|
+
_ cookie: UnsafeMutableRawPointer?,
|
|
126
|
+
_ bytePtr: UnsafeMutablePointer<Int8>?,
|
|
127
|
+
_ count: Int32
|
|
128
|
+
) -> Int32 {
|
|
129
|
+
guard let cookie, let bytePtr else { return 0 }
|
|
130
|
+
return Int32(fileFromCookie(cookie: cookie).readData(
|
|
131
|
+
buffer: UnsafeMutableRawBufferPointer(start: bytePtr, count: Int(count))
|
|
132
|
+
))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private func writeStub(
|
|
136
|
+
_ cookie: UnsafeMutableRawPointer?,
|
|
137
|
+
_ bytePtr: UnsafePointer<Int8>?,
|
|
138
|
+
_ count: Int32
|
|
139
|
+
) -> Int32 {
|
|
140
|
+
guard let cookie, let bytePtr else { return 0 }
|
|
141
|
+
return Int32(fileFromCookie(cookie: cookie).writeData(
|
|
142
|
+
buffer: UnsafeRawBufferPointer(start: bytePtr, count: Int(count))
|
|
143
|
+
))
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private func seekStub(
|
|
147
|
+
_ cookie: UnsafeMutableRawPointer?,
|
|
148
|
+
_ offset: fpos_t,
|
|
149
|
+
_ whence: Int32
|
|
150
|
+
) -> fpos_t {
|
|
151
|
+
guard let cookie else { return 0 }
|
|
152
|
+
return fpos_t(fileFromCookie(cookie: cookie).seek(offset: Int(offset), whence: whence))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#else
|
|
156
|
+
|
|
157
|
+
extension Archive.AccessMode {
|
|
158
|
+
|
|
159
|
+
var posixMode: String {
|
|
160
|
+
switch self {
|
|
161
|
+
case .read: "rb"
|
|
162
|
+
case .create: "wb+"
|
|
163
|
+
case .update: "rb+"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private func readStub(
|
|
169
|
+
_ cookie: UnsafeMutableRawPointer?,
|
|
170
|
+
_ bytePtr: UnsafeMutablePointer<Int8>?,
|
|
171
|
+
_ count: Int
|
|
172
|
+
) -> Int {
|
|
173
|
+
guard let cookie, let bytePtr else { return 0 }
|
|
174
|
+
return fileFromCookie(cookie: cookie).readData(
|
|
175
|
+
buffer: UnsafeMutableRawBufferPointer(start: bytePtr, count: count)
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private func writeStub(
|
|
180
|
+
_ cookie: UnsafeMutableRawPointer?,
|
|
181
|
+
_ bytePtr: UnsafePointer<Int8>?,
|
|
182
|
+
_ count: Int
|
|
183
|
+
) -> Int {
|
|
184
|
+
guard let cookie, let bytePtr else { return 0 }
|
|
185
|
+
return fileFromCookie(cookie: cookie).writeData(
|
|
186
|
+
buffer: UnsafeRawBufferPointer(start: bytePtr, count: count)
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private func seekStub(
|
|
191
|
+
_ cookie: UnsafeMutableRawPointer?,
|
|
192
|
+
_ offset: UnsafeMutablePointer<Int>?,
|
|
193
|
+
_ whence: Int32
|
|
194
|
+
) -> Int32 {
|
|
195
|
+
guard let cookie, let offset else { return 0 }
|
|
196
|
+
let result = fileFromCookie(cookie: cookie).seek(offset: Int(offset.pointee), whence: whence)
|
|
197
|
+
if result >= 0 {
|
|
198
|
+
offset.pointee = result
|
|
199
|
+
return 0
|
|
200
|
+
} else {
|
|
201
|
+
return -1
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
#endif
|
|
205
|
+
#endif
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Archive+Progress.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 Archive {
|
|
14
|
+
/// The number of the work units that have to be performed when
|
|
15
|
+
/// removing `entry` from the receiver.
|
|
16
|
+
///
|
|
17
|
+
/// - Parameter entry: The entry that will be removed.
|
|
18
|
+
/// - Returns: The number of the work units.
|
|
19
|
+
func totalUnitCountForRemoving(_ entry: Entry) -> Int64 {
|
|
20
|
+
Int64(offsetToStartOfCentralDirectory - entry.localSize)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func makeProgressForRemoving(_ entry: Entry) -> Progress {
|
|
24
|
+
Progress(totalUnitCount: totalUnitCountForRemoving(entry))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// The number of the work units that have to be performed when
|
|
28
|
+
/// reading `entry` from the receiver.
|
|
29
|
+
///
|
|
30
|
+
/// - Parameter entry: The entry that will be read.
|
|
31
|
+
/// - Returns: The number of the work units.
|
|
32
|
+
func totalUnitCountForReading(_ entry: Entry) -> Int64 {
|
|
33
|
+
switch entry.type {
|
|
34
|
+
case .file, .symlink:
|
|
35
|
+
Int64(entry.uncompressedSize)
|
|
36
|
+
case .directory:
|
|
37
|
+
defaultDirectoryUnitCount
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func makeProgressForReading(_ entry: Entry) -> Progress {
|
|
42
|
+
Progress(totalUnitCount: totalUnitCountForReading(entry))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// The number of the work units that have to be performed when
|
|
46
|
+
/// adding the file at `url` to the receiver.
|
|
47
|
+
/// - Parameter entry: The entry that will be removed.
|
|
48
|
+
/// - Returns: The number of the work units.
|
|
49
|
+
func totalUnitCountForAddingItem(at url: URL) -> Int64 {
|
|
50
|
+
var count = Int64(0)
|
|
51
|
+
do {
|
|
52
|
+
let type = try FileManager.typeForItem(at: url)
|
|
53
|
+
switch type {
|
|
54
|
+
case .file, .symlink:
|
|
55
|
+
count = Int64(try FileManager.fileSizeForItem(at: url))
|
|
56
|
+
case .directory:
|
|
57
|
+
count = defaultDirectoryUnitCount
|
|
58
|
+
}
|
|
59
|
+
} catch { count = -1 }
|
|
60
|
+
return count
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func makeProgressForAddingItem(at url: URL) -> Progress {
|
|
64
|
+
Progress(totalUnitCount: totalUnitCountForAddingItem(at: url))
|
|
65
|
+
}
|
|
66
|
+
}
|