@nativescript-community/ui-image 4.3.2 → 4.3.4
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 +16 -0
- package/index-common.d.ts +3 -0
- package/index-common.js +5 -0
- package/index.android.d.ts +1 -0
- package/index.android.js +100 -41
- package/package.json +2 -2
- package/platforms/android/ui_image.aar +0 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
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.4](https://github.com/nativescript-community/ui-image/compare/v4.3.3...v4.3.4) (2022-09-20)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [4.3.3](https://github.com/nativescript-community/ui-image/compare/v4.3.2...v4.3.3) (2022-09-12)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
6
22
|
## [4.3.2](https://github.com/nativescript-community/ui-image/compare/v4.3.1...v4.3.2) (2022-07-15)
|
7
23
|
|
8
24
|
|
package/index-common.d.ts
CHANGED
@@ -42,6 +42,7 @@ export interface ImageError {
|
|
42
42
|
export interface ImagePipelineConfigSetting {
|
43
43
|
isDownsampleEnabled?: boolean;
|
44
44
|
leakTracker?: any;
|
45
|
+
useOkhttp?: boolean;
|
45
46
|
}
|
46
47
|
export declare class EventData implements IEventData {
|
47
48
|
private _eventName;
|
@@ -84,6 +85,7 @@ export declare class ImageBase extends View {
|
|
84
85
|
decodeWidth: number;
|
85
86
|
decodeHeight: number;
|
86
87
|
animatedImageView: boolean;
|
88
|
+
loadMode: 'sync' | 'async';
|
87
89
|
alwaysFade: boolean;
|
88
90
|
noCache: boolean;
|
89
91
|
tintColor: Color;
|
@@ -115,6 +117,7 @@ export declare class ImageBase extends View {
|
|
115
117
|
static roundTopRightRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
|
116
118
|
static roundBottomLeftRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
|
117
119
|
static roundBottomRightRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
|
120
|
+
static loadModeProperty: Property<ImageBase, "sync" | "async">;
|
118
121
|
static clipToBoundsProperty: Property<ImageBase, boolean>;
|
119
122
|
static animatedImageViewProperty: Property<ImageBase, boolean>;
|
120
123
|
get nativeImageViewProtected(): any;
|
package/index-common.js
CHANGED
@@ -168,6 +168,10 @@ ImageBase.roundBottomRightRadiusProperty = new Property({
|
|
168
168
|
defaultValue: 0,
|
169
169
|
valueConverter: (v) => Length.toDevicePixels(Length.parse(v))
|
170
170
|
});
|
171
|
+
ImageBase.loadModeProperty = new Property({
|
172
|
+
name: 'loadMode',
|
173
|
+
defaultValue: 'sync'
|
174
|
+
});
|
171
175
|
ImageBase.clipToBoundsProperty = new Property({ name: 'clipToBounds', defaultValue: true, valueConverter: booleanConverter });
|
172
176
|
ImageBase.animatedImageViewProperty = new Property({ name: 'animatedImageView', defaultValue: false, valueConverter: booleanConverter });
|
173
177
|
ImageBase.srcProperty.register(ImageBase);
|
@@ -198,4 +202,5 @@ ImageBase.alwaysFadeProperty.register(ImageBase);
|
|
198
202
|
ImageBase.noCacheProperty.register(ImageBase);
|
199
203
|
ImageBase.clipToBoundsProperty.register(ImageBase);
|
200
204
|
ImageBase.animatedImageViewProperty.register(ImageBase);
|
205
|
+
ImageBase.loadModeProperty.register(ImageBase);
|
201
206
|
//# sourceMappingURL=index-common.js.map
|
package/index.android.d.ts
CHANGED
@@ -62,6 +62,7 @@ export declare class FailureEventData extends EventData {
|
|
62
62
|
set error(value: ImageError);
|
63
63
|
}
|
64
64
|
export declare const needRequestImage: (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) => void;
|
65
|
+
export declare const needUpdateHierarchy: (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) => void;
|
65
66
|
export declare class Img extends ImageBase {
|
66
67
|
nativeViewProtected: com.nativescript.image.DraweeView;
|
67
68
|
nativeImageViewProtected: com.nativescript.image.DraweeView;
|
package/index.android.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _a, _b, _c, _d;
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
2
2
|
export * from './index-common';
|
3
3
|
import { Color, Image, ImageAsset, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
|
4
4
|
import { android as androidApp } from '@nativescript/core/application';
|
@@ -14,11 +14,23 @@ export function initialize(config) {
|
|
14
14
|
initializeConfig = config;
|
15
15
|
return;
|
16
16
|
}
|
17
|
-
|
18
|
-
|
17
|
+
let builder;
|
18
|
+
const useOkhttp = config === null || config === void 0 ? void 0 : config.useOkhttp;
|
19
|
+
if (useOkhttp) {
|
20
|
+
if (useOkhttp instanceof okhttp3.OkHttpClient) {
|
21
|
+
builder = com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory.newBuilder(context, useOkhttp);
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
builder = com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory.newBuilder(context, new okhttp3.OkHttpClient());
|
25
|
+
}
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
builder = com.facebook.imagepipeline.core.ImagePipelineConfig.newBuilder(context);
|
29
|
+
}
|
30
|
+
if (config === null || config === void 0 ? void 0 : config.isDownsampleEnabled) {
|
19
31
|
builder.setDownsampleEnabled(true);
|
20
32
|
}
|
21
|
-
if (config
|
33
|
+
if (config === null || config === void 0 ? void 0 : config.leakTracker) {
|
22
34
|
builder.setCloseableReferenceLeakTracker(config.leakTracker);
|
23
35
|
}
|
24
36
|
const imagePipelineConfig = builder.build();
|
@@ -54,13 +66,9 @@ function getUri(src) {
|
|
54
66
|
imagePath = src;
|
55
67
|
}
|
56
68
|
if (isFileOrResourcePath(imagePath)) {
|
57
|
-
const res = ad.getApplicationContext().getResources();
|
58
|
-
if (!res) {
|
59
|
-
return null;
|
60
|
-
}
|
61
69
|
if (imagePath.indexOf(RESOURCE_PREFIX) === 0) {
|
62
|
-
const resName = imagePath.
|
63
|
-
const identifier =
|
70
|
+
const resName = imagePath.substring(RESOURCE_PREFIX.length);
|
71
|
+
const identifier = Utils.ad.resources.getDrawableId(resName);
|
64
72
|
if (0 < identifier) {
|
65
73
|
uri = new android.net.Uri.Builder().scheme(com.facebook.common.util.UriUtil.LOCAL_RESOURCE_SCHEME).path(java.lang.String.valueOf(identifier)).build();
|
66
74
|
}
|
@@ -219,6 +227,16 @@ export const needRequestImage = function (target, propertyKey, descriptor) {
|
|
219
227
|
return originalMethod.apply(this, args);
|
220
228
|
};
|
221
229
|
};
|
230
|
+
export const needUpdateHierarchy = function (target, propertyKey, descriptor) {
|
231
|
+
const originalMethod = descriptor.value;
|
232
|
+
descriptor.value = function (...args) {
|
233
|
+
if (!this._canUpdateHierarchy) {
|
234
|
+
this._needUpdateHierarchy = true;
|
235
|
+
return;
|
236
|
+
}
|
237
|
+
return originalMethod.apply(this, args);
|
238
|
+
};
|
239
|
+
};
|
222
240
|
export class Img extends ImageBase {
|
223
241
|
constructor() {
|
224
242
|
super(...arguments);
|
@@ -283,64 +301,64 @@ export class Img extends ImageBase {
|
|
283
301
|
this.src = null;
|
284
302
|
this.src = src;
|
285
303
|
}
|
286
|
-
[ImageBase.placeholderImageUriProperty.setNative]() {
|
304
|
+
[_a = ImageBase.placeholderImageUriProperty.setNative]() {
|
287
305
|
this.updateHierarchy();
|
288
306
|
}
|
289
|
-
[ImageBase.failureImageUriProperty.setNative]() {
|
307
|
+
[_b = ImageBase.failureImageUriProperty.setNative]() {
|
290
308
|
this.updateHierarchy();
|
291
309
|
}
|
292
|
-
[ImageBase.stretchProperty.setNative]() {
|
310
|
+
[_c = ImageBase.stretchProperty.setNative]() {
|
293
311
|
this.updateHierarchy();
|
294
312
|
}
|
295
|
-
[ImageBase.fadeDurationProperty.setNative]() {
|
313
|
+
[_d = ImageBase.fadeDurationProperty.setNative]() {
|
296
314
|
this.updateHierarchy();
|
297
315
|
}
|
298
|
-
[ImageBase.backgroundUriProperty.setNative]() {
|
316
|
+
[_e = ImageBase.backgroundUriProperty.setNative]() {
|
299
317
|
this.updateHierarchy();
|
300
318
|
}
|
301
|
-
[ImageBase.showProgressBarProperty.setNative]() {
|
319
|
+
[_f = ImageBase.showProgressBarProperty.setNative]() {
|
302
320
|
this.updateHierarchy();
|
303
321
|
}
|
304
|
-
[ImageBase.progressBarColorProperty.setNative]() {
|
322
|
+
[_g = ImageBase.progressBarColorProperty.setNative]() {
|
305
323
|
this.updateHierarchy();
|
306
324
|
}
|
307
|
-
[ImageBase.roundAsCircleProperty.setNative]() {
|
325
|
+
[_h = ImageBase.roundAsCircleProperty.setNative]() {
|
308
326
|
this.updateHierarchy();
|
309
327
|
}
|
310
|
-
[ImageBase.roundTopLeftRadiusProperty.setNative]() {
|
328
|
+
[_j = ImageBase.roundTopLeftRadiusProperty.setNative]() {
|
311
329
|
this.updateHierarchy();
|
312
330
|
}
|
313
331
|
[ImageBase.imageRotationProperty.setNative](value) {
|
314
|
-
var
|
332
|
+
var _u;
|
315
333
|
const scaleType = this.nativeImageViewProtected.getHierarchy().getActualImageScaleType();
|
316
|
-
(
|
334
|
+
(_u = scaleType['setImageRotation']) === null || _u === void 0 ? void 0 : _u.call(scaleType, value);
|
317
335
|
this.nativeImageViewProtected.invalidate();
|
318
336
|
}
|
319
|
-
[ImageBase.roundTopRightRadiusProperty.setNative]() {
|
337
|
+
[_k = ImageBase.roundTopRightRadiusProperty.setNative]() {
|
320
338
|
this.updateHierarchy();
|
321
339
|
}
|
322
|
-
[ImageBase.roundBottomLeftRadiusProperty.setNative]() {
|
340
|
+
[_l = ImageBase.roundBottomLeftRadiusProperty.setNative]() {
|
323
341
|
this.updateHierarchy();
|
324
342
|
}
|
325
|
-
[ImageBase.roundBottomRightRadiusProperty.setNative]() {
|
343
|
+
[_m = ImageBase.roundBottomRightRadiusProperty.setNative]() {
|
326
344
|
this.updateHierarchy();
|
327
345
|
}
|
328
|
-
[ImageBase.tintColorProperty.setNative](value) {
|
346
|
+
[_o = ImageBase.tintColorProperty.setNative](value) {
|
329
347
|
this.updateHierarchy();
|
330
348
|
}
|
331
|
-
[ImageBase.blurRadiusProperty.setNative]() {
|
349
|
+
[_p = ImageBase.blurRadiusProperty.setNative]() {
|
332
350
|
this.initImage();
|
333
351
|
}
|
334
|
-
[
|
352
|
+
[_q = ImageBase.srcProperty.setNative]() {
|
335
353
|
this.initImage();
|
336
354
|
}
|
337
|
-
[
|
355
|
+
[_r = ImageBase.lowerResSrcProperty.setNative]() {
|
338
356
|
this.initImage();
|
339
357
|
}
|
340
|
-
[
|
358
|
+
[_s = ImageBase.blurDownSamplingProperty.setNative]() {
|
341
359
|
this.initImage();
|
342
360
|
}
|
343
|
-
[
|
361
|
+
[_t = ImageBase.aspectRatioProperty.setNative]() {
|
344
362
|
this.initImage();
|
345
363
|
}
|
346
364
|
async initImage() {
|
@@ -369,8 +387,12 @@ export class Img extends ImageBase {
|
|
369
387
|
hierarchy.setImage(drawable, 1, hierarchy.getFadeDuration() === 0);
|
370
388
|
return;
|
371
389
|
}
|
390
|
+
const uri = getUri(src);
|
391
|
+
if (!uri) {
|
392
|
+
console.log(`Error: 'src' not valid: ${src}`);
|
393
|
+
return;
|
394
|
+
}
|
372
395
|
if (this.noCache) {
|
373
|
-
const uri = getUri(src);
|
374
396
|
const imagePipeLine = getImagePipeline();
|
375
397
|
const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
|
376
398
|
if (isInCache) {
|
@@ -378,11 +400,6 @@ export class Img extends ImageBase {
|
|
378
400
|
}
|
379
401
|
}
|
380
402
|
this.isLoading = true;
|
381
|
-
const uri = getUri(src);
|
382
|
-
if (!uri) {
|
383
|
-
console.log(`Error: 'src' not valid: ${src}`);
|
384
|
-
return;
|
385
|
-
}
|
386
403
|
let requestBuilder = com.facebook.imagepipeline.request.ImageRequestBuilder.newBuilderWithSource(uri).setRotationOptions(com.facebook.imagepipeline.common.RotationOptions.autoRotate());
|
387
404
|
if (this.progressiveRenderingEnabled === true) {
|
388
405
|
requestBuilder = requestBuilder.setProgressiveRenderingEnabled(this.progressiveRenderingEnabled);
|
@@ -423,7 +440,7 @@ export class Img extends ImageBase {
|
|
423
440
|
},
|
424
441
|
onFailure(id, throwable) {
|
425
442
|
if (Trace.isEnabled()) {
|
426
|
-
CLog(CLogTypes.info, 'onFailure', id, throwable);
|
443
|
+
CLog(CLogTypes.info, 'onFailure', id, throwable.getLocalizedMessage());
|
427
444
|
}
|
428
445
|
const nativeView = that && that.get();
|
429
446
|
if (nativeView) {
|
@@ -661,17 +678,59 @@ export class Img extends ImageBase {
|
|
661
678
|
}
|
662
679
|
}
|
663
680
|
__decorate([
|
664
|
-
|
681
|
+
needUpdateHierarchy
|
665
682
|
], Img.prototype, _a, null);
|
666
683
|
__decorate([
|
667
|
-
|
684
|
+
needUpdateHierarchy
|
668
685
|
], Img.prototype, _b, null);
|
669
686
|
__decorate([
|
670
|
-
|
687
|
+
needUpdateHierarchy
|
671
688
|
], Img.prototype, _c, null);
|
672
689
|
__decorate([
|
673
|
-
|
690
|
+
needUpdateHierarchy
|
674
691
|
], Img.prototype, _d, null);
|
692
|
+
__decorate([
|
693
|
+
needUpdateHierarchy
|
694
|
+
], Img.prototype, _e, null);
|
695
|
+
__decorate([
|
696
|
+
needUpdateHierarchy
|
697
|
+
], Img.prototype, _f, null);
|
698
|
+
__decorate([
|
699
|
+
needUpdateHierarchy
|
700
|
+
], Img.prototype, _g, null);
|
701
|
+
__decorate([
|
702
|
+
needUpdateHierarchy
|
703
|
+
], Img.prototype, _h, null);
|
704
|
+
__decorate([
|
705
|
+
needUpdateHierarchy
|
706
|
+
], Img.prototype, _j, null);
|
707
|
+
__decorate([
|
708
|
+
needUpdateHierarchy
|
709
|
+
], Img.prototype, _k, null);
|
710
|
+
__decorate([
|
711
|
+
needUpdateHierarchy
|
712
|
+
], Img.prototype, _l, null);
|
713
|
+
__decorate([
|
714
|
+
needUpdateHierarchy
|
715
|
+
], Img.prototype, _m, null);
|
716
|
+
__decorate([
|
717
|
+
needUpdateHierarchy
|
718
|
+
], Img.prototype, _o, null);
|
719
|
+
__decorate([
|
720
|
+
needRequestImage
|
721
|
+
], Img.prototype, _p, null);
|
722
|
+
__decorate([
|
723
|
+
needRequestImage
|
724
|
+
], Img.prototype, _q, null);
|
725
|
+
__decorate([
|
726
|
+
needRequestImage
|
727
|
+
], Img.prototype, _r, null);
|
728
|
+
__decorate([
|
729
|
+
needRequestImage
|
730
|
+
], Img.prototype, _s, null);
|
731
|
+
__decorate([
|
732
|
+
needRequestImage
|
733
|
+
], Img.prototype, _t, null);
|
675
734
|
class GenericDraweeHierarchyBuilder {
|
676
735
|
constructor() {
|
677
736
|
const res = ad.getApplicationContext().getResources();
|
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.4",
|
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,
|
@@ -44,5 +44,5 @@
|
|
44
44
|
},
|
45
45
|
"license": "Apache-2.0",
|
46
46
|
"readmeFilename": "README.md",
|
47
|
-
"gitHead": "
|
47
|
+
"gitHead": "9bd6af7233a62486e754dcdbeb8a95a53e73c041"
|
48
48
|
}
|
Binary file
|