@momo-kits/native-kits 0.0.1-beta.5 → 0.89.1-2

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 (406) hide show
  1. package/README.md +1 -0
  2. package/android/.gradle/8.0/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/8.0/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/8.0/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/8.0/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/8.0/gc.properties +0 -0
  8. package/android/.gradle/config.properties +2 -0
  9. package/android/.gradle/vcs-1/gc.properties +0 -0
  10. package/android/.idea/gradle.xml +12 -0
  11. package/android/.idea/migrations.xml +10 -0
  12. package/android/.idea/misc.xml +10 -0
  13. package/android/.idea/vcs.xml +6 -0
  14. package/android/.idea/workspace.xml +50 -0
  15. package/android/build.gradle +35 -69
  16. package/android/local.properties +8 -0
  17. package/android/proguard-rules.pro +21 -0
  18. package/android/src/main/AndroidManifest.xml +2 -2
  19. package/android/src/main/java/com/momoplatform/nativekits/foundations/Button.kt +16 -0
  20. package/android/src/main/java/com/momoplatform/nativekits/libs/Logo.kt +63 -0
  21. package/android/src/main/java/com/momoplatform/nativekits/libs/TrustBanner.kt +246 -0
  22. package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
  23. package/android/src/main/res/drawable-v24/ic_launcher_foreground.xml +30 -0
  24. package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
  25. package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
  26. package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
  27. package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
  28. package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
  29. package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
  30. package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
  31. package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
  32. package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
  33. package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
  34. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
  35. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
  36. package/android/src/main/res/values/colors.xml +10 -0
  37. package/android/src/main/res/values/strings.xml +3 -0
  38. package/android/src/main/res/values/themes.xml +3 -0
  39. package/android/src/main/res/values-night/themes.xml +3 -0
  40. package/android/src/main/res/xml/backup_rules.xml +13 -0
  41. package/android/src/main/res/xml/data_extraction_rules.xml +19 -0
  42. package/build.gradle.kts +18 -0
  43. package/compose/build.gradle.kts +82 -0
  44. package/compose/src/androidMain/AndroidManifest.xml +2 -0
  45. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
  46. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +8 -0
  47. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Utils.android.kt +14 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Components.kt +194 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +197 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +133 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +62 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +27 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +288 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +80 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +42 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +126 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +51 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +299 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +246 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +223 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +244 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +281 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PromotionPopup.kt +72 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +65 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +64 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +63 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +73 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +42 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +150 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +173 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +242 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +2 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1321 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +5 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +97 -0
  83. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
  84. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +9 -0
  85. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Utils.ios.kt +18 -0
  86. package/gradle.properties +19 -0
  87. package/gradlew +240 -0
  88. package/gradlew.bat +91 -0
  89. package/ios/Button/Button.swift +9 -2
  90. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
  91. package/ios/Colors+Radius+Spacing/Colors.swift +21 -19
  92. package/ios/Input/Input.swift +1 -0
  93. package/ios/OTPKeyboard/KeyboardButton.swift +12 -4
  94. package/ios/Popup/PopupDisplay.swift +72 -81
  95. package/ios/Popup/PopupInput.swift +96 -0
  96. package/ios/Popup/PopupPromotion.swift +52 -0
  97. package/ios/ScrollIndicator/ScrollIndicator.swift +79 -0
  98. package/ios/Template/Logo/Logo.swift +75 -0
  99. package/ios/Template/TrustBanner/TrustBanner.swift +189 -0
  100. package/ios/native-kits.podspec +1 -1
  101. package/local.properties +8 -0
  102. package/package.json +6 -6
  103. package/publish.sh +1 -10
  104. package/settings.gradle.kts +41 -0
  105. package/android/gradle.properties +0 -5
  106. package/android/src/main/java/com/momoplatform/nativekits/NativeKitsPackage.kt +0 -17
  107. package/android/src/main/java/com/momoplatform/nativekits/NativeKitsViewManager.kt +0 -20
  108. package/example/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -63
  109. package/example/ios/Example/Assets.xcassets/Background.colorset/Contents.json +0 -38
  110. package/example/ios/Example/Assets.xcassets/Border.colorset/Contents.json +0 -38
  111. package/example/ios/Example/Assets.xcassets/Card.colorset/Contents.json +0 -38
  112. package/example/ios/Example/Assets.xcassets/Contents.json +0 -6
  113. package/example/ios/Example/Assets.xcassets/Error.colorset/Contents.json +0 -38
  114. package/example/ios/Example/Assets.xcassets/Primary.colorset/Contents.json +0 -38
  115. package/example/ios/Example/Assets.xcassets/PrimaryDark.colorset/Contents.json +0 -38
  116. package/example/ios/Example/Assets.xcassets/PrimaryLight.colorset/Contents.json +0 -38
  117. package/example/ios/Example/Assets.xcassets/Secondary.colorset/Contents.json +0 -38
  118. package/example/ios/Example/Assets.xcassets/Success.colorset/Contents.json +0 -38
  119. package/example/ios/Example/Assets.xcassets/Text.colorset/Contents.json +0 -38
  120. package/example/ios/Example/Assets.xcassets/TextSecondary.colorset/Contents.json +0 -38
  121. package/example/ios/Example/Assets.xcassets/Warning.colorset/Contents.json +0 -38
  122. package/example/ios/Example/ComponentDetail.swift +0 -35
  123. package/example/ios/Example/ComponentItem.swift +0 -24
  124. package/example/ios/Example/ComponentModel.swift +0 -38
  125. package/example/ios/Example/ContentView.swift +0 -39
  126. package/example/ios/Example/Example.entitlements +0 -10
  127. package/example/ios/Example/Foundation/ButtonDemo.swift +0 -80
  128. package/example/ios/Example/Foundation/ImageDemo.swift +0 -43
  129. package/example/ios/Example/Foundation/Popup/ActionSheets.swift +0 -136
  130. package/example/ios/Example/Foundation/Popup/Floats.swift +0 -127
  131. package/example/ios/Example/Foundation/Popup/Popups.swift +0 -51
  132. package/example/ios/Example/Foundation/PopupDemo.swift +0 -389
  133. package/example/ios/Example/Foundation/TextInputDemo.swift +0 -36
  134. package/example/ios/Example/Foundation/TypographyDemo.swift +0 -53
  135. package/example/ios/Example/Foundation.swift +0 -26
  136. package/example/ios/Example/Info.plist +0 -18
  137. package/example/ios/Example/Library/CheckboxDemo.swift +0 -19
  138. package/example/ios/Example/Library/SwipeableDemo.swift +0 -105
  139. package/example/ios/Example/Library/SwitchDemo.swift +0 -19
  140. package/example/ios/Example/Library.swift +0 -26
  141. package/example/ios/Example/Main.swift +0 -27
  142. package/example/ios/Example/Overview.swift +0 -20
  143. package/example/ios/Example/Preview Content/Preview Assets.xcassets/Contents.json +0 -6
  144. package/example/ios/Example/Resource/SFProText-Black.ttf +0 -0
  145. package/example/ios/Example/Resource/SFProText-Bold.ttf +0 -0
  146. package/example/ios/Example/Resource/SFProText-Heavy.ttf +0 -0
  147. package/example/ios/Example/Resource/SFProText-Light.ttf +0 -0
  148. package/example/ios/Example/Resource/SFProText-Medium.ttf +0 -0
  149. package/example/ios/Example/Resource/SFProText-Regular.ttf +0 -0
  150. package/example/ios/Example/Resource/SFProText-Semibold.ttf +0 -0
  151. package/example/ios/Example/Resource/SFProText-Thin.ttf +0 -0
  152. package/example/ios/Example/Resource/SFProText-Ultralight.ttf +0 -0
  153. package/example/ios/Example/Resource/foundation.json +0 -33
  154. package/example/ios/Example/Resource/library.json +0 -18
  155. package/example/ios/Example/Utils.swift +0 -30
  156. package/example/ios/Example/ViewModifier/DarkViewModifier.swift +0 -22
  157. package/example/ios/Example.xcodeproj/project.pbxproj +0 -581
  158. package/example/ios/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  159. package/example/ios/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  160. package/example/ios/Example.xcodeproj/project.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  161. package/example/ios/Example.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  162. package/example/ios/Example.xcworkspace/contents.xcworkspacedata +0 -10
  163. package/example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  164. package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  165. package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
  166. package/example/ios/Podfile +0 -7
  167. package/example/ios/Podfile.lock +0 -35
  168. package/example/ios/Pods/Local Podspecs/MoMoUIKits.podspec.json +0 -37
  169. package/example/ios/Pods/Manifest.lock +0 -35
  170. package/example/ios/Pods/Pods.xcodeproj/project.pbxproj +0 -2047
  171. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
  172. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
  173. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
  174. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
  175. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
  176. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
  177. package/example/ios/Pods/SDWebImage/LICENSE +0 -20
  178. package/example/ios/Pods/SDWebImage/README.md +0 -352
  179. package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSButton+WebCache.h +0 -340
  180. package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSButton+WebCache.m +0 -172
  181. package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.h +0 -63
  182. package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.m +0 -165
  183. package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.h +0 -67
  184. package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.m +0 -120
  185. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImage.h +0 -114
  186. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImage.m +0 -392
  187. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImagePlayer.h +0 -112
  188. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImagePlayer.m +0 -420
  189. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageRep.h +0 -23
  190. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageRep.m +0 -133
  191. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView+WebCache.h +0 -168
  192. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView+WebCache.m +0 -79
  193. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView.h +0 -110
  194. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView.m +0 -540
  195. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDDiskCache.h +0 -145
  196. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDDiskCache.m +0 -326
  197. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDGraphicsImageRenderer.h +0 -73
  198. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDGraphicsImageRenderer.m +0 -256
  199. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAPNGCoder.h +0 -19
  200. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAPNGCoder.m +0 -58
  201. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAWebPCoder.h +0 -23
  202. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAWebPCoder.m +0 -98
  203. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCache.h +0 -450
  204. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCache.m +0 -1030
  205. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheConfig.h +0 -153
  206. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheConfig.m +0 -68
  207. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheDefine.h +0 -156
  208. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheDefine.m +0 -138
  209. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCachesManager.h +0 -81
  210. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCachesManager.m +0 -556
  211. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoder.h +0 -297
  212. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoder.m +0 -26
  213. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.h +0 -153
  214. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.m +0 -822
  215. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCodersManager.h +0 -58
  216. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCodersManager.m +0 -130
  217. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageFrame.h +0 -36
  218. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageFrame.m +0 -28
  219. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGIFCoder.h +0 -22
  220. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGIFCoder.m +0 -58
  221. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGraphics.h +0 -28
  222. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGraphics.m +0 -127
  223. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageHEICCoder.h +0 -25
  224. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageHEICCoder.m +0 -101
  225. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOAnimatedCoder.h +0 -58
  226. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOAnimatedCoder.m +0 -807
  227. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOCoder.h +0 -30
  228. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOCoder.m +0 -420
  229. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoader.h +0 -146
  230. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoader.m +0 -170
  231. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoadersManager.h +0 -40
  232. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoadersManager.m +0 -123
  233. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageTransformer.h +0 -241
  234. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageTransformer.m +0 -331
  235. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDMemoryCache.h +0 -78
  236. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDMemoryCache.m +0 -158
  237. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.h +0 -32
  238. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.m +0 -39
  239. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.h +0 -36
  240. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.m +0 -39
  241. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.h +0 -95
  242. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.m +0 -17
  243. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDefine.h +0 -352
  244. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDefine.m +0 -149
  245. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloader.h +0 -314
  246. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloader.m +0 -658
  247. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderConfig.h +0 -113
  248. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderConfig.m +0 -60
  249. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderDecryptor.h +0 -49
  250. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderDecryptor.m +0 -55
  251. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderOperation.h +0 -191
  252. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderOperation.m +0 -722
  253. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h +0 -69
  254. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.m +0 -71
  255. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderResponseModifier.h +0 -69
  256. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderResponseModifier.m +0 -73
  257. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageError.h +0 -32
  258. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageError.m +0 -16
  259. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageIndicator.h +0 -115
  260. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageIndicator.m +0 -275
  261. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageManager.h +0 -290
  262. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageManager.m +0 -775
  263. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOperation.h +0 -27
  264. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOperation.m +0 -14
  265. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.h +0 -72
  266. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.m +0 -59
  267. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImagePrefetcher.h +0 -143
  268. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImagePrefetcher.m +0 -303
  269. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageTransition.h +0 -131
  270. package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageTransition.m +0 -194
  271. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIButton+WebCache.h +0 -387
  272. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIButton+WebCache.m +0 -234
  273. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ExtendedCacheData.h +0 -24
  274. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ExtendedCacheData.m +0 -23
  275. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.h +0 -46
  276. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.m +0 -60
  277. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.h +0 -26
  278. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.m +0 -22
  279. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.h +0 -27
  280. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.m +0 -47
  281. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.h +0 -89
  282. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.m +0 -221
  283. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MultiFormat.h +0 -80
  284. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MultiFormat.m +0 -47
  285. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Transform.h +0 -146
  286. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Transform.m +0 -824
  287. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+HighlightedWebCache.h +0 -129
  288. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+HighlightedWebCache.m +0 -76
  289. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+WebCache.h +0 -194
  290. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+WebCache.m +0 -67
  291. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCache.h +0 -110
  292. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCache.m +0 -446
  293. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCacheOperation.h +0 -48
  294. package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCacheOperation.m +0 -82
  295. package/example/ios/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+SDRoundedCorners.h +0 -24
  296. package/example/ios/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+SDRoundedCorners.m +0 -42
  297. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAssociatedObject.h +0 -14
  298. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAssociatedObject.m +0 -29
  299. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h +0 -21
  300. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.m +0 -92
  301. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDeviceHelper.h +0 -18
  302. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDeviceHelper.m +0 -32
  303. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDisplayLink.h +0 -29
  304. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDisplayLink.m +0 -227
  305. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDFileAttributeHelper.h +0 -19
  306. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDFileAttributeHelper.m +0 -127
  307. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.h +0 -23
  308. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.m +0 -164
  309. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h +0 -21
  310. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.m +0 -83
  311. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageIOAnimatedCoderInternal.h +0 -39
  312. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.h +0 -122
  313. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.m +0 -13
  314. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.h +0 -20
  315. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.m +0 -79
  316. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWebImageTransitionInternal.h +0 -19
  317. package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDmetamacros.h +0 -667
  318. package/example/ios/Pods/SDWebImage/SDWebImage/Private/UIColor+SDHexString.h +0 -18
  319. package/example/ios/Pods/SDWebImage/SDWebImage/Private/UIColor+SDHexString.m +0 -42
  320. package/example/ios/Pods/SDWebImage/WebImage/SDWebImage.h +0 -89
  321. package/example/ios/Pods/SDWebImageSwiftUI/LICENSE +0 -19
  322. package/example/ios/Pods/SDWebImageSwiftUI/README.md +0 -690
  323. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/AnimatedImage.swift +0 -870
  324. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/Backport.swift +0 -59
  325. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/OnChange.swift +0 -52
  326. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/Overlay.swift +0 -124
  327. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/StateObject.swift +0 -151
  328. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Image.swift +0 -78
  329. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImageManager.swift +0 -132
  330. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImagePlayer.swift +0 -122
  331. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImageViewWrapper.swift +0 -133
  332. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/ActivityIndicator.swift +0 -82
  333. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift +0 -97
  334. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/ProgressIndicator.swift +0 -114
  335. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/SDWebImageSwiftUI.swift +0 -64
  336. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/SwiftUICompatibility.swift +0 -92
  337. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Transition/Transition.swift +0 -93
  338. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/WebImage.swift +0 -509
  339. package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Module/SDWebImageSwiftUI.h +0 -15
  340. package/example/ios/Pods/SkeletonUI/LICENSE +0 -21
  341. package/example/ios/Pods/SkeletonUI/README.md +0 -137
  342. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Angle/AngleInteractor.swift +0 -29
  343. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Angle/AnglePresenter.swift +0 -7
  344. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Animation/AnimationInteractor.swift +0 -56
  345. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Appearance/AppearanceInteractor.swift +0 -58
  346. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Appearance/AppearancePresenter.swift +0 -5
  347. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/ClosedRange+Normalize.swift +0 -16
  348. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Image+OptionalType.swift +0 -102
  349. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/ModifiedContent+SkeletonModifier.swift +0 -26
  350. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Optional+OptionalType.swift +0 -5
  351. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/SecureField+OptionalType.swift +0 -19
  352. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Text+OptionalType.swift +0 -27
  353. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/TextField+OptionalType.swift +0 -35
  354. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Toggle+OptionalType.swift +0 -29
  355. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift +0 -8
  356. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/View+SkeletonModifier.swift +0 -8
  357. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift +0 -52
  358. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Multiline/MultilineInteractor.swift +0 -41
  359. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Multiline/MultilinePresenter.swift +0 -9
  360. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Opacity/OpacityInteractor.swift +0 -29
  361. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Opacity/OpacityPresenter.swift +0 -7
  362. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Position/PositionInteractor.swift +0 -29
  363. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Position/PositionPresenter.swift +0 -7
  364. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Protocols/OptionalType.swift +0 -4
  365. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Radius/RadiusInteractor.swift +0 -29
  366. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Radius/RadiusPresenter.swift +0 -7
  367. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Shape/ShapeInteractor.swift +0 -33
  368. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Shape/ShapePresenter.swift +0 -5
  369. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonForEach.swift +0 -20
  370. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift +0 -27
  371. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonList.swift +0 -20
  372. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift +0 -15
  373. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonShape.swift +0 -64
  374. package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonView.swift +0 -25
  375. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-dummy.m +0 -5
  376. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-prefix.pch +0 -12
  377. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-umbrella.h +0 -16
  378. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.debug.xcconfig +0 -15
  379. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.modulemap +0 -6
  380. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.release.xcconfig +0 -15
  381. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.markdown +0 -75
  382. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.plist +0 -119
  383. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-dummy.m +0 -5
  384. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-umbrella.h +0 -16
  385. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig +0 -15
  386. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.modulemap +0 -6
  387. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig +0 -15
  388. package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m +0 -5
  389. package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch +0 -12
  390. package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h +0 -75
  391. package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.debug.xcconfig +0 -14
  392. package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap +0 -6
  393. package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.release.xcconfig +0 -14
  394. package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-dummy.m +0 -5
  395. package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-prefix.pch +0 -12
  396. package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-umbrella.h +0 -17
  397. package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.debug.xcconfig +0 -17
  398. package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.modulemap +0 -6
  399. package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.release.xcconfig +0 -17
  400. package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-dummy.m +0 -5
  401. package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-prefix.pch +0 -12
  402. package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-umbrella.h +0 -16
  403. package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.debug.xcconfig +0 -12
  404. package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.modulemap +0 -6
  405. package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.release.xcconfig +0 -12
  406. package/ios/Extensions/View++.swift +0 -9
