@nativescript-community/ui-image 4.3.37 → 4.3.38

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,10 @@
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.38](https://github.com/nativescript-community/ui-image/compare/v4.3.37...v4.3.38) (2024-03-29)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-image
9
+
6
10
  ## [4.3.37](https://github.com/nativescript-community/ui-image/compare/v4.3.36...v4.3.37) (2024-03-29)
7
11
 
8
12
  **Note:** Version bump only for package @nativescript-community/ui-image
package/index-common.d.ts CHANGED
@@ -39,6 +39,7 @@ export interface ImageError {
39
39
  getErrorType(): string;
40
40
  toString(): string;
41
41
  }
42
+ export declare function wrapNativeException(ex: any, errorType?: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"): any;
42
43
  export interface ImagePipelineConfigSetting {
43
44
  isDownsampleEnabled?: boolean;
44
45
  leakTracker?: any;
package/index-common.js CHANGED
@@ -74,6 +74,29 @@ export var ScaleType;
74
74
  ScaleType["FitXY"] = "fitXY";
75
75
  ScaleType["FocusCrop"] = "focusCrop";
76
76
  })(ScaleType || (ScaleType = {}));
77
+ export function wrapNativeException(ex, errorType = typeof ex) {
78
+ if (typeof ex === 'string') {
79
+ return new Error(ex);
80
+ }
81
+ if (!(ex instanceof Error)) {
82
+ if (__ANDROID__) {
83
+ const err = new Error(ex.toString());
84
+ err['nativeException'] = ex;
85
+ //@ts-ignore
86
+ err['stackTrace'] = com.tns.NativeScriptException.getStackTraceAsString(ex);
87
+ return err;
88
+ }
89
+ if (__IOS__) {
90
+ const err = new Error(ex.localizedDescription);
91
+ err['nativeException'] = ex;
92
+ err['code'] = ex.code;
93
+ err['domain'] = ex.domain;
94
+ // TODO: we loose native stack. see how to get it
95
+ return err;
96
+ }
97
+ }
98
+ return ex;
99
+ }
77
100
  export class EventData {
78
101
  get eventName() {
79
102
  return this._eventName;
@@ -57,11 +57,6 @@ export declare class IntermediateEventData extends EventData {
57
57
  get imageInfo(): ImageInfo;
58
58
  set imageInfo(value: ImageInfo);
59
59
  }
60
- export declare class FailureEventData extends EventData {
61
- private _error;
62
- get error(): ImageError;
63
- set error(value: ImageError);
64
- }
65
60
  export declare const needUpdateHierarchy: (targetOrNeedsLayout: any, propertyKey?: string | Symbol, descriptor?: PropertyDescriptor) => any;
66
61
  export declare class Img extends ImageBase {
67
62
  nativeViewProtected: com.nativescript.image.DraweeView;
package/index.android.js CHANGED
@@ -3,7 +3,7 @@ export * from './index-common';
3
3
  import { Application, ImageAsset, ImageSource, Trace, Utils, backgroundInternalProperty, knownFolders, path } from '@nativescript/core';
4
4
  import { isString } from '@nativescript/core/utils/types';
5
5
  import { layout } from '@nativescript/core/utils/layout-helper';
6
- import { CLog, CLogTypes, EventData, ImageBase, ScaleType, aspectRatioProperty, backgroundUriProperty, blurDownSamplingProperty, blurRadiusProperty, fadeDurationProperty, failureImageUriProperty, imageRotationProperty, lowerResSrcProperty, needRequestImage, placeholderImageUriProperty, progressBarColorProperty, roundAsCircleProperty, roundBottomLeftRadiusProperty, roundBottomRightRadiusProperty, roundTopLeftRadiusProperty, roundTopRightRadiusProperty, showProgressBarProperty, srcProperty, stretchProperty, tintColorProperty } from './index-common';
6
+ import { CLog, CLogTypes, EventData, ImageBase, ScaleType, aspectRatioProperty, backgroundUriProperty, blurDownSamplingProperty, blurRadiusProperty, fadeDurationProperty, failureImageUriProperty, imageRotationProperty, lowerResSrcProperty, needRequestImage, placeholderImageUriProperty, progressBarColorProperty, roundAsCircleProperty, roundBottomLeftRadiusProperty, roundBottomRightRadiusProperty, roundTopLeftRadiusProperty, roundTopRightRadiusProperty, showProgressBarProperty, srcProperty, stretchProperty, tintColorProperty, wrapNativeException } from './index-common';
7
7
  let initialized = false;
8
8
  let initializeConfig;
9
9
  export function initialize(config) {
@@ -257,14 +257,6 @@ export class IntermediateEventData extends EventData {
257
257
  this._imageInfo = value;
258
258
  }
259
259
  }
260
- export class FailureEventData extends EventData {
261
- get error() {
262
- return this._error;
263
- }
264
- set error(value) {
265
- this._error = value;
266
- }
267
- }
268
260
  export const needUpdateHierarchy = function (targetOrNeedsLayout, propertyKey, descriptor) {
269
261
  if (typeof targetOrNeedsLayout === 'boolean') {
270
262
  return function (target2, propertyKey, descriptor) {
@@ -520,7 +512,7 @@ export class Img extends ImageBase {
520
512
  const imageError = new ImageError(throwable);
521
513
  nativeView.notify({
522
514
  eventName,
523
- error: imageError
515
+ error: wrapNativeException(throwable)
524
516
  });
525
517
  }
526
518
  }
@@ -533,10 +525,9 @@ export class Img extends ImageBase {
533
525
  if (nativeView) {
534
526
  const eventName = ImageBase.intermediateImageFailedEvent;
535
527
  if (nativeView.hasListeners(eventName)) {
536
- const imageError = new ImageError(throwable);
537
528
  nativeView.notify({
538
529
  eventName,
539
- error: imageError
530
+ error: wrapNativeException(throwable)
540
531
  });
541
532
  }
542
533
  }
package/index.d.ts CHANGED
@@ -314,21 +314,11 @@ export class IntermediateEventData {
314
314
  /**
315
315
  * Instances of this class are provided to the handlers of the {@link failure} and {@link intermediateImageFailed}.
316
316
  */
317
- export class FailureEventData {
318
- /**
319
- * Returns the name of the event that has been fired.
320
- */
321
- eventName: string;
322
-
323
- /**
324
- * The object that fires the event.
325
- */
326
- object: any;
327
-
317
+ export class FailureEventData extends EventData {
328
318
  /**
329
319
  * An object containing information about the status of the event.
330
320
  */
331
- error: ImageError;
321
+ error: Error;
332
322
  }
333
323
 
334
324
  /**
package/index.ios.js CHANGED
@@ -3,7 +3,7 @@ export * from './index-common';
3
3
  import { ImageAsset, ImageSource, Screen, Trace, Utils, knownFolders, path } from '@nativescript/core';
4
4
  import { layout } from '@nativescript/core/utils/layout-helper';
5
5
  import { isString } from '@nativescript/core/utils/types';
6
- import { CLog, CLogTypes, ImageBase, ScaleType, failureImageUriProperty, imageRotationProperty, placeholderImageUriProperty, srcProperty, stretchProperty } from './index-common';
6
+ import { CLog, CLogTypes, ImageBase, ScaleType, failureImageUriProperty, imageRotationProperty, placeholderImageUriProperty, srcProperty, stretchProperty, wrapNativeException } from './index-common';
7
7
  export class ImageInfo {
8
8
  constructor(width, height) {
9
9
  this.width = width;
@@ -237,7 +237,7 @@ export class Img extends ImageBase {
237
237
  if (error) {
238
238
  this.notify({
239
239
  eventName: Img.failureEvent,
240
- error
240
+ error: wrapNativeException(error)
241
241
  });
242
242
  if (this.failureImageUri) {
243
243
  image = this.getUIImage(this.failureImageUri);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.3.37",
3
+ "version": "4.3.38",
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": "a1f4614ab21fa8dea1cbe21fbd5525f83779b793"
39
+ "gitHead": "aa234b1ae9d262dca05972288e5a7fd2cb7d82eb"
40
40
  }