@nativescript/core 9.0.0-next-10-06-2025-18277360121 → 9.0.0-next-10-09-2025-18367604937

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 (181) hide show
  1. package/package.json +1 -1
  2. package/platforms/android/widgets-release.aar +0 -0
  3. package/platforms/ios/TNSWidgets.xcframework/Info.plist +102 -0
  4. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers/NSCCrypto.h +60 -0
  5. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers/TNSProcess.h +29 -0
  6. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
  7. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Modules/module.modulemap +6 -0
  8. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
  9. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +20 -0
  10. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  11. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +82 -0
  12. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSCCrypto.h +60 -0
  13. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSData+Async.h +24 -0
  14. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSFileHandle+Async.h +22 -0
  15. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSString+Async.h +25 -0
  16. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSLabel.h +16 -0
  17. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSProcess.h +29 -0
  18. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSWidgets.h +25 -0
  19. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +26 -0
  20. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +17 -0
  21. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Modules/module.modulemap +6 -0
  22. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +17 -0
  23. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +18 -0
  24. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Resources/Info.plist +52 -0
  25. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSCCrypto.h +60 -0
  26. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSData+Async.h +24 -0
  27. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSFileHandle+Async.h +22 -0
  28. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSString+Async.h +25 -0
  29. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSLabel.h +16 -0
  30. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSProcess.h +29 -0
  31. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSWidgets.h +25 -0
  32. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIImage+TNSBlocks.h +26 -0
  33. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIView+PassThroughParent.h +17 -0
  34. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Modules/module.modulemap +6 -0
  35. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/NSObject+Swizzling.h +17 -0
  36. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/UIView+PropertyBag.h +18 -0
  37. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Resources/Info.plist +52 -0
  38. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/TNSWidgets +0 -0
  39. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSCCrypto.h +60 -0
  40. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSData+Async.h +24 -0
  41. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSFileHandle+Async.h +22 -0
  42. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/NSString+Async.h +25 -0
  43. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSLabel.h +16 -0
  44. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSProcess.h +29 -0
  45. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/TNSWidgets.h +25 -0
  46. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/UIImage+TNSBlocks.h +26 -0
  47. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Headers/UIView+PassThroughParent.h +17 -0
  48. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Modules/module.modulemap +6 -0
  49. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/PrivateHeaders/NSObject+Swizzling.h +17 -0
  50. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/PrivateHeaders/UIView+PropertyBag.h +18 -0
  51. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Resources/Info.plist +52 -0
  52. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/TNSWidgets +0 -0
  53. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +20 -0
  54. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  55. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +82 -0
  56. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +82 -0
  57. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSCCrypto.h +60 -0
  58. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSData+Async.h +24 -0
  59. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSFileHandle+Async.h +22 -0
  60. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSString+Async.h +25 -0
  61. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSLabel.h +16 -0
  62. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSProcess.h +29 -0
  63. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSWidgets.h +25 -0
  64. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +26 -0
  65. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +17 -0
  66. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
  67. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Modules/module.modulemap +6 -0
  68. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +17 -0
  69. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +18 -0
  70. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
  71. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +223 -0
  72. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +20 -0
  73. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  74. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +82 -0
  75. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +82 -0
  76. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSCCrypto.h +60 -0
  77. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSData+Async.h +24 -0
  78. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSFileHandle+Async.h +22 -0
  79. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/NSString+Async.h +25 -0
  80. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSLabel.h +16 -0
  81. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSProcess.h +29 -0
  82. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/TNSWidgets.h +25 -0
  83. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +26 -0
  84. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +17 -0
  85. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Info.plist +0 -0
  86. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Modules/module.modulemap +6 -0
  87. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +17 -0
  88. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +18 -0
  89. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/TNSWidgets +0 -0
  90. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +20 -0
  91. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  92. package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +82 -0
  93. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSCCrypto.h +60 -0
  94. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSData+Async.h +24 -0
  95. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSFileHandle+Async.h +22 -0
  96. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/NSString+Async.h +25 -0
  97. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSLabel.h +16 -0
  98. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSProcess.h +29 -0
  99. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/TNSWidgets.h +25 -0
  100. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +26 -0
  101. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +17 -0
  102. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
  103. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Modules/module.modulemap +6 -0
  104. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +17 -0
  105. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +18 -0
  106. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
  107. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +223 -0
  108. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +20 -0
  109. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  110. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +82 -0
  111. package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +82 -0
  112. package/platforms/ios/src/module.modulemap +0 -5
  113. package/ui/button/index.d.ts +1 -1
  114. package/ui/slider/index.d.ts +1 -1
  115. package/platforms/android/include.gradle +0 -51
  116. package/platforms/android/java/org/nativescript/Process.java +0 -59
  117. package/platforms/android/java/org/nativescript/widgets/AbsoluteLayout.java +0 -88
  118. package/platforms/android/java/org/nativescript/widgets/AnimatorHelper.java +0 -61
  119. package/platforms/android/java/org/nativescript/widgets/Async.java +0 -1356
  120. package/platforms/android/java/org/nativescript/widgets/BorderDrawable.java +0 -936
  121. package/platforms/android/java/org/nativescript/widgets/BottomNavigationBar.java +0 -308
  122. package/platforms/android/java/org/nativescript/widgets/BoxShadowDrawable.java +0 -175
  123. package/platforms/android/java/org/nativescript/widgets/CSSValue.java +0 -34
  124. package/platforms/android/java/org/nativescript/widgets/CommonLayoutParams.java +0 -456
  125. package/platforms/android/java/org/nativescript/widgets/ContentLayout.java +0 -85
  126. package/platforms/android/java/org/nativescript/widgets/CustomTransition.java +0 -135
  127. package/platforms/android/java/org/nativescript/widgets/CustomTypefaceSpan.java +0 -44
  128. package/platforms/android/java/org/nativescript/widgets/Dock.java +0 -15
  129. package/platforms/android/java/org/nativescript/widgets/DockLayout.java +0 -185
  130. package/platforms/android/java/org/nativescript/widgets/FileHelper.java +0 -815
  131. package/platforms/android/java/org/nativescript/widgets/FlexLine.java +0 -177
  132. package/platforms/android/java/org/nativescript/widgets/FlexboxLayout.java +0 -2769
  133. package/platforms/android/java/org/nativescript/widgets/FragmentBase.java +0 -14
  134. package/platforms/android/java/org/nativescript/widgets/GridLayout.java +0 -1172
  135. package/platforms/android/java/org/nativescript/widgets/GridUnitType.java +0 -10
  136. package/platforms/android/java/org/nativescript/widgets/HorizontalScrollView.java +0 -256
  137. package/platforms/android/java/org/nativescript/widgets/ImageView.java +0 -423
  138. package/platforms/android/java/org/nativescript/widgets/ItemSpec.java +0 -56
  139. package/platforms/android/java/org/nativescript/widgets/LayoutBase.java +0 -98
  140. package/platforms/android/java/org/nativescript/widgets/LinearGradientDefinition.java +0 -46
  141. package/platforms/android/java/org/nativescript/widgets/Orientation.java +0 -9
  142. package/platforms/android/java/org/nativescript/widgets/OriginPoint.java +0 -74
  143. package/platforms/android/java/org/nativescript/widgets/ScrollSavedState.java +0 -63
  144. package/platforms/android/java/org/nativescript/widgets/SegmentedBarColorDrawable.java +0 -27
  145. package/platforms/android/java/org/nativescript/widgets/StackLayout.java +0 -231
  146. package/platforms/android/java/org/nativescript/widgets/StyleableTextView.java +0 -50
  147. package/platforms/android/java/org/nativescript/widgets/TabIconRenderingMode.java +0 -6
  148. package/platforms/android/java/org/nativescript/widgets/TabItemSpec.java +0 -15
  149. package/platforms/android/java/org/nativescript/widgets/TabLayout.java +0 -451
  150. package/platforms/android/java/org/nativescript/widgets/TabStrip.java +0 -294
  151. package/platforms/android/java/org/nativescript/widgets/TabViewPager.java +0 -64
  152. package/platforms/android/java/org/nativescript/widgets/TabsBar.java +0 -443
  153. package/platforms/android/java/org/nativescript/widgets/Utils.java +0 -546
  154. package/platforms/android/java/org/nativescript/widgets/VerticalScrollView.java +0 -258
  155. package/platforms/android/java/org/nativescript/widgets/ViewHelper.java +0 -564
  156. package/platforms/android/java/org/nativescript/widgets/WrapLayout.java +0 -252
  157. package/platforms/android/java/org/nativescript/widgets/image/AsyncTask.java +0 -679
  158. package/platforms/android/java/org/nativescript/widgets/image/BitmapOwner.java +0 -17
  159. package/platforms/android/java/org/nativescript/widgets/image/Cache.java +0 -471
  160. package/platforms/android/java/org/nativescript/widgets/image/DiskLruCache.java +0 -970
  161. package/platforms/android/java/org/nativescript/widgets/image/Fetcher.java +0 -747
  162. package/platforms/android/java/org/nativescript/widgets/image/Utils.java +0 -58
  163. package/platforms/android/java/org/nativescript/widgets/image/Worker.java +0 -571
  164. package/platforms/ios/src/TNSWidgets/Info.plist +0 -26
  165. package/platforms/ios/src/TNSWidgets/NSData+Async.m +0 -42
  166. package/platforms/ios/src/TNSWidgets/NSFileHandle+Async.m +0 -82
  167. package/platforms/ios/src/TNSWidgets/NSObject+Swizzling.m +0 -68
  168. package/platforms/ios/src/TNSWidgets/NSString+Async.m +0 -51
  169. package/platforms/ios/src/TNSWidgets/TNSLabel.m +0 -42
  170. package/platforms/ios/src/TNSWidgets/UIImage+TNSBlocks.m +0 -77
  171. package/platforms/ios/src/TNSWidgets/UIView+PassThroughParent.m +0 -53
  172. package/platforms/ios/src/TNSWidgets/UIView+PropertyBag.m +0 -72
  173. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers}/NSData+Async.h +0 -0
  174. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers}/NSFileHandle+Async.h +0 -0
  175. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers}/NSString+Async.h +0 -0
  176. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers}/TNSLabel.h +0 -0
  177. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers}/TNSWidgets.h +0 -0
  178. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers}/UIImage+TNSBlocks.h +0 -0
  179. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Headers}/UIView+PassThroughParent.h +0 -0
  180. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/PrivateHeaders}/NSObject+Swizzling.h +0 -0
  181. /package/platforms/ios/{src/TNSWidgets → TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/PrivateHeaders}/UIView+PropertyBag.h +0 -0
