@nativescript-community/ui-image 4.3.35 → 4.3.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/index-common.d.ts +3 -1
- package/index.android.d.ts +2 -1
- package/index.android.js +18 -8
- package/index.d.ts +1 -1
- package/index.ios.d.ts +4 -3
- package/index.ios.js +56 -40
- package/package.json +2 -2
- package/platforms/android/ui_image.aar +0 -0
- package/vue/index.mjs +0 -8
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [4.3.37](https://github.com/nativescript-community/ui-image/compare/v4.3.36...v4.3.37) (2024-03-29)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
9
|
+
|
10
|
+
## [4.3.36](https://github.com/nativescript-community/ui-image/compare/v4.3.35...v4.3.36) (2024-03-28)
|
11
|
+
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
13
|
+
|
6
14
|
## [4.3.35](https://github.com/nativescript-community/ui-image/compare/v4.3.34...v4.3.35) (2024-03-22)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @nativescript-community/ui-image
|
package/index-common.d.ts
CHANGED
@@ -84,6 +84,8 @@ export declare const loadModeProperty: Property<ImageBase, "sync" | "async">;
|
|
84
84
|
export declare const clipToBoundsProperty: Property<ImageBase, boolean>;
|
85
85
|
export declare const animatedImageViewProperty: Property<ImageBase, boolean>;
|
86
86
|
export declare const needRequestImage: (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) => void;
|
87
|
+
export type BasicSrcType = string | ImageSource | ImageAsset;
|
88
|
+
export type SrcType = BasicSrcType | (() => BasicSrcType | PromiseLike<BasicSrcType>) | PromiseLike<BasicSrcType>;
|
87
89
|
export declare abstract class ImageBase extends View {
|
88
90
|
static finalImageSetEvent: string;
|
89
91
|
static failureEvent: string;
|
@@ -91,7 +93,7 @@ export declare abstract class ImageBase extends View {
|
|
91
93
|
static intermediateImageSetEvent: string;
|
92
94
|
static releaseEvent: string;
|
93
95
|
static submitEvent: string;
|
94
|
-
src:
|
96
|
+
src: SrcType;
|
95
97
|
lowerResSrc: string;
|
96
98
|
placeholderImageUri: string;
|
97
99
|
failureImageUri: string;
|
package/index.android.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export * from './index-common';
|
2
|
-
import { AnimatedImage, EventData, ImageBase, ImageError as ImageErrorBase, ImageInfo as ImageInfoBase, ImagePipelineConfigSetting } from './index-common';
|
2
|
+
import { AnimatedImage, EventData, ImageBase, ImageError as ImageErrorBase, ImageInfo as ImageInfoBase, ImagePipelineConfigSetting, SrcType } from './index-common';
|
3
3
|
export declare function initialize(config?: ImagePipelineConfigSetting): void;
|
4
4
|
export declare function getImagePipeline(): ImagePipeline;
|
5
5
|
export declare function shutDown(): void;
|
@@ -77,6 +77,7 @@ export declare class Img extends ImageBase {
|
|
77
77
|
get cacheKey(): string | globalAndroid.net.Uri;
|
78
78
|
updateImageUri(): Promise<void>;
|
79
79
|
controllerListener: com.facebook.drawee.controller.ControllerListener<com.facebook.imagepipeline.image.ImageInfo>;
|
80
|
+
protected handleImageSrc(src: SrcType): Promise<void>;
|
80
81
|
protected initImage(): Promise<void>;
|
81
82
|
private updateHierarchy;
|
82
83
|
private getDrawable;
|
package/index.android.js
CHANGED
@@ -355,7 +355,8 @@ export class Img extends ImageBase {
|
|
355
355
|
}
|
356
356
|
get cacheKey() {
|
357
357
|
const src = this.src;
|
358
|
-
|
358
|
+
const srcType = typeof src;
|
359
|
+
if (src && (srcType === 'string' || src instanceof ImageAsset)) {
|
359
360
|
return getUri(src);
|
360
361
|
}
|
361
362
|
return undefined;
|
@@ -363,15 +364,14 @@ export class Img extends ImageBase {
|
|
363
364
|
async updateImageUri() {
|
364
365
|
const imagePipeLine = getImagePipeline();
|
365
366
|
const cacheKey = this.cacheKey;
|
366
|
-
const src = this.src;
|
367
367
|
if (cacheKey) {
|
368
368
|
// const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
|
369
369
|
// // if (isInCache) {
|
370
370
|
await imagePipeLine.evictFromCache(cacheKey);
|
371
371
|
// }
|
372
372
|
}
|
373
|
-
this.
|
374
|
-
this.
|
373
|
+
this.handleImageSrc(null);
|
374
|
+
this.initImage();
|
375
375
|
}
|
376
376
|
[_a = placeholderImageUriProperty.setNative]() {
|
377
377
|
this.updateHierarchy();
|
@@ -436,13 +436,19 @@ export class Img extends ImageBase {
|
|
436
436
|
super[backgroundInternalProperty.setNative](value);
|
437
437
|
this.nativeViewProtected.setClipToOutline(value?.hasBorderRadius());
|
438
438
|
}
|
439
|
-
async
|
439
|
+
async handleImageSrc(src) {
|
440
440
|
const view = this.nativeViewProtected;
|
441
441
|
if (view) {
|
442
|
-
// this.nativeImageViewProtected.setImageURI(null);
|
443
|
-
const src = this.src;
|
444
442
|
if (src instanceof Promise) {
|
445
|
-
this.
|
443
|
+
this.handleImageSrc(await src);
|
444
|
+
return;
|
445
|
+
}
|
446
|
+
else if (typeof src === 'function') {
|
447
|
+
const newSrc = src();
|
448
|
+
if (newSrc instanceof Promise) {
|
449
|
+
await newSrc;
|
450
|
+
}
|
451
|
+
this.handleImageSrc(newSrc);
|
446
452
|
return;
|
447
453
|
}
|
448
454
|
if (src) {
|
@@ -636,6 +642,10 @@ export class Img extends ImageBase {
|
|
636
642
|
}
|
637
643
|
}
|
638
644
|
}
|
645
|
+
async initImage() {
|
646
|
+
// this.nativeImageViewProtected.setImageURI(null);
|
647
|
+
this.handleImageSrc(this.src);
|
648
|
+
}
|
639
649
|
updateHierarchy() {
|
640
650
|
if (!this.mCanUpdateHierarchy) {
|
641
651
|
this.mNeedUpdateHierarchy = true;
|
package/index.d.ts
CHANGED
@@ -363,7 +363,7 @@ export class ImagePipeline {
|
|
363
363
|
* Returns the actual cache key for url + context
|
364
364
|
* this is an iOS feature because imageView properties are used for the cache key
|
365
365
|
*/
|
366
|
-
getCacheKey(uri: string,
|
366
|
+
getCacheKey(uri: string, options: Partial<Img>): string;
|
367
367
|
|
368
368
|
/**
|
369
369
|
* Returns whether the image is stored in the disk cache.
|
package/index.ios.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export * from './index-common';
|
2
|
-
import { EventData, ImageBase, ImageInfo as ImageInfoBase, ImagePipelineConfigSetting } from './index-common';
|
2
|
+
import { EventData, ImageBase, ImageInfo as ImageInfoBase, ImagePipelineConfigSetting, SrcType } from './index-common';
|
3
3
|
export declare class ImageInfo implements ImageInfoBase {
|
4
4
|
private width;
|
5
5
|
private height;
|
@@ -16,7 +16,7 @@ export declare function shutDown(): void;
|
|
16
16
|
export declare class ImagePipeline {
|
17
17
|
private mIos;
|
18
18
|
constructor();
|
19
|
-
getCacheKey(uri: string,
|
19
|
+
getCacheKey(uri: string, options: Partial<Img>): string;
|
20
20
|
isInDiskCache(key: string): boolean;
|
21
21
|
isInBitmapMemoryCache(key: string): boolean;
|
22
22
|
evictFromMemoryCache(key: string): void;
|
@@ -40,7 +40,7 @@ export declare class Img extends ImageBase {
|
|
40
40
|
contextOptions: any;
|
41
41
|
get cacheKey(): string;
|
42
42
|
protected mImageSourceAffectsLayout: boolean;
|
43
|
-
|
43
|
+
mCIFilter: CIFilter;
|
44
44
|
createNativeView(): UIImageView;
|
45
45
|
_setNativeClipToBounds(): void;
|
46
46
|
onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
|
@@ -50,6 +50,7 @@ export declare class Img extends ImageBase {
|
|
50
50
|
private onLoadProgress;
|
51
51
|
private getUIImage;
|
52
52
|
protected initImage(): Promise<void>;
|
53
|
+
protected handleImageSrc(src: SrcType): Promise<void>;
|
53
54
|
placeholderImage: UIImage;
|
54
55
|
startAnimating(): void;
|
55
56
|
stopAnimating(): void;
|
package/index.ios.js
CHANGED
@@ -73,11 +73,45 @@ export function initialize(config) {
|
|
73
73
|
SDImageLoadersManager.sharedManager.loaders = NSArray.arrayWithArray([SDWebImageDownloader.sharedDownloader, SDImagePhotosLoader.sharedLoader]);
|
74
74
|
}
|
75
75
|
export function shutDown() { }
|
76
|
+
function getContextFromOptions(options) {
|
77
|
+
const context = NSMutableDictionary.dictionary();
|
78
|
+
const transformers = [];
|
79
|
+
if (options.decodeWidth || options.decodeHeight) {
|
80
|
+
//@ts-ignore
|
81
|
+
transformers.push(NSImageDecodeSizeTransformer.transformerWithDecodeWidthDecodeHeight(options.decodeWidth || options.decodeHeight, options.decodeHeight || options.decodeWidth));
|
82
|
+
}
|
83
|
+
if (options.tintColor) {
|
84
|
+
transformers.push(SDImageTintTransformer.transformerWithColor(options.tintColor.ios));
|
85
|
+
}
|
86
|
+
if (options.blurRadius) {
|
87
|
+
transformers.push(SDImageBlurTransformer.transformerWithRadius(options.blurRadius));
|
88
|
+
}
|
89
|
+
if (options.roundAsCircle === true) {
|
90
|
+
//@ts-ignore
|
91
|
+
transformers.push(NSImageRoundAsCircleTransformer.transformer());
|
92
|
+
}
|
93
|
+
if (options.imageRotation !== 0 && !isNaN(options.imageRotation)) {
|
94
|
+
transformers.push(SDImageRotationTransformer.transformerWithAngleFitSize(-options.imageRotation * (Math.PI / 180), true));
|
95
|
+
}
|
96
|
+
if (options.roundBottomLeftRadius || options.roundBottomRightRadius || options.roundTopLeftRadius || options.roundTopRightRadius) {
|
97
|
+
transformers.push(
|
98
|
+
//@ts-ignore
|
99
|
+
NSImageRoundCornerTransformer.transformerWithTopLefRadiusTopRightRadiusBottomRightRadiusBottomLeftRadius(layout.toDeviceIndependentPixels(options.roundTopLeftRadius), layout.toDeviceIndependentPixels(options.roundTopRightRadius), layout.toDeviceIndependentPixels(options.roundBottomRightRadius), layout.toDeviceIndependentPixels(options.roundBottomLeftRadius)));
|
100
|
+
}
|
101
|
+
if (options.mCIFilter) {
|
102
|
+
transformers.push(SDImageFilterTransformer.transformerWithFilter(options.mCIFilter));
|
103
|
+
}
|
104
|
+
if (transformers.length > 0) {
|
105
|
+
context.setValueForKey(SDImagePipelineTransformer.transformerWithTransformers(transformers), SDWebImageContextImageTransformer);
|
106
|
+
}
|
107
|
+
return context;
|
108
|
+
}
|
76
109
|
export class ImagePipeline {
|
77
110
|
constructor() {
|
78
111
|
this.mIos = SDImageCache.sharedImageCache;
|
79
112
|
}
|
80
|
-
getCacheKey(uri,
|
113
|
+
getCacheKey(uri, options) {
|
114
|
+
const context = getContextFromOptions(options);
|
81
115
|
return SDWebImageManager.sharedManager.cacheKeyForURLContext(NSURL.URLWithString(uri), context);
|
82
116
|
}
|
83
117
|
isInDiskCache(key) {
|
@@ -283,7 +317,8 @@ export class Img extends ImageBase {
|
|
283
317
|
async updateImageUri() {
|
284
318
|
const imagePipeLine = getImagePipeline();
|
285
319
|
const src = this.src;
|
286
|
-
|
320
|
+
const srcType = typeof src;
|
321
|
+
if (src && (srcType === 'string' || src instanceof ImageAsset)) {
|
287
322
|
const cachekKey = this.mCacheKey || getUri(src).absoluteString;
|
288
323
|
// const isInCache = imagePipeLine.isInBitmapMemoryCache(cachekKey);
|
289
324
|
// if (isInCache) {
|
@@ -353,10 +388,21 @@ export class Img extends ImageBase {
|
|
353
388
|
return image?.ios;
|
354
389
|
}
|
355
390
|
async initImage() {
|
391
|
+
// this.nativeImageViewProtected.setImageURI(null);
|
392
|
+
this.handleImageSrc(this.src);
|
393
|
+
}
|
394
|
+
async handleImageSrc(src) {
|
356
395
|
if (this.nativeViewProtected) {
|
357
|
-
const src = this.src;
|
358
396
|
if (src instanceof Promise) {
|
359
|
-
this.
|
397
|
+
this.handleImageSrc(await src);
|
398
|
+
return;
|
399
|
+
}
|
400
|
+
else if (typeof src === 'function') {
|
401
|
+
const newSrc = src();
|
402
|
+
if (newSrc instanceof Promise) {
|
403
|
+
await newSrc;
|
404
|
+
}
|
405
|
+
this.handleImageSrc(newSrc);
|
360
406
|
return;
|
361
407
|
}
|
362
408
|
if (src) {
|
@@ -396,47 +442,17 @@ export class Img extends ImageBase {
|
|
396
442
|
if (this.alwaysFade === true) {
|
397
443
|
options |= 131072 /* SDWebImageOptions.ForceTransition */;
|
398
444
|
}
|
399
|
-
const context = NSMutableDictionary.dictionary();
|
400
|
-
const transformers = [];
|
401
445
|
if (this.progressiveRenderingEnabled === true) {
|
402
446
|
options = options | 4 /* SDWebImageOptions.ProgressiveLoad */;
|
403
447
|
}
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
if (this.tintColor) {
|
409
|
-
transformers.push(SDImageTintTransformer.transformerWithColor(this.tintColor.ios));
|
410
|
-
}
|
411
|
-
if (this.blurRadius) {
|
412
|
-
transformers.push(SDImageBlurTransformer.transformerWithRadius(this.blurRadius));
|
413
|
-
}
|
414
|
-
if (this.roundAsCircle === true) {
|
415
|
-
//@ts-ignore
|
416
|
-
transformers.push(NSImageRoundAsCircleTransformer.transformer());
|
417
|
-
}
|
418
|
-
if (this.imageRotation !== 0 && !isNaN(this.imageRotation)) {
|
419
|
-
transformers.push(SDImageRotationTransformer.transformerWithAngleFitSize(-this.imageRotation * (Math.PI / 180), true));
|
420
|
-
}
|
421
|
-
if (this.roundBottomLeftRadius || this.roundBottomRightRadius || this.roundTopLeftRadius || this.roundTopRightRadius) {
|
422
|
-
transformers.push(
|
423
|
-
//@ts-ignore
|
424
|
-
NSImageRoundCornerTransformer.transformerWithTopLefRadiusTopRightRadiusBottomRightRadiusBottomLeftRadius(layout.toDeviceIndependentPixels(this.roundTopLeftRadius), layout.toDeviceIndependentPixels(this.roundTopRightRadius), layout.toDeviceIndependentPixels(this.roundBottomRightRadius), layout.toDeviceIndependentPixels(this.roundBottomLeftRadius)));
|
425
|
-
}
|
426
|
-
if (this.mCIFilter) {
|
427
|
-
transformers.push(SDImageFilterTransformer.transformerWithFilter(this.mCIFilter));
|
428
|
-
}
|
429
|
-
if (transformers.length > 0) {
|
430
|
-
if (this.animatedImageView) {
|
431
|
-
// as we use SDAnimatedImageView all images are loaded as SDAnimatedImage;
|
432
|
-
options |= 512 /* SDWebImageOptions.TransformAnimatedImage */;
|
433
|
-
}
|
434
|
-
context.setValueForKey(SDImagePipelineTransformer.transformerWithTransformers(transformers), SDWebImageContextImageTransformer);
|
435
|
-
// context.setValueForKey(SDImageCacheType.Memory, SDWebImageContextOriginalStoreCacheType);
|
448
|
+
const context = getContextFromOptions(this);
|
449
|
+
if (this.animatedImageView) {
|
450
|
+
// as we use SDAnimatedImageView all images are loaded as SDAnimatedImage;
|
451
|
+
options |= 512 /* SDWebImageOptions.TransformAnimatedImage */;
|
436
452
|
}
|
437
453
|
if (this.contextOptions && typeof this.contextOptions === 'object') {
|
438
|
-
Object.keys(this.contextOptions).forEach(k => {
|
439
|
-
|
454
|
+
Object.keys(this.contextOptions).forEach((k) => {
|
455
|
+
const value = this.contextOptions[k];
|
440
456
|
context.setValueForKey(value, k);
|
441
457
|
});
|
442
458
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-image",
|
3
|
-
"version": "4.3.
|
3
|
+
"version": "4.3.37",
|
4
4
|
"description": "Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.",
|
5
5
|
"main": "./index",
|
6
6
|
"sideEffects": false,
|
@@ -36,5 +36,5 @@
|
|
36
36
|
},
|
37
37
|
"license": "Apache-2.0",
|
38
38
|
"readmeFilename": "README.md",
|
39
|
-
"gitHead": "
|
39
|
+
"gitHead": "a1f4614ab21fa8dea1cbe21fbd5525f83779b793"
|
40
40
|
}
|
Binary file
|