@nativescript-community/ui-image 4.3.28 → 4.3.29

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,12 @@
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.29](https://github.com/nativescript-community/ui-image/compare/v4.3.28...v4.3.29) (2024-02-02)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **ios:** npm release fix ([68a75fe](https://github.com/nativescript-community/ui-image/commit/68a75fe83488c83d897b0358b580563390d027a3))
11
+
6
12
  ## [4.3.28](https://github.com/nativescript-community/ui-image/compare/v4.3.27...v4.3.28) (2024-01-23)
7
13
 
8
14
  ### Bug Fixes
@@ -5,11 +5,11 @@ export class ImgDirective {
5
5
  static ɵfac = function ImgDirective_Factory(t) { return new (t || ImgDirective)(); };
6
6
  static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ImgDirective, selectors: [["NSImg"]] });
7
7
  }
8
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImgDirective, [{
8
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImgDirective, [{
9
9
  type: Directive,
10
10
  args: [{
11
11
  selector: 'NSImg'
12
12
  }]
13
- }], function () { return []; }, null); })();
13
+ }], () => [], null); })();
14
14
  export const NSIMG_DIRECTIVES = [ImgDirective];
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aXZlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9pbWFnZS9hbmd1bGFyL2RpcmVjdGl2ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFN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JlY3RpdmUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuQERpcmVjdGl2ZSh7XG4gICAgc2VsZWN0b3I6ICdOU0ltZydcbn0pXG5leHBvcnQgY2xhc3MgSW1nRGlyZWN0aXZlIHtcbiAgICBjb25zdHJ1Y3RvcigpIHt9XG59XG5leHBvcnQgY29uc3QgTlNJTUdfRElSRUNUSVZFUyA9IFtJbWdEaXJlY3RpdmVdO1xuIl19
@@ -10,7 +10,7 @@ export class TNSImageModule {
10
10
  static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TNSImageModule });
11
11
  static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
12
12
  }
13
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TNSImageModule, [{
13
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TNSImageModule, [{
14
14
  type: NgModule,
15
15
  args: [{
16
16
  declarations: [NSIMG_DIRECTIVES],
@@ -19,4 +19,4 @@ export class TNSImageModule {
19
19
  }], null, null); })();
20
20
  (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TNSImageModule, { declarations: [i1.ImgDirective], exports: [i1.ImgDirective] }); })();
21
21
  registerElement('NSImg', () => Img);
22
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2ltYWdlL2FuZ3VsYXIvbW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRXhELE9BQU8sRUFBRSxZQUFZLEVBQUUsZ0JBQWdCLEVBQUUsTU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7IEltZ0RpcmVjdGl2ZSB9O1xuQE5nTW9kdWxlKHtcbiAgICBkZWNsYXJhdGlvbnM6IFtOU0lNR19ESVJFQ1RJVkVTXSxcbiAgICBleHBvcnRzOiBbTlNJTUdfRElSRUNUSVZFU10sXG59KVxuZXhwb3J0IGNsYXNzIFROU0ltYWdlTW9kdWxlIHt9XG5cbnJlZ2lzdGVyRWxlbWVudCgnTlNJbWcnLCAoKSA9PiBJbWcpO1xuIl19
@@ -8,12 +8,12 @@ class ImgDirective {
8
8
  static ɵfac = function ImgDirective_Factory(t) { return new (t || ImgDirective)(); };
9
9
  static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ImgDirective, selectors: [["NSImg"]] });
10
10
  }
11
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImgDirective, [{
11
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImgDirective, [{
12
12
  type: Directive,
13
13
  args: [{
14
14
  selector: 'NSImg'
15
15
  }]
16
- }], function () { return []; }, null); })();
16
+ }], () => [], null); })();
17
17
  const NSIMG_DIRECTIVES = [ImgDirective];
18
18
 
19
19
  class TNSImageModule {
@@ -21,7 +21,7 @@ class TNSImageModule {
21
21
  static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TNSImageModule });
22
22
  static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
23
23
  }
