@octane-xplat/nativescript-mason-core 0.0.1 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +113 -2
  3. package/artifact-inventory.json +746 -0
  4. package/box-shadow.d.ts +10 -0
  5. package/box-shadow.js +48 -0
  6. package/common.d.ts +482 -0
  7. package/common.js +2645 -0
  8. package/css-colors.d.ts +17 -0
  9. package/css-colors.js +54 -0
  10. package/css-filter.d.ts +17 -0
  11. package/css-filter.js +140 -0
  12. package/css-keyframes.d.ts +41 -0
  13. package/css-keyframes.js +437 -0
  14. package/css-math.d.ts +34 -0
  15. package/css-math.js +300 -0
  16. package/css-shorthands.d.ts +65 -0
  17. package/css-shorthands.js +673 -0
  18. package/css-transform.d.ts +6 -0
  19. package/css-transform.js +100 -0
  20. package/diagnostics.d.ts +51 -0
  21. package/diagnostics.js +52 -0
  22. package/display-density.d.ts +9 -0
  23. package/display-density.js +20 -0
  24. package/fonts.d.ts +20 -0
  25. package/fonts.js +88 -0
  26. package/foreign-layout.d.ts +6 -0
  27. package/foreign-layout.js +149 -0
  28. package/gradient-stops.d.ts +25 -0
  29. package/gradient-stops.js +112 -0
  30. package/index.android.d.ts +9 -0
  31. package/index.android.js +8 -0
  32. package/index.d.ts +10 -0
  33. package/index.ios.d.ts +9 -0
  34. package/index.ios.js +8 -0
  35. package/ios-host-README.md +124 -0
  36. package/layout-types.d.ts +192 -0
  37. package/mask.d.ts +54 -0
  38. package/mask.js +26 -0
  39. package/native-types-README.md +51 -0
  40. package/package.json +44 -6
  41. package/panel-helpers.d.ts +3 -0
  42. package/panel-helpers.js +8 -0
  43. package/platforms/android/MasonCore.aar +0 -0
  44. package/platforms/android/include.gradle +6 -0
  45. package/platforms/android/manifest.json +73 -0
  46. package/platforms/ios/FontManager.LICENSE +201 -0
  47. package/platforms/ios/MasonCore.xcframework/Info.plist +43 -0
  48. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/Mason.h +25 -0
  49. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
  50. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/mason_native.h +601 -0
  51. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Info.plist +0 -0
  52. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/MasonCore +0 -0
  53. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  54. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.abi.json +100095 -0
  55. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.private.swiftinterface +3174 -0
  56. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  57. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftinterface +3174 -0
  58. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/module.modulemap +9 -0
  59. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
  60. package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
  61. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/Mason.h +25 -0
  62. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
  63. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/mason_native.h +601 -0
  64. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Info.plist +0 -0
  65. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/MasonCore +0 -0
  66. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  67. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.abi.json +100095 -0
  68. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3174 -0
  69. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  70. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3174 -0
  71. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/module.modulemap +9 -0
  72. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
  73. package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
  74. package/platforms/ios/Package.resolved +24 -0
  75. package/platforms/ios/SDWebImage.LICENSE +20 -0
  76. package/platforms/ios/build.xcconfig +4 -0
  77. package/platforms/ios/device-manifest.json +213 -0
  78. package/platforms/ios/include/FontManager/NSCFontDescriptors.h +36 -0
  79. package/platforms/ios/include/FontManager/NSCFontFace.h +98 -0
  80. package/platforms/ios/include/FontManager/NSCFontFaceSet.h +73 -0
  81. package/platforms/ios/include/FontManager/NSCFontManagerUmbrella.h +7 -0
  82. package/platforms/ios/include/FontManager/NSCFontParser.h +22 -0
  83. package/platforms/ios/include/FontManager/NSCFontRegex.h +4 -0
  84. package/platforms/ios/include/FontManager/NSCFontResolver.h +43 -0
  85. package/platforms/ios/include/FontManager/NSCFontStyle.h +27 -0
  86. package/platforms/ios/include/FontManager/NSCFontTypes.h +41 -0
  87. package/platforms/ios/include/SDWebImage/NSButton+WebCache.h +340 -0
  88. package/platforms/ios/include/SDWebImage/NSData+ImageContentType.h +63 -0
  89. package/platforms/ios/include/SDWebImage/NSImage+Compatibility.h +67 -0
  90. package/platforms/ios/include/SDWebImage/SDAnimatedImage.h +136 -0
  91. package/platforms/ios/include/SDWebImage/SDAnimatedImagePlayer.h +113 -0
  92. package/platforms/ios/include/SDWebImage/SDAnimatedImageRep.h +33 -0
  93. package/platforms/ios/include/SDWebImage/SDAnimatedImageView+WebCache.h +168 -0
  94. package/platforms/ios/include/SDWebImage/SDAnimatedImageView.h +125 -0
  95. package/platforms/ios/include/SDWebImage/SDCallbackQueue.h +59 -0
  96. package/platforms/ios/include/SDWebImage/SDDiskCache.h +146 -0
  97. package/platforms/ios/include/SDWebImage/SDGraphicsImageRenderer.h +84 -0
  98. package/platforms/ios/include/SDWebImage/SDImageAPNGCoder.h +19 -0
  99. package/platforms/ios/include/SDWebImage/SDImageAWebPCoder.h +23 -0
  100. package/platforms/ios/include/SDWebImage/SDImageCache.h +482 -0
  101. package/platforms/ios/include/SDWebImage/SDImageCacheConfig.h +153 -0
  102. package/platforms/ios/include/SDWebImage/SDImageCacheDefine.h +179 -0
  103. package/platforms/ios/include/SDWebImage/SDImageCachesManager.h +81 -0
  104. package/platforms/ios/include/SDWebImage/SDImageCoder.h +347 -0
  105. package/platforms/ios/include/SDWebImage/SDImageCoderHelper.h +251 -0
  106. package/platforms/ios/include/SDWebImage/SDImageCodersManager.h +58 -0
  107. package/platforms/ios/include/SDWebImage/SDImageFrame.h +44 -0
  108. package/platforms/ios/include/SDWebImage/SDImageGIFCoder.h +22 -0
  109. package/platforms/ios/include/SDWebImage/SDImageGraphics.h +28 -0
  110. package/platforms/ios/include/SDWebImage/SDImageHEICCoder.h +25 -0
  111. package/platforms/ios/include/SDWebImage/SDImageIOAnimatedCoder.h +65 -0
  112. package/platforms/ios/include/SDWebImage/SDImageIOCoder.h +30 -0
  113. package/platforms/ios/include/SDWebImage/SDImageLoader.h +146 -0
  114. package/platforms/ios/include/SDWebImage/SDImageLoadersManager.h +40 -0
  115. package/platforms/ios/include/SDWebImage/SDImageTransformer.h +283 -0
  116. package/platforms/ios/include/SDWebImage/SDMemoryCache.h +78 -0
  117. package/platforms/ios/include/SDWebImage/SDWebImage.h +91 -0
  118. package/platforms/ios/include/SDWebImage/SDWebImageCacheKeyFilter.h +35 -0
  119. package/platforms/ios/include/SDWebImage/SDWebImageCacheSerializer.h +39 -0
  120. package/platforms/ios/include/SDWebImage/SDWebImageCompat.h +102 -0
  121. package/platforms/ios/include/SDWebImage/SDWebImageDefine.h +420 -0
  122. package/platforms/ios/include/SDWebImage/SDWebImageDownloader.h +320 -0
  123. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderConfig.h +113 -0
  124. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderDecryptor.h +52 -0
  125. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderOperation.h +191 -0
  126. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderRequestModifier.h +72 -0
  127. package/platforms/ios/include/SDWebImage/SDWebImageDownloaderResponseModifier.h +72 -0
  128. package/platforms/ios/include/SDWebImage/SDWebImageError.h +33 -0
  129. package/platforms/ios/include/SDWebImage/SDWebImageIndicator.h +119 -0
  130. package/platforms/ios/include/SDWebImage/SDWebImageManager.h +290 -0
  131. package/platforms/ios/include/SDWebImage/SDWebImageOperation.h +27 -0
  132. package/platforms/ios/include/SDWebImage/SDWebImageOptionsProcessor.h +78 -0
  133. package/platforms/ios/include/SDWebImage/SDWebImagePrefetcher.h +168 -0
  134. package/platforms/ios/include/SDWebImage/SDWebImageTransition.h +131 -0
  135. package/platforms/ios/include/SDWebImage/UIButton+WebCache.h +402 -0
  136. package/platforms/ios/include/SDWebImage/UIImage+ExtendedCacheData.h +24 -0
  137. package/platforms/ios/include/SDWebImage/UIImage+ForceDecode.h +52 -0
  138. package/platforms/ios/include/SDWebImage/UIImage+GIF.h +26 -0
  139. package/platforms/ios/include/SDWebImage/UIImage+MemoryCacheCost.h +27 -0
  140. package/platforms/ios/include/SDWebImage/UIImage+Metadata.h +104 -0
  141. package/platforms/ios/include/SDWebImage/UIImage+MultiFormat.h +81 -0
  142. package/platforms/ios/include/SDWebImage/UIImage+Transform.h +164 -0
  143. package/platforms/ios/include/SDWebImage/UIImageView+HighlightedWebCache.h +142 -0
  144. package/platforms/ios/include/SDWebImage/UIImageView+WebCache.h +209 -0
  145. package/platforms/ios/include/SDWebImage/UIView+WebCache.h +131 -0
  146. package/platforms/ios/include/SDWebImage/UIView+WebCacheOperation.h +52 -0
  147. package/platforms/ios/include/SDWebImage/UIView+WebCacheState.h +63 -0
  148. package/platforms/ios/include/module.modulemap +2 -0
  149. package/platforms/ios/manifest.json +132 -0
  150. package/platforms/ios/simulator-manifest.json +213 -0
  151. package/plugin-README.md +197 -0
  152. package/properties.d.ts +154 -0
  153. package/properties.js +2454 -0
  154. package/pseudo.d.ts +9 -0
  155. package/pseudo.js +57 -0
  156. package/scroll/index.android.d.ts +15 -0
  157. package/scroll/index.android.js +72 -0
  158. package/scroll/index.d.ts +5 -0
  159. package/scroll/index.ios.d.ts +18 -0
  160. package/scroll/index.ios.js +106 -0
  161. package/style.d.ts +768 -0
  162. package/style.js +7151 -0
  163. package/symbols.d.ts +25 -0
  164. package/symbols.js +41 -0
  165. package/tree/index.android.d.ts +11 -0
  166. package/tree/index.android.js +42 -0
  167. package/tree/index.d.ts +15 -0
  168. package/tree/index.ios.d.ts +26 -0
  169. package/tree/index.ios.js +53 -0
  170. package/typings/android-declarations.d.ts +4 -0
  171. package/typings/android.d.ts +9730 -0
  172. package/typings/manifest.json +45 -0
  173. package/typings/native.d.ts +5 -0
  174. package/typings/objc!FontManager.d.ts +389 -0
  175. package/typings/objc!MasonCore.d.ts +2472 -0
  176. package/typings/objc!SDWebImage.d.ts +3378 -0
  177. package/units.d.ts +29 -0
  178. package/units.js +44 -0
  179. package/utils/index.android.d.ts +211 -0
  180. package/utils/index.android.js +595 -0
  181. package/utils/index.ios.d.ts +222 -0
  182. package/utils/index.ios.js +790 -0
  183. package/view/index.android.d.ts +13 -0
  184. package/view/index.android.js +74 -0
  185. package/view/index.d.ts +2 -0
  186. package/view/index.ios.d.ts +24 -0
  187. package/view/index.ios.js +157 -0