@@ -1,658 +0,0 @@
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 "SDWebImageDownloader.h"
10
- #import "SDWebImageDownloaderConfig.h"
11
- #import "SDWebImageDownloaderOperation.h"
12
- #import "SDWebImageError.h"
13
- #import "SDWebImageCacheKeyFilter.h"
14
- #import "SDImageCacheDefine.h"
15
- #import "SDInternalMacros.h"
16
-
17
- NSNotificationName const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification";
18
- NSNotificationName const SDWebImageDownloadReceiveResponseNotification = @"SDWebImageDownloadReceiveResponseNotification";
19
- NSNotificationName const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification";
20
- NSNotificationName const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinishNotification";
21
-
22
- static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext;
23
-
24
- @interface SDWebImageDownloadToken ()
25
-
26
- @property (nonatomic, strong, nullable, readwrite) NSURL *url;
27
- @property (nonatomic, strong, nullable, readwrite) NSURLRequest *request;
28
- @property (nonatomic, strong, nullable, readwrite) NSURLResponse *response;
29
- @property (nonatomic, strong, nullable, readwrite) NSURLSessionTaskMetrics *metrics API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0));
30
- @property (nonatomic, weak, nullable, readwrite) id downloadOperationCancelToken;
31
- @property (nonatomic, weak, nullable) NSOperation<SDWebImageDownloaderOperation> *downloadOperation;
32
- @property (nonatomic, assign, getter=isCancelled) BOOL cancelled;
33
-
34
- - (nonnull instancetype)init NS_UNAVAILABLE;
35
- + (nonnull instancetype)new NS_UNAVAILABLE;
36
- - (nonnull instancetype)initWithDownloadOperation:(nullable NSOperation<SDWebImageDownloaderOperation> *)downloadOperation;
37
-
38
- @end
39
-
40
- @interface SDWebImageDownloader () <NSURLSessionTaskDelegate, NSURLSessionDataDelegate>
41
-
42
- @property (strong, nonatomic, nonnull) NSOperationQueue *downloadQueue;
43
- @property (strong, nonatomic, nonnull) NSMutableDictionary<NSURL *, NSOperation<SDWebImageDownloaderOperation> *> *URLOperations;
44
- @property (strong, nonatomic, nullable) NSMutableDictionary<NSString *, NSString *> *HTTPHeaders;
45
-
46
- // The session in which data tasks will run
47
- @property (strong, nonatomic) NSURLSession *session;
48
-
49
- @end
50
-
51
- @implementation SDWebImageDownloader {
52
- SD_LOCK_DECLARE(_HTTPHeadersLock); // A lock to keep the access to `HTTPHeaders` thread-safe
53
- SD_LOCK_DECLARE(_operationsLock); // A lock to keep the access to `URLOperations` thread-safe
54
- }
55
-
56
- + (void)initialize {
57
- // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator )
58
- // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
59
- if (NSClassFromString(@"SDNetworkActivityIndicator")) {
60
-
61
- #pragma clang diagnostic push
62
- #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
63
- id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")];
64
- #pragma clang diagnostic pop
65
-
66
- // Remove observer in case it was previously added.
67
- [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil];
68
- [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil];
69
-
70
- [[NSNotificationCenter defaultCenter] addObserver:activityIndicator
71
- selector:NSSelectorFromString(@"startActivity")
72
- name:SDWebImageDownloadStartNotification object:nil];
73
- [[NSNotificationCenter defaultCenter] addObserver:activityIndicator
74
- selector:NSSelectorFromString(@"stopActivity")
75
- name:SDWebImageDownloadStopNotification object:nil];
76
- }
77
- }
78
-
79
- + (nonnull instancetype)sharedDownloader {
80
- static dispatch_once_t once;
81
- static id instance;
82
- dispatch_once(&once, ^{
83
- instance = [self new];
84
- });
85
- return instance;
86
- }
87
-
88
- - (nonnull instancetype)init {
89
- return [self initWithConfig:SDWebImageDownloaderConfig.defaultDownloaderConfig];
90
- }
91
-
92
- - (instancetype)initWithConfig:(SDWebImageDownloaderConfig *)config {
93
- self = [super init];
94
- if (self) {
95
- if (!config) {
96
- config = SDWebImageDownloaderConfig.defaultDownloaderConfig;
97
- }
98
- _config = [config copy];
99
- [_config addObserver:self forKeyPath:NSStringFromSelector(@selector(maxConcurrentDownloads)) options:0 context:SDWebImageDownloaderContext];
100
- _downloadQueue = [NSOperationQueue new];
101
- _downloadQueue.maxConcurrentOperationCount = _config.maxConcurrentDownloads;
102
- _downloadQueue.name = @"com.hackemist.SDWebImageDownloader";
103
- _URLOperations = [NSMutableDictionary new];
104
- NSMutableDictionary<NSString *, NSString *> *headerDictionary = [NSMutableDictionary dictionary];
105
- NSString *userAgent = nil;
106
- #if SD_UIKIT
107
- // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
108
- userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
109
- #elif SD_WATCH
110
- // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
111
- userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]];
112
- #elif SD_MAC
113
- userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]];
114
- #endif
115
- if (userAgent) {
116
- if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) {
117
- NSMutableString *mutableUserAgent = [userAgent mutableCopy];
118
- if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) {
119
- userAgent = mutableUserAgent;
120
- }
121
- }
122
- headerDictionary[@"User-Agent"] = userAgent;
123
- }
124
- headerDictionary[@"Accept"] = @"image/*,*/*;q=0.8";
125
- _HTTPHeaders = headerDictionary;
126
- SD_LOCK_INIT(_HTTPHeadersLock);
127
- SD_LOCK_INIT(_operationsLock);
128
- NSURLSessionConfiguration *sessionConfiguration = _config.sessionConfiguration;
129
- if (!sessionConfiguration) {
130
- sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
131
- }
132
- /**
133
- * Create the session for this task
134
- * We send nil as delegate queue so that the session creates a serial operation queue for performing all delegate
135
- * method calls and completion handler calls.
136
- */
137
- _session = [NSURLSession sessionWithConfiguration:sessionConfiguration
138
- delegate:self
139
- delegateQueue:nil];
140
- }
141
- return self;
142
- }
143
-
144
- - (void)dealloc {
145
- [self.downloadQueue cancelAllOperations];
146
- [self.config removeObserver:self forKeyPath:NSStringFromSelector(@selector(maxConcurrentDownloads)) context:SDWebImageDownloaderContext];
147
-
148
- // Invalide the URLSession after all operations been cancelled
149
- [self.session invalidateAndCancel];
150
- self.session = nil;
151
- }
152
-
153
- - (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations {
154
- if (self == [SDWebImageDownloader sharedDownloader]) {
155
- return;
156
- }
157
- if (cancelPendingOperations) {
158
- [self.session invalidateAndCancel];
159
- } else {
160
- [self.session finishTasksAndInvalidate];
161
- }
162
- }
163
-
164
- - (void)setValue:(nullable NSString *)value forHTTPHeaderField:(nullable NSString *)field {
165
- if (!field) {
166
- return;
167
- }
168
- SD_LOCK(_HTTPHeadersLock);
169
- [self.HTTPHeaders setValue:value forKey:field];
170
- SD_UNLOCK(_HTTPHeadersLock);
171
- }
172
-
173
- - (nullable NSString *)valueForHTTPHeaderField:(nullable NSString *)field {
174
- if (!field) {
175
- return nil;
176
- }
177
- SD_LOCK(_HTTPHeadersLock);
178
- NSString *value = [self.HTTPHeaders objectForKey:field];
179
- SD_UNLOCK(_HTTPHeadersLock);
180
- return value;
181
- }
182
-
183
- - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(NSURL *)url
184
- completed:(SDWebImageDownloaderCompletedBlock)completedBlock {
185
- return [self downloadImageWithURL:url options:0 progress:nil completed:completedBlock];
186
- }
187
-
188
- - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(NSURL *)url
189
- options:(SDWebImageDownloaderOptions)options
190
- progress:(SDWebImageDownloaderProgressBlock)progressBlock
191
- completed:(SDWebImageDownloaderCompletedBlock)completedBlock {
192
- return [self downloadImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock];
193
- }
194
-
195
- - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url
196
- options:(SDWebImageDownloaderOptions)options
197
- context:(nullable SDWebImageContext *)context
198
- progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
199
- completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock {
200
- // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data.
201
- if (url == nil) {
202
- if (completedBlock) {
203
- NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidURL userInfo:@{NSLocalizedDescriptionKey : @"Image url is nil"}];
204
- completedBlock(nil, nil, error, YES);
205
- }
206
- return nil;
207
- }
208
-
209
- SD_LOCK(_operationsLock);
210
- id downloadOperationCancelToken;
211
- // When different thumbnail size download with same url, we need to make sure each callback called with desired size
212
- id<SDWebImageCacheKeyFilter> cacheKeyFilter = context[SDWebImageContextCacheKeyFilter];
213
- NSString *cacheKey;
214
- if (cacheKeyFilter) {
215
- cacheKey = [cacheKeyFilter cacheKeyForURL:url];
216
- } else {
217
- cacheKey = url.absoluteString;
218
- }
219
- SDImageCoderOptions *decodeOptions = SDGetDecodeOptionsFromContext(context, [self.class imageOptionsFromDownloaderOptions:options], cacheKey);
220
- NSOperation<SDWebImageDownloaderOperation> *operation = [self.URLOperations objectForKey:url];
221
- // There is a case that the operation may be marked as finished or cancelled, but not been removed from `self.URLOperations`.
222
- if (!operation || operation.isFinished || operation.isCancelled) {
223
- operation = [self createDownloaderOperationWithUrl:url options:options context:context];
224
- if (!operation) {
225
- SD_UNLOCK(_operationsLock);
226
- if (completedBlock) {
227
- NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidDownloadOperation userInfo:@{NSLocalizedDescriptionKey : @"Downloader operation is nil"}];
228
- completedBlock(nil, nil, error, YES);
229
- }
230
- return nil;
231
- }
232
- @weakify(self);
233
- operation.completionBlock = ^{
234
- @strongify(self);
235
- if (!self) {
236
- return;
237
- }
238
- SD_LOCK(self->_operationsLock);
239
- [self.URLOperations removeObjectForKey:url];
240
- SD_UNLOCK(self->_operationsLock);
241
- };
242
- [self.URLOperations setObject:operation forKey:url];
243
- // Add the handlers before submitting to operation queue, avoid the race condition that operation finished before setting handlers.
244
- downloadOperationCancelToken = [operation addHandlersForProgress:progressBlock completed:completedBlock decodeOptions:decodeOptions];
245
- // Add operation to operation queue only after all configuration done according to Apple's doc.
246
- // `addOperation:` does not synchronously execute the `operation.completionBlock` so this will not cause deadlock.
247
- [self.downloadQueue addOperation:operation];
248
- } else {
249
- // When we reuse the download operation to attach more callbacks, there may be thread safe issue because the getter of callbacks may in another queue (decoding queue or delegate queue)
250
- // So we lock the operation here, and in `SDWebImageDownloaderOperation`, we use `@synchonzied (self)`, to ensure the thread safe between these two classes.
251
- @synchronized (operation) {
252
- downloadOperationCancelToken = [operation addHandlersForProgress:progressBlock completed:completedBlock decodeOptions:decodeOptions];
253
- }
254
- if (!operation.isExecuting) {
255
- if (options & SDWebImageDownloaderHighPriority) {
256
- operation.queuePriority = NSOperationQueuePriorityHigh;
257
- } else if (options & SDWebImageDownloaderLowPriority) {
258
- operation.queuePriority = NSOperationQueuePriorityLow;
259
- } else {
260
- operation.queuePriority = NSOperationQueuePriorityNormal;
261
- }
262
- }
263
- }
264
- SD_UNLOCK(_operationsLock);
265
-
266
- SDWebImageDownloadToken *token = [[SDWebImageDownloadToken alloc] initWithDownloadOperation:operation];
267
- token.url = url;
268
- token.request = operation.request;
269
- token.downloadOperationCancelToken = downloadOperationCancelToken;
270
-
271
- return token;
272
- }
273
-
274
- #pragma mark Helper methods
275
- + (SDWebImageOptions)imageOptionsFromDownloaderOptions:(SDWebImageDownloaderOptions)downloadOptions {
276
- SDWebImageOptions options = 0;
277
- if (downloadOptions & SDWebImageDownloaderScaleDownLargeImages) options |= SDWebImageScaleDownLargeImages;
278
- if (downloadOptions & SDWebImageDownloaderDecodeFirstFrameOnly) options |= SDWebImageDecodeFirstFrameOnly;
279
- if (downloadOptions & SDWebImageDownloaderPreloadAllFrames) options |= SDWebImagePreloadAllFrames;
280
- if (downloadOptions & SDWebImageDownloaderAvoidDecodeImage) options |= SDWebImageAvoidDecodeImage;
281
- if (downloadOptions & SDWebImageDownloaderMatchAnimatedImageClass) options |= SDWebImageMatchAnimatedImageClass;
282
-
283
- return options;
284
- }
285
-
286
- - (nullable NSOperation<SDWebImageDownloaderOperation> *)createDownloaderOperationWithUrl:(nonnull NSURL *)url
287
- options:(SDWebImageDownloaderOptions)options
288
- context:(nullable SDWebImageContext *)context {
289
- NSTimeInterval timeoutInterval = self.config.downloadTimeout;
290
- if (timeoutInterval == 0.0) {
291
- timeoutInterval = 15.0;
292
- }
293
-
294
- // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
295
- NSURLRequestCachePolicy cachePolicy = options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData;
296
- NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval];
297
- mutableRequest.HTTPShouldHandleCookies = SD_OPTIONS_CONTAINS(options, SDWebImageDownloaderHandleCookies);
298
- mutableRequest.HTTPShouldUsePipelining = YES;
299
- SD_LOCK(_HTTPHeadersLock);
300
- mutableRequest.allHTTPHeaderFields = self.HTTPHeaders;
301
- SD_UNLOCK(_HTTPHeadersLock);
302
-
303
- // Context Option
304
- SDWebImageMutableContext *mutableContext;
305
- if (context) {
306
- mutableContext = [context mutableCopy];
307
- } else {
308
- mutableContext = [NSMutableDictionary dictionary];
309
- }
310
-
311
- // Request Modifier
312
- id<SDWebImageDownloaderRequestModifier> requestModifier;
313
- if ([context valueForKey:SDWebImageContextDownloadRequestModifier]) {
314
- requestModifier = [context valueForKey:SDWebImageContextDownloadRequestModifier];
315
- } else {
316
- requestModifier = self.requestModifier;
317
- }
318
-
319
- NSURLRequest *request;
320
- if (requestModifier) {
321
- NSURLRequest *modifiedRequest = [requestModifier modifiedRequestWithRequest:[mutableRequest copy]];
322
- // If modified request is nil, early return
323
- if (!modifiedRequest) {
324
- return nil;
325
- } else {
326
- request = [modifiedRequest copy];
327
- }
328
- } else {
329
- request = [mutableRequest copy];
330
- }
331
- // Response Modifier
332
- id<SDWebImageDownloaderResponseModifier> responseModifier;
333
- if ([context valueForKey:SDWebImageContextDownloadResponseModifier]) {
334
- responseModifier = [context valueForKey:SDWebImageContextDownloadResponseModifier];
335
- } else {
336
- responseModifier = self.responseModifier;
337
- }
338
- if (responseModifier) {
339
- mutableContext[SDWebImageContextDownloadResponseModifier] = responseModifier;
340
- }
341
- // Decryptor
342
- id<SDWebImageDownloaderDecryptor> decryptor;
343
- if ([context valueForKey:SDWebImageContextDownloadDecryptor]) {
344
- decryptor = [context valueForKey:SDWebImageContextDownloadDecryptor];
345
- } else {
346
- decryptor = self.decryptor;
347
- }
348
- if (decryptor) {
349
- mutableContext[SDWebImageContextDownloadDecryptor] = decryptor;
350
- }
351
-
352
- context = [mutableContext copy];
353
-
354
- // Operation Class
355
- Class operationClass = self.config.operationClass;
356
- if (!operationClass) {
357
- operationClass = [SDWebImageDownloaderOperation class];
358
- }
359
- NSOperation<SDWebImageDownloaderOperation> *operation = [[operationClass alloc] initWithRequest:request inSession:self.session options:options context:context];
360
-
361
- if ([operation respondsToSelector:@selector(setCredential:)]) {
362
- if (self.config.urlCredential) {
363
- operation.credential = self.config.urlCredential;
364
- } else if (self.config.username && self.config.password) {
365
- operation.credential = [NSURLCredential credentialWithUser:self.config.username password:self.config.password persistence:NSURLCredentialPersistenceForSession];
366
- }
367
- }
368
-
369
- if ([operation respondsToSelector:@selector(setMinimumProgressInterval:)]) {
370
- operation.minimumProgressInterval = MIN(MAX(self.config.minimumProgressInterval, 0), 1);
371
- }
372
-
373
- if ([operation respondsToSelector:@selector(setAcceptableStatusCodes:)]) {
374
- operation.acceptableStatusCodes = self.config.acceptableStatusCodes;
375
- }
376
-
377
- if ([operation respondsToSelector:@selector(setAcceptableContentTypes:)]) {
378
- operation.acceptableContentTypes = self.config.acceptableContentTypes;
379
- }
380
-
381
- if (options & SDWebImageDownloaderHighPriority) {
382
- operation.queuePriority = NSOperationQueuePriorityHigh;
383
- } else if (options & SDWebImageDownloaderLowPriority) {
384
- operation.queuePriority = NSOperationQueuePriorityLow;
385
- }
386
-
387
- if (self.config.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) {
388
- // Emulate LIFO execution order by systematically, each previous adding operation can dependency the new operation
389
- // This can gurantee the new operation to be execulated firstly, even if when some operations finished, meanwhile you appending new operations
390
- // Just make last added operation dependents new operation can not solve this problem. See test case #test15DownloaderLIFOExecutionOrder
391
- for (NSOperation *pendingOperation in self.downloadQueue.operations) {
392
- [pendingOperation addDependency:operation];
393
- }
394
- }
395
-
396
- return operation;
397
- }
398
-
399
- - (void)cancelAllDownloads {
400
- [self.downloadQueue cancelAllOperations];
401
- }
402
-
403
- #pragma mark - Properties
404
-
405
- - (BOOL)isSuspended {
406
- return self.downloadQueue.isSuspended;
407
- }
408
-
409
- - (void)setSuspended:(BOOL)suspended {
410
- self.downloadQueue.suspended = suspended;
411
- }
412
-
413
- - (NSUInteger)currentDownloadCount {
414
- return self.downloadQueue.operationCount;
415
- }
416
-
417
- - (NSURLSessionConfiguration *)sessionConfiguration {
418
- return self.session.configuration;
419
- }
420
-
421
- #pragma mark - KVO
422
-
423
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
424
- if (context == SDWebImageDownloaderContext) {
425
- if ([keyPath isEqualToString:NSStringFromSelector(@selector(maxConcurrentDownloads))]) {
426
- self.downloadQueue.maxConcurrentOperationCount = self.config.maxConcurrentDownloads;
427
- }
428
- } else {
429
- [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
430
- }
431
- }
432
-
433
- #pragma mark Helper methods
434
-
435
- - (NSOperation<SDWebImageDownloaderOperation> *)operationWithTask:(NSURLSessionTask *)task {
436
- NSOperation<SDWebImageDownloaderOperation> *returnOperation = nil;
437
- for (NSOperation<SDWebImageDownloaderOperation> *operation in self.downloadQueue.operations) {
438
- if ([operation respondsToSelector:@selector(dataTask)]) {
439
- // So we lock the operation here, and in `SDWebImageDownloaderOperation`, we use `@synchonzied (self)`, to ensure the thread safe between these two classes.
440
- NSURLSessionTask *operationTask;
441
- @synchronized (operation) {
442
- operationTask = operation.dataTask;
443
- }
444
- if (operationTask.taskIdentifier == task.taskIdentifier) {
445
- returnOperation = operation;
446
- break;
447
- }
448
- }
449
- }
450
- return returnOperation;
451
- }
452
-
453
- #pragma mark NSURLSessionDataDelegate
454
-
455
- - (void)URLSession:(NSURLSession *)session
456
- dataTask:(NSURLSessionDataTask *)dataTask
457
- didReceiveResponse:(NSURLResponse *)response
458
- completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler {
459
-
460
- // Identify the operation that runs this task and pass it the delegate method
461
- NSOperation<SDWebImageDownloaderOperation> *dataOperation = [self operationWithTask:dataTask];
462
- if ([dataOperation respondsToSelector:@selector(URLSession:dataTask:didReceiveResponse:completionHandler:)]) {
463
- [dataOperation URLSession:session dataTask:dataTask didReceiveResponse:response completionHandler:completionHandler];
464
- } else {
465
- if (completionHandler) {
466
- completionHandler(NSURLSessionResponseAllow);
467
- }
468
- }
469
- }
470
-
471
- - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data {
472
-
473
- // Identify the operation that runs this task and pass it the delegate method
474
- NSOperation<SDWebImageDownloaderOperation> *dataOperation = [self operationWithTask:dataTask];
475
- if ([dataOperation respondsToSelector:@selector(URLSession:dataTask:didReceiveData:)]) {
476
- [dataOperation URLSession:session dataTask:dataTask didReceiveData:data];
477
- }
478
- }
479
-
480
- - (void)URLSession:(NSURLSession *)session
481
- dataTask:(NSURLSessionDataTask *)dataTask
482
- willCacheResponse:(NSCachedURLResponse *)proposedResponse
483
- completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler {
484
-
485
- // Identify the operation that runs this task and pass it the delegate method
486
- NSOperation<SDWebImageDownloaderOperation> *dataOperation = [self operationWithTask:dataTask];
487
- if ([dataOperation respondsToSelector:@selector(URLSession:dataTask:willCacheResponse:completionHandler:)]) {
488
- [dataOperation URLSession:session dataTask:dataTask willCacheResponse:proposedResponse completionHandler:completionHandler];
489
- } else {
490
- if (completionHandler) {
491
- completionHandler(proposedResponse);
492
- }
493
- }
494
- }
495
-
496
- #pragma mark NSURLSessionTaskDelegate
497
-
498
- - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {
499
-
500
- // Identify the operation that runs this task and pass it the delegate method
501
- NSOperation<SDWebImageDownloaderOperation> *dataOperation = [self operationWithTask:task];
502
- if ([dataOperation respondsToSelector:@selector(URLSession:task:didCompleteWithError:)]) {
503
- [dataOperation URLSession:session task:task didCompleteWithError:error];
504
- }
505
- }
506
-
507
- - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task willPerformHTTPRedirection:(NSHTTPURLResponse *)response newRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURLRequest * _Nullable))completionHandler {
508
-
509
- // Identify the operation that runs this task and pass it the delegate method
510
- NSOperation<SDWebImageDownloaderOperation> *dataOperation = [self operationWithTask:task];
511
- if ([dataOperation respondsToSelector:@selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)]) {
512
- [dataOperation URLSession:session task:task willPerformHTTPRedirection:response newRequest:request completionHandler:completionHandler];
513
- } else {
514
- if (completionHandler) {
515
- completionHandler(request);
516
- }
517
- }
518
- }
519
-
520
- - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler {
521
-
522
- // Identify the operation that runs this task and pass it the delegate method
523
- NSOperation<SDWebImageDownloaderOperation> *dataOperation = [self operationWithTask:task];
524
- if ([dataOperation respondsToSelector:@selector(URLSession:task:didReceiveChallenge:completionHandler:)]) {
525
- [dataOperation URLSession:session task:task didReceiveChallenge:challenge completionHandler:completionHandler];
526
- } else {
527
- if (completionHandler) {
528
- completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
529
- }
530
- }
531
- }
532
-
533
- - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0)) {
534
-
535
- // Identify the operation that runs this task and pass it the delegate method
536
- NSOperation<SDWebImageDownloaderOperation> *dataOperation = [self operationWithTask:task];
537
- if ([dataOperation respondsToSelector:@selector(URLSession:task:didFinishCollectingMetrics:)]) {
538
- [dataOperation URLSession:session task:task didFinishCollectingMetrics:metrics];
539
- }
540
- }
541
-
542
- @end
543
-
544
- @implementation SDWebImageDownloadToken
545
-
546
- - (void)dealloc {
547
- [[NSNotificationCenter defaultCenter] removeObserver:self name:SDWebImageDownloadReceiveResponseNotification object:nil];
548
- [[NSNotificationCenter defaultCenter] removeObserver:self name:SDWebImageDownloadStopNotification object:nil];
549
- }
550
-
551
- - (instancetype)initWithDownloadOperation:(NSOperation<SDWebImageDownloaderOperation> *)downloadOperation {
552
- self = [super init];
553
- if (self) {
554
- _downloadOperation = downloadOperation;
555
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadDidReceiveResponse:) name:SDWebImageDownloadReceiveResponseNotification object:downloadOperation];
556
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadDidStop:) name:SDWebImageDownloadStopNotification object:downloadOperation];
557
- }
558
- return self;
559
- }
560
-
561
- - (void)downloadDidReceiveResponse:(NSNotification *)notification {
562
- NSOperation<SDWebImageDownloaderOperation> *downloadOperation = notification.object;
563
- if (downloadOperation && downloadOperation == self.downloadOperation) {
564
- self.response = downloadOperation.response;
565
- }
566
- }
567
-
568
- - (void)downloadDidStop:(NSNotification *)notification {
569
- NSOperation<SDWebImageDownloaderOperation> *downloadOperation = notification.object;
570
- if (downloadOperation && downloadOperation == self.downloadOperation) {
571
- if ([downloadOperation respondsToSelector:@selector(metrics)]) {
572
- if (@available(iOS 10.0, tvOS 10.0, macOS 10.12, watchOS 3.0, *)) {
573
- self.metrics = downloadOperation.metrics;
574
- }
575
- }
576
- }
577
- }
578
-
579
- - (void)cancel {
580
- @synchronized (self) {
581
- if (self.isCancelled) {
582
- return;
583
- }
584
- self.cancelled = YES;
585
- [self.downloadOperation cancel:self.downloadOperationCancelToken];
586
- self.downloadOperationCancelToken = nil;
587
- }
588
- }
589
-
590
- @end
591
-
592
- @implementation SDWebImageDownloader (SDImageLoader)
593
-
594
- - (BOOL)canRequestImageForURL:(NSURL *)url {
595
- return [self canRequestImageForURL:url options:0 context:nil];
596
- }
597
-
598
- - (BOOL)canRequestImageForURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context {
599
- if (!url) {
600
- return NO;
601
- }
602
- // Always pass YES to let URLSession or custom download operation to determine
603
- return YES;
604
- }
605
-
606
- - (id<SDWebImageOperation>)requestImageWithURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context progress:(SDImageLoaderProgressBlock)progressBlock completed:(SDImageLoaderCompletedBlock)completedBlock {
607
- UIImage *cachedImage = context[SDWebImageContextLoaderCachedImage];
608
-
609
- SDWebImageDownloaderOptions downloaderOptions = 0;
610
- if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority;
611
- if (options & SDWebImageProgressiveLoad) downloaderOptions |= SDWebImageDownloaderProgressiveLoad;
612
- if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache;
613
- if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground;
614
- if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies;
615
- if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates;
616
- if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority;
617
- if (options & SDWebImageScaleDownLargeImages) downloaderOptions |= SDWebImageDownloaderScaleDownLargeImages;
618
- if (options & SDWebImageAvoidDecodeImage) downloaderOptions |= SDWebImageDownloaderAvoidDecodeImage;
619
- if (options & SDWebImageDecodeFirstFrameOnly) downloaderOptions |= SDWebImageDownloaderDecodeFirstFrameOnly;
620
- if (options & SDWebImagePreloadAllFrames) downloaderOptions |= SDWebImageDownloaderPreloadAllFrames;
621
- if (options & SDWebImageMatchAnimatedImageClass) downloaderOptions |= SDWebImageDownloaderMatchAnimatedImageClass;
622
-
623
- if (cachedImage && options & SDWebImageRefreshCached) {
624
- // force progressive off if image already cached but forced refreshing
625
- downloaderOptions &= ~SDWebImageDownloaderProgressiveLoad;
626
- // ignore image read from NSURLCache if image if cached but force refreshing
627
- downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
628
- }
629
-
630
- return [self downloadImageWithURL:url options:downloaderOptions context:context progress:progressBlock completed:completedBlock];
631
- }
632
-
633
- - (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error {
634
- return [self shouldBlockFailedURLWithURL:url error:error options:0 context:nil];
635
- }
636
-
637
- - (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error options:(SDWebImageOptions)options context:(SDWebImageContext *)context {
638
- BOOL shouldBlockFailedURL;
639
- // Filter the error domain and check error codes
640
- if ([error.domain isEqualToString:SDWebImageErrorDomain]) {
641
- shouldBlockFailedURL = ( error.code == SDWebImageErrorInvalidURL
642
- || error.code == SDWebImageErrorBadImageData);
643
- } else if ([error.domain isEqualToString:NSURLErrorDomain]) {
644
- shouldBlockFailedURL = ( error.code != NSURLErrorNotConnectedToInternet
645
- && error.code != NSURLErrorCancelled
646
- && error.code != NSURLErrorTimedOut
647
- && error.code != NSURLErrorInternationalRoamingOff
648
- && error.code != NSURLErrorDataNotAllowed
649
- && error.code != NSURLErrorCannotFindHost
650
- && error.code != NSURLErrorCannotConnectToHost
651
- && error.code != NSURLErrorNetworkConnectionLost);
652
- } else {
653
- shouldBlockFailedURL = NO;
654
- }
655
- return shouldBlockFailedURL;
656
- }
657
-
658
- @end