@@ -1,970 +0,0 @@
1
- /*
2
- * Copyright (C) 2011 The Android Open Source Project
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- package org.nativescript.widgets.image;
18
-
19
- import java.io.BufferedInputStream;
20
- import java.io.BufferedWriter;
21
- import java.io.Closeable;
22
- import java.io.EOFException;
23
- import java.io.File;
24
- import java.io.FileInputStream;
25
- import java.io.FileNotFoundException;
26
- import java.io.FileOutputStream;
27
- import java.io.FileWriter;
28
- import java.io.FilterOutputStream;
29
- import java.io.IOException;
30
- import java.io.InputStream;
31
- import java.io.InputStreamReader;
32
- import java.io.OutputStream;
33
- import java.io.OutputStreamWriter;
34
- import java.io.Reader;
35
- import java.io.StringWriter;
36
- import java.io.Writer;
37
- import java.lang.reflect.Array;
38
- import java.nio.charset.Charset;
39
- import java.nio.charset.StandardCharsets;
40
- import java.util.ArrayList;
41
- import java.util.Arrays;
42
- import java.util.Iterator;
43
- import java.util.LinkedHashMap;
44
- import java.util.Map;
45
- import java.util.concurrent.Callable;
46
- import java.util.concurrent.ExecutorService;
47
- import java.util.concurrent.LinkedBlockingQueue;
48
- import java.util.concurrent.ThreadPoolExecutor;
49
- import java.util.concurrent.TimeUnit;
50
-
51
- /**
52
- * *****************************************************************************
53
- * Taken from the JB source code, can be found in:
54
- * libcore/luni/src/main/java/libcore/io/DiskLruCache.java
55
- * or direct link:
56
- * https://android.googlesource.com/platform/libcore/+/android-4.1.1_r1/luni/src/main/java/libcore/io/DiskLruCache.java
57
- * *****************************************************************************
58
- * <p>
59
- * A cache that uses a bounded amount of space on a filesystem. Each cache
60
- * entry has a string key and a fixed number of values. Values are byte
61
- * sequences, accessible as streams or files. Each value must be between {@code
62
- * 0} and {@code Integer.MAX_VALUE} bytes in length.
63
- *
64
- * <p>The cache stores its data in a directory on the filesystem. This
65
- * directory must be exclusive to the cache; the cache may delete or overwrite
66
- * files from its directory. It is an error for multiple processes to use the
67
- * same cache directory at the same time.
68
- *
69
- * <p>This cache limits the number of bytes that it will store on the
70
- * filesystem. When the number of stored bytes exceeds the limit, the cache will
71
- * remove entries in the background until the limit is satisfied. The limit is
72
- * not strict: the cache may temporarily exceed it while waiting for files to be
73
- * deleted. The limit does not include filesystem overhead or the cache
74
- * journal so space-sensitive applications should set a conservative limit.
75
- *
76
- * <p>Clients call {@link #edit} to create or update the values of an entry. An
77
- * entry may have only one editor at one time; if a value is not available to be
78
- * edited then {@link #edit} will return null.
79
- * <ul>
80
- * <li>When an entry is being <strong>created</strong> it is necessary to
81
- * supply a full set of values; the empty value should be used as a
82
- * placeholder if necessary.
83
- * <li>When an entry is being <strong>edited</strong>, it is not necessary
84
- * to supply data for every value; values default to their previous
85
- * value.
86
- * </ul>
87
- * Every {@link #edit} call must be matched by a call to {@link Editor#commit}
88
- * or {@link Editor#abort}. Committing is atomic: a read observes the full set
89
- * of values as they were before or after the commit, but never a mix of values.
90
- *
91
- * <p>Clients call {@link #get} to read a snapshot of an entry. The read will
92
- * observe the value at the time that {@link #get} was called. Updates and
93
- * removals after the call do not impact ongoing reads.
94
- *
95
- * <p>This class is tolerant of some I/O errors. If files are missing from the
96
- * filesystem, the corresponding entries will be dropped from the cache. If
97
- * an error occurs while writing a cache value, the edit will fail silently.
98
- * Callers should handle other problems by catching {@code IOException} and
99
- * responding appropriately.
100
- */
101
- public final class DiskLruCache implements Closeable {
102
- static final String JOURNAL_FILE = "journal";
103
- static final String JOURNAL_FILE_TMP = "journal.tmp";
104
- static final String MAGIC = "libcore.io.DiskLruCache";
105
- static final String VERSION_1 = "1";
106
- static final long ANY_SEQUENCE_NUMBER = -1;
107
- private static final String CLEAN = "CLEAN";
108
- private static final String DIRTY = "DIRTY";
109
- private static final String REMOVE = "REMOVE";
110
- private static final String READ = "READ";
111
-
112
- private static final Charset UTF_8 = StandardCharsets.UTF_8;
113
- private static final int IO_BUFFER_SIZE = 8 * 1024;
114
-
115
- /*
116
- * This cache uses a journal file named "journal". A typical journal file
117
- * looks like this:
118
- * libcore.io.DiskLruCache
119
- * 1
120
- * 100
121
- * 2
122
- *
123
- * CLEAN 3400330d1dfc7f3f7f4b8d4d803dfcf6 832 21054
124
- * DIRTY 335c4c6028171cfddfbaae1a9c313c52
125
- * CLEAN 335c4c6028171cfddfbaae1a9c313c52 3934 2342
126
- * REMOVE 335c4c6028171cfddfbaae1a9c313c52
127
- * DIRTY 1ab96a171faeeee38496d8b330771a7a
128
- * CLEAN 1ab96a171faeeee38496d8b330771a7a 1600 234
129
- * READ 335c4c6028171cfddfbaae1a9c313c52
130
- * READ 3400330d1dfc7f3f7f4b8d4d803dfcf6
131
- *
132
- * The first five lines of the journal form its header. They are the
133
- * constant string "libcore.io.DiskLruCache", the disk cache's version,
134
- * the application's version, the value count, and a blank line.
135
- *
136
- * Each of the subsequent lines in the file is a record of the state of a
137
- * cache entry. Each line contains space-separated values: a state, a key,
138
- * and optional state-specific values.
139
- * o DIRTY lines track that an entry is actively being created or updated.
140
- * Every successful DIRTY action should be followed by a CLEAN or REMOVE
141
- * action. DIRTY lines without a matching CLEAN or REMOVE indicate that
142
- * temporary files may need to be deleted.
143
- * o CLEAN lines track a cache entry that has been successfully published
144
- * and may be read. A publish line is followed by the lengths of each of
145
- * its values.
146
- * o READ lines track accesses for LRU.
147
- * o REMOVE lines track entries that have been deleted.
148
- *
149
- * The journal file is appended to as cache operations occur. The journal may
150
- * occasionally be compacted by dropping redundant lines. A temporary file named
151
- * "journal.tmp" will be used during compaction; that file should be deleted if
152
- * it exists when the cache is opened.
153
- */
154
-
155
- private final File directory;
156
- private final File journalFile;
157
- private final File journalFileTmp;
158
- private final int appVersion;
159
- private final long maxSize;
160
- private final int valueCount;
161
- private long size = 0;
162
- private Writer journalWriter;
163
- private final LinkedHashMap<String, Entry> lruEntries
164
- = new LinkedHashMap<String, Entry>(0, 0.75f, true);
165
- private int redundantOpCount;
166
-
167
- /**
168
- * To differentiate between old and current snapshots, each entry is given
169
- * a sequence number each time an edit is committed. A snapshot is stale if
170
- * its sequence number is not equal to its entry's sequence number.
171
- */
172
- private long nextSequenceNumber = 0;
173
-
174
- /* From java.util.Arrays */
175
- @SuppressWarnings("unchecked")
176
- private static <T> T[] copyOfRange(T[] original, int start, int end) {
177
- final int originalLength = original.length; // For exception priority compatibility.
178
- if (start > end) {
179
- throw new IllegalArgumentException();
180
- }
181
- if (start < 0 || start > originalLength) {
182
- throw new ArrayIndexOutOfBoundsException();
183
- }
184
- final int resultLength = end - start;
185
- final int copyLength = Math.min(resultLength, originalLength - start);
186
- final T[] result = (T[]) Array
187
- .newInstance(original.getClass().getComponentType(), resultLength);
188
- System.arraycopy(original, start, result, 0, copyLength);
189
- return result;
190
- }
191
-
192
- /**
193
- * Returns the remainder of 'reader' as a string, closing it when done.
194
- */
195
- public static String readFully(Reader reader) throws IOException {
196
- try {
197
- StringWriter writer = new StringWriter();
198
- char[] buffer = new char[1024];
199
- int count;
200
- while ((count = reader.read(buffer)) != -1) {
201
- writer.write(buffer, 0, count);
202
- }
203
- return writer.toString();
204
- } finally {
205
- reader.close();
206
- }
207
- }
208
-
209
- /**
210
- * Returns the ASCII characters up to but not including the next "\r\n", or
211
- * "\n".
212
- *
213
- * @throws EOFException if the stream is exhausted before the next newline
214
- * character.
215
- */
216
- public static String readAsciiLine(InputStream in) throws IOException {
217
- // TODO: support UTF-8 here instead
218
-
219
- StringBuilder result = new StringBuilder(80);
220
- while (true) {
221
- int c = in.read();
222
- if (c == -1) {
223
- throw new EOFException();
224
- } else if (c == '\n') {
225
- break;
226
- }
227
-
228
- result.append((char) c);
229
- }
230
- int length = result.length();
231
- if (length > 0 && result.charAt(length - 1) == '\r') {
232
- result.setLength(length - 1);
233
- }
234
- return result.toString();
235
- }
236
-
237
- /**
238
- * Closes 'closeable', ignoring any checked exceptions. Does nothing if 'closeable' is null.
239
- */
240
- public static void closeQuietly(Closeable closeable) {
241
- if (closeable != null) {
242
- try {
243
- closeable.close();
244
- } catch (RuntimeException rethrown) {
245
- throw rethrown;
246
- } catch (Exception ignored) {
247
- }
248
- }
249
- }
250
-
251
- /**
252
- * Recursively delete everything in {@code dir}.
253
- */
254
- // TODO: this should specify paths as Strings rather than as Files
255
- public static void deleteContents(File dir) throws IOException {
256
- File[] files = dir.listFiles();
257
- if (files == null) {
258
- return;
259
- }
260
- for (File file : files) {
261
- if (file.isDirectory()) {
262
- deleteContents(file);
263
- }
264
- if (!file.delete()) {
265
- throw new IOException("failed to delete file: " + file);
266
- }
267
- }
268
- }
269
-
270
- /**
271
- * This cache uses a single background thread to evict entries.
272
- */
273
- private final ExecutorService executorService = new ThreadPoolExecutor(0, 1,
274
- 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
275
- private final Callable<Void> cleanupCallable = new Callable<Void>() {
276
- @Override
277
- public Void call() throws Exception {
278
- synchronized (DiskLruCache.this) {
279
- if (journalWriter == null) {
280
- return null; // closed
281
- }
282
- trimToSize();
283
- if (journalRebuildRequired()) {
284
- rebuildJournal();
285
- redundantOpCount = 0;
286
- }
287
- }
288
- return null;
289
- }
290
- };
291
-
292
- private DiskLruCache(File directory, int appVersion, int valueCount, long maxSize) {
293
- this.directory = directory;
294
- this.appVersion = appVersion;
295
- this.journalFile = new File(directory, JOURNAL_FILE);
296
- this.journalFileTmp = new File(directory, JOURNAL_FILE_TMP);
297
- this.valueCount = valueCount;
298
- this.maxSize = maxSize;
299
- }
300
-
301
- /**
302
- * Opens the cache in {@code directory}, creating a cache if none exists
303
- * there.
304
- *
305
- * @param directory a writable directory
306
- * @param appVersion
307
- * @param valueCount the number of values per cache entry. Must be positive.
308
- * @param maxSize the maximum number of bytes this cache should use to store
309
- * @throws IOException if reading or writing the cache directory fails
310
- */
311
- public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize)
312
- throws IOException {
313
- if (maxSize <= 0) {
314
- throw new IllegalArgumentException("maxSize <= 0");
315
- }
316
- if (valueCount <= 0) {
317
- throw new IllegalArgumentException("valueCount <= 0");
318
- }
319
-
320
- // prefer to pick up where we left off
321
- DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
322
- if (cache.journalFile.exists()) {
323
- try {
324
- cache.readJournal();
325
- cache.processJournal();
326
- cache.journalWriter = new BufferedWriter(new FileWriter(cache.journalFile, true),
327
- IO_BUFFER_SIZE);
328
- return cache;
329
- } catch (IOException journalIsCorrupt) {
330
- // System.logW("DiskLruCache " + directory + " is corrupt: "
331
- // + journalIsCorrupt.getMessage() + ", removing");
332
- cache.delete();
333
- }
334
- }
335
-
336
- // create a new empty cache
337
- directory.mkdirs();
338
- cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
339
- cache.rebuildJournal();
340
- return cache;
341
- }
342
-
343
- private void readJournal() throws IOException {
344
- InputStream in = new BufferedInputStream(new FileInputStream(journalFile), IO_BUFFER_SIZE);
345
- try {
346
- String magic = readAsciiLine(in);
347
- String version = readAsciiLine(in);
348
- String appVersionString = readAsciiLine(in);
349
- String valueCountString = readAsciiLine(in);
350
- String blank = readAsciiLine(in);
351
- if (!MAGIC.equals(magic)
352
- || !VERSION_1.equals(version)
353
- || !Integer.toString(appVersion).equals(appVersionString)
354
- || !Integer.toString(valueCount).equals(valueCountString)
355
- || !"".equals(blank)) {
356
- throw new IOException("unexpected journal header: ["
357
- + magic + ", " + version + ", " + valueCountString + ", " + blank + "]");
358
- }
359
-
360
- while (true) {
361
- try {
362
- readJournalLine(readAsciiLine(in));
363
- } catch (EOFException endOfJournal) {
364
- break;
365
- }
366
- }
367
- } finally {
368
- closeQuietly(in);
369
- }
370
- }
371
-
372
- private void readJournalLine(String line) throws IOException {
373
- String[] parts = line.split(" ");
374
- if (parts.length < 2) {
375
- throw new IOException("unexpected journal line: " + line);
376
- }
377
-
378
- String key = parts[1];
379
- if (parts[0].equals(REMOVE) && parts.length == 2) {
380
- lruEntries.remove(key);
381
- return;
382
- }
383
-
384
- Entry entry = lruEntries.get(key);
385
- if (entry == null) {
386
- entry = new Entry(key);
387
- lruEntries.put(key, entry);
388
- }
389
-
390
- if (parts[0].equals(CLEAN) && parts.length == 2 + valueCount) {
391
- entry.readable = true;
392
- entry.currentEditor = null;
393
- entry.setLengths(copyOfRange(parts, 2, parts.length));
394
- } else if (parts[0].equals(DIRTY) && parts.length == 2) {
395
- entry.currentEditor = new Editor(entry);
396
- } else if (parts[0].equals(READ) && parts.length == 2) {
397
- // this work was already done by calling lruEntries.get()
398
- } else {
399
- throw new IOException("unexpected journal line: " + line);
400
- }
401
- }
402
-
403
- /**
404
- * Computes the initial size and collects garbage as a part of opening the
405
- * cache. Dirty entries are assumed to be inconsistent and will be deleted.
406
- */
407
- private void processJournal() throws IOException {
408
- deleteIfExists(journalFileTmp);
409
- for (Iterator<Entry> i = lruEntries.values().iterator(); i.hasNext(); ) {
410
- Entry entry = i.next();
411
- if (entry.currentEditor == null) {
412
- for (int t = 0; t < valueCount; t++) {
413
- size += entry.lengths[t];
414
- }
415
- } else {
416
- entry.currentEditor = null;
417
- for (int t = 0; t < valueCount; t++) {
418
- deleteIfExists(entry.getCleanFile(t));
419
- deleteIfExists(entry.getDirtyFile(t));
420
- }
421
- i.remove();
422
- }
423
- }
424
- }
425
-
426
- /**
427
- * Creates a new journal that omits redundant information. This replaces the
428
- * current journal if it exists.
429
- */
430
- private synchronized void rebuildJournal() throws IOException {
431
- if (journalWriter != null) {
432
- journalWriter.close();
433
- }
434
-
435
- Writer writer = new BufferedWriter(new FileWriter(journalFileTmp), IO_BUFFER_SIZE);
436
- writer.write(MAGIC);
437
- writer.write("\n");
438
- writer.write(VERSION_1);
439
- writer.write("\n");
440
- writer.write(Integer.toString(appVersion));
441
- writer.write("\n");
442
- writer.write(Integer.toString(valueCount));
443
- writer.write("\n");
444
- writer.write("\n");
445
-
446
- for (Entry entry : lruEntries.values()) {
447
- if (entry.currentEditor != null) {
448
- writer.write(DIRTY + ' ' + entry.key + '\n');
449
- } else {
450
- writer.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
451
- }
452
- }
453
-
454
- writer.close();
455
- journalFileTmp.renameTo(journalFile);
456
- journalWriter = new BufferedWriter(new FileWriter(journalFile, true), IO_BUFFER_SIZE);
457
- }
458
-
459
- private static void deleteIfExists(File file) throws IOException {
460
- // try {
461
- // Libcore.os.remove(file.getPath());
462
- // } catch (ErrnoException errnoException) {
463
- // if (errnoException.errno != OsConstants.ENOENT) {
464
- // throw errnoException.rethrowAsIOException();
465
- // }
466
- // }
467
- if (file.exists() && !file.delete()) {
468
- throw new IOException();
469
- }
470
- }
471
-
472
- /**
473
- * Returns a snapshot of the entry named {@code key}, or null if it doesn't
474
- * exist is not currently readable. If a value is returned, it is moved to
475
- * the head of the LRU queue.
476
- */
477
- public synchronized Snapshot get(String key) throws IOException {
478
- checkNotClosed();
479
- validateKey(key);
480
- Entry entry = lruEntries.get(key);
481
- if (entry == null) {
482
- return null;
483
- }
484
-
485
- if (!entry.readable) {
486
- return null;
487
- }
488
-
489
- /*
490
- * Open all streams eagerly to guarantee that we see a single published
491
- * snapshot. If we opened streams lazily then the streams could come
492
- * from different edits.
493
- */
494
- InputStream[] ins = new InputStream[valueCount];
495
- try {
496
- for (int i = 0; i < valueCount; i++) {
497
- ins[i] = new FileInputStream(entry.getCleanFile(i));
498
- }
499
- } catch (FileNotFoundException e) {
500
- // a file must have been deleted manually!
501
- return null;
502
- }
503
-
504
- redundantOpCount++;
505
- journalWriter.append(READ + ' ' + key + '\n');
506
- if (journalRebuildRequired()) {
507
- executorService.submit(cleanupCallable);
508
- }
509
-
510
- return new Snapshot(key, entry.sequenceNumber, ins);
511
- }
512
-
513
- /**
514
- * Returns an editor for the entry named {@code key}, or null if another
515
- * edit is in progress.
516
- */
517
- public Editor edit(String key) throws IOException {
518
- return edit(key, ANY_SEQUENCE_NUMBER);
519
- }
520
-
521
- private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException {
522
- checkNotClosed();
523
- validateKey(key);
524
- Entry entry = lruEntries.get(key);
525
- if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER
526
- && (entry == null || entry.sequenceNumber != expectedSequenceNumber)) {
527
- return null; // snapshot is stale
528
- }
529
- if (entry == null) {
530
- entry = new Entry(key);
531
- lruEntries.put(key, entry);
532
- } else if (entry.currentEditor != null) {
533
- return null; // another edit is in progress
534
- }
535
-
536
- Editor editor = new Editor(entry);
537
- entry.currentEditor = editor;
538
-
539
- // flush the journal before creating files to prevent file leaks
540
- journalWriter.write(DIRTY + ' ' + key + '\n');
541
- journalWriter.flush();
542
- return editor;
543
- }
544
-
545
- /**
546
- * Returns the directory where this cache stores its data.
547
- */
548
- public File getDirectory() {
549
- return directory;
550
- }
551
-
552
- /**
553
- * Returns the maximum number of bytes that this cache should use to store
554
- * its data.
555
- */
556
- public long maxSize() {
557
- return maxSize;
558
- }
559
-
560
- /**
561
- * Returns the number of bytes currently being used to store the values in
562
- * this cache. This may be greater than the max size if a background
563
- * deletion is pending.
564
- */
565
- public synchronized long size() {
566
- return size;
567
- }
568
-
569
- private synchronized void completeEdit(Editor editor, boolean success) throws IOException {
570
- Entry entry = editor.entry;
571
- if (entry.currentEditor != editor) {
572
- throw new IllegalStateException();
573
- }
574
-
575
- // if this edit is creating the entry for the first time, every index must have a value
576
- if (success && !entry.readable) {
577
- for (int i = 0; i < valueCount; i++) {
578
- if (!entry.getDirtyFile(i).exists()) {
579
- editor.abort();
580
- throw new IllegalStateException("edit didn't create file " + i);
581
- }
582
- }
583
- }
584
-
585
- for (int i = 0; i < valueCount; i++) {
586
- File dirty = entry.getDirtyFile(i);
587
- if (success) {
588
- if (dirty.exists()) {
589
- File clean = entry.getCleanFile(i);
590
- dirty.renameTo(clean);
591
- long oldLength = entry.lengths[i];
592
- long newLength = clean.length();
593
- entry.lengths[i] = newLength;
594
- size = size - oldLength + newLength;
595
- }
596
- } else {
597
- deleteIfExists(dirty);
598
- }
599
- }
600
-
601
- redundantOpCount++;
602
- entry.currentEditor = null;
603
- if (entry.readable | success) {
604
- entry.readable = true;
605
- journalWriter.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
606
- if (success) {
607
- entry.sequenceNumber = nextSequenceNumber++;
608
- }
609
- } else {
610
- lruEntries.remove(entry.key);
611
- journalWriter.write(REMOVE + ' ' + entry.key + '\n');
612
- }
613
-
614
- if (size > maxSize || journalRebuildRequired()) {
615
- executorService.submit(cleanupCallable);
616
- }
617
- }
618
-
619
- /**
620
- * We only rebuild the journal when it will halve the size of the journal
621
- * and eliminate at least 2000 ops.
622
- */
623
- private boolean journalRebuildRequired() {
624
- final int REDUNDANT_OP_COMPACT_THRESHOLD = 2000;
625
- return redundantOpCount >= REDUNDANT_OP_COMPACT_THRESHOLD
626
- && redundantOpCount >= lruEntries.size();
627
- }
628
-
629
- /**
630
- * Drops the entry for {@code key} if it exists and can be removed. Entries
631
- * actively being edited cannot be removed.
632
- *
633
- * @return true if an entry was removed.
634
- */
635
- public synchronized boolean remove(String key) throws IOException {
636
- checkNotClosed();
637
- validateKey(key);
638
- Entry entry = lruEntries.get(key);
639
- if (entry == null || entry.currentEditor != null) {
640
- return false;
641
- }
642
-
643
- for (int i = 0; i < valueCount; i++) {
644
- File file = entry.getCleanFile(i);
645
- if (!file.delete()) {
646
- throw new IOException("failed to delete " + file);
647
- }
648
- size -= entry.lengths[i];
649
- entry.lengths[i] = 0;
650
- }
651
-
652
- redundantOpCount++;
653
- journalWriter.append(REMOVE + ' ' + key + '\n');
654
- lruEntries.remove(key);
655
-
656
- if (journalRebuildRequired()) {
657
- executorService.submit(cleanupCallable);
658
- }
659
-
660
- return true;
661
- }
662
-
663
- /**
664
- * Returns true if this cache has been closed.
665
- */
666
- public boolean isClosed() {
667
- return journalWriter == null;
668
- }
669
-
670
- private void checkNotClosed() {
671
- if (journalWriter == null) {
672
- throw new IllegalStateException("cache is closed");
673
- }
674
- }
675
-
676
- /**
677
- * Force buffered operations to the filesystem.
678
- */
679
- public synchronized void flush() throws IOException {
680
- checkNotClosed();
681
- trimToSize();
682
- journalWriter.flush();
683
- }
684
-
685
- /**
686
- * Closes this cache. Stored values will remain on the filesystem.
687
- */
688
- public synchronized void close() throws IOException {
689
- if (journalWriter == null) {
690
- return; // already closed
691
- }
692
- for (Entry entry : new ArrayList<Entry>(lruEntries.values())) {
693
- if (entry.currentEditor != null) {
694
- entry.currentEditor.abort();
695
- }
696
- }
697
- trimToSize();
698
- journalWriter.close();
699
- journalWriter = null;
700
- }
701
-
702
- private void trimToSize() throws IOException {
703
- while (size > maxSize) {
704
- // Map.Entry<String, Entry> toEvict = lruEntries.eldest();
705
- final Map.Entry<String, Entry> toEvict = lruEntries.entrySet().iterator().next();
706
- remove(toEvict.getKey());
707
- }
708
- }
709
-
710
- /**
711
- * Closes the cache and deletes all of its stored values. This will delete
712
- * all files in the cache directory including files that weren't created by
713
- * the cache.
714
- */
715
- public void delete() throws IOException {
716
- close();
717
- deleteContents(directory);
718
- }
719
-
720
- private void validateKey(String key) {
721
- if (key.contains(" ") || key.contains("\n") || key.contains("\r")) {
722
- throw new IllegalArgumentException(
723
- "keys must not contain spaces or newlines: \"" + key + "\"");
724
- }
725
- }
726
-
727
- private static String inputStreamToString(InputStream in) throws IOException {
728
- return readFully(new InputStreamReader(in, UTF_8));
729
- }
730
-
731
- /**
732
- * A snapshot of the values for an entry.
733
- */
734
- public final class Snapshot implements Closeable {
735
- private final String key;
736
- private final long sequenceNumber;
737
- private final InputStream[] ins;
738
-
739
- private Snapshot(String key, long sequenceNumber, InputStream[] ins) {
740
- this.key = key;
741
- this.sequenceNumber = sequenceNumber;
742
- this.ins = ins;
743
- }
744
-
745
- /**
746
- * Returns an editor for this snapshot's entry, or null if either the
747
- * entry has changed since this snapshot was created or if another edit
748
- * is in progress.
749
- */
750
- public Editor edit() throws IOException {
751
- return DiskLruCache.this.edit(key, sequenceNumber);
752
- }
753
-
754
- /**
755
- * Returns the unbuffered stream with the value for {@code index}.
756
- */
757
- public InputStream getInputStream(int index) {
758
- return ins[index];
759
- }
760
-
761
- /**
762
- * Returns the string value for {@code index}.
763
- */
764
- public String getString(int index) throws IOException {
765
- return inputStreamToString(getInputStream(index));
766
- }
767
-
768
- @Override
769
- public void close() {
770
- for (InputStream in : ins) {
771
- closeQuietly(in);
772
- }
773
- }
774
- }
775
-
776
- /**
777
- * Edits the values for an entry.
778
- */
779
- public final class Editor {
780
- private final Entry entry;
781
- private boolean hasErrors;
782
-
783
- private Editor(Entry entry) {
784
- this.entry = entry;
785
- }
786
-
787
- /**
788
- * Returns an unbuffered input stream to read the last committed value,
789
- * or null if no value has been committed.
790
- */
791
- public InputStream newInputStream(int index) throws IOException {
792
- synchronized (DiskLruCache.this) {
793
- if (entry.currentEditor != this) {
794
- throw new IllegalStateException();
795
- }
796
- if (!entry.readable) {
797
- return null;
798
- }
799
- return new FileInputStream(entry.getCleanFile(index));
800
- }
801
- }
802
-
803
- /**
804
- * Returns the last committed value as a string, or null if no value
805
- * has been committed.
806
- */
807
- public String getString(int index) throws IOException {
808
- InputStream in = newInputStream(index);
809
- return in != null ? inputStreamToString(in) : null;
810
- }
811
-
812
- /**
813
- * Returns a new unbuffered output stream to write the value at
814
- * {@code index}. If the underlying output stream encounters errors
815
- * when writing to the filesystem, this edit will be aborted when
816
- * {@link #commit} is called. The returned output stream does not throw
817
- * IOExceptions.
818
- */
819
- public OutputStream newOutputStream(int index) throws IOException {
820
- synchronized (DiskLruCache.this) {
821
- if (entry.currentEditor != this) {
822
- throw new IllegalStateException();
823
- }
824
- return new FaultHidingOutputStream(new FileOutputStream(entry.getDirtyFile(index)));
825
- }
826
- }
827
-
828
- /**
829
- * Sets the value at {@code index} to {@code value}.
830
- */
831
- public void set(int index, String value) throws IOException {
832
- Writer writer = null;
833
- try {
834
- writer = new OutputStreamWriter(newOutputStream(index), UTF_8);
835
- writer.write(value);
836
- } finally {
837
- closeQuietly(writer);
838
- }
839
- }
840
-
841
- /**
842
- * Commits this edit so it is visible to readers. This releases the
843
- * edit lock so another edit may be started on the same key.
844
- */
845
- public void commit() throws IOException {
846
- if (hasErrors) {
847
- completeEdit(this, false);
848
- remove(entry.key); // the previous entry is stale
849
- } else {
850
- completeEdit(this, true);
851
- }
852
- }
853
-
854
- /**
855
- * Aborts this edit. This releases the edit lock so another edit may be
856
- * started on the same key.
857
- */
858
- public void abort() throws IOException {
859
- completeEdit(this, false);
860
- }
861
-
862
- private class FaultHidingOutputStream extends FilterOutputStream {
863
- private FaultHidingOutputStream(OutputStream out) {
864
- super(out);
865
- }
866
-
867
- @Override
868
- public void write(int oneByte) {
869
- try {
870
- out.write(oneByte);
871
- } catch (IOException e) {
872
- hasErrors = true;
873
- }
874
- }
875
-
876
- @Override
877
- public void write(byte[] buffer, int offset, int length) {
878
- try {
879
- out.write(buffer, offset, length);
880
- } catch (IOException e) {
881
- hasErrors = true;
882
- }
883
- }
884
-
885
- @Override
886
- public void close() {
887
- try {
888
- out.close();
889
- } catch (IOException e) {
890
- hasErrors = true;
891
- }
892
- }
893
-
894
- @Override
895
- public void flush() {
896
- try {
897
- out.flush();
898
- } catch (IOException e) {
899
- hasErrors = true;
900
- }
901
- }
902
- }
903
- }
904
-
905
- private final class Entry {
906
- private final String key;
907
-
908
- /**
909
- * Lengths of this entry's files.
910
- */
911
- private final long[] lengths;
912
-
913
- /**
914
- * True if this entry has ever been published
915
- */
916
- private boolean readable;
917
-
918
- /**
919
- * The ongoing edit or null if this entry is not being edited.
920
- */
921
- private Editor currentEditor;
922
-
923
- /**
924
- * The sequence number of the most recently committed edit to this entry.
925
- */
926
- private long sequenceNumber;
927
-
928
- private Entry(String key) {
929
- this.key = key;
930
- this.lengths = new long[valueCount];
931
- }
932
-
933
- public String getLengths() throws IOException {
934
- StringBuilder result = new StringBuilder();
935
- for (long size : lengths) {
936
- result.append(' ').append(size);
937
- }
938
- return result.toString();
939
- }
940
-
941
- /**
942
- * Set lengths using decimal numbers like "10123".
943
- */
944
- private void setLengths(String[] strings) throws IOException {
945
- if (strings.length != valueCount) {
946
- throw invalidLengths(strings);
947
- }
948
-
949
- try {
950
- for (int i = 0; i < strings.length; i++) {
951
- lengths[i] = Long.parseLong(strings[i]);
952
- }
953
- } catch (NumberFormatException e) {
954
- throw invalidLengths(strings);
955
- }
956
- }
957
-
958
- private IOException invalidLengths(String[] strings) throws IOException {
959
- throw new IOException("unexpected journal line: " + Arrays.toString(strings));
960
- }
961
-
962
- public File getCleanFile(int i) {
963
- return new File(directory, key + "." + i);
964
- }
965
-
966
- public File getDirtyFile(int i) {
967
- return new File(directory, key + "." + i + ".tmp");
968
- }
969
- }
970
- }