@nativescript-community/ui-image 4.3.34 → 4.3.36
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 +5 -3
- package/index.ios.js +62 -38
- package/package.json +2 -2
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.36](https://github.com/nativescript-community/ui-image/compare/v4.3.35...v4.3.36) (2024-03-28)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
9
|
+
|
10
|
+
## [4.3.35](https://github.com/nativescript-community/ui-image/compare/v4.3.34...v4.3.35) (2024-03-22)
|
11
|
+
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
13
|
+
|
6
14
|
## [4.3.34](https://github.com/nativescript-community/ui-image/compare/v4.3.33...v4.3.34) (2024-02-27)
|
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;
|
@@ -37,9 +37,10 @@ export declare class Img extends ImageBase {
|
|
37
37
|
nativeImageViewProtected: SDAnimatedImageView | UIImageView;
|
38
38
|
isLoading: boolean;
|
39
39
|
mCacheKey: string;
|
40
|
+
contextOptions: any;
|
40
41
|
get cacheKey(): string;
|
41
42
|
protected mImageSourceAffectsLayout: boolean;
|
42
|
-
|
43
|
+
mCIFilter: CIFilter;
|
43
44
|
createNativeView(): UIImageView;
|
44
45
|
_setNativeClipToBounds(): void;
|
45
46
|
onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
|
@@ -49,6 +50,7 @@ export declare class Img extends ImageBase {
|
|
49
50
|
private onLoadProgress;
|
50
51
|
private getUIImage;
|
51
52
|
protected initImage(): Promise<void>;
|
53
|
+
protected handleImageSrc(src: SrcType): Promise<void>;
|
52
54
|
placeholderImage: UIImage;
|
53
55
|
startAnimating(): void;
|
54
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) {
|
@@ -186,6 +220,7 @@ export class Img extends ImageBase {
|
|
186
220
|
constructor() {
|
187
221
|
super(...arguments);
|
188
222
|
this.isLoading = false;
|
223
|
+
this.contextOptions = null;
|
189
224
|
this.mImageSourceAffectsLayout = true;
|
190
225
|
this.handleImageLoaded = (image, error, cacheType) => {
|
191
226
|
this.isLoading = false;
|
@@ -282,17 +317,18 @@ export class Img extends ImageBase {
|
|
282
317
|
async updateImageUri() {
|
283
318
|
const imagePipeLine = getImagePipeline();
|
284
319
|
const src = this.src;
|
285
|
-
|
320
|
+
const srcType = typeof src;
|
321
|
+
if (src && (srcType === 'string' || src instanceof ImageAsset)) {
|
286
322
|
const cachekKey = this.mCacheKey || getUri(src).absoluteString;
|
287
323
|
// const isInCache = imagePipeLine.isInBitmapMemoryCache(cachekKey);
|
288
324
|
// if (isInCache) {
|
289
325
|
await imagePipeLine.evictFromCache(cachekKey);
|
290
326
|
// }
|
291
327
|
}
|
292
|
-
this.src = null;
|
328
|
+
// this.src = null;
|
293
329
|
// ensure we clear the image as
|
294
330
|
this._setNativeImage(null, false);
|
295
|
-
this.
|
331
|
+
this.initImage();
|
296
332
|
}
|
297
333
|
_setNativeImage(nativeImage, animated = true) {
|
298
334
|
if (animated && this.fadeDuration) {
|
@@ -352,10 +388,21 @@ export class Img extends ImageBase {
|
|
352
388
|
return image?.ios;
|
353
389
|
}
|
354
390
|
async initImage() {
|
391
|
+
// this.nativeImageViewProtected.setImageURI(null);
|
392
|
+
this.handleImageSrc(this.src);
|
393
|
+
}
|
394
|
+
async handleImageSrc(src) {
|
355
395
|
if (this.nativeViewProtected) {
|
356
|
-
const src = this.src;
|
357
396
|
if (src instanceof Promise) {
|
358
|
-
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);
|
359
406
|
return;
|
360
407
|
}
|
361
408
|
if (src) {
|
@@ -395,42 +442,19 @@ export class Img extends ImageBase {
|
|
395
442
|
if (this.alwaysFade === true) {
|
396
443
|
options |= 131072 /* SDWebImageOptions.ForceTransition */;
|
397
444
|
}
|
398
|
-
const context = NSMutableDictionary.dictionary();
|
399
|
-
const transformers = [];
|
400
445
|
if (this.progressiveRenderingEnabled === true) {
|
401
446
|
options = options | 4 /* SDWebImageOptions.ProgressiveLoad */;
|
402
447
|
}
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
if (this.tintColor) {
|
408
|
-
transformers.push(SDImageTintTransformer.transformerWithColor(this.tintColor.ios));
|
409
|
-
}
|
410
|
-
if (this.blurRadius) {
|
411
|
-
transformers.push(SDImageBlurTransformer.transformerWithRadius(this.blurRadius));
|
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 */;
|
412
452
|
}
|
413
|
-
if (this.
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
transformers.push(SDImageRotationTransformer.transformerWithAngleFitSize(-this.imageRotation * (Math.PI / 180), true));
|
419
|
-
}
|
420
|
-
if (this.roundBottomLeftRadius || this.roundBottomRightRadius || this.roundTopLeftRadius || this.roundTopRightRadius) {
|
421
|
-
transformers.push(
|
422
|
-
//@ts-ignore
|
423
|
-
NSImageRoundCornerTransformer.transformerWithTopLefRadiusTopRightRadiusBottomRightRadiusBottomLeftRadius(layout.toDeviceIndependentPixels(this.roundTopLeftRadius), layout.toDeviceIndependentPixels(this.roundTopRightRadius), layout.toDeviceIndependentPixels(this.roundBottomRightRadius), layout.toDeviceIndependentPixels(this.roundBottomLeftRadius)));
|
424
|
-
}
|
425
|
-
if (this.mCIFilter) {
|
426
|
-
transformers.push(SDImageFilterTransformer.transformerWithFilter(this.mCIFilter));
|
427
|
-
}
|
428
|
-
if (transformers.length > 0) {
|
429
|
-
if (this.animatedImageView) {
|
430
|
-
// as we use SDAnimatedImageView all images are loaded as SDAnimatedImage;
|
431
|
-
options |= 512 /* SDWebImageOptions.TransformAnimatedImage */;
|
432
|
-
}
|
433
|
-
context.setValueForKey(SDImagePipelineTransformer.transformerWithTransformers(transformers), SDWebImageContextImageTransformer);
|
453
|
+
if (this.contextOptions && typeof this.contextOptions === 'object') {
|
454
|
+
Object.keys(this.contextOptions).forEach((k) => {
|
455
|
+
const value = this.contextOptions[k];
|
456
|
+
context.setValueForKey(value, k);
|
457
|
+
});
|
434
458
|
}
|
435
459
|
this.mCacheKey = SDWebImageManager.sharedManager.cacheKeyForURLContext(uri, context);
|
436
460
|
this.nativeImageViewProtected.sd_setImageWithURLPlaceholderImageOptionsContextProgressCompleted(uri, this.placeholderImage, options, context, this.onLoadProgress, this.handleImageLoaded);
|
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.36",
|
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": "7b2244af770b88316960d3b8cc5b4eb7dccaff0b"
|
40
40
|
}
|