@mintplayer/ng-qr-code 21.0.0 → 21.1.0

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.
@@ -1,10 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Input, Directive, Component } from '@angular/core';
2
+ import { inject, ViewContainerRef, Input, Directive, Component } from '@angular/core';
3
3
  import * as qrCodeService from '@mintplayer/qr-code';
4
4
 
5
5
  class QrCodeDirective {
6
- constructor(viewContainerRef) {
7
- this.viewContainerRef = viewContainerRef;
6
+ constructor() {
7
+ this.viewContainerRef = inject(ViewContainerRef);
8
8
  //#region Version
9
9
  this.version = null;
10
10
  this.darkColor = '#000000FF';
@@ -96,7 +96,7 @@ class QrCodeDirective {
96
96
  return value;
97
97
  }
98
98
  }
99
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: QrCodeDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
99
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: QrCodeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
100
100
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: QrCodeDirective, isStandalone: true, selector: "canvas[qrCode]", inputs: { value: ["qrCode", "value"], qrCodeVersion: "qrCodeVersion", width: "width", height: "height", darkColor: "darkColor", lightColor: "lightColor", errorCorrectionLevel: ["qrCodeErrorCorrectionLevel", "errorCorrectionLevel"], centerImageSrc: ["qrCodeCenterImageSrc", "centerImageSrc"], centerImageWidth: ["qrCodeCenterImageWidth", "centerImageWidth"], centerImageHeight: ["qrCodeCenterImageHeight", "centerImageHeight"], margin: ["qrCodeMargin", "margin"] }, usesOnChanges: true, ngImport: i0 }); }
101
101
  }
102
102
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: QrCodeDirective, decorators: [{
@@ -105,7 +105,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
105
105
  selector: 'canvas[qrCode]',
106
106
  standalone: true
107
107
  }]
