@nativescript-community/ui-image 4.3.5 → 4.3.7

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 CHANGED
@@ -3,6 +3,25 @@
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.7](https://github.com/nativescript-community/ui-image/compare/v4.3.6...v4.3.7) (2023-05-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **android:** better native-api-usage ([be61cc8](https://github.com/nativescript-community/ui-image/commit/be61cc8b4963baf91c743eee465d7ddba2233e84))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.3.6](https://github.com/nativescript-community/ui-image/compare/v4.3.5...v4.3.6) (2022-12-01)
18
+
19
+ **Note:** Version bump only for package @nativescript-community/ui-image
20
+
21
+
22
+
23
+
24
+
6
25
  ## [4.3.5](https://github.com/nativescript-community/ui-image/compare/v4.3.4...v4.3.5) (2022-09-29)
7
26
 
8
27
  **Note:** Version bump only for package @nativescript-community/ui-image
package/README.md CHANGED
@@ -56,9 +56,15 @@
56
56
  * [Flavors](#flavors)
57
57
  * [Demos](#demos)
58
58
  * [Demos and Development](#demos-and-development)
59
- * [Setup](#setup)
59
+ * [Repo Setup](#repo-setup)
60
60
  * [Build](#build)
61
61
  * [Demos](#demos-1)
62
+ * [Contributing](#contributing)
63
+ * [Update repo ](#update-repo-)
64
+ * [Update readme ](#update-readme-)
65
+ * [Update doc ](#update-doc-)
66
+ * [Publish](#publish)
67
+ * [modifying submodules](#modifying-submodules)
62
68
  * [Questions](#questions)
63
69
 
64
70
 
@@ -630,18 +636,18 @@ $ ns run ios|android
630
636
  ## Demos and Development
631
637
 
632
638
 
633
- ### Setup
634
-
635
- To run the demos, you must clone this repo **recursively**.
639
+ ### Repo Setup
636
640
 
641
+ The repo uses submodules. If you did not clone with ` --recursive` then you need to call
637
642
  ```
638
- git clone https://github.com/@nativescript-community/ui-image.git --recursive
643
+ git submodule update --init
639
644
  ```
640
645
 
641
- **Install Dependencies:**
642
- ```bash
643
- npm i # or 'yarn install' or 'pnpm install'
644
- ```
646
+ The package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.
647
+
648
+ To develop and test:
649
+ if you use `yarn` then run `yarn`
650
+ if you use `pnpm` then run `pnpm i`
645
651
 
646
652
  **Interactive Menu:**
647
653
 
@@ -650,10 +656,9 @@ To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`)
650
656
  ### Build
651
657
 
652
658
  ```bash
653
- npm run build
654
-
655
- npm run build.angular # or for Angular
659
+ npm run build.all
656
660
  ```
661
+ WARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`
657
662
 
658
663
  ### Demos
659
664
 
@@ -662,6 +667,61 @@ npm run demo.[ng|react|svelte|vue].[ios|android]
662
667
 
663
668
  npm run demo.svelte.ios # Example
664
669
  ```
670
+
671
+ Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`
672
+ Instead you work in `demo-snippets/[ng|react|svelte|vue]`
673
+ You can start from the `install.ts` of each flavor to see how to register new demos
674
+
675
+
676
+ [](#contributing)
677
+
678
+ ## Contributing
679
+
680
+ ### Update repo
681
+
682
+ You can update the repo files quite easily
683
+
684
+ First update the submodules
685
+
686
+ ```bash
687
+ npm run update
688
+ ```
689
+
690
+ Then commit the changes
691
+ Then update common files
692
+
693
+ ```bash
694
+ npm run sync
695
+ ```
696
+ Then you can run `yarn|pnpm`, commit changed files if any
697
+
698
+ ### Update readme
699
+ ```bash
700
+ npm run readme
701
+ ```
702
+
703
+ ### Update doc
704
+ ```bash
705
+ npm run doc
706
+ ```
707
+
708
+ ### Publish
709
+
710
+ The publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)
711
+ Simply run
712
+ ```shell
713
+ npm run publish
714
+ ```
715
+
716
+ ### modifying submodules
717
+
718
+ The repo uses https:// for submodules which means you won't be able to push directly into the submodules.
719
+ One easy solution is t modify `~/.gitconfig` and add
720
+ ```
721
+ [url "ssh://git@github.com/"]
722
+ pushInsteadOf = https://github.com/
723
+ ```
724
+
665
725
 
666
726
  [](#questions)
667
727
 
package/index-common.js CHANGED
@@ -46,6 +46,7 @@ export class EventData {
46
46
  }
47
47
  }
48
48
  export class ImageBase extends View {
49
+ // public static blendingModeProperty = new Property<ImageBase, string>({ name: 'blendingMode' });
49
50
  get nativeImageViewProtected() {
50
51
  return this.nativeViewProtected;
51
52
  }
@@ -98,6 +99,7 @@ export class ImageBase extends View {
98
99
  scaleH = measureScale / nativeScale;
99
100
  }
100
101
  else {
102
+ // No infinite dimensions.
101
103
  switch (this.stretch) {
102
104
  case ScaleType.FitXY:
103
105
  case ScaleType.FocusCrop:
@@ -203,4 +205,5 @@ ImageBase.noCacheProperty.register(ImageBase);
203
205
  ImageBase.clipToBoundsProperty.register(ImageBase);
204
206
  ImageBase.animatedImageViewProperty.register(ImageBase);
205
207
  ImageBase.loadModeProperty.register(ImageBase);
208
+ // ImageBase.blendingModeProperty.register(ImageBase);
206
209
  //# sourceMappingURL=index-common.js.map
package/index.android.js CHANGED
@@ -3,36 +3,40 @@ 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';
5
5
  import { isString } from '@nativescript/core/utils/types';
6
- import { RESOURCE_PREFIX, ad, isFileOrResourcePath, isFontIconURI } from '@nativescript/core/utils/utils';
7
6
  import { CLog, CLogTypes, EventData, ImageBase, ScaleType } from './index-common';
7
+ import { layout } from '@nativescript/core/utils/layout-helper';
8
8
  let initialized = false;
9
9
  let initializeConfig;
10
10
  export function initialize(config) {
11
11
  if (!initialized) {
12
- const context = ad.getApplicationContext();
12
+ const context = Utils.ad.getApplicationContext();
13
13
  if (!context) {
14
14
  initializeConfig = config;
15
15
  return;
16
16
  }
17
17
  let builder;
18
- const useOkhttp = config === null || config === void 0 ? void 0 : config.useOkhttp;
18
+ const useOkhttp = config?.useOkhttp;
19
19
  if (useOkhttp) {
20
+ //@ts-ignore
20
21
  if (useOkhttp instanceof okhttp3.OkHttpClient) {
22
+ //@ts-ignore
21
23
  builder = com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory.newBuilder(context, useOkhttp);
22
24
  }
23
25
  else {
26
+ //@ts-ignore
24
27
  builder = com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory.newBuilder(context, new okhttp3.OkHttpClient());
25
28
  }
26
29
  }
27
30
  else {
28
31
  builder = com.facebook.imagepipeline.core.ImagePipelineConfig.newBuilder(context);
29
32
  }
30
- if (config === null || config === void 0 ? void 0 : config.isDownsampleEnabled) {
33
+ if (config?.isDownsampleEnabled) {
31
34
  builder.setDownsampleEnabled(true);
32
35
  }
33
- if (config === null || config === void 0 ? void 0 : config.leakTracker) {
36
+ if (config?.leakTracker) {
34
37
  builder.setCloseableReferenceLeakTracker(config.leakTracker);
35
38
  }
39
+ // builder.experiment().setNativeCodeDisabled(true);
36
40
  const imagePipelineConfig = builder.build();
37
41
  com.facebook.drawee.backends.pipeline.Fresco.initialize(context, imagePipelineConfig);
38
42
  initialized = true;
@@ -65,9 +69,9 @@ function getUri(src) {
65
69
  else {
66
70
  imagePath = src;
67
71
  }
68
- if (isFileOrResourcePath(imagePath)) {
69
- if (imagePath.indexOf(RESOURCE_PREFIX) === 0) {
70
- const resName = imagePath.substring(RESOURCE_PREFIX.length);
72
+ if (Utils.isFileOrResourcePath(imagePath)) {
73
+ if (imagePath.indexOf(Utils.RESOURCE_PREFIX) === 0) {
74
+ const resName = imagePath.substring(Utils.RESOURCE_PREFIX.length);
71
75
  const identifier = Utils.ad.resources.getDrawableId(resName);
72
76
  if (0 < identifier) {
73
77
  uri = new android.net.Uri.Builder().scheme(com.facebook.common.util.UriUtil.LOCAL_RESOURCE_SCHEME).path(java.lang.String.valueOf(identifier)).build();
@@ -134,6 +138,7 @@ export class ImagePipeline {
134
138
  else {
135
139
  datasource = this._android.prefetchToBitmapCache(request, uri);
136
140
  }
141
+ // initializeBaseDataSubscriber();
137
142
  datasource.subscribe(new com.nativescript.image.BaseDataSubscriber(new com.nativescript.image.BaseDataSubscriberListener({
138
143
  onFailure: reject,
139
144
  onNewResult: resolve
@@ -151,6 +156,42 @@ export class ImagePipeline {
151
156
  this._android = value;
152
157
  }
153
158
  fetchImage() {
159
+ // ImagePipeline imagePipeline = Fresco.getImagePipeline();
160
+ // ImageRequest imageRequest = ImageRequestBuilder
161
+ // .newBuilderWithSource(imageUri)
162
+ // .setRequestPriority(Priority.HIGH)
163
+ // .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
164
+ // .build();
165
+ // DataSource<CloseableReference<CloseableImage>> dataSource =
166
+ // imagePipeline.fetchDecodedImage(imageRequest, mContext);
167
+ // try {
168
+ // dataSource.subscribe(new BaseBitmapDataSubscriber() {
169
+ // @Override
170
+ // public void onNewResultImpl(Bitmap bitmap) {
171
+ // if (bitmap == null) {
172
+ // Log.d(TAG, "Bitmap data source returned success, but bitmap null.");
173
+ // return;
174
+ // }
175
+ // // The bitmap provided to this method is only guaranteed to be around
176
+ // // for the lifespan of this method. The image pipeline frees the
177
+ // // bitmap's memory after this method has completed.
178
+ // //
179
+ // // This is fine when passing the bitmap to a system process as
180
+ // // Android automatically creates a copy.
181
+ // //
182
+ // // If you need to keep the bitmap around, look into using a
183
+ // // BaseDataSubscriber instead of a BaseBitmapDataSubscriber.
184
+ // }
185
+ // @Override
186
+ // public void onFailureImpl(DataSource dataSource) {
187
+ // // No cleanup required here
188
+ // }
189
+ // }, CallerThreadExecutor.getInstance());
190
+ // } finally {
191
+ // if (dataSource != null) {
192
+ // dataSource.close();
193
+ // }
194
+ // }
154
195
  }
155
196
  }
156
197
  export class ImageError {
@@ -221,6 +262,8 @@ export const needRequestImage = function (target, propertyKey, descriptor) {
221
262
  descriptor.value = function (...args) {
222
263
  if (!this._canRequestImage) {
223
264
  this._needRequestImage = true;
265
+ // we need to ensure a hierarchy is set or the default aspect ratio wont be set
266
+ // because aspectFit is the default (wanted) but then we wont go into stretchProperty.setNative
224
267
  this._needUpdateHierarchy = true;
225
268
  return;
226
269
  }
@@ -247,6 +290,7 @@ export class Img extends ImageBase {
247
290
  this._needRequestImage = false;
248
291
  }
249
292
  onResumeNativeUpdates() {
293
+ // {N} suspends properties update on `_suspendNativeUpdates`. So we only need to do this in onResumeNativeUpdates
250
294
  this._canRequestImage = false;
251
295
  this._canUpdateHierarchy = false;
252
296
  super.onResumeNativeUpdates();
@@ -266,6 +310,7 @@ export class Img extends ImageBase {
266
310
  initialize(initializeConfig);
267
311
  }
268
312
  const view = new com.nativescript.image.DraweeView(this._context);
313
+ // (view as any).setClipToBounds(false);
269
314
  return view;
270
315
  }
271
316
  updateViewSize(imageInfo) {
@@ -288,6 +333,13 @@ export class Img extends ImageBase {
288
333
  draweeView.setAspectRatio(0);
289
334
  }
290
335
  }
336
+ // public initNativeView(): void {
337
+ // this.initDrawee();
338
+ // this.updateHierarchy();
339
+ // }
340
+ // public disposeNativeView() {
341
+ // this.nativeImageViewProtected.setImageURI(null, null);
342
+ // }
291
343
  updateImageUri() {
292
344
  const imagePipeLine = getImagePipeline();
293
345
  const src = this.src;
@@ -329,9 +381,8 @@ export class Img extends ImageBase {
329
381
  this.updateHierarchy();
330
382
  }
331
383
  [ImageBase.imageRotationProperty.setNative](value) {
332
- var _u;
333
384
  const scaleType = this.nativeImageViewProtected.getHierarchy().getActualImageScaleType();
334
- (_u = scaleType['setImageRotation']) === null || _u === void 0 ? void 0 : _u.call(scaleType, value);
385
+ scaleType['setImageRotation']?.(value);
335
386
  this.nativeImageViewProtected.invalidate();
336
387
  }
337
388
  [_k = ImageBase.roundTopRightRadiusProperty.setNative]() {
@@ -361,8 +412,23 @@ export class Img extends ImageBase {
361
412
  [_t = ImageBase.aspectRatioProperty.setNative]() {
362
413
  this.initImage();
363
414
  }
415
+ // [ImageBase.blendingModeProperty.setNative](value: string) {
416
+ // console.log('blendingModeProperty', value);
417
+ // switch (value) {
418
+ // case 'multiply':
419
+ // (this.nativeImageViewProtected as any).setXfermode(android.graphics.PorterDuff.Mode.MULTIPLY);
420
+ // break;
421
+ // case 'lighten':
422
+ // (this.nativeImageViewProtected as any).setXfermode(android.graphics.PorterDuff.Mode.LIGHTEN);
423
+ // break;
424
+ // }
425
+ // }
426
+ // private initDrawee() {
427
+ // this.initImage();
428
+ // }
364
429
  async initImage() {
365
430
  if (this.nativeImageViewProtected) {
431
+ // this.nativeImageViewProtected.setImageURI(null);
366
432
  const src = this.src;
367
433
  if (src instanceof Promise) {
368
434
  this.src = await src;
@@ -371,15 +437,16 @@ export class Img extends ImageBase {
371
437
  if (src) {
372
438
  let drawable;
373
439
  if (src instanceof ImageSource) {
374
- drawable = new android.graphics.drawable.BitmapDrawable(ad.getApplicationContext().getResources(), src.android);
440
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), src.android);
375
441
  this.updateViewSize(src.android);
376
442
  }
377
- else if (isFontIconURI(src)) {
443
+ else if (Utils.isFontIconURI(src)) {
378
444
  const fontIconCode = src.split('//')[1];
379
445
  if (fontIconCode !== undefined) {
446
+ // support sync mode only
380
447
  const font = this.style.fontInternal;
381
448
  const color = this.style.color;
382
- drawable = new android.graphics.drawable.BitmapDrawable(ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
449
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
383
450
  }
384
451
  }
385
452
  if (drawable) {
@@ -394,12 +461,13 @@ export class Img extends ImageBase {
394
461
  }
395
462
  if (this.noCache) {
396
463
  const imagePipeLine = getImagePipeline();
397
- const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
464
+ const isInCache = imagePipeLine.isInBitmapMemoryCache(uri) || imagePipeLine.isInDiskCache(uri);
398
465
  if (isInCache) {
399
466
  imagePipeLine.evictFromCache(uri);
400
467
  }
401
468
  }
402
469
  this.isLoading = true;
470
+ // const progressiveRenderingEnabledValue = this.progressiveRenderingEnabled !== undefined ? this.progressiveRenderingEnabled : false;
403
471
  let requestBuilder = com.facebook.imagepipeline.request.ImageRequestBuilder.newBuilderWithSource(uri).setRotationOptions(com.facebook.imagepipeline.common.RotationOptions.autoRotate());
404
472
  if (this.progressiveRenderingEnabled === true) {
405
473
  requestBuilder = requestBuilder.setProgressiveRenderingEnabled(this.progressiveRenderingEnabled);
@@ -444,6 +512,7 @@ export class Img extends ImageBase {
444
512
  }
445
513
  const nativeView = that && that.get();
446
514
  if (nativeView) {
515
+ // const nView = nativeView.nativeViewProtected;
447
516
  nativeView.isLoading = false;
448
517
  const imageError = new ImageError(throwable);
449
518
  const args = {
@@ -527,6 +596,8 @@ export class Img extends ImageBase {
527
596
  }
528
597
  }
529
598
  });
599
+ // const async = this.loadMode === 'async';
600
+ // if (async) {
530
601
  const builder = com.facebook.drawee.backends.pipeline.Fresco.newDraweeControllerBuilder();
531
602
  builder.setImageRequest(request);
532
603
  builder.setCallerContext(src);
@@ -553,6 +624,13 @@ export class Img extends ImageBase {
553
624
  }
554
625
  const controller = builder.build();
555
626
  this.nativeImageViewProtected.setController(controller);
627
+ // } else {
628
+ // const dataSource = com.facebook.drawee.backends.pipeline.Fresco.getImagePipeline().fetchDecodedImage(request, src);
629
+ // const result = com.facebook.datasource.DataSources.waitForFinalResult(dataSource);
630
+ // const bitmap = result.get().underlyingBitmap;
631
+ // CloseableReference.closeSafely(result);
632
+ // dataSource.close();
633
+ // }
556
634
  }
557
635
  else {
558
636
  this.nativeImageViewProtected.setController(null);
@@ -620,17 +698,18 @@ export class Img extends ImageBase {
620
698
  getDrawable(path) {
621
699
  let drawable;
622
700
  if (typeof path === 'string') {
623
- if (isFontIconURI(path)) {
701
+ if (Utils.isFontIconURI(path)) {
624
702
  const fontIconCode = path.split('//')[1];
625
703
  if (fontIconCode !== undefined) {
704
+ // support sync mode only
626
705
  const font = this.style.fontInternal;
627
706
  const color = this.style.color;
628
- drawable = new android.graphics.drawable.BitmapDrawable(ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
707
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
629
708
  }
630
709
  }
631
- else if (isFileOrResourcePath(path)) {
632
- if (path.indexOf(RESOURCE_PREFIX) === 0) {
633
- return this.getDrawableFromResource(path);
710
+ else if (Utils.isFileOrResourcePath(path)) {
711
+ if (path.indexOf(Utils.RESOURCE_PREFIX) === 0) {
712
+ return this.getDrawableFromResource(path); // number!
634
713
  }
635
714
  else {
636
715
  drawable = this.getDrawableFromLocalFile(path);
@@ -638,7 +717,7 @@ export class Img extends ImageBase {
638
717
  }
639
718
  }
640
719
  else {
641
- drawable = new android.graphics.drawable.BitmapDrawable(ad.getApplicationContext().getResources(), path.android);
720
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), path.android);
642
721
  }
643
722
  return drawable;
644
723
  }
@@ -646,12 +725,13 @@ export class Img extends ImageBase {
646
725
  const img = ImageSource.fromFileSync(localFilePath);
647
726
  let drawable = null;
648
727
  if (img) {
649
- drawable = new android.graphics.drawable.BitmapDrawable(ad.getApplicationContext().getResources(), img.android);
728
+ drawable = new android.graphics.drawable.BitmapDrawable(Utils.ad.getApplicationContext().getResources(), img.android);
650
729
  }
651
730
  return drawable;
652
731
  }
653
732
  getDrawableFromResource(resourceName) {
654
- const identifier = ad.getApplication().getResources().getIdentifier(resourceName.substr(RESOURCE_PREFIX.length), 'drawable', ad.getApplication().getPackageName());
733
+ const identifier = Utils.ad.getApplication().getResources().getIdentifier(resourceName.substr(Utils.RESOURCE_PREFIX.length), 'drawable', Utils.ad.getApplication().getPackageName());
734
+ // we return the identifier to allow Fresco to handle memory / caching
655
735
  return identifier;
656
736
  }
657
737
  startAnimating() {
@@ -733,7 +813,7 @@ __decorate([
733
813
  ], Img.prototype, _t, null);
734
814
  class GenericDraweeHierarchyBuilder {
735
815
  constructor() {
736
- const res = ad.getApplicationContext().getResources();
816
+ const res = Utils.ad.getApplicationContext().getResources();
737
817
  this.nativeBuilder = new com.facebook.drawee.generic.GenericDraweeHierarchyBuilder(res);
738
818
  }
739
819
  setPlaceholderImage(drawable, scaleType) {
@@ -831,23 +911,31 @@ function getScaleType(scaleType) {
831
911
  if (isString(scaleType)) {
832
912
  switch (scaleType) {
833
913
  case ScaleType.Center:
914
+ //@ts-ignore
834
915
  return new com.nativescript.image.ScalingUtils.ScaleTypeCenter();
835
916
  case ScaleType.AspectFill:
836
917
  case ScaleType.CenterCrop:
918
+ //@ts-ignore
837
919
  return new com.nativescript.image.ScalingUtils.ScaleTypeCenterCrop();
838
920
  case ScaleType.CenterInside:
921
+ //@ts-ignore
839
922
  return new com.nativescript.image.ScalingUtils.ScaleTypeCenterInside();
840
923
  case ScaleType.FitCenter:
841
924
  case ScaleType.AspectFit:
925
+ //@ts-ignore
842
926
  return new com.nativescript.image.ScalingUtils.ScaleTypeFitCenter();
843
927
  case ScaleType.FitEnd:
928
+ //@ts-ignore
844
929
  return new com.nativescript.image.ScalingUtils.ScaleTypeFitEnd();
845
930
  case ScaleType.FitStart:
931
+ //@ts-ignore
846
932
  return new com.nativescript.image.ScalingUtils.ScaleTypeFitStart();
847
933
  case ScaleType.Fill:
848
934
  case ScaleType.FitXY:
935
+ //@ts-ignore
849
936
  return new com.nativescript.image.ScalingUtils.ScaleTypeFitXY();
850
937
  case ScaleType.FocusCrop:
938
+ //@ts-ignore
851
939
  return new com.nativescript.image.ScalingUtils.ScaleTypeFocusCrop();
852
940
  default:
853
941
  break;
package/index.ios.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from './index-common';
2
- import { ImageAsset, ImageSource, Screen, Trace, knownFolders, path } from '@nativescript/core';
2
+ import { ImageAsset, ImageSource, Screen, Trace, Utils, knownFolders, path } from '@nativescript/core';
3
3
  import { isString } from '@nativescript/core/utils/types';
4
- import { RESOURCE_PREFIX, isFileOrResourcePath, isFontIconURI, layout } from '@nativescript/core/utils/utils';
5
4
  import { CLog, CLogTypes, EventData, ImageBase, ScaleType } from './index-common';
5
+ import { layout } from '@nativescript/core/utils/layout-helper';
6
6
  export class ImageInfo {
7
7
  constructor(width, height) {
8
8
  this.width = width;
@@ -23,17 +23,17 @@ function getScaleType(scaleType) {
23
23
  case ScaleType.Center:
24
24
  case ScaleType.CenterCrop:
25
25
  case ScaleType.AspectFill:
26
- return 2;
26
+ return 2 /* SDImageScaleMode.AspectFill */;
27
27
  case ScaleType.CenterInside:
28
28
  case ScaleType.FitCenter:
29
29
  case ScaleType.FitEnd:
30
30
  case ScaleType.FitStart:
31
31
  case ScaleType.AspectFit:
32
- return 1;
32
+ return 1 /* SDImageScaleMode.AspectFit */;
33
33
  case ScaleType.FitXY:
34
34
  case ScaleType.FocusCrop:
35
35
  case ScaleType.Fill:
36
- return 0;
36
+ return 0 /* SDImageScaleMode.Fill */;
37
37
  default:
38
38
  break;
39
39
  }
@@ -44,24 +44,24 @@ function getUIImageScaleType(scaleType) {
44
44
  if (isString(scaleType)) {
45
45
  switch (scaleType) {
46
46
  case ScaleType.Center:
47
- return 4;
47
+ return UIViewContentMode.Center;
48
48
  case ScaleType.FocusCrop:
49
49
  case ScaleType.CenterCrop:
50
50
  case ScaleType.AspectFill:
51
- return 2;
51
+ return UIViewContentMode.ScaleAspectFill;
52
52
  case ScaleType.AspectFit:
53
53
  case ScaleType.CenterInside:
54
54
  case ScaleType.FitCenter:
55
- return 1;
55
+ return UIViewContentMode.ScaleAspectFit;
56
56
  case ScaleType.FitEnd:
57
- return 8;
57
+ return UIViewContentMode.Right;
58
58
  case ScaleType.FitStart:
59
- return 7;
59
+ return UIViewContentMode.Left;
60
60
  case ScaleType.Fill:
61
61
  case ScaleType.FitXY:
62
- return 0;
62
+ return UIViewContentMode.ScaleToFill;
63
63
  case ScaleType.None:
64
- return 9;
64
+ return UIViewContentMode.TopLeft;
65
65
  default:
66
66
  break;
67
67
  }
@@ -102,10 +102,10 @@ export class ImagePipeline {
102
102
  this._ios.clearDiskOnCompletion(null);
103
103
  }
104
104
  prefetchToDiskCache(uri) {
105
- return this.prefetchToCacheType(uri, 1);
105
+ return this.prefetchToCacheType(uri, 1 /* SDImageCacheType.Disk */);
106
106
  }
107
107
  prefetchToMemoryCache(uri) {
108
- return this.prefetchToCacheType(uri, 2);
108
+ return this.prefetchToCacheType(uri, 2 /* SDImageCacheType.Memory */);
109
109
  }
110
110
  prefetchToCacheType(uri, cacheType) {
111
111
  return new Promise((resolve, reject) => {
@@ -135,8 +135,8 @@ function getUri(src) {
135
135
  if (src instanceof ImageAsset) {
136
136
  return NSURL.sd_URLWithAsset(src.ios);
137
137
  }
138
- if (uri.indexOf(RESOURCE_PREFIX) === 0) {
139
- const resName = uri.substr(RESOURCE_PREFIX.length);
138
+ if (uri.indexOf(Utils.RESOURCE_PREFIX) === 0) {
139
+ const resName = uri.substr(Utils.RESOURCE_PREFIX.length);
140
140
  if (screenScale === -1) {
141
141
  screenScale = Screen.mainScreen.scale;
142
142
  }
@@ -171,7 +171,7 @@ export class Img extends ImageBase {
171
171
  if (!this.nativeViewProtected) {
172
172
  return;
173
173
  }
174
- const animate = (this.alwaysFade || cacheType !== 2) && this.fadeDuration > 0;
174
+ const animate = (this.alwaysFade || cacheType !== 2 /* SDImageCacheType.Memory */) && this.fadeDuration > 0;
175
175
  if (image) {
176
176
  this._setNativeImage(image, animate);
177
177
  }
@@ -207,16 +207,18 @@ export class Img extends ImageBase {
207
207
  }
208
208
  createNativeView() {
209
209
  const result = this.animatedImageView ? SDAnimatedImageView.new() : UIImageView.new();
210
- result.contentMode = 1;
210
+ result.contentMode = UIViewContentMode.ScaleAspectFit;
211
211
  result.clipsToBounds = true;
212
- result.userInteractionEnabled = true;
212
+ result.userInteractionEnabled = true; // needed for gestures to work
213
213
  result.tintColor = null;
214
214
  return result;
215
215
  }
216
216
  _setNativeClipToBounds() {
217
+ // Always set clipsToBounds for images
217
218
  this.nativeViewProtected.clipsToBounds = true;
218
219
  }
219
220
  onMeasure(widthMeasureSpec, heightMeasureSpec) {
221
+ // We don't call super because we measure native view with specific size.
220
222
  const width = layout.getMeasureSpecSize(widthMeasureSpec);
221
223
  const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
222
224
  const height = layout.getMeasureSpecSize(heightMeasureSpec);
@@ -233,6 +235,7 @@ export class Img extends ImageBase {
233
235
  const nativeHeight = image ? layout.toDevicePixels(image.size.height) : 0;
234
236
  const imgRatio = nativeWidth / nativeHeight;
235
237
  const ratio = this.aspectRatio || imgRatio;
238
+ // const scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.aspectRatio || imgRatio );
236
239
  if (!finiteWidth) {
237
240
  widthMeasureSpec = layout.makeMeasureSpec(height * ratio, layout.EXACTLY);
238
241
  }
@@ -260,11 +263,28 @@ export class Img extends ImageBase {
260
263
  }
261
264
  _setNativeImage(nativeImage, animated = true) {
262
265
  if (animated) {
266
+ // switch (this.transition) {
267
+ // case 'fade':
263
268
  this.nativeImageViewProtected.alpha = 0.0;
264
269
  this.nativeImageViewProtected.image = nativeImage;
265
270
  UIView.animateWithDurationAnimations(this.fadeDuration / 1000, () => {
266
271
  this.nativeImageViewProtected.alpha = this.opacity;
267
272
  });
273
+ // break;
274
+ // case 'curlUp':
275
+ // UIView.transitionWithViewDurationOptionsAnimationsCompletion(
276
+ // this.nativeImageViewProtected,
277
+ // 0.3,
278
+ // UIViewAnimationOptions.TransitionCrossDissolve,
279
+ // () => {
280
+ // this._setNativeImage(image);
281
+ // },
282
+ // null
283
+ // );
284
+ // break;
285
+ // default:
286
+ // this._setNativeImage(image);
287
+ // }
268
288
  }
269
289
  else {
270
290
  this.nativeImageViewProtected.image = nativeImage;
@@ -280,15 +300,16 @@ export class Img extends ImageBase {
280
300
  }
281
301
  let image;
282
302
  if (typeof imagePath === 'string') {
283
- if (isFontIconURI(imagePath)) {
303
+ if (Utils.isFontIconURI(imagePath)) {
284
304
  const fontIconCode = imagePath.split('//')[1];
285
305
  if (fontIconCode !== undefined) {
306
+ // support sync mode only
286
307
  const font = this.style.fontInternal;
287
308
  const color = this.style.color;
288
309
  image = ImageSource.fromFontIconCodeSync(fontIconCode, font, color).ios;
289
310
  }
290
311
  }
291
- if (!image && isFileOrResourcePath(imagePath)) {
312
+ if (!image && Utils.isFileOrResourcePath(imagePath)) {
292
313
  image = ImageSource.fromFileOrResourceSync(imagePath);
293
314
  }
294
315
  }
@@ -314,9 +335,10 @@ export class Img extends ImageBase {
314
335
  return;
315
336
  }
316
337
  else if (typeof src === 'string') {
317
- if (isFontIconURI(src)) {
338
+ if (Utils.isFontIconURI(src)) {
318
339
  const fontIconCode = src.split('//')[1];
319
340
  if (fontIconCode !== undefined) {
341
+ // support sync mode only
320
342
  const font = this.style.fontInternal;
321
343
  const color = this.style.color;
322
344
  this._setNativeImage(ImageSource.fromFontIconCodeSync(fontIconCode, font, color).ios, animate);
@@ -334,16 +356,17 @@ export class Img extends ImageBase {
334
356
  }
335
357
  }
336
358
  this.isLoading = true;
337
- let options = 2048 | 1024;
359
+ let options = 2048 /* SDWebImageOptions.ScaleDownLargeImages */ | 1024 /* SDWebImageOptions.AvoidAutoSetImage */;
338
360
  if (this.alwaysFade === true) {
339
- options |= 131072;
361
+ options |= 131072 /* SDWebImageOptions.ForceTransition */;
340
362
  }
341
363
  const context = NSMutableDictionary.dictionary();
342
364
  const transformers = [];
343
365
  if (this.progressiveRenderingEnabled === true) {
344
- options = options | 4;
366
+ options = options | 4 /* SDWebImageOptions.ProgressiveLoad */;
345
367
  }
346
368
  if (this.decodeWidth && this.decodeHeight) {
369
+ //@ts-ignore
347
370
  transformers.push(NSImageDecodeSizeTransformer.transformerWithDecodeWidthDecodeHeight(this.decodeWidth, this.decodeHeight));
348
371
  }
349
372
  if (this.tintColor) {
@@ -353,14 +376,18 @@ export class Img extends ImageBase {
353
376
  transformers.push(SDImageBlurTransformer.transformerWithRadius(this.blurRadius));
354
377
  }
355
378
  if (this.roundAsCircle === true) {
379
+ //@ts-ignore
356
380
  transformers.push(NSImageRoundAsCircleTransformer.transformer());
357
381
  }
358
382
  if (this.roundBottomLeftRadius || this.roundBottomRightRadius || this.roundTopLeftRadius || this.roundTopRightRadius) {
359
- transformers.push(NSImageRoundCornerTransformer.transformerWithTopLefRadiusTopRightRadiusBottomRightRadiusBottomLeftRadius(layout.toDeviceIndependentPixels(this.roundTopLeftRadius), layout.toDeviceIndependentPixels(this.roundTopRightRadius), layout.toDeviceIndependentPixels(this.roundBottomRightRadius), layout.toDeviceIndependentPixels(this.roundBottomLeftRadius)));
383
+ transformers.push(
384
+ //@ts-ignore
385
+ NSImageRoundCornerTransformer.transformerWithTopLefRadiusTopRightRadiusBottomRightRadiusBottomLeftRadius(layout.toDeviceIndependentPixels(this.roundTopLeftRadius), layout.toDeviceIndependentPixels(this.roundTopRightRadius), layout.toDeviceIndependentPixels(this.roundBottomRightRadius), layout.toDeviceIndependentPixels(this.roundBottomLeftRadius)));
360
386
  }
361
387
  if (transformers.length > 0) {
362
388
  if (this.animatedImageView) {
363
- options |= 512;
389
+ // as we use SDAnimatedImageView all images are loaded as SDAnimatedImage;
390
+ options |= 512 /* SDWebImageOptions.TransformAnimatedImage */;
364
391
  }
365
392
  context.setValueForKey(SDImagePipelineTransformer.transformerWithTransformers(transformers), SDWebImageContextImageTransformer);
366
393
  }
@@ -382,6 +409,7 @@ export class Img extends ImageBase {
382
409
  this.initImage();
383
410
  }
384
411
  [ImageBase.failureImageUriProperty.setNative]() {
412
+ // this.updateHierarchy();
385
413
  }
386
414
  [ImageBase.stretchProperty.setNative](value) {
387
415
  if (!this.nativeView) {
@@ -389,6 +417,20 @@ export class Img extends ImageBase {
389
417
  }
390
418
  this.nativeImageViewProtected.contentMode = getUIImageScaleType(value);
391
419
  }
420
+ // [ImageBase.blendingModeProperty.setNative](value: string) {
421
+ // console.log('blendingModeProperty', value);
422
+ // switch (value) {
423
+ // case 'multiply':
424
+ // this.nativeImageViewProtected.layer.compositingFilter = 'multiply';
425
+ // break;
426
+ // case 'lighten':
427
+ // this.nativeImageViewProtected.layer.compositingFilter = 'lighten';
428
+ // break;
429
+ // case 'screen':
430
+ // this.nativeImageViewProtected.layer.compositingFilter = 'screen';
431
+ // break;
432
+ // }
433
+ // }
392
434
  startAnimating() {
393
435
  this.nativeImageViewProtected.startAnimating();
394
436
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.3.5",
3
+ "version": "4.3.7",
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": "8e01d92bb19439fe14e45f384a5238cfa4fc90e8"
47
+ "gitHead": "e97c94836db13b09c15553f71ddac95f6d8a38f3"
48
48
  }
@@ -1,35 +1,36 @@
1
1
  {
2
2
  "uses": [
3
- "com.facebook.drawee.drawable:ScalingUtils*",
4
- "com.facebook.drawee.drawable.ScalingUtils:ScaleType*",
5
- "com.facebook.drawee.generic:RoundingParams*",
6
- "com.facebook.drawee.drawable:ProgressBarDrawable*",
7
- "com.facebook.drawee.view:DraweeView*",
8
- "com.facebook.drawee.interfaces:DraweeHierarchy*",
9
- "com.facebook.drawee.interfaces:SettableDraweeHierarchy*",
10
- "com.facebook.drawee.interfaces:SimpleDraweeControllerBuilder*",
11
- "com.facebook.drawee.interfaces:DraweeController*",
12
- "com.facebook.drawee.generic:GenericDraweeHierarchyBuilder*",
13
- "com.facebook.drawee.generic:GenericDraweeHierarchy*",
14
- "com.facebook.imagepipeline.request:ImageRequestBuilder*",
15
- "com.facebook.imagepipeline.request:ImageRequest*",
16
- "com.facebook.imagepipeline.core:ImagePipelineConfig*",
17
- "com.facebook.imagepipeline.common:RotationOptions*",
18
- "com.facebook.imagepipeline.common:ResizeOptions*",
19
- "com.facebook.drawee.backends.pipeline:Fresco*",
20
- "com.facebook.drawee.backends.pipeline:PipelineDraweeControllerBuilder*",
21
- "com.facebook.drawee.backends.pipeline:PipelineDraweeController*",
22
- "com.facebook.drawee.controller:AbstractDraweeControllerBuilder*",
23
- "com.facebook.drawee.controller:AbstractDraweeController*",
24
- "com.facebook.drawee.backends.pipeline.info:ImagePerfDataListener*",
25
- "com.facebook.drawee.backends.pipeline.info:ImagePerfData*",
26
- "com.facebook.drawee.controller:ControllerListener*",
27
- "com.nativescript.image:DraweeView*",
28
- "com.nativescript.image:ScalingBlurPostprocessor*",
3
+ "com.facebook.drawee.drawable:ScalingUtils",
4
+ "com.facebook.drawee.drawable:ScalingUtils.ScaleType",
5
+ "com.facebook.drawee.generic:RoundingParams",
6
+ "com.facebook.drawee.drawable:ProgressBarDrawable",
7
+ "com.facebook.drawee.view:DraweeView",
8
+ "com.facebook.drawee.interfaces:DraweeHierarchy",
9
+ "com.facebook.drawee.interfaces:SettableDraweeHierarchy",
10
+ "com.facebook.drawee.interfaces:SimpleDraweeControllerBuilder",
11
+ "com.facebook.drawee.interfaces:DraweeController",
12
+ "com.facebook.drawee.generic:GenericDraweeHierarchyBuilder",
13
+ "com.facebook.drawee.generic:GenericDraweeHierarchy",
14
+ "com.facebook.imagepipeline.request:ImageRequestBuilder",
15
+ "com.facebook.imagepipeline.request:ImageRequest",
16
+ "com.facebook.imagepipeline.core:ImagePipelineConfig",
17
+ "com.facebook.imagepipeline.core:ImagePipeline",
18
+ "com.facebook.imagepipeline.common:RotationOptions",
19
+ "com.facebook.imagepipeline.common:ResizeOptions",
20
+ "com.facebook.drawee.backends.pipeline:Fresco",
21
+ "com.facebook.drawee.backends.pipeline:PipelineDraweeControllerBuilder",
22
+ "com.facebook.drawee.backends.pipeline:PipelineDraweeController",
23
+ "com.facebook.drawee.controller:AbstractDraweeControllerBuilder",
24
+ "com.facebook.drawee.controller:AbstractDraweeController",
25
+ "com.facebook.drawee.backends.pipeline.info:ImagePerfDataListener",
26
+ "com.facebook.drawee.backends.pipeline.info:ImagePerfData",
27
+ "com.facebook.drawee.controller:ControllerListener",
28
+ "com.nativescript.image:DraweeView",
29
+ "com.nativescript.image:ScalingBlurPostprocessor",
29
30
  "android.graphics.drawable:Animatable",
30
- "com.facebook.imagepipeline.image:ImageInfo*",
31
- "com.facebook.common.util:UriUtil*",
32
- "android.net:Uri*",
33
- "android.net.Uri:Builder*"
31
+ "com.facebook.imagepipeline.image:ImageInfo",
32
+ "com.facebook.common.util:UriUtil",
33
+ "android.net:Uri",
34
+ "android.net.Uri:Builder"
34
35
  ]
35
36
  }
@@ -1,7 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class ImgDirective {
3
- constructor();
4
- static ɵfac: i0.ɵɵFactoryDeclaration<ImgDirective, never>;
5
- static ɵdir: i0.ɵɵDirectiveDeclaration<ImgDirective, "NSImg", never, {}, {}, never, never, false>;
6
- }
7
- export declare const NSIMG_DIRECTIVES: (typeof ImgDirective)[];
@@ -1,15 +0,0 @@
1
- import { Directive } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- export class ImgDirective {
4
- constructor() { }
5
- }
6
- ImgDirective.ɵfac = function ImgDirective_Factory(t) { return new (t || ImgDirective)(); };
7
- ImgDirective.ɵdir = i0.ɵɵdefineDirective({ type: ImgDirective, selectors: [["NSImg"]] });
8
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImgDirective, [{
9
- type: Directive,
10
- args: [{
11
- selector: 'NSImg'
12
- }]
13
- }], function () { return []; }, null); })();
14
- export const NSIMG_DIRECTIVES = [ImgDirective];
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aXZlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9pbWFnZS9hbmd1bGFyL2RpcmVjdGl2ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFLMUMsTUFBTSxPQUFPLFlBQVk7SUFDckIsZ0JBQWUsQ0FBQzs7d0VBRFAsWUFBWTtpREFBWixZQUFZO3VGQUFaLFlBQVk7Y0FIeEIsU0FBUztlQUFDO2dCQUNQLFFBQVEsRUFBRSxPQUFPO2FBQ3BCOztBQUlELE1BQU0sQ0FBQyxNQUFNLGdCQUFnQixHQUFHLENBQUMsWUFBWSxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBEaXJlY3RpdmUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuQERpcmVjdGl2ZSh7XG4gICAgc2VsZWN0b3I6ICdOU0ltZydcbn0pXG5leHBvcnQgY2xhc3MgSW1nRGlyZWN0aXZlIHtcbiAgICBjb25zdHJ1Y3RvcigpIHt9XG59XG5leHBvcnQgY29uc3QgTlNJTUdfRElSRUNUSVZFUyA9IFtJbWdEaXJlY3RpdmVdO1xuIl19
@@ -1,2 +0,0 @@
1
- export * from './module';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvaW1hZ2UvYW5ndWxhci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxjQUFjLFVBQVUsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIlxuZXhwb3J0ICogZnJvbSAnLi9tb2R1bGUnO1xuIl19
@@ -1,22 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { registerElement } from '@nativescript/angular';
3
- import { ImgDirective, NSIMG_DIRECTIVES } from './directives';
4
- import { Img } from '@nativescript-community/ui-image';
5
- import * as i0 from "@angular/core";
6
- import * as i1 from "./directives";
7
- export { ImgDirective };
8
- export class TNSImageModule {
9
- }
10
- TNSImageModule.ɵfac = function TNSImageModule_Factory(t) { return new (t || TNSImageModule)(); };
11
- TNSImageModule.ɵmod = i0.ɵɵdefineNgModule({ type: TNSImageModule });
12
- TNSImageModule.ɵinj = i0.ɵɵdefineInjector({});
13
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TNSImageModule, [{
14
- type: NgModule,
15
- args: [{
16
- declarations: [NSIMG_DIRECTIVES],
17
- exports: [NSIMG_DIRECTIVES],
18
- }]
19
- }], null, null); })();
20
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TNSImageModule, { declarations: [i1.ImgDirective], exports: [i1.ImgDirective] }); })();
21
- registerElement('NSImg', () => Img);
22
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2ltYWdlL2FuZ3VsYXIvbW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRXhELE9BQU8sRUFBRSxZQUFZLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFDOUQsT0FBTyxFQUFFLEdBQUcsRUFBRSxNQUFNLGtDQUFrQyxDQUFDOzs7QUFDdkQsT0FBTyxFQUFFLFlBQVksRUFBRSxDQUFDO0FBS3hCLE1BQU0sT0FBTyxjQUFjOzs0RUFBZCxjQUFjO2tEQUFkLGNBQWM7O3VGQUFkLGNBQWM7Y0FKMUIsUUFBUTtlQUFDO2dCQUNOLFlBQVksRUFBRSxDQUFDLGdCQUFnQixDQUFDO2dCQUNoQyxPQUFPLEVBQUUsQ0FBQyxnQkFBZ0IsQ0FBQzthQUM5Qjs7d0ZBQ1ksY0FBYztBQUUzQixlQUFlLENBQUMsT0FBTyxFQUFFLEdBQUcsRUFBRSxDQUFDLEdBQUcsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiXG5pbXBvcnQgeyBOZ01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuaW1wb3J0IHsgcmVnaXN0ZXJFbGVtZW50IH0gZnJvbSAnQG5hdGl2ZXNjcmlwdC9hbmd1bGFyJztcblxuaW1wb3J0IHsgSW1nRGlyZWN0aXZlLCBOU0lNR19ESVJFQ1RJVkVTIH0gZnJvbSAnLi9kaXJlY3RpdmVzJztcbmltcG9ydCB7IEltZyB9IGZyb20gJ0BuYXRpdmVzY3JpcHQtY29tbXVuaXR5L3VpLWltYWdlJztcbmV4cG9ydCB7IEltZ0RpcmVjdGl2ZSB9O1xuQE5nTW9kdWxlKHtcbiAgICBkZWNsYXJhdGlvbnM6IFtOU0lNR19ESVJFQ1RJVkVTXSxcbiAgICBleHBvcnRzOiBbTlNJTUdfRElSRUNUSVZFU10sXG59KVxuZXhwb3J0IGNsYXNzIFROU0ltYWdlTW9kdWxlIHt9XG5cbnJlZ2lzdGVyRWxlbWVudCgnTlNJbWcnLCAoKSA9PiBJbWcpO1xuIl19
@@ -1,2 +0,0 @@
1
- export * from './index';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmF0aXZlc2NyaXB0LWNvbW11bml0eS11aS1pbWFnZS1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2ltYWdlL2FuZ3VsYXIvbmF0aXZlc2NyaXB0LWNvbW11bml0eS11aS1pbWFnZS1hbmd1bGFyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
@@ -1,39 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Directive, NgModule } from '@angular/core';
3
- import { registerElement } from '@nativescript/angular';
4
- import { Img } from '@nativescript-community/ui-image';
5
-
6
- class ImgDirective {
7
- constructor() { }
8
- }
9
- ImgDirective.ɵfac = function ImgDirective_Factory(t) { return new (t || ImgDirective)(); };
10
- ImgDirective.ɵdir = i0.ɵɵdefineDirective({ type: ImgDirective, selectors: [["NSImg"]] });
11
- (function () {
12
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImgDirective, [{
13
- type: Directive,
14
- args: [{
15
- selector: 'NSImg'
16
- }]
17
- }], function () { return []; }, null);
18
- })();
19
- const NSIMG_DIRECTIVES = [ImgDirective];
20
-
21
- class TNSImageModule {
22
- }
23
- TNSImageModule.ɵfac = function TNSImageModule_Factory(t) { return new (t || TNSImageModule)(); };
24
- TNSImageModule.ɵmod = i0.ɵɵdefineNgModule({ type: TNSImageModule });
25
- TNSImageModule.ɵinj = i0.ɵɵdefineInjector({});
26
- (function () {
27
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TNSImageModule, [{
28
- type: NgModule,
29
- args: [{
30
- declarations: [NSIMG_DIRECTIVES],
31
- exports: [NSIMG_DIRECTIVES],
32
- }]
33
- }], null, null);
34
- })();
35
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TNSImageModule, { declarations: [ImgDirective], exports: [ImgDirective] }); })();
36
- registerElement('NSImg', () => Img);
37
-
38
- export { ImgDirective, TNSImageModule };
39
- //# sourceMappingURL=nativescript-community-ui-image-angular.mjs.map
@@ -1,35 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Directive, NgModule } from '@angular/core';
3
- import { registerElement } from '@nativescript/angular';
4
- import { Img } from '@nativescript-community/ui-image';
5
-
6
- class ImgDirective {
7
- constructor() { }
8
- }
9
- ImgDirective.ɵfac = function ImgDirective_Factory(t) { return new (t || ImgDirective)(); };
10
- ImgDirective.ɵdir = i0.ɵɵdefineDirective({ type: ImgDirective, selectors: [["NSImg"]] });
11
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImgDirective, [{
12
- type: Directive,
13
- args: [{
14
- selector: 'NSImg'
15
- }]
16
- }], function () { return []; }, null); })();
17
- const NSIMG_DIRECTIVES = [ImgDirective];
18
-
19
- class TNSImageModule {
20
- }
21
- TNSImageModule.ɵfac = function TNSImageModule_Factory(t) { return new (t || TNSImageModule)(); };
22
- TNSImageModule.ɵmod = i0.ɵɵdefineNgModule({ type: TNSImageModule });
23
- TNSImageModule.ɵinj = i0.ɵɵdefineInjector({});
24
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TNSImageModule, [{
25
- type: NgModule,
26
- args: [{
27
- declarations: [NSIMG_DIRECTIVES],
28
- exports: [NSIMG_DIRECTIVES],
29
- }]
30
- }], null, null); })();
31
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TNSImageModule, { declarations: [ImgDirective], exports: [ImgDirective] }); })();
32
- registerElement('NSImg', () => Img);
33
-
34
- export { ImgDirective, TNSImageModule };
35
- //# sourceMappingURL=nativescript-community-ui-image-angular.mjs.map
@@ -1 +0,0 @@
1
- export * from './module';
@@ -1,9 +0,0 @@
1
- import { ImgDirective } from './directives';
2
- import * as i0 from "@angular/core";
3
- import * as i1 from "./directives";
4
- export { ImgDirective };
5
- export declare class TNSImageModule {
6
- static ɵfac: i0.ɵɵFactoryDeclaration<TNSImageModule, never>;
7
- static ɵmod: i0.ɵɵNgModuleDeclaration<TNSImageModule, [typeof i1.ImgDirective], never, [typeof i1.ImgDirective]>;
8
- static ɵinj: i0.ɵɵInjectorDeclaration<TNSImageModule>;
9
- }
@@ -1,2 +0,0 @@
1
- /// <amd-module name="@nativescript-community/ui-image-angular" />
2
- export * from './index';
@@ -1,30 +0,0 @@
1
- {
2
- "name": "@nativescript-community/ui-image-angular",
3
- "main": "index.js",
4
- "module": "fesm2015/nativescript-community-ui-image-angular.mjs",
5
- "es2020": "fesm2020/nativescript-community-ui-image-angular.mjs",
6
- "esm2020": "esm2020/nativescript-community-ui-image-angular.mjs",
7
- "fesm2020": "fesm2020/nativescript-community-ui-image-angular.mjs",
8
- "fesm2015": "fesm2015/nativescript-community-ui-image-angular.mjs",
9
- "typings": "nativescript-community-ui-image-angular.d.ts",
10
- "exports": {
11
- "./package.json": {
12
- "default": "./package.json"
13
- },
14
- ".": {
15
- "types": "./nativescript-community-ui-image-angular.d.ts",
16
- "esm2020": "./esm2020/nativescript-community-ui-image-angular.mjs",
17
- "es2020": "./fesm2020/nativescript-community-ui-image-angular.mjs",
18
- "es2015": "./fesm2015/nativescript-community-ui-image-angular.mjs",
19
- "node": "./fesm2015/nativescript-community-ui-image-angular.mjs",
20
- "default": "./fesm2020/nativescript-community-ui-image-angular.mjs"
21
- }
22
- },
23
- "sideEffects": false,
24
- "dependencies": {
25
- "tslib": "^2.3.0"
26
- },
27
- "scripts": {
28
- "prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by Ivy in full compilation mode. This is not allowed.\\nPlease delete and rebuild the package with Ivy partial compilation mode, before attempting to publish.\\n')\" && exit 1"
29
- }
30
- }
@@ -1,85 +0,0 @@
1
- export * from './index-common';
2
- import { AnimatedImage, EventData, ImageBase, ImageError as ImageErrorBase, ImageInfo as ImageInfoBase, ImagePipelineConfigSetting } from './index-common';
3
- export declare function initialize(config?: ImagePipelineConfigSetting): void;
4
- export declare function getImagePipeline(): ImagePipeline;
5
- export declare function shutDown(): void;
6
- export declare class ImagePipeline {
7
- private _android;
8
- toUri(value: string | android.net.Uri): globalAndroid.net.Uri;
9
- isInDiskCache(uri: string | android.net.Uri): boolean;
10
- isInBitmapMemoryCache(uri: string | android.net.Uri): boolean;
11
- evictFromMemoryCache(uri: string | android.net.Uri): void;
12
- evictFromDiskCache(uri: string | android.net.Uri): void;
13
- evictFromCache(uri: string | android.net.Uri): void;
14
- clearCaches(): void;
15
- clearMemoryCaches(): void;
16
- clearDiskCaches(): void;
17
- prefetchToDiskCache(uri: string): Promise<void>;
18
- prefetchToMemoryCache(uri: string): Promise<void>;
19
- private prefetchToCache;
20
- get android(): any;
21
- set android(value: any);
22
- fetchImage(): void;
23
- }
24
- export declare class ImageError implements ImageErrorBase {
25
- private _stringValue;
26
- private _message;
27
- private _errorType;
28
- constructor(throwable: java.lang.Throwable);
29
- getMessage(): string;
30
- getErrorType(): string;
31
- toString(): string;
32
- }
33
- export interface QualityInfo {
34
- getQuality(): any;
35
- isOfFullQuality(): any;
36
- isOfGoodEnoughQuality(): any;
37
- }
38
- export declare class ImageInfo implements ImageInfoBase {
39
- private _nativeImageInfo;
40
- constructor(imageInfo: any);
41
- getHeight(): number;
42
- getWidth(): number;
43
- getQualityInfo(): QualityInfo;
44
- }
45
- export declare class FinalEventData extends EventData {
46
- private _imageInfo;
47
- private _animatable;
48
- get imageInfo(): ImageInfo;
49
- set imageInfo(value: ImageInfo);
50
- get animatable(): AnimatedImage;
51
- set animatable(value: AnimatedImage);
52
- get android(): AnimatedImage;
53
- }
54
- export declare class IntermediateEventData extends EventData {
55
- private _imageInfo;
56
- get imageInfo(): ImageInfo;
57
- set imageInfo(value: ImageInfo);
58
- }
59
- export declare class FailureEventData extends EventData {
60
- private _error;
61
- get error(): ImageError;
62
- set error(value: ImageError);
63
- }
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;
66
- export declare class Img extends ImageBase {
67
- nativeViewProtected: com.nativescript.image.DraweeView;
68
- nativeImageViewProtected: com.nativescript.image.DraweeView;
69
- isLoading: boolean;
70
- _canRequestImage: boolean;
71
- _canUpdateHierarchy: boolean;
72
- _needUpdateHierarchy: boolean;
73
- _needRequestImage: boolean;
74
- onResumeNativeUpdates(): void;
75
- createNativeView(): com.nativescript.image.DraweeView;
76
- updateViewSize(imageInfo: any): void;
77
- updateImageUri(): void;
78
- private initImage;
79
- private updateHierarchy;
80
- private getDrawable;
81
- private getDrawableFromLocalFile;
82
- private getDrawableFromResource;
83
- startAnimating(): void;
84
- stopAnimating(): void;
85
- }
package/index.ios.d.ts DELETED
@@ -1,50 +0,0 @@
1
- export * from './index-common';
2
- import { EventData, ImageBase, ImageInfo as ImageInfoBase, ImagePipelineConfigSetting } from './index-common';
3
- export declare class ImageInfo implements ImageInfoBase {
4
- private width;
5
- private height;
6
- constructor(width: number, height: number);
7
- getHeight(): number;
8
- getWidth(): number;
9
- }
10
- export interface FinalEventData extends EventData {
11
- imageInfo: ImageInfo;
12
- ios: UIImage;
13
- }
14
- export declare function initialize(config?: ImagePipelineConfigSetting): void;
15
- export declare function shutDown(): void;
16
- export declare class ImagePipeline {
17
- private _ios;
18
- constructor();
19
- isInDiskCache(uri: string): boolean;
20
- isInBitmapMemoryCache(uri: string): boolean;
21
- evictFromMemoryCache(uri: string): void;
22
- evictFromDiskCache(uri: string): void;
23
- evictFromCache(uri: string): void;
24
- clearCaches(): void;
25
- clearMemoryCaches(): void;
26
- clearDiskCaches(): void;
27
- prefetchToDiskCache(uri: string): Promise<void>;
28
- prefetchToMemoryCache(uri: string): Promise<void>;
29
- private prefetchToCacheType;
30
- get ios(): SDImageCache;
31
- }
32
- export declare function getImagePipeline(): ImagePipeline;
33
- export declare class Img extends ImageBase {
34
- nativeViewProtected: SDAnimatedImageView | UIImageView;
35
- nativeImageViewProtected: SDAnimatedImageView | UIImageView;
36
- isLoading: boolean;
37
- private _imageSourceAffectsLayout;
38
- createNativeView(): UIImageView;
39
- _setNativeClipToBounds(): void;
40
- onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
41
- updateImageUri(): void;
42
- _setNativeImage(nativeImage: UIImage, animated?: boolean): void;
43
- private handleImageLoaded;
44
- private onLoadProgress;
45
- private getUIImage;
46
- private initImage;
47
- placeholderImage: UIImage;
48
- startAnimating(): void;
49
- stopAnimating(): void;
50
- }
Binary file
package/vue/index.mjs DELETED
@@ -1,8 +0,0 @@
1
- import { Img } from '../image';
2
- const ImagePlugin = {
3
- install(Vue) {
4
- Vue.registerElement('NSImg', () => Img);
5
- }
6
- };
7
- export default ImagePlugin;
8
- //# sourceMappingURL=index.mjs.map