24
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TNSImageModule, [{
24
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TNSImageModule, [{
25
25
  type: NgModule,
26
26
  args: [{
27
27
  declarations: [NSIMG_DIRECTIVES],
package/index-common.d.ts CHANGED
@@ -3,10 +3,10 @@ import { EventData as IEventData } from '@nativescript/core/data/observable';
3
3
  import { ImageAsset } from '@nativescript/core/image-asset';
4
4
  import { ImageSource } from '@nativescript/core/image-source';
5
5
  export declare enum CLogTypes {
6
- log,
7
- info,
8
- warning,
9
- error
6
+ log = 0,
7
+ info = 1,
8
+ warning = 2,
9
+ error = 3
10
10
  }
11
11
  export declare const ImageViewTraceCategory = "NativescriptImage";
12
12
  export declare const CLog: (type: CLogTypes, ...args: any[]) => void;
package/index-common.js CHANGED
@@ -1,6 +1,4 @@
1
- import { Color, CoreTypes, Length, Property, ShorthandProperty, Trace, View, booleanConverter } from '@nativescript/core';
2
- import { ImageAsset } from '@nativescript/core/image-asset';
3
- import { ImageSource } from '@nativescript/core/image-source';
1
+ import { Length, Property, Trace, View, booleanConverter } from '@nativescript/core';
4
2
  import { isAndroid } from '@nativescript/core/platform';
5
3
  function isNonNegativeFiniteNumber(value) {
6
4
  return isFinite(value) && !isNaN(value) && value >= 0;
@@ -52,10 +50,10 @@ function parseThickness(value) {
52
50
  }
53
51
  export var CLogTypes;
54
52
  (function (CLogTypes) {
55
- CLogTypes[CLogTypes["log"] = Trace.messageType.log] = "log";
56
- CLogTypes[CLogTypes["info"] = Trace.messageType.info] = "info";
57
- CLogTypes[CLogTypes["warning"] = Trace.messageType.warn] = "warning";
58
- CLogTypes[CLogTypes["error"] = Trace.messageType.error] = "error";
53
+ CLogTypes[CLogTypes["log"] = 0] = "log";
54
+ CLogTypes[CLogTypes["info"] = 1] = "info";
55
+ CLogTypes[CLogTypes["warning"] = 2] = "warning";
56
+ CLogTypes[CLogTypes["error"] = 3] = "error";
59
57
  })(CLogTypes || (CLogTypes = {}));
60
58
  export const ImageViewTraceCategory = 'NativescriptImage';
61
59
  export const CLog = (type, ...args) => {
package/index.android.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
2
2
  export * from './index-common';
3
- import { Application, Background, Color, ImageAsset, ImageSource, Trace, Utils, backgroundInternalProperty, knownFolders, path } from '@nativescript/core';
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
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';
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, EventData, ImageBase, ScaleType, failureImageUriProperty, imageRotationProperty, placeholderImageUriProperty, srcProperty, stretchProperty } from './index-common';
6
+ import { CLog, CLogTypes, ImageBase, ScaleType, failureImageUriProperty, imageRotationProperty, placeholderImageUriProperty, srcProperty, stretchProperty } from './index-common';
7
7
  export class ImageInfo {
8
8
  constructor(width, height) {
9
9
  this.width = width;
package/package.json CHANGED
@@ -1,18 +1,10 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.3.28",
3
+ "version": "4.3.29",
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,
7
7
  "typings": "./index.d.ts",
8
- "scripts": {
9
- "build": "npm run tsc && npm run readme",
10
- "build.all": "npm run build && npm run build.angular",
11
- "build.angular": "ng-packagr -p ../../src/image/angular/ng-package.json -c ../../src/image/angular/tsconfig.json",
12
- "readme": "readme generate -c ../../tools/readme/blueprint.json",
13
- "tsc": "cpy '**/*.d.ts' '../../packages/image' --parents --cwd=../../src/image && tsc -skipLibCheck -d",
14
- "clean": "rimraf ./*.d.ts ./*.js ./*.js.map"
15
- },
16
8
  "nativescript": {
17
9
  "platforms": {
18
10
  "android": "6.0.0",
@@ -44,5 +36,5 @@
44
36
  },
45
37
  "license": "Apache-2.0",
46
38
  "readmeFilename": "README.md",
47
- "gitHead": "482d5862d487c81f0ae413887f9ae3070c549772"
39
+ "gitHead": "0940ba815f6f11c1b94f13050689e4e1d472855a"
48
40
  }
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ #import <UIKit/UIKit.h>
2
+ #import <Foundation/Foundation.h>
3
+ #import <CoreText/CoreText.h>
4
+
5
+ #import "NSImageRoundCornerTransformer.h"
6
+ #import "NSImageDecodeSizeTransformer.h"
7
+ #import "NSImageRoundAsCircleTransformer.h"
@@ -0,0 +1,11 @@
1
+ #import <SDWebImage/SDImageTransformer.h>
2
+
3
+ @interface NSImageDecodeSizeTransformer: NSObject <SDImageTransformer>
4
+
5
+ @property (nonatomic, assign, readonly) CGFloat decodeWidth;
6
+ @property (nonatomic, assign, readonly) CGFloat decodeHeight;
7
+
8
+ - (nonnull instancetype)init NS_UNAVAILABLE;
9
+ + (nonnull instancetype)transformerWithDecodeWidth:(CGFloat)decodeWidth decodeHeight:(CGFloat)decodeHeight;
10
+
11
+ @end
@@ -0,0 +1,44 @@
1
+ #import "NSImageDecodeSizeTransformer.h"
2
+ #import <SDWebImage/SDGraphicsImageRenderer.h>
3
+
4
+ @interface NSImageDecodeSizeTransformer ()
5
+
6
+ @property (nonatomic, assign) CGFloat decodeWidth;
7
+ @property (nonatomic, assign) CGFloat decodeHeight;
8
+
9
+ @end
10
+
11
+ @implementation NSImageDecodeSizeTransformer
12
+ + (nonnull instancetype)transformerWithDecodeWidth:(CGFloat)decodeWidth decodeHeight:(CGFloat)decodeHeight {
13
+ NSImageDecodeSizeTransformer *transformer = [NSImageDecodeSizeTransformer new];
14
+ transformer.decodeWidth = decodeWidth;
15
+ transformer.decodeHeight = decodeHeight;
16
+
17
+ return transformer;
18
+ }
19
+
20
+ - (NSString *)transformerKey {
21
+ return [NSString stringWithFormat:@"NSImageDecodeSizeTransformer(%f,%f)", self.decodeWidth, self.decodeHeight];
22
+ }
23
+
24
+ - (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key {
25
+ if (!image) {
26
+ return nil;
27
+ }
28
+ CGFloat widthRatio = 1.0f;
29
+ CGFloat heightRatio = 1.0f;
30
+
31
+ CGFloat width = (CGFloat)image.size.width;
32
+ CGFloat height = (CGFloat)image.size.height;
33
+ if (self.decodeWidth && self.decodeHeight) {
34
+ widthRatio = self.decodeWidth / width;
35
+ heightRatio = self.decodeHeight / height;
36
+ } else if (self.decodeWidth > 0) {
37
+ widthRatio = self.decodeWidth / width;
38
+ } else {
39
+ heightRatio = self.decodeHeight / height;
40
+ }
41
+ return [image sd_resizedImageWithSize:CGSizeMake(width * widthRatio, height * heightRatio) scaleMode:2];
42
+ }
43
+
44
+ @end
@@ -0,0 +1,8 @@
1
+ #import <SDWebImage/SDImageTransformer.h>
2
+
3
+ @interface NSImageRoundAsCircleTransformer: NSObject <SDImageTransformer>
4
+
5
+ - (nonnull instancetype)init NS_UNAVAILABLE;
6
+ + (nonnull instancetype)transformer;
7
+
8
+ @end
@@ -0,0 +1,40 @@
1
+ #import "NSImageRoundAsCircleTransformer.h"
2
+ #import <SDWebImage/SDGraphicsImageRenderer.h>
3
+
4
+ @interface NSImageRoundAsCircleTransformer ()
5
+
6
+ @end
7
+
8
+ @implementation NSImageRoundAsCircleTransformer
9
+ + (instancetype)transformer {
10
+
11
+ NSImageRoundAsCircleTransformer *transformer = [NSImageRoundAsCircleTransformer new];
12
+ return transformer;
13
+ }
14
+
15
+ - (NSString *)transformerKey {
16
+ return [NSString stringWithFormat:@"NSImageRoundAsCircleTransformer"];
17
+ }
18
+
19
+ - (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key {
20
+ if (!image) {
21
+ return nil;
22
+ }
23
+
24
+ CGFloat width = (CGFloat)image.size.width;
25
+ CGFloat height = (CGFloat)image.size.height;
26
+ CGFloat minwidth = MIN(width, height);
27
+ CGFloat cornerRadius = minwidth / 2;
28
+
29
+ UIImage * resultImage = [image sd_resizedImageWithSize:CGSizeMake(minwidth, minwidth) scaleMode:SDImageScaleModeAspectFill];
30
+ resultImage = [resultImage sd_roundedCornerImageWithRadius:cornerRadius corners:UIRectCornerAllCorners borderWidth:0 borderColor:nil];
31
+ return resultImage;
32
+ // const result = (image as any)
33
+ // .sd_resizedImageWithSizeScaleMode(CGSizeMake(minwidth, minwidth), SDImageScaleMode.AspectFill)
34
+ // .sd_roundedCornerImageWithRadiusCornersBorderWidthBorderColor(cornerRadius, UIRectCorner.BottomLeft | UIRectCorner.BottomRight | UIRectCorner.TopLeft | UIRectCorner.TopRight, 0, null)
35
+ // .sd_resizedImageWithSizeScaleMode(CGSizeMake(width, height), SDImageScaleMode.AspectFit);
36
+ // return result;
37
+ // return resultImage;
38
+ }
39
+
40
+ @end
@@ -0,0 +1,13 @@
1
+ #import <SDWebImage/SDImageTransformer.h>
2
+
3
+ @interface NSImageRoundCornerTransformer: NSObject <SDImageTransformer>
4
+
5
+ @property (nonatomic, assign, readonly) CGFloat topLeftRadius;
6
+ @property (nonatomic, assign, readonly) CGFloat topRightRadius;
7
+ @property (nonatomic, assign, readonly) CGFloat bottomRightRadius;
8
+ @property (nonatomic, assign, readonly) CGFloat bottomLeftRadius;
9
+
10
+ - (nonnull instancetype)init NS_UNAVAILABLE;
11
+ + (nonnull instancetype)transformerWithTopLefRadius:(CGFloat)topLeftRadius topRightRadius:(CGFloat)topRightRadius bottomRightRadius:(CGFloat)bottomRightRadius bottomLeftRadius:(CGFloat)bottomLeftRadius;
12
+
13
+ @end
@@ -0,0 +1,59 @@
1
+ #import "NSImageRoundCornerTransformer.h"
2
+ #import <SDWebImage/SDGraphicsImageRenderer.h>
3
+
4
+ @interface NSImageRoundCornerTransformer ()
5
+
6
+ @property (nonatomic, assign) CGFloat topLeftRadius;
7
+ @property (nonatomic, assign) CGFloat topRightRadius;
8
+ @property (nonatomic, assign) CGFloat bottomRightRadius;
9
+ @property (nonatomic, assign) CGFloat bottomLeftRadius;
10
+
11
+ @end
12
+
13
+ @implementation NSImageRoundCornerTransformer
14
+ + (instancetype)transformerWithTopLefRadius:(CGFloat)topLeftRadius topRightRadius:(CGFloat)topRightRadius bottomRightRadius:(CGFloat)bottomRightRadius bottomLeftRadius:(CGFloat)bottomLeftRadius {
15
+
16
+ NSImageRoundCornerTransformer *transformer = [NSImageRoundCornerTransformer new];
17
+ transformer.topLeftRadius = topLeftRadius;
18
+ transformer.topRightRadius = topRightRadius;
19
+ transformer.bottomRightRadius = bottomRightRadius;
20
+ transformer.bottomLeftRadius = bottomLeftRadius;
21
+
22
+ return transformer;
23
+ }
24
+
25
+ - (NSString *)transformerKey {
26
+ return [NSString stringWithFormat:@"NSImageRoundCornerTransformer(%f,%f,%f,%f)", self.topLeftRadius,self.topRightRadius,self.bottomRightRadius,self.bottomLeftRadius];
27
+ }
28
+
29
+ - (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key {
30
+ if (!image) {
31
+ return nil;
32
+ }
33
+
34
+ SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
35
+ format.scale = image.scale;
36
+ SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:image.size format:format];
37
+ UIImage *resultImage = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
38
+ CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
39
+
40
+ UIBezierPath *newPath = [UIBezierPath bezierPath];
41
+
42
+ CGFloat left = M_PI;
43
+ CGFloat up = 1.5*M_PI;
44
+ CGFloat down = M_PI_2;
45
+ CGFloat right = 0.0;
46
+ [newPath addArcWithCenter:CGPointMake( CGRectGetMinX(rect) + self.topLeftRadius, CGRectGetMinY( rect) + self.topLeftRadius) radius: self.topLeftRadius startAngle: left endAngle: up clockwise: true];
47
+ [newPath addArcWithCenter:CGPointMake( CGRectGetMaxX(rect) - self.topRightRadius, CGRectGetMinY( rect) + self.topRightRadius) radius: self.topRightRadius startAngle: up endAngle: right clockwise: true];
48
+ [newPath addArcWithCenter:CGPointMake( CGRectGetMaxX(rect) - self.bottomRightRadius, CGRectGetMaxY( rect) - self.bottomRightRadius) radius: self.bottomRightRadius startAngle: right endAngle: down clockwise: true];
49
+ [newPath addArcWithCenter:CGPointMake(CGRectGetMinX(rect) + self.bottomLeftRadius, CGRectGetMaxY( rect) - self.bottomLeftRadius) radius: self.bottomLeftRadius startAngle: down endAngle: left clockwise: true];
50
+ [newPath closePath];
51
+ CGContextSaveGState(context);
52
+ [newPath addClip];
53
+ [image drawInRect:rect];
54
+ CGContextRestoreGState(context);
55
+ }];
56
+ return resultImage;
57
+ }
58
+
59
+ @end
@@ -0,0 +1,5 @@
1
+ module NImage {
2
+ umbrella header "NImage.h"
3
+ export *
4
+ module * { export * }
5
+ }
package/vue/index.mjs ADDED
@@ -0,0 +1,8 @@
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