108
- }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { value: [{
108
+ }], propDecorators: { value: [{
109
109
  type: Input,
110
110
  args: ['qrCode']
111
111
  }], qrCodeVersion: [{
@@ -1 +1 @@
1
- {"version":3,"file":"mintplayer-ng-qr-code.mjs","sources":["../../../../libs/mintplayer-ng-qr-code/src/lib/directives/qr-code/qr-code.directive.ts","../../../../libs/mintplayer-ng-qr-code/src/lib/components/qr-code/qr-code.component.ts","../../../../libs/mintplayer-ng-qr-code/src/lib/components/qr-code/qr-code.component.html","../../../../libs/mintplayer-ng-qr-code/src/mintplayer-ng-qr-code.ts"],"sourcesContent":["import { Directive, Input, OnChanges, ViewContainerRef } from '@angular/core';\nimport { QRCodeErrorCorrectionLevel } from '@mintplayer/qr-code';\nimport * as qrCodeService from '@mintplayer/qr-code';\nimport { RgbaColor } from '../../types/rgba-color';\n\n@Directive({\n selector: 'canvas[qrCode]',\n standalone: true\n})\nexport class QrCodeDirective implements OnChanges {\n\n constructor(private viewContainerRef: ViewContainerRef) {}\n\n static readonly VALID_COLOR_REGEX = /^#(?:[0-9a-fA-F]{3,4}){1,2}$/;\n static readonly DEFAULT_ERROR_CORRECTION_LEVEL: QRCodeErrorCorrectionLevel = 'M';\n static readonly DEFAULT_CENTER_IMAGE_SIZE = 40;\n\n @Input('qrCode') value!: string;\n\n //#region Version\n private version: number | null = null;\n @Input() set qrCodeVersion(value: number | null) {\n if (value && (value > 40)) {\n this.version = 40;\n } else if (value && (value < 1)) {\n this.version = 1;\n } else {\n this.version = null;\n }\n }\n //#endregion\n\n \n @Input() width?: number;\n @Input() height?: number;\n @Input() darkColor?: RgbaColor = '#000000FF';\n @Input() lightColor?: RgbaColor = '#FFFFFFFF';\n \n @Input('qrCodeErrorCorrectionLevel') errorCorrectionLevel?: QRCodeErrorCorrectionLevel = QrCodeDirective.DEFAULT_ERROR_CORRECTION_LEVEL;\n @Input('qrCodeCenterImageSrc') centerImageSrc?: string;\n @Input('qrCodeCenterImageWidth') centerImageWidth?: number | string;\n @Input('qrCodeCenterImageHeight') centerImageHeight?: number | string;\n @Input('qrCodeMargin') margin? = 16;\n\n private centerImage?: HTMLImageElement;\n\n async ngOnChanges() {\n if (!this.value) {\n return;\n }\n\n const canvas = this.viewContainerRef.element.nativeElement as HTMLCanvasElement | null;\n if (!canvas || (typeof window === 'undefined')) {\n // native element not available on server side rendering\n return;\n }\n\n if (typeof window !== 'undefined') {\n const context = canvas.getContext('2d');\n if (context) {\n context.clearRect(0, 0, context.canvas.width, context.canvas.height);\n\n const errorCorrectionLevel = this.errorCorrectionLevel ?? QrCodeDirective.DEFAULT_ERROR_CORRECTION_LEVEL\n\n const dark = !this.darkColor \n ? undefined\n : QrCodeDirective.VALID_COLOR_REGEX.test(this.darkColor)\n ? this.darkColor\n : undefined;\n const light = !this.lightColor\n ? undefined\n : QrCodeDirective.VALID_COLOR_REGEX.test(this.lightColor)\n ? this.lightColor\n : undefined;\n\n await qrCodeService\n .toCanvas(canvas, this.value, {\n version: this.version ?? undefined,\n errorCorrectionLevel,\n width: this.width,\n margin: this.margin,\n color: {\n dark,\n light,\n },\n });\n\n const centerImageSrc = this.centerImageSrc;\n const centerImageWidth = this.getIntOrDefault(this.centerImageWidth, QrCodeDirective.DEFAULT_CENTER_IMAGE_SIZE);\n const centerImageHeight = this.getIntOrDefault(this.centerImageHeight, QrCodeDirective.DEFAULT_CENTER_IMAGE_SIZE);\n\n if (centerImageSrc && context) {\n\n if (!this.centerImage) {\n this.centerImage = new Image(centerImageWidth, centerImageHeight);\n }\n\n if (centerImageSrc !== this.centerImage?.src) {\n this.centerImage.src = centerImageSrc;\n }\n\n if (centerImageWidth !== this.centerImage.width) {\n this.centerImage.width = centerImageWidth;\n }\n\n if (centerImageHeight !== this.centerImage.height) {\n this.centerImage.height = centerImageHeight;\n }\n\n const centerImage = this.centerImage;\n\n centerImage.onload = () => {\n context.drawImage(\n centerImage,\n canvas.width / 2 - centerImageWidth / 2,\n canvas.height / 2 - centerImageHeight / 2, centerImageWidth, centerImageHeight,\n );\n }\n }\n }\n }\n }\n\n private getIntOrDefault(value: string | number | undefined, defaultValue: number): number {\n if (value === undefined || value === '') {\n return defaultValue;\n } else if (typeof value === 'string') {\n return parseInt(value, 10);\n } else {\n return value;\n }\n }\n\n}\n","import { Component, Input } from '@angular/core';\nimport { QRCodeErrorCorrectionLevel } from '@mintplayer/qr-code';\nimport { RgbaColor } from '../../types/rgba-color';\nimport { QrCodeDirective } from '../../directives/qr-code/qr-code.directive';\n\n@Component({\n selector: 'qr-code',\n templateUrl: './qr-code.component.html',\n styleUrls: ['./qr-code.component.scss'],\n standalone: true,\n imports: [QrCodeDirective]\n})\nexport class QrCodeComponent {\n @Input() value?: string;\n @Input() size?: number;\n @Input() darkColor?: RgbaColor;\n @Input() lightColor?: RgbaColor;\n @Input() errorCorrectionLevel?: QRCodeErrorCorrectionLevel;\n @Input() centerImageSrc?: string;\n @Input() centerImageSize?: string | number;\n @Input() margin?: number;\n}\n","@if (value) {\n <canvas\n [qrCode]=\"value\"\n [qrCodeErrorCorrectionLevel]=\"errorCorrectionLevel\"\n [qrCodeCenterImageSrc]=\"centerImageSrc\"\n [qrCodeCenterImageWidth]=\"centerImageSize\"\n [qrCodeCenterImageHeight]=\"centerImageSize\"\n [qrCodeMargin]=\"margin\"\n [width]=\"size\"\n [height]=\"size\"\n [darkColor]=\"darkColor\"\n [lightColor]=\"lightColor\">\n </canvas>\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MASa,eAAe,CAAA;AAE1B,IAAA,WAAA,CAAoB,gBAAkC,EAAA;QAAlC,IAAA,CAAA,gBAAgB,GAAhB,gBAAgB;;QAS5B,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,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDHW,eAAe,EAAA,QAAA,EAAA,gBAAA,EAAA,MAAA,EAAA,CAAA,QAAA,EAAA,eAAA,EAAA,OAAA,EAAA,QAAA,EAAA,WAAA,EAAA,YAAA,EAAA,4BAAA,EAAA,sBAAA,EAAA,wBAAA,EAAA,yBAAA,EAAA,cAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA;;2FAEd,eAAe,EAAA,UAAA,EAAA,CAAA;kBAP3B,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,SAAS,EAAA,UAAA,EAGP,IAAI,EAAA,OAAA,EACP,CAAC,eAAe,CAAC,EAAA,QAAA,EAAA,0cAAA,EAAA;;sBAGzB;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;;AEpBH;;AAEG;;;;"}
1
+ {"version":3,"file":"mintplayer-ng-qr-code.mjs","sources":["../../../../libs/mintplayer-ng-qr-code/src/lib/directives/qr-code/qr-code.directive.ts","../../../../libs/mintplayer-ng-qr-code/src/lib/components/qr-code/qr-code.component.ts","../../../../libs/mintplayer-ng-qr-code/src/lib/components/qr-code/qr-code.component.html","../../../../libs/mintplayer-ng-qr-code/src/mintplayer-ng-qr-code.ts"],"sourcesContent":["import { Directive, inject, Input, OnChanges, ViewContainerRef } from '@angular/core';\nimport { QRCodeErrorCorrectionLevel } from '@mintplayer/qr-code';\nimport * as qrCodeService from '@mintplayer/qr-code';\nimport { RgbaColor } from '../../types/rgba-color';\n\n@Directive({\n selector: 'canvas[qrCode]',\n standalone: true\n})\nexport class QrCodeDirective implements OnChanges {\n private viewContainerRef = inject(ViewContainerRef);\n\n static readonly VALID_COLOR_REGEX = /^#(?:[0-9a-fA-F]{3,4}){1,2}$/;\n static readonly DEFAULT_ERROR_CORRECTION_LEVEL: QRCodeErrorCorrectionLevel = 'M';\n static readonly DEFAULT_CENTER_IMAGE_SIZE = 40;\n\n @Input('qrCode') value!: string;\n\n //#region Version\n private version: number | null = null;\n @Input() set qrCodeVersion(value: number | null) {\n if (value && (value > 40)) {\n this.version = 40;\n } else if (value && (value < 1)) {\n this.version = 1;\n } else {\n this.version = null;\n }\n }\n //#endregion\n\n \n @Input() width?: number;\n @Input() height?: number;\n @Input() darkColor?: RgbaColor = '#000000FF';\n @Input() lightColor?: RgbaColor = '#FFFFFFFF';\n \n @Input('qrCodeErrorCorrectionLevel') errorCorrectionLevel?: QRCodeErrorCorrectionLevel = QrCodeDirective.DEFAULT_ERROR_CORRECTION_LEVEL;\n @Input('qrCodeCenterImageSrc') centerImageSrc?: string;\n @Input('qrCodeCenterImageWidth') centerImageWidth?: number | string;\n @Input('qrCodeCenterImageHeight') centerImageHeight?: number | string;\n @Input('qrCodeMargin') margin? = 16;\n\n private centerImage?: HTMLImageElement;\n\n async ngOnChanges() {\n if (!this.value) {\n return;\n }\n\n const canvas = this.viewContainerRef.element.nativeElement as HTMLCanvasElement | null;\n if (!canvas || (typeof window === 'undefined')) {\n // native element not available on server side rendering\n return;\n }\n\n if (typeof window !== 'undefined') {\n const context = canvas.getContext('2d');\n if (context) {\n context.clearRect(0, 0, context.canvas.width, context.canvas.height);\n\n const errorCorrectionLevel = this.errorCorrectionLevel ?? QrCodeDirective.DEFAULT_ERROR_CORRECTION_LEVEL\n\n const dark = !this.darkColor \n ? undefined\n : QrCodeDirective.VALID_COLOR_REGEX.test(this.darkColor)\n ? this.darkColor\n : undefined;\n const light = !this.lightColor\n ? undefined\n : QrCodeDirective.VALID_COLOR_REGEX.test(this.lightColor)\n ? this.lightColor\n : undefined;\n\n await qrCodeService\n .toCanvas(canvas, this.value, {\n version: this.version ?? undefined,\n errorCorrectionLevel,\n width: this.width,\n margin: this.margin,\n color: {\n dark,\n light,\n },\n });\n\n const centerImageSrc = this.centerImageSrc;\n const centerImageWidth = this.getIntOrDefault(this.centerImageWidth, QrCodeDirective.DEFAULT_CENTER_IMAGE_SIZE);\n const centerImageHeight = this.getIntOrDefault(this.centerImageHeight, QrCodeDirective.DEFAULT_CENTER_IMAGE_SIZE);\n\n if (centerImageSrc && context) {\n\n if (!this.centerImage) {\n this.centerImage = new Image(centerImageWidth, centerImageHeight);\n }\n\n if (centerImageSrc !== this.centerImage?.src) {\n this.centerImage.src = centerImageSrc;\n }\n\n if (centerImageWidth !== this.centerImage.width) {\n this.centerImage.width = centerImageWidth;\n }\n\n if (centerImageHeight !== this.centerImage.height) {\n this.centerImage.height = centerImageHeight;\n }\n\n const centerImage = this.centerImage;\n\n centerImage.onload = () => {\n context.drawImage(\n centerImage,\n canvas.width / 2 - centerImageWidth / 2,\n canvas.height / 2 - centerImageHeight / 2, centerImageWidth, centerImageHeight,\n );\n }\n }\n }\n }\n }\n\n private getIntOrDefault(value: string | number | undefined, defaultValue: number): number {\n if (value === undefined || value === '') {\n return defaultValue;\n } else if (typeof value === 'string') {\n return parseInt(value, 10);\n } else {\n return value;\n }\n }\n\n}\n","import { Component, Input } from '@angular/core';\nimport { QRCodeErrorCorrectionLevel } from '@mintplayer/qr-code';\nimport { RgbaColor } from '../../types/rgba-color';\nimport { QrCodeDirective } from '../../directives/qr-code/qr-code.directive';\n\n@Component({\n selector: 'qr-code',\n templateUrl: './qr-code.component.html',\n styleUrls: ['./qr-code.component.scss'],\n standalone: true,\n imports: [QrCodeDirective]\n})\nexport class QrCodeComponent {\n @Input() value?: string;\n @Input() size?: number;\n @Input() darkColor?: RgbaColor;\n @Input() lightColor?: RgbaColor;\n @Input() errorCorrectionLevel?: QRCodeErrorCorrectionLevel;\n @Input() centerImageSrc?: string;\n @Input() centerImageSize?: string | number;\n @Input() margin?: number;\n}\n","@if (value) {\n <canvas\n [qrCode]=\"value\"\n [qrCodeErrorCorrectionLevel]=\"errorCorrectionLevel\"\n [qrCodeCenterImageSrc]=\"centerImageSrc\"\n [qrCodeCenterImageWidth]=\"centerImageSize\"\n [qrCodeCenterImageHeight]=\"centerImageSize\"\n [qrCodeMargin]=\"margin\"\n [width]=\"size\"\n [height]=\"size\"\n [darkColor]=\"darkColor\"\n [lightColor]=\"lightColor\">\n </canvas>\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MASa,eAAe,CAAA;AAJ5B,IAAA,WAAA,GAAA;AAKU,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;;QAS3C,IAAA,CAAA,OAAO,GAAkB,IAAI;QAe5B,IAAA,CAAA,SAAS,GAAe,WAAW;QACnC,IAAA,CAAA,UAAU,GAAe,WAAW;AAER,QAAA,IAAA,CAAA,oBAAoB,GAAgC,eAAe,CAAC,8BAA8B;QAIhH,IAAA,CAAA,MAAM,GAAI,EAAE;AA2FpC,IAAA;aAxHiB,IAAA,CAAA,iBAAiB,GAAG,8BAAH,CAAkC;aACnD,IAAA,CAAA,8BAA8B,GAA+B,GAA/B,CAAmC;aACjE,IAAA,CAAA,yBAAyB,GAAG,EAAH,CAAM;IAM/C,IAAa,aAAa,CAAC,KAAoB,EAAA;QAC7C,IAAI,KAAK,KAAK,KAAK,GAAG,EAAE,CAAC,EAAE;AACzB,YAAA,IAAI,CAAC,OAAO,GAAG,EAAE;QACnB;aAAO,IAAI,KAAK,KAAK,KAAK,GAAG,CAAC,CAAC,EAAE;AAC/B,YAAA,IAAI,CAAC,OAAO,GAAG,CAAC;QAClB;aAAO;AACL,YAAA,IAAI,CAAC,OAAO,GAAG,IAAI;QACrB;IACF;AAiBA,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf;QACF;QAEA,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,aAAyC;QACtF,IAAI,CAAC,MAAM,KAAK,OAAO,MAAM,KAAK,WAAW,CAAC,EAAE;;YAE9C;QACF;AAEA,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,MAAM,OAAO,GAAG,MAAM,CAAC,U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A,oBAAA,EAAA,sBAAA,EAAA,cAAA,EAAA,gBAAA,EAAA,eAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,QAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECZ5B,0cAaC,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDHW,eAAe,EAAA,QAAA,EAAA,gBAAA,EAAA,MAAA,EAAA,CAAA,QAAA,EAAA,eAAA,EAAA,OAAA,EAAA,QAAA,EAAA,WAAA,EAAA,YAAA,EAAA,4BAAA,EAAA,sBAAA,EAAA,wBAAA,EAAA,yBAAA,EAAA,cAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA;;2FAEd,eAAe,EAAA,UAAA,EAAA,CAAA;kBAP3B,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,SAAS,EAAA,UAAA,EAGP,IAAI,EAAA,OAAA,EACP,CAAC,eAAe,CAAC,EAAA,QAAA,EAAA,0cAAA,EAAA;;sBAGzB;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;sBACA;;;AEpBH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mintplayer/ng-qr-code",
3
3
  "private": false,
4
- "version": "21.0.0",
4
+ "version": "21.1.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/MintPlayer/mintplayer-ng-bootstrap",
@@ -1,6 +1,6 @@
1
1
  import { QRCodeErrorCorrectionLevel } from '@mintplayer/qr-code';
2
2
  import * as i0 from '@angular/core';
3
- import { OnChanges, ViewContainerRef } from '@angular/core';
3
+ import { OnChanges } from '@angular/core';
4
4
 
5
5
  type RgbaColor = `#${string}`;
6
6
 
@@ -19,7 +19,6 @@ declare class QrCodeComponent {
19
19
 
20
20
  declare class QrCodeDirective implements OnChanges {
21
21
  private viewContainerRef;
22
- constructor(viewContainerRef: ViewContainerRef);
23
22
  static readonly VALID_COLOR_REGEX: RegExp;
24
23
  static readonly DEFAULT_ERROR_CORRECTION_LEVEL: QRCodeErrorCorrectionLevel;
25
24
  static readonly DEFAULT_CENTER_IMAGE_SIZE = 40;