@@ -0,0 +1,113 @@
1
+ /*
2
+ * This file is part of the SDWebImage package.
3
+ * (c) Olivier Poitrey <rs@dailymotion.com>
4
+ *
5
+ * For the full copyright and license information, please view the LICENSE
6
+ * file that was distributed with this source code.
7
+ */
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import "SDWebImageCompat.h"
11
+ #import "SDImageCoder.h"
12
+
13
+ /// Animated image playback mode
14
+ typedef NS_ENUM(NSUInteger, SDAnimatedImagePlaybackMode) {
15
+ /**
16
+ * From first to last frame and stop or next loop.
17
+ */
18
+ SDAnimatedImagePlaybackModeNormal = 0,
19
+ /**
20
+ * From last frame to first frame and stop or next loop.
21
+ */
22
+ SDAnimatedImagePlaybackModeReverse,
23
+ /**
24
+ * From first frame to last frame and reverse again, like reciprocating.
25
+ */
26
+ SDAnimatedImagePlaybackModeBounce,
27
+ /**
28
+ * From last frame to first frame and reverse again, like reversed reciprocating.
29
+ */
30
+ SDAnimatedImagePlaybackModeReversedBounce,
31
+ };
32
+
33
+ /// A player to control the playback of animated image, which can be used to drive Animated ImageView or any rendering usage, like CALayer/WatchKit/SwiftUI rendering.
34
+ @interface SDAnimatedImagePlayer : NSObject
35
+
36
+ /// Current playing frame image. This value is KVO Compliance.
37
+ @property (nonatomic, readonly, nullable) UIImage *currentFrame;
38
+
39
+ /// Current frame index, zero based. This value is KVO Compliance.
40
+ @property (nonatomic, readonly) NSUInteger currentFrameIndex;
41
+
42
+ /// Current loop count since its latest animating. This value is KVO Compliance.
43
+ @property (nonatomic, readonly) NSUInteger currentLoopCount;
44
+
45
+ /// Total frame count for animated image rendering. Defaults is animated image's frame count.
46
+ /// @note For progressive animation, you can update this value when your provider receive more frames.
47
+ @property (nonatomic, assign) NSUInteger totalFrameCount;
48
+
49
+ /// Total loop count for animated image rendering. Default is animated image's loop count.
50
+ @property (nonatomic, assign) NSUInteger totalLoopCount;
51
+
52
+ /// The animation playback rate. Default is 1.0
53
+ /// `1.0` means the normal speed.
54
+ /// `0.0` means stopping the animation.
55
+ /// `0.0-1.0` means the slow speed.
56
+ /// `> 1.0` means the fast speed.
57
+ /// `< 0.0` is not supported currently and stop animation. (may support reverse playback in the future)
58
+ @property (nonatomic, assign) double playbackRate;
59
+
60
+ /// Asynchronous setup animation playback mode. Default mode is SDAnimatedImagePlaybackModeNormal.
61
+ @property (nonatomic, assign) SDAnimatedImagePlaybackMode playbackMode;
62
+
63
+ /// Provide a max buffer size by bytes. This is used to adjust frame buffer count and can be useful when the decoding cost is expensive (such as Animated WebP software decoding). Default is 0.
64
+ /// `0` means automatically adjust by calculating current memory usage.
65
+ /// `1` means without any buffer cache, each of frames will be decoded and then be freed after rendering. (Lowest Memory and Highest CPU)
66
+ /// `NSUIntegerMax` means cache all the buffer. (Lowest CPU and Highest Memory)
67
+ @property (nonatomic, assign) NSUInteger maxBufferSize;
68
+
69
+ /// You can specify a runloop mode to let it rendering.
70
+ /// Default is NSRunLoopCommonModes on multi-core device, NSDefaultRunLoopMode on single-core device
71
+ @property (nonatomic, copy, nonnull) NSRunLoopMode runLoopMode;
72
+
73
+ /// Create a player with animated image provider. If the provider's `animatedImageFrameCount` is less than 1, returns nil.
74
+ /// The provider can be any protocol implementation, like `SDAnimatedImage`, `SDImageGIFCoder`, etc.
75
+ /// @note This provider can represent mutable content, like progressive animated loading. But you need to update the frame count by yourself
76
+ /// @param provider The animated provider
77
+ - (nullable instancetype)initWithProvider:(nonnull id<SDAnimatedImageProvider>)provider;
78
+
79
+ /// Create a player with animated image provider. If the provider's `animatedImageFrameCount` is less than 1, returns nil.
80
+ /// The provider can be any protocol implementation, like `SDAnimatedImage` or `SDImageGIFCoder`, etc.
81
+ /// @note This provider can represent mutable content, like progressive animated loading. But you need to update the frame count by yourself
82
+ /// @param provider The animated provider
83
+ + (nullable instancetype)playerWithProvider:(nonnull id<SDAnimatedImageProvider>)provider;
84
+
85
+ /// The handler block when current frame and index changed.
86
+ @property (nonatomic, copy, nullable) void (^animationFrameHandler)(NSUInteger index, UIImage * _Nonnull frame);
87
+
88
+ /// The handler block when one loop count finished.
89
+ @property (nonatomic, copy, nullable) void (^animationLoopHandler)(NSUInteger loopCount);
90
+
91
+ /// Return the status whether animation is playing.
92
+ @property (nonatomic, readonly) BOOL isPlaying;
93
+
94
+ /// Start the animation. Or resume the previously paused animation.
95
+ - (void)startPlaying;
96
+
97
+ /// Pause the animation. Keep the current frame index and loop count.
98
+ - (void)pausePlaying;
99
+
100
+ /// Stop the animation. Reset the current frame index and loop count.
101
+ - (void)stopPlaying;
102
+
103
+ /// Seek to the desired frame index and loop count.
104
+ /// @note This can be used for advanced control like progressive loading, or skipping specify frames.
105
+ /// @param index The frame index
106
+ /// @param loopCount The loop count
107
+ - (void)seekToFrameAtIndex:(NSUInteger)index loopCount:(NSUInteger)loopCount;
108
+
109
+ /// Clear the frame cache buffer. The frame cache buffer size can be controlled by `maxBufferSize`.
110
+ /// By default, when stop or pause the animation, the frame buffer is still kept to ready for the next restart
111
+ - (void)clearFrameBuffer;
112
+
113
+ @end
@@ -0,0 +1,33 @@
1
+ /*
2
+ * This file is part of the SDWebImage package.
3
+ * (c) Olivier Poitrey <rs@dailymotion.com>
4
+ *
5
+ * For the full copyright and license information, please view the LICENSE
6
+ * file that was distributed with this source code.
7
+ */
8
+
9
+ #import "SDWebImageCompat.h"
10
+
11
+ #if SD_MAC
12
+
13
+ #import "NSData+ImageContentType.h"
14
+
15
+ /**
16
+ A subclass of `NSBitmapImageRep` to fix that GIF duration issue because `NSBitmapImageRep` will reset `NSImageCurrentFrameDuration` by using `kCGImagePropertyGIFDelayTime` but not `kCGImagePropertyGIFUnclampedDelayTime`.
17
+ This also fix the GIF loop count issue, which will use the Netscape standard (See http://www6.uniovi.es/gifanim/gifabout.htm) to only place once when the `kCGImagePropertyGIFLoopCount` is nil. This is what modern browser's behavior.
18
+ Built in GIF coder use this instead of `NSBitmapImageRep` for better GIF rendering. If you do not want this, only enable `SDImageIOCoder`, which just call `NSImage` API and actually use `NSBitmapImageRep` for GIF image.
19
+ This also support APNG format using `SDImageAPNGCoder`. Which provide full alpha-channel support and the correct duration match the `kCGImagePropertyAPNGUnclampedDelayTime`.
20
+ */
21
+ @interface SDAnimatedImageRep : NSBitmapImageRep
22
+
23
+ /// Current animated image format.
24
+ /// @note This format is only valid when `animatedImageData` not nil
25
+ @property (nonatomic, assign, readonly) SDImageFormat animatedImageFormat;
26
+
27
+ /// This allows to retrive the compressed data like GIF using `sd_imageData` on parent `NSImage`, without re-encoding (waste CPU and RAM)
28
+ /// @note This is typically nonnull when you create with `initWithData:`, even it's marked as weak, because ImageIO retain it
29
+ @property (nonatomic, readonly, nullable, weak) NSData *animatedImageData;
30
+
31
+ @end
32
+
33
+ #endif
@@ -0,0 +1,168 @@
1
+ /*
2
+ * This file is part of the SDWebImage package.
3
+ * (c) Olivier Poitrey <rs@dailymotion.com>
4
+ *
5
+ * For the full copyright and license information, please view the LICENSE
6
+ * file that was distributed with this source code.
7
+ */
8
+
9
+ #import "SDAnimatedImageView.h"
10
+
11
+ #if SD_UIKIT || SD_MAC
12
+
13
+ #import "SDWebImageManager.h"
14
+
15
+ /**
16
+ Integrates SDWebImage async downloading and caching of remote images with SDAnimatedImageView.
17
+ */
18
+ @interface SDAnimatedImageView (WebCache)
19
+
20
+ /**
21
+ * Set the imageView `image` with an `url`.
22
+ *
23
+ * The download is asynchronous and cached.
24
+ *
25
+ * @param url The url for the image.
26
+ */
27
+ - (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT;
28
+
29
+ /**
30
+ * Set the imageView `image` with an `url` and a placeholder.
31
+ *
32
+ * The download is asynchronous and cached.
33
+ *
34
+ * @param url The url for the image.
35
+ * @param placeholder The image to be set initially, until the image request finishes.
36
+ * @see sd_setImageWithURL:placeholderImage:options:
37
+ */
38
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
39
+ placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT;
40
+
41
+ /**
42
+ * Set the imageView `image` with an `url`, placeholder and custom options.
43
+ *
44
+ * The download is asynchronous and cached.
45
+ *
46
+ * @param url The url for the image.
47
+ * @param placeholder The image to be set initially, until the image request finishes.
48
+ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
49
+ */
50
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
51
+ placeholderImage:(nullable UIImage *)placeholder
52
+ options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT;
53
+
54
+ /**
55
+ * Set the imageView `image` with an `url`, placeholder, custom options and context.
56
+ *
57
+ * The download is asynchronous and cached.
58
+ *
59
+ * @param url The url for the image.
60
+ * @param placeholder The image to be set initially, until the image request finishes.
61
+ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
62
+ * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
63
+ */
64
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
65
+ placeholderImage:(nullable UIImage *)placeholder
66
+ options:(SDWebImageOptions)options
67
+ context:(nullable SDWebImageContext *)context;
68
+
69
+ /**
70
+ * Set the imageView `image` with an `url`.
71
+ *
72
+ * The download is asynchronous and cached.
73
+ *
74
+ * @param url The url for the image.
75
+ * @param completedBlock A block called when operation has been completed. This block has no return value
76
+ * and takes the requested UIImage as first parameter. In case of error the image parameter
77
+ * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
78
+ * indicating if the image was retrieved from the local cache or from the network.
79
+ * The fourth parameter is the original image url.
80
+ */
81
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
82
+ completed:(nullable SDExternalCompletionBlock)completedBlock;
83
+
84
+ /**
85
+ * Set the imageView `image` with an `url`, placeholder.
86
+ *
87
+ * The download is asynchronous and cached.
88
+ *
89
+ * @param url The url for the image.
90
+ * @param placeholder The image to be set initially, until the image request finishes.
91
+ * @param completedBlock A block called when operation has been completed. This block has no return value
92
+ * and takes the requested UIImage as first parameter. In case of error the image parameter
93
+ * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
94
+ * indicating if the image was retrieved from the local cache or from the network.
95
+ * The fourth parameter is the original image url.
96
+ */
97
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
98
+ placeholderImage:(nullable UIImage *)placeholder
99
+ completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT;
100
+
101
+ /**
102
+ * Set the imageView `image` with an `url`, placeholder and custom options.
103
+ *
104
+ * The download is asynchronous and cached.
105
+ *
106
+ * @param url The url for the image.
107
+ * @param placeholder The image to be set initially, until the image request finishes.
108
+ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
109
+ * @param completedBlock A block called when operation has been completed. This block has no return value
110
+ * and takes the requested UIImage as first parameter. In case of error the image parameter
111
+ * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
112
+ * indicating if the image was retrieved from the local cache or from the network.
113
+ * The fourth parameter is the original image url.
114
+ */
115
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
116
+ placeholderImage:(nullable UIImage *)placeholder
117
+ options:(SDWebImageOptions)options
118
+ completed:(nullable SDExternalCompletionBlock)completedBlock;
119
+
120
+ /**
121
+ * Set the imageView `image` with an `url`, placeholder and custom options.
122
+ *
123
+ * The download is asynchronous and cached.
124
+ *
125
+ * @param url The url for the image.
126
+ * @param placeholder The image to be set initially, until the image request finishes.
127
+ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
128
+ * @param progressBlock A block called while image is downloading
129
+ * @note the progress block is executed on a background queue
130
+ * @param completedBlock A block called when operation has been completed. This block has no return value
131
+ * and takes the requested UIImage as first parameter. In case of error the image parameter
132
+ * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
133
+ * indicating if the image was retrieved from the local cache or from the network.
134
+ * The fourth parameter is the original image url.
135
+ */
136
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
137
+ placeholderImage:(nullable UIImage *)placeholder
138
+ options:(SDWebImageOptions)options
139
+ progress:(nullable SDImageLoaderProgressBlock)progressBlock
140
+ completed:(nullable SDExternalCompletionBlock)completedBlock;
141
+
142
+ /**
143
+ * Set the imageView `image` with an `url`, placeholder, custom options and context.
144
+ *
145
+ * The download is asynchronous and cached.
146
+ *
147
+ * @param url The url for the image.
148
+ * @param placeholder The image to be set initially, until the image request finishes.
149
+ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
150
+ * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
151
+ * @param progressBlock A block called while image is downloading
152
+ * @note the progress block is executed on a background queue
153
+ * @param completedBlock A block called when operation has been completed. This block has no return value
154
+ * and takes the requested UIImage as first parameter. In case of error the image parameter
155
+ * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
156
+ * indicating if the image was retrieved from the local cache or from the network.
157
+ * The fourth parameter is the original image url.
158
+ */
159
+ - (void)sd_setImageWithURL:(nullable NSURL *)url
160
+ placeholderImage:(nullable UIImage *)placeholder
161
+ options:(SDWebImageOptions)options
162
+ context:(nullable SDWebImageContext *)context
163
+ progress:(nullable SDImageLoaderProgressBlock)progressBlock
164
+ completed:(nullable SDExternalCompletionBlock)completedBlock;
165
+
166
+ @end
167
+
168
+ #endif
@@ -0,0 +1,125 @@
1
+ /*
2
+ * This file is part of the SDWebImage package.
3
+ * (c) Olivier Poitrey <rs@dailymotion.com>
4
+ *
5
+ * For the full copyright and license information, please view the LICENSE
6
+ * file that was distributed with this source code.
7
+ */
8
+
9
+ #import "SDWebImageCompat.h"
10
+
11
+ #if SD_UIKIT || SD_MAC
12
+
13
+ #import "SDAnimatedImage.h"
14
+ #import "SDAnimatedImagePlayer.h"
15
+ #import "SDImageTransformer.h"
16
+
17
+ /**
18
+ A drop-in replacement for UIImageView/NSImageView, you can use this for animated image rendering.
19
+ Call `setImage:` with `UIImage(NSImage)` which conforms to `SDAnimatedImage` protocol will start animated image rendering. Call with normal UIImage(NSImage) will back to normal UIImageView(NSImageView) rendering
20
+ For UIKit: use `-startAnimating`, `-stopAnimating` to control animating. `isAnimating` to check animation state.
21
+ For AppKit: use `-setAnimates:` to control animating, `animates` to check animation state. This view is layer-backed.
22
+ */
23
+ NS_SWIFT_UI_ACTOR
24
+ @interface SDAnimatedImageView : UIImageView
25
+ /**
26
+ The internal animation player.
27
+ This property is only used for advanced usage, like inspecting/debugging animation status, control progressive loading, complicated animation frame index control, etc.
28
+ @warning Pay attention if you directly update the player's property like `totalFrameCount`, `totalLoopCount`, the same property on `SDAnimatedImageView` may not get synced.
29
+ */
30
+ @property (nonatomic, strong, readonly, nullable) SDAnimatedImagePlayer *player;
31
+
32
+ /**
33
+ The transformer for each decoded animated image frame.
34
+ We supports post-transform on animated image frame from version 5.20.
35
+ When you configure the transformer on `SDAnimatedImageView` and animation is playing, the `transformedImageWithImage:forKey:` will be called just after the frame is decoded. (note: The `key` arg is always empty for backward-compatible and may be removed in the future)
36
+
37
+ Example to tint the alpha animated image frame with a black color:
38
+ * @code
39
+ imageView.animationTransformer = [SDImageTintTransformer transformerWithColor:UIColor.blackColor];
40
+ * @endcode
41
+ @note The `transformerKey` property is used to ensure the buffer cache available. So make sure it's correct value match the actual logic on transformer. Which means, for the `same frame index + same transformer key`, the transformed image should always be the same.
42
+ */
43
+ @property (nonatomic, strong, nullable) id<SDImageTransformer> animationTransformer;
44
+
45
+ /**
46
+ Current display frame image. This value is KVO Compliance.
47
+ */
48
+ @property (nonatomic, strong, readonly, nullable) UIImage *currentFrame;
49
+ /**
50
+ Current frame index, zero based. This value is KVO Compliance.
51
+ */
52
+ @property (nonatomic, assign, readonly) NSUInteger currentFrameIndex;
53
+ /**
54
+ Current loop count since its latest animating. This value is KVO Compliance.
55
+ */
56
+ @property (nonatomic, assign, readonly) NSUInteger currentLoopCount;
57
+ /**
58
+ YES to choose `animationRepeatCount` property for animation loop count. No to use animated image's `animatedImageLoopCount` instead.
59
+ Default is NO.
60
+ */
61
+ @property (nonatomic, assign) BOOL shouldCustomLoopCount;
62
+ /**
63
+ Total loop count for animated image rendering. Default is animated image's loop count.
64
+ If you need to set custom loop count, set `shouldCustomLoopCount` to YES and change this value.
65
+ This class override UIImageView's `animationRepeatCount` property on iOS, use this property as well.
66
+ */
67
+ @property (nonatomic, assign) NSInteger animationRepeatCount;
68
+ /**
69
+ The animation playback rate. Default is 1.0.
70
+ `1.0` means the normal speed.
71
+ `0.0` means stopping the animation.
72
+ `0.0-1.0` means the slow speed.
73
+ `> 1.0` means the fast speed.
74
+ `< 0.0` is not supported currently and stop animation. (may support reverse playback in the future)
75
+ */
76
+ @property (nonatomic, assign) double playbackRate;
77
+
78
+ /// Asynchronous setup animation playback mode. Default mode is SDAnimatedImagePlaybackModeNormal.
79
+ @property (nonatomic, assign) SDAnimatedImagePlaybackMode playbackMode;
80
+
81
+ /**
82
+ Provide a max buffer size by bytes. This is used to adjust frame buffer count and can be useful when the decoding cost is expensive (such as Animated WebP software decoding). Default is 0.
83
+ `0` means automatically adjust by calculating current memory usage.
84
+ `1` means without any buffer cache, each of frames will be decoded and then be freed after rendering. (Lowest Memory and Highest CPU)
85
+ `NSUIntegerMax` means cache all the buffer. (Lowest CPU and Highest Memory)
86
+ */
87
+ @property (nonatomic, assign) NSUInteger maxBufferSize;
88
+ /**
89
+ Whehter or not to enable incremental image load for animated image. This is for the animated image which `sd_isIncremental` is YES (See `UIImage+Metadata.h`). If enable, animated image rendering will stop at the last frame available currently, and continue when another `setImage:` trigger, where the new animated image's `animatedImageData` should be updated from the previous one. If the `sd_isIncremental` is NO. The incremental image load stop.
90
+ @note If you are confused about this description, open Chrome browser to view some large GIF images with low network speed to see the animation behavior.
91
+ @note The best practice to use incremental load is using `initWithAnimatedCoder:scale:` in `SDAnimatedImage` with animated coder which conform to `SDProgressiveImageCoder` as well. Then call incremental update and incremental decode method to produce the image.
92
+ Default is YES. Set to NO to only render the static poster for incremental animated image.
93
+ */
94
+ @property (nonatomic, assign) BOOL shouldIncrementalLoad;
95
+
96
+ /**
97
+ Whether or not to clear the frame buffer cache when animation stopped. See `maxBufferSize`
98
+ This is useful when you want to limit the memory usage during frequently visibility changes (such as image view inside a list view, then push and pop)
99
+ Default is NO.
100
+ */
101
+ @property (nonatomic, assign) BOOL clearBufferWhenStopped;
102
+
103
+ /**
104
+ Whether or not to reset the current frame index when animation stopped.
105
+ For some of use case, you may want to reset the frame index to 0 when stop, but some other want to keep the current frame index.
106
+ Default is NO.
107
+ */
108
+ @property (nonatomic, assign) BOOL resetFrameIndexWhenStopped;
109
+
110
+ /**
111
+ If the image which conforms to `SDAnimatedImage` protocol has more than one frame, set this value to `YES` will automatically
112
+ play/stop the animation when the view become visible/invisible.
113
+ Default is YES.
114
+ */
115
+ @property (nonatomic, assign) BOOL autoPlayAnimatedImage;
116
+
117
+ /**
118
+ You can specify a runloop mode to let it rendering.
119
+ Default is NSRunLoopCommonModes on multi-core device, NSDefaultRunLoopMode on single-core device
120
+ @note This is useful for some cases, for example, always specify NSDefaultRunLoopMode, if you want to pause the animation when user scroll (for Mac user, drag the mouse or touchpad)
121
+ */
122
+ @property (nonatomic, copy, nonnull) NSRunLoopMode runLoopMode;
123
+ @end
124
+
125
+ #endif
@@ -0,0 +1,59 @@
1
+ /*
2
+ * This file is part of the SDWebImage package.
3
+ * (c) Olivier Poitrey <rs@dailymotion.com>
4
+ *
5
+ * For the full copyright and license information, please view the LICENSE
6
+ * file that was distributed with this source code.
7
+ */
8
+
9
+
10
+ #import "SDWebImageCompat.h"
11
+
12
+ /// SDCallbackPolicy controls how we execute the block on the queue, like whether to use `dispatch_async/dispatch_sync`, check if current queue match target queue, or just invoke without any context.
13
+ typedef NS_ENUM(NSUInteger, SDCallbackPolicy) {
14
+ /// When the current queue is equal to callback queue, sync/async will just invoke `block` directly without dispatch. Else it use `dispatch_async`/`dispatch_sync` to dispatch block on queue. This is useful for UIKit rendering to ensure all blocks executed in the same runloop
15
+ SDCallbackPolicySafeExecute = 0,
16
+ /// Follow async/sync using the correspond `dispatch_async`/`dispatch_sync` to dispatch block on queue
17
+ SDCallbackPolicyDispatch = 1,
18
+ /// Ignore any async/sync and just directly invoke `block` in current queue (without `dispatch_async`/`dispatch_sync`)
19
+ SDCallbackPolicyInvoke = 2,
20
+ /// Ensure callback in main thread. Do `dispatch_async` if the `NSThread.isMainTrhead == true` ; else do invoke `block`. Never use `dispatch_sync`, suitable for special UI-related code
21
+ SDCallbackPolicySafeAsyncMainThread = 3,
22
+ };
23
+
24
+ /// SDCallbackQueue is a wrapper used to control how the completionBlock should perform on queues, used by our `Cache`/`Manager`/`Loader`.
25
+ /// Useful when you call SDWebImage in non-main queue and want to avoid it callback into main queue, which may cause issue.
26
+ @interface SDCallbackQueue : NSObject
27
+
28
+ /// The main queue. This is the default value, has the same effect when passing `nil` to `SDWebImageContextCallbackQueue`
29
+ /// The policy defaults to `SDCallbackPolicySafeAsyncMainThread`
30
+ @property (nonnull, class, readonly) SDCallbackQueue *mainQueue;
31
+
32
+ /// The caller current queue. Using `dispatch_get_current_queue`. This is not a dynamic value and only keep the first call time queue.
33
+ /// The policy defaults to `SDCallbackPolicySafeExecute`
34
+ @property (nonnull, class, readonly) SDCallbackQueue *currentQueue;
35
+
36
+ /// The global concurrent queue (user-initiated QoS). Using `dispatch_get_global_queue`.
37
+ /// The policy defaults to `SDCallbackPolicySafeExecute`
38
+ @property (nonnull, class, readonly) SDCallbackQueue *globalQueue;
39
+
40
+ /// The current queue's callback policy.
41
+ @property (nonatomic, assign, readwrite) SDCallbackPolicy policy;
42
+
43
+ - (nonnull instancetype)init NS_UNAVAILABLE;
44
+ + (nonnull instancetype)new NS_UNAVAILABLE;
45
+ /// Create the callback queue with a GCD queue. The policy defaults to `SDCallbackPolicySafeExecute`
46
+ /// - Parameter queue: The GCD queue, should not be NULL
47
+ - (nonnull instancetype)initWithDispatchQueue:(nonnull dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER;
48
+
49
+ #pragma mark - Execution Entry
50
+
51
+ /// Submits a block for execution and returns after that block finishes executing.
52
+ /// - Parameter block: The block that contains the work to perform.
53
+ - (void)sync:(nonnull dispatch_block_t)block API_DEPRECATED("No longer use, may cause deadlock when misused", macos(10.10, 10.10), ios(8.0, 8.0), tvos(9.0, 9.0), watchos(2.0, 2.0));;
54
+
55
+ /// Schedules a block asynchronously for execution.
56
+ /// - Parameter block: The block that contains the work to perform.
57
+ - (void)async:(nonnull dispatch_block_t)block;
58
+
59
+ @end
@@ -0,0 +1,146 @@
1
+ /*
2
+ * This file is part of the SDWebImage package.
3
+ * (c) Olivier Poitrey <rs@dailymotion.com>
4
+ *
5
+ * For the full copyright and license information, please view the LICENSE
6
+ * file that was distributed with this source code.
7
+ */
8
+
9
+ #import "SDWebImageCompat.h"
10
+
11
+ @class SDImageCacheConfig;
12
+ /**
13
+ A protocol to allow custom disk cache used in SDImageCache.
14
+ */
15
+ @protocol SDDiskCache <NSObject>
16
+
17
+ // All of these method are called from the same global queue to avoid blocking on main queue and thread-safe problem. But it's also recommend to ensure thread-safe yourself using lock or other ways.
18
+ @required
19
+ /**
20
+ Create a new disk cache based on the specified path. You can check `maxDiskSize` and `maxDiskAge` used for disk cache.
21
+
22
+ @param cachePath Full path of a directory in which the cache will write data.
23
+ Once initialized you should not read and write to this directory.
24
+ @param config The cache config to be used to create the cache.
25
+
26
+ @return A new cache object, or nil if an error occurs.
27
+ */
28
+ - (nullable instancetype)initWithCachePath:(nonnull NSString *)cachePath config:(nonnull SDImageCacheConfig *)config;
29
+
30
+ /**
31
+ Returns a boolean value that indicates whether a given key is in cache.
32
+ This method may blocks the calling thread until file read finished.
33
+
34
+ @param key A string identifying the data. If nil, just return NO.
35
+ @return Whether the key is in cache.
36
+ */
37
+ - (BOOL)containsDataForKey:(nonnull NSString *)key;
38
+
39
+ /**
40
+ Returns the data associated with a given key.
41
+ This method may blocks the calling thread until file read finished.
42
+
43
+ @param key A string identifying the data. If nil, just return nil.
44
+ @return The value associated with key, or nil if no value is associated with key.
45
+ */
46
+ - (nullable NSData *)dataForKey:(nonnull NSString *)key;
47
+
48
+ /**
49
+ Sets the value of the specified key in the cache.
50
+ This method may blocks the calling thread until file write finished.
51
+
52
+ @param data The data to be stored in the cache.
53
+ @param key The key with which to associate the value. If nil, this method has no effect.
54
+ */
55
+ - (void)setData:(nullable NSData *)data forKey:(nonnull NSString *)key;
56
+
57
+ /**
58
+ Returns the extended data associated with a given key.
59
+ This method may blocks the calling thread until file read finished.
60
+
61
+ @param key A string identifying the data. If nil, just return nil.
62
+ @return The value associated with key, or nil if no value is associated with key.
63
+ */
64
+ - (nullable NSData *)extendedDataForKey:(nonnull NSString *)key;
65
+
66
+ /**
67
+ Set extended data with a given key.
68
+
69
+ @discussion You can set any extended data to exist cache key. Without override the exist disk file data.
70
+ on UNIX, the common way for this is to use the Extended file attributes (xattr)
71
+
72
+ @param extendedData The extended data (pass nil to remove).
73
+ @param key The key with which to associate the value. If nil, this method has no effect.
74
+ */
75
+ - (void)setExtendedData:(nullable NSData *)extendedData forKey:(nonnull NSString *)key;
76
+
77
+ /**
78
+ Removes the value of the specified key in the cache.
79
+ This method may blocks the calling thread until file delete finished.
80
+
81
+ @param key The key identifying the value to be removed. If nil, this method has no effect.
82
+ */
83
+ - (void)removeDataForKey:(nonnull NSString *)key;
84
+
85
+ /**
86
+ Empties the cache.
87
+ This method may blocks the calling thread until file delete finished.
88
+ */
89
+ - (void)removeAllData;
90
+
91
+ /**
92
+ Removes the expired data from the cache. You can choose the data to remove base on `ageLimit`, `countLimit` and `sizeLimit` options.
93
+ */
94
+ - (void)removeExpiredData;
95
+
96
+ /**
97
+ The cache path for key
98
+
99
+ @param key A string identifying the value
100
+ @return The cache path for key. Or nil if the key can not associate to a path
101
+ */
102
+ - (nullable NSString *)cachePathForKey:(nonnull NSString *)key;
103
+
104
+ /**
105
+ Returns the number of data in this cache.
106
+ This method may blocks the calling thread until file read finished.
107
+
108
+ @return The total data count.
109
+ */
110
+ - (NSUInteger)totalCount;
111
+
112
+ /**
113
+ Returns the total size (in bytes) of data in this cache.
114
+ This method may blocks the calling thread until file read finished.
115
+
116
+ @return The total data size in bytes.
117
+ */
118
+ - (NSUInteger)totalSize;
119
+
120
+ @end
121
+
122
+ /**
123
+ The built-in disk cache.
124
+ */
125
+ @interface SDDiskCache : NSObject <SDDiskCache>
126
+ /**
127
+ Cache Config object - storing all kind of settings.
128
+ */
129
+ @property (nonatomic, strong, readonly, nonnull) SDImageCacheConfig *config;
130
+
131
+ - (nonnull instancetype)init NS_UNAVAILABLE;
132
+ + (nonnull instancetype)new NS_UNAVAILABLE;
133
+
134
+ /**
135
+ Move the cache directory from old location to new location, the old location will be removed after finish.
136
+ If the old location does not exist, does nothing.
137
+ If the new location does not exist, only do a movement of directory.
138
+ If the new location does exist, will move and merge the files from old location.
139
+ If the new location does exist, but is not a directory, will remove it and do a movement of directory.
140
+
141
+ @param srcPath old location of cache directory
142
+ @param dstPath new location of cache directory
143
+ */
144
+ - (void)moveCacheDirectoryFromPath:(nonnull NSString *)srcPath toPath:(nonnull NSString *)dstPath;
145
+
146
+ @end