qr-scanner-app 0.0.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.
Files changed (36) hide show
  1. package/.editorconfig +17 -0
  2. package/.firebase/hosting.ZGlzdC9xci1zY2FubmVyLWFwcA.cache +7 -0
  3. package/.firebase/hosting.ZGlzdC9xci1zY2FubmVyLWFwcC9icm93c2Vy.cache +13 -0
  4. package/.firebaserc +5 -0
  5. package/.vscode/extensions.json +4 -0
  6. package/.vscode/launch.json +20 -0
  7. package/.vscode/tasks.json +42 -0
  8. package/README.md +59 -0
  9. package/angular.json +134 -0
  10. package/firebase.json +16 -0
  11. package/package.json +43 -0
  12. package/projects/ngx-custom-qr-scanner/README.md +63 -0
  13. package/projects/ngx-custom-qr-scanner/ng-package.json +7 -0
  14. package/projects/ngx-custom-qr-scanner/package.json +27 -0
  15. package/projects/ngx-custom-qr-scanner/src/lib/ngx-custom-qr-scanner.component.spec.ts +23 -0
  16. package/projects/ngx-custom-qr-scanner/src/lib/ngx-custom-qr-scanner.component.ts +412 -0
  17. package/projects/ngx-custom-qr-scanner/src/lib/ngx-custom-qr-scanner.service.spec.ts +16 -0
  18. package/projects/ngx-custom-qr-scanner/src/lib/ngx-custom-qr-scanner.service.ts +9 -0
  19. package/projects/ngx-custom-qr-scanner/src/public-api.ts +6 -0
  20. package/projects/ngx-custom-qr-scanner/tsconfig.lib.json +15 -0
  21. package/projects/ngx-custom-qr-scanner/tsconfig.lib.prod.json +11 -0
  22. package/projects/ngx-custom-qr-scanner/tsconfig.spec.json +15 -0
  23. package/public/favicon.ico +0 -0
  24. package/src/app/app.component.css +0 -0
  25. package/src/app/app.component.html +1 -0
  26. package/src/app/app.component.spec.ts +29 -0
  27. package/src/app/app.component.ts +13 -0
  28. package/src/app/app.config.ts +8 -0
  29. package/src/app/app.routes.ts +3 -0
  30. package/src/app/safe.pipe.ts +28 -0
  31. package/src/index.html +16 -0
  32. package/src/main.ts +6 -0
  33. package/src/styles.css +1 -0
  34. package/tsconfig.app.json +15 -0
  35. package/tsconfig.json +32 -0
  36. package/tsconfig.spec.json +15 -0
package/.editorconfig ADDED
@@ -0,0 +1,17 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+ ij_typescript_use_double_quotes = false
14
+
15
+ [*.md]
16
+ max_line_length = off
17
+ trim_trailing_whitespace = false
@@ -0,0 +1,7 @@
1
+ browser/styles-5INURTSO.css,1770988179363,f1b651238a58fe290baec6c5e32f3bdb1943dd2bd582f02569231f7a757c7837
2
+ browser/index.html,1770988179364,d298e2708dc2f260f9f1891fb748aaee33584ac1309e3587015245aa43b31bdd
3
+ prerendered-routes.json,1770988179365,5c19cca0df6fbfe49815495e7145ec4551d30ac216520a6ce811ec2cca054a67
4
+ 3rdpartylicenses.txt,1770988179364,0327bcb868bf4fd5efa4b8257eea09d3623d81d58e25da91c7139b78bd5899b9
5
+ browser/polyfills-B6TNHZQ6.js,1770988179364,0d470d11ef45790298a0211b78859f53935f24a7d05c357a0bce142e2e12a925
6
+ browser/favicon.ico,1770988179363,8f1fc0f94ae643bb8757c3cb49f69bf6cb2228f632cb77c7e47d8ee3995d88a7
7
+ browser/main-VYJBJ3K3.js,1770988179365,78a6749820aba30057621fbe467750be97907dc329f5afd928cb63bb0ae62489
@@ -0,0 +1,13 @@
1
+ styles-5INURTSO.css,1771255855743,f1b651238a58fe290baec6c5e32f3bdb1943dd2bd582f02569231f7a757c7837
2
+ index.html,1771255855744,624777144d01c4275a6683bb0d8a4004f174b23173a23f88b6a31f3bc0cdfed0
3
+ chunk-2VMXMS7J.js,1771255855744,8f326e731f352307dfeb3085d7b33b00559f350cab254d5e8a180698dc9093e6
4
+ polyfills-B6TNHZQ6.js,1771255855744,0d470d11ef45790298a0211b78859f53935f24a7d05c357a0bce142e2e12a925
5
+ chunk-6H7TWJR4.js,1771255855744,6c12100c12753c2ef75ba236e57662da29199b2095cefac6446d5b69ddfe1adb
6
+ assets/wasm/index.mjs,1771255855745,7173b80a747bfc839b92f9a5b684e93d2a70bb8536cbda8faef88a620e7ced8c
7
+ favicon.ico,1771255855743,8f1fc0f94ae643bb8757c3cb49f69bf6cb2228f632cb77c7e47d8ee3995d88a7
8
+ assets/wasm/index.js,1771255855745,42a66bdad28941e9162db3f486fcb3e9c5c26ba47812e58a9bdf4e86a39ff72a
9
+ assets/wasm/index.d.ts,1771255855746,d666cf1980dca563d15a9f3d4ddfa2daefc56b1a75fe13865911e9caa755c185
10
+ assets/wasm/index.mjs.map,1771255855746,fde00a63e44377611b67351f627111f1fbd571d606da07a5de7de6945574db40
11
+ assets/wasm/index.js.map,1771255855745,67bcabf551d05ba1431ec2d05a932ee73651585cd693b7dcb50f677c7fac17e0
12
+ main-64QMUHWT.js,1771255855744,0d1eb2cfc40c12844356f4401d8c3bc71fb384bd315dc13d5750b1d7790ca74b
13
+ assets/wasm/ngx-scanner-qrcode.wasm,1771255855748,e47e0b2b77ae1ad36cf44f0eeea5dec89996ff027412b3060f2fb9916d7ec632
package/.firebaserc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "projects": {
3
+ "default": "loving-petcare-d984a"
4
+ }
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+ "recommendations": ["angular.ng-template"]
4
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
+ "version": "0.2.0",
4
+ "configurations": [
5
+ {
6
+ "name": "ng serve",
7
+ "type": "chrome",
8
+ "request": "launch",
9
+ "preLaunchTask": "npm: start",
10
+ "url": "http://localhost:4200/"
11
+ },
12
+ {
13
+ "name": "ng test",
14
+ "type": "chrome",
15
+ "request": "launch",
16
+ "preLaunchTask": "npm: test",
17
+ "url": "http://localhost:9876/debug.html"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
+ "version": "2.0.0",
4
+ "tasks": [
5
+ {
6
+ "type": "npm",
7
+ "script": "start",
8
+ "isBackground": true,
9
+ "problemMatcher": {
10
+ "owner": "typescript",
11
+ "pattern": "$tsc",
12
+ "background": {
13
+ "activeOnStart": true,
14
+ "beginsPattern": {
15
+ "regexp": "(.*?)"
16
+ },
17
+ "endsPattern": {
18
+ "regexp": "bundle generation complete"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "type": "npm",
25
+ "script": "test",
26
+ "isBackground": true,
27
+ "problemMatcher": {
28
+ "owner": "typescript",
29
+ "pattern": "$tsc",
30
+ "background": {
31
+ "activeOnStart": true,
32
+ "beginsPattern": {
33
+ "regexp": "(.*?)"
34
+ },
35
+ "endsPattern": {
36
+ "regexp": "bundle generation complete"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # QrScannerApp
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.20.
4
+
5
+ ## Development server
6
+
7
+ To start a local development server, run:
8
+
9
+ ```bash
10
+ ng serve
11
+ ```
12
+
13
+ Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14
+
15
+ ## Code scaffolding
16
+
17
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18
+
19
+ ```bash
20
+ ng generate component component-name
21
+ ```
22
+
23
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24
+
25
+ ```bash
26
+ ng generate --help
27
+ ```
28
+
29
+ ## Building
30
+
31
+ To build the project run:
32
+
33
+ ```bash
34
+ ng build
35
+ ```
36
+
37
+ This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
38
+
39
+ ## Running unit tests
40
+
41
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
42
+
43
+ ```bash
44
+ ng test
45
+ ```
46
+
47
+ ## Running end-to-end tests
48
+
49
+ For end-to-end (e2e) testing, run:
50
+
51
+ ```bash
52
+ ng e2e
53
+ ```
54
+
55
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
56
+
57
+ ## Additional Resources
58
+
59
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
package/angular.json ADDED
@@ -0,0 +1,134 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "newProjectRoot": "projects",
5
+ "projects": {
6
+ "qr-scanner-app": {
7
+ "projectType": "application",
8
+ "schematics": {},
9
+ "root": "",
10
+ "sourceRoot": "src",
11
+ "prefix": "app",
12
+ "architect": {
13
+ "build": {
14
+ "builder": "@angular-devkit/build-angular:application",
15
+ "options": {
16
+ "outputPath": "dist/qr-scanner-app",
17
+ "index": "src/index.html",
18
+ "browser": "src/main.ts",
19
+ "polyfills": [
20
+ "zone.js"
21
+ ],
22
+ "tsConfig": "tsconfig.app.json",
23
+ "assets": [
24
+ {
25
+ "glob": "**/*",
26
+ "input": "public"
27
+ },
28
+ {
29
+ "glob": "**/*",
30
+ "input": "node_modules/ngx-scanner-qrcode/wasm/",
31
+ "output": "./assets/wasm/"
32
+ }
33
+ ],
34
+ "styles": [
35
+ "src/styles.css"
36
+ ],
37
+ "scripts": []
38
+ },
39
+ "configurations": {
40
+ "production": {
41
+ "budgets": [
42
+ {
43
+ "type": "initial",
44
+ "maximumWarning": "500kB",
45
+ "maximumError": "1MB"
46
+ },
47
+ {
48
+ "type": "anyComponentStyle",
49
+ "maximumWarning": "4kB",
50
+ "maximumError": "8kB"
51
+ }
52
+ ],
53
+ "outputHashing": "all"
54
+ },
55
+ "development": {
56
+ "optimization": false,
57
+ "extractLicenses": false,
58
+ "sourceMap": true
59
+ }
60
+ },
61
+ "defaultConfiguration": "production"
62
+ },
63
+ "serve": {
64
+ "builder": "@angular-devkit/build-angular:dev-server",
65
+ "configurations": {
66
+ "production": {
67
+ "buildTarget": "qr-scanner-app:build:production"
68
+ },
69
+ "development": {
70
+ "buildTarget": "qr-scanner-app:build:development"
71
+ }
72
+ },
73
+ "defaultConfiguration": "development"
74
+ },
75
+ "extract-i18n": {
76
+ "builder": "@angular-devkit/build-angular:extract-i18n"
77
+ },
78
+ "test": {
79
+ "builder": "@angular-devkit/build-angular:karma",
80
+ "options": {
81
+ "polyfills": [
82
+ "zone.js",
83
+ "zone.js/testing"
84
+ ],
85
+ "tsConfig": "tsconfig.spec.json",
86
+ "assets": [
87
+ {
88
+ "glob": "**/*",
89
+ "input": "public"
90
+ }
91
+ ],
92
+ "styles": [
93
+ "src/styles.css"
94
+ ],
95
+ "scripts": []
96
+ }
97
+ }
98
+ }
99
+ },
100
+ "ngx-custom-qr-scanner": {
101
+ "projectType": "library",
102
+ "root": "projects/ngx-custom-qr-scanner",
103
+ "sourceRoot": "projects/ngx-custom-qr-scanner/src",
104
+ "prefix": "lib",
105
+ "architect": {
106
+ "build": {
107
+ "builder": "@angular-devkit/build-angular:ng-packagr",
108
+ "options": {
109
+ "project": "projects/ngx-custom-qr-scanner/ng-package.json"
110
+ },
111
+ "configurations": {
112
+ "production": {
113
+ "tsConfig": "projects/ngx-custom-qr-scanner/tsconfig.lib.prod.json"
114
+ },
115
+ "development": {
116
+ "tsConfig": "projects/ngx-custom-qr-scanner/tsconfig.lib.json"
117
+ }
118
+ },
119
+ "defaultConfiguration": "production"
120
+ },
121
+ "test": {
122
+ "builder": "@angular-devkit/build-angular:karma",
123
+ "options": {
124
+ "tsConfig": "projects/ngx-custom-qr-scanner/tsconfig.spec.json",
125
+ "polyfills": [
126
+ "zone.js",
127
+ "zone.js/testing"
128
+ ]
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
package/firebase.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "hosting": {
3
+ "public": "dist/qr-scanner-app/browser",
4
+ "ignore": [
5
+ "firebase.json",
6
+ "**/.*",
7
+ "**/node_modules/**"
8
+ ],
9
+ "rewrites": [
10
+ {
11
+ "source": "**",
12
+ "destination": "/index.html"
13
+ }
14
+ ]
15
+ }
16
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "qr-scanner-app",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "ng": "ng",
6
+ "start": "ng serve",
7
+ "build": "ng build",
8
+ "watch": "ng build --watch --configuration development",
9
+ "test": "ng test"
10
+ },
11
+ "private": false,
12
+ "dependencies": {
13
+ "@angular/common": "^19.2.0",
14
+ "@angular/compiler": "^19.2.0",
15
+ "@angular/core": "^19.2.0",
16
+ "@angular/forms": "^19.2.18",
17
+ "@angular/platform-browser": "^19.2.0",
18
+ "@angular/platform-browser-dynamic": "^19.2.0",
19
+ "@angular/router": "^19.2.0",
20
+ "@zxing/browser": "^0.1.5",
21
+ "@zxing/library": "^0.21.3",
22
+ "html5-qrcode": "^2.3.8",
23
+ "ngx-scanner-qrcode": "^1.7.6",
24
+ "qr-scanner": "^1.4.2",
25
+ "rxjs": "~7.8.0",
26
+ "tslib": "^2.3.0",
27
+ "zone.js": "~0.15.0"
28
+ },
29
+ "devDependencies": {
30
+ "@angular-devkit/build-angular": "^19.2.20",
31
+ "@angular/cli": "^19.2.20",
32
+ "@angular/compiler-cli": "^19.2.0",
33
+ "@types/jasmine": "~5.1.0",
34
+ "jasmine-core": "~5.6.0",
35
+ "karma": "~6.4.0",
36
+ "karma-chrome-launcher": "~3.2.0",
37
+ "karma-coverage": "~2.2.0",
38
+ "karma-jasmine": "~5.1.0",
39
+ "karma-jasmine-html-reporter": "~2.1.0",
40
+ "ng-packagr": "^19.2.0",
41
+ "typescript": "~5.7.2"
42
+ }
43
+ }
@@ -0,0 +1,63 @@
1
+ # NgxCustomQrScanner
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
+
9
+ ```bash
10
+ ng generate component component-name
11
+ ```
12
+
13
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
+
15
+ ```bash
16
+ ng generate --help
17
+ ```
18
+
19
+ ## Building
20
+
21
+ To build the library, run:
22
+
23
+ ```bash
24
+ ng build ngx-custom-qr-scanner
25
+ ```
26
+
27
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
+
29
+ ### Publishing the Library
30
+
31
+ Once the project is built, you can publish your library by following these steps:
32
+
33
+ 1. Navigate to the `dist` directory:
34
+ ```bash
35
+ cd dist/ngx-custom-qr-scanner
36
+ ```
37
+
38
+ 2. Run the `npm publish` command to publish your library to the npm registry:
39
+ ```bash
40
+ npm publish
41
+ ```
42
+
43
+ ## Running unit tests
44
+
45
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
46
+
47
+ ```bash
48
+ ng test
49
+ ```
50
+
51
+ ## Running end-to-end tests
52
+
53
+ For end-to-end (e2e) testing, run:
54
+
55
+ ```bash
56
+ ng e2e
57
+ ```
58
+
59
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
60
+
61
+ ## Additional Resources
62
+
63
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ngx-custom-qr-scanner",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "ngx-custom-qr-scanner",
3
+ "version": "0.0.1",
4
+ "description": "A reusable Angular QR scanner library",
5
+ "keywords": [
6
+ "angular",
7
+ "qr-scanner",
8
+ "ngx",
9
+ "barcode"
10
+ ],
11
+ "private": false,
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/username/repo"
16
+ },
17
+ "author": "Your Name",
18
+ "peerDependencies": {
19
+ "@angular/common": "^19.2.0",
20
+ "@angular/core": "^19.2.0",
21
+ "qr-scanner": "^1.4.2"
22
+ },
23
+ "dependencies": {
24
+ "tslib": "^2.3.0"
25
+ },
26
+ "sideEffects": false
27
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { NgxCustomQrScannerComponent } from './ngx-custom-qr-scanner.component';
4
+
5
+ describe('NgxCustomQrScannerComponent', () => {
6
+ let component: NgxCustomQrScannerComponent;
7
+ let fixture: ComponentFixture<NgxCustomQrScannerComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [NgxCustomQrScannerComponent]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(NgxCustomQrScannerComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,412 @@
1
+ import { Component, AfterViewInit, OnDestroy, ViewChild, ElementRef, ViewEncapsulation } from '@angular/core';
2
+ import QrScanner from 'qr-scanner';
3
+ import { CommonModule } from '@angular/common';
4
+
5
+ @Component({
6
+ selector: 'ngx-custom-qr-scanner',
7
+ standalone: true,
8
+ imports: [CommonModule],
9
+ template: `
10
+ <div class="scanner-container">
11
+ <!-- Left Sidebar -->
12
+ <div class="sidebar left-sidebar">
13
+ <div class="thumbnails">
14
+ <div class="thumb-placeholder">
15
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
16
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
17
+ <circle cx="8.5" cy="8.5" r="1.5"></circle>
18
+ <polyline points="21 15 16 10 5 21"></polyline>
19
+ </svg>
20
+ </div>
21
+ </div>
22
+ <div class="vertical-text">
23
+ <span>T</span><span>y</span><span>r</span><span>e</span>
24
+ <span class="spacer"></span>
25
+ <span>Q</span><span>R</span>
26
+ <span class="spacer"></span>
27
+ <span>C</span><span>o</span><span>d</span><span>e</span>
28
+ </div>
29
+ </div>
30
+
31
+ <!-- Center Camera Area -->
32
+ <div class="camera-area">
33
+ <video #video playsinline></video>
34
+
35
+ <!-- Overlay Layer -->
36
+ <div class="overlay">
37
+ <div class="scan-region">
38
+ <div class="corner top-left"></div>
39
+ <div class="corner top-right"></div>
40
+ <div class="corner bottom-left"></div>
41
+ <div class="corner bottom-right"></div>
42
+
43
+ <!-- Scan line animation -->
44
+ <div class="scan-line"></div>
45
+ </div>
46
+
47
+ <div class="instruction-bubble">
48
+ Only Tire-care and touch the barcode mount with full interest
49
+ </div>
50
+ </div>
51
+ </div>
52
+
53
+ <!-- Right Sidebar -->
54
+ <div class="sidebar right-sidebar">
55
+ <!-- Torch Control -->
56
+ <div class="control-group torch-group">
57
+ <div class="label">Torch</div>
58
+ <button class="torch-btn" (click)="toggleFlash()" [class.active]="flashOn">
59
+ <svg viewBox="0 0 24 24" width="32" height="32" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
60
+ <path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"></path>
61
+ </svg>
62
+ </button>
63
+ </div>
64
+
65
+ <!-- Zoom Control -->
66
+ <div class="control-group zoom-group">
67
+ <div class="label">Zoom Slider</div>
68
+ <div class="zoom-value">{{ zoom | number:'1.0-1' }}</div>
69
+ <div class="slider-container">
70
+ <input type="range"
71
+ min="1"
72
+ [max]="maxZoom"
73
+ step="0.1"
74
+ [value]="zoom"
75
+ (input)="onZoomChange($event)"
76
+ class="zoom-slider">
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ `,
82
+ styles: [`
83
+ :host {
84
+ display: block;
85
+ width: 100%;
86
+ height: 100%;
87
+ background: #000;
88
+ color: white;
89
+ font-family: sans-serif;
90
+ overflow: hidden;
91
+ }
92
+
93
+ .scanner-container {
94
+ display: flex;
95
+ flex-direction: row;
96
+ height: 100vh;
97
+ width: 100vw;
98
+ }
99
+
100
+ /* Sidebars */
101
+ .sidebar {
102
+ background-color: #E60000; /* Vibrant Red */
103
+ width: 120px;
104
+ flex-shrink: 0;
105
+ display: flex;
106
+ flex-direction: column;
107
+ align-items: center;
108
+ padding: 20px 0;
109
+ z-index: 10;
110
+ }
111
+
112
+ /* Left Sidebar Specifics */
113
+ .left-sidebar {
114
+ justify-content: flex-start;
115
+ gap: 40px;
116
+ }
117
+
118
+ .thumbnails .thumb-placeholder {
119
+ width: 80px;
120
+ height: 60px;
121
+ background: rgba(255,255,255,0.2);
122
+ border: 2px solid rgba(255,255,255,0.5);
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: center;
126
+ }
127
+
128
+ .vertical-text {
129
+ display: flex;
130
+ flex-direction: column;
131
+ align-items: center;
132
+ font-size: 1.2rem;
133
+ font-weight: bold;
134
+ letter-spacing: 2px;
135
+ text-transform: uppercase;
136
+ color: white;
137
+ }
138
+ .vertical-text span {
139
+ line-height: 1.5;
140
+ }
141
+ .vertical-text .spacer {
142
+ height: 20px;
143
+ }
144
+
145
+ /* Right Sidebar Specifics */
146
+ .right-sidebar {
147
+ justify-content: flex-start;
148
+ gap: 60px;
149
+ }
150
+
151
+ .control-group {
152
+ display: flex;
153
+ flex-direction: column;
154
+ align-items: center;
155
+ gap: 10px;
156
+ width: 100%;
157
+ }
158
+
159
+ .label {
160
+ font-size: 0.9rem;
161
+ font-weight: 500;
162
+ }
163
+
164
+ /* Torch Button */
165
+ .torch-btn {
166
+ background: none;
167
+ border: none;
168
+ color: white;
169
+ cursor: pointer;
170
+ padding: 10px;
171
+ border-radius: 50%;
172
+ border: 2px solid white;
173
+ transition: all 0.2s;
174
+ }
175
+ .torch-btn.active {
176
+ background: white;
177
+ color: #E60000;
178
+ }
179
+
180
+ /* Zoom Slider */
181
+ .zoom-group {
182
+ margin-top: auto;
183
+ margin-bottom: 50px;
184
+ }
185
+
186
+ .zoom-value {
187
+ font-size: 1.2rem;
188
+ font-weight: bold;
189
+ }
190
+
191
+ .slider-container {
192
+ height: 150px;
193
+ display: flex;
194
+ align-items: center;
195
+ }
196
+
197
+ .zoom-slider {
198
+ -webkit-appearance: none;
199
+ width: 150px;
200
+ height: 4px;
201
+ background: rgba(255,255,255,0.3);
202
+ border-radius: 2px;
203
+ outline: none;
204
+ transform: rotate(-90deg); /* Vertical Slider */
205
+ }
206
+
207
+ .zoom-slider::-webkit-slider-thumb {
208
+ -webkit-appearance: none;
209
+ width: 20px;
210
+ height: 20px;
211
+ border-radius: 50%;
212
+ background: #0000FF; /* Blue thumb */
213
+ cursor: pointer;
214
+ border: 2px solid white;
215
+ }
216
+
217
+ /* Center Camera Area */
218
+ .camera-area {
219
+ flex-grow: 1;
220
+ position: relative;
221
+ background: #000;
222
+ overflow: hidden;
223
+ display: flex;
224
+ align-items: center;
225
+ justify-content: center;
226
+ }
227
+
228
+ video {
229
+ width: 100%;
230
+ height: 100%;
231
+ object-fit: cover;
232
+ }
233
+
234
+ .overlay {
235
+ position: absolute;
236
+ top: 0;
237
+ left: 0;
238
+ width: 100%;
239
+ height: 100%;
240
+ pointer-events: none;
241
+ display: flex;
242
+ flex-direction: column;
243
+ align-items: center;
244
+ justify-content: center;
245
+ }
246
+
247
+ .scan-region {
248
+ width: 250px;
249
+ height: 250px;
250
+ position: relative;
251
+ box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); /* Dimming outside */
252
+ }
253
+
254
+ .corner {
255
+ position: absolute;
256
+ width: 30px;
257
+ height: 30px;
258
+ border: 4px solid white;
259
+ }
260
+
261
+ .top-left { top: -2px; left: -2px; border-right: none; border-bottom: none; }
262
+ .top-right { top: -2px; right: -2px; border-left: none; border-bottom: none; }
263
+ .bottom-left { bottom: -2px; left: -2px; border-right: none; border-top: none; }
264
+ .bottom-right { bottom: -2px; right: -2px; border-left: none; border-top: none; }
265
+
266
+ .scan-line {
267
+ width: 100%;
268
+ height: 2px;
269
+ background: #00FFFF;
270
+ position: absolute;
271
+ top: 0;
272
+ animation: scan 2s infinite linear;
273
+ box-shadow: 0 0 4px #00FFFF;
274
+ }
275
+
276
+ @keyframes scan {
277
+ 0% { top: 0; opacity: 0; }
278
+ 10% { opacity: 1; }
279
+ 90% { opacity: 1; }
280
+ 100% { top: 100%; opacity: 0; }
281
+ }
282
+
283
+ .instruction-bubble {
284
+ margin-top: 20px;
285
+ background: white;
286
+ color: black;
287
+ padding: 10px 20px;
288
+ border-radius: 20px;
289
+ font-size: 0.8rem;
290
+ text-align: center;
291
+ max-width: 80%;
292
+ box-shadow: 0 2px 5px rgba(0,0,0,0.3);
293
+ }
294
+
295
+ /* Responsive Adjustments */
296
+ @media (max-width: 768px) {
297
+ .scanner-container {
298
+ flex-direction: column;
299
+ }
300
+ .sidebar {
301
+ width: 100%;
302
+ height: 80px;
303
+ flex-direction: row;
304
+ padding: 0 20px;
305
+ }
306
+ .left-sidebar {
307
+ order: 1; /* Move to top if needed, or keep order */
308
+ justify-content: space-between;
309
+ }
310
+ .right-sidebar {
311
+ order: 3;
312
+ justify-content: space-around;
313
+ }
314
+ .camera-area {
315
+ order: 2;
316
+ }
317
+ .vertical-text {
318
+ flex-direction: row;
319
+ gap: 5px;
320
+ }
321
+ .vertical-text .spacer {
322
+ width: 10px;
323
+ height: auto;
324
+ display: inline-block;
325
+ }
326
+ .zoom-slider {
327
+ transform: none; /* Horizontal on mobile */
328
+ width: 100px;
329
+ }
330
+ .slider-container {
331
+ height: auto;
332
+ }
333
+ }
334
+ `]
335
+ })
336
+ export class NgxCustomQrScannerComponent implements AfterViewInit, OnDestroy {
337
+ @ViewChild('video', { static: true }) videoRef!: ElementRef<HTMLVideoElement>;
338
+
339
+ qrScanner!: QrScanner;
340
+ flashOn = false;
341
+ zoom = 1;
342
+ maxZoom = 5;
343
+
344
+ async ngAfterViewInit() {
345
+ this.qrScanner = new QrScanner(
346
+ this.videoRef.nativeElement,
347
+ (result: { data: string }) => alert('✅ QR Scanned: ' + result.data),
348
+ {
349
+ preferredCamera: 'environment',
350
+ highlightScanRegion: true,
351
+ highlightCodeOutline: true,
352
+ }
353
+ );
354
+
355
+ this.qrScanner.setInversionMode('both');
356
+
357
+ try {
358
+ await this.qrScanner.start();
359
+ await this.initZoom();
360
+ } catch (err) {
361
+ console.error(err);
362
+ }
363
+ }
364
+
365
+ async toggleFlash() {
366
+ if (await this.qrScanner.hasFlash()) {
367
+ this.qrScanner.toggleFlash(); // no arguments
368
+ this.flashOn = !this.flashOn;
369
+ }
370
+ }
371
+
372
+ private getVideoTrack(): MediaStreamTrack | null {
373
+ // Access internal video element securely
374
+ // @ts-ignore
375
+ const video: HTMLVideoElement = this.qrScanner.$video;
376
+ if (video?.srcObject instanceof MediaStream) {
377
+ return video.srcObject.getVideoTracks()[0];
378
+ }
379
+ return null;
380
+ }
381
+
382
+ async initZoom() {
383
+ const track = this.getVideoTrack();
384
+ if (track) {
385
+ const caps = track.getCapabilities() as any;
386
+ if (caps.zoom) {
387
+ this.maxZoom = caps.zoom.max || 5;
388
+ this.zoom = caps.zoom.min || 1;
389
+ }
390
+ }
391
+ }
392
+
393
+ async onZoomChange(event: any) {
394
+ const value = parseFloat(event.target.value);
395
+ this.zoom = value;
396
+
397
+ const track = this.getVideoTrack();
398
+ if (track) {
399
+ const caps = track.getCapabilities() as any;
400
+ if (caps.zoom) {
401
+ // clamp value
402
+ const z = Math.max(caps.zoom.min, Math.min(value, caps.zoom.max));
403
+ await track.applyConstraints({ advanced: [{ zoom: z }] } as any);
404
+ }
405
+ }
406
+ }
407
+
408
+ ngOnDestroy() {
409
+ this.qrScanner?.stop();
410
+ this.qrScanner?.destroy();
411
+ }
412
+ }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { NgxCustomQrScannerService } from './ngx-custom-qr-scanner.service';
4
+
5
+ describe('NgxCustomQrScannerService', () => {
6
+ let service: NgxCustomQrScannerService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(NgxCustomQrScannerService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,9 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class NgxCustomQrScannerService {
7
+
8
+ constructor() { }
9
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Public API Surface of ngx-custom-qr-scanner
3
+ */
4
+
5
+ export * from './lib/ngx-custom-qr-scanner.service';
6
+ export * from './lib/ngx-custom-qr-scanner.component';
@@ -0,0 +1,15 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/lib",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "inlineSources": true,
10
+ "types": []
11
+ },
12
+ "exclude": [
13
+ "**/*.spec.ts"
14
+ ]
15
+ }
@@ -0,0 +1,11 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.lib.json",
5
+ "compilerOptions": {
6
+ "declarationMap": false
7
+ },
8
+ "angularCompilerOptions": {
9
+ "compilationMode": "partial"
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/spec",
7
+ "types": [
8
+ "jasmine"
9
+ ]
10
+ },
11
+ "include": [
12
+ "**/*.spec.ts",
13
+ "**/*.d.ts"
14
+ ]
15
+ }
Binary file
File without changes
@@ -0,0 +1 @@
1
+ <ngx-custom-qr-scanner></ngx-custom-qr-scanner>
@@ -0,0 +1,29 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+ import { AppComponent } from './app.component';
3
+
4
+ describe('AppComponent', () => {
5
+ beforeEach(async () => {
6
+ await TestBed.configureTestingModule({
7
+ imports: [AppComponent],
8
+ }).compileComponents();
9
+ });
10
+
11
+ it('should create the app', () => {
12
+ const fixture = TestBed.createComponent(AppComponent);
13
+ const app = fixture.componentInstance;
14
+ expect(app).toBeTruthy();
15
+ });
16
+
17
+ it(`should have the 'qr-scanner-app' title`, () => {
18
+ const fixture = TestBed.createComponent(AppComponent);
19
+ const app = fixture.componentInstance;
20
+ expect(app.title).toEqual('qr-scanner-app');
21
+ });
22
+
23
+ it('should render title', () => {
24
+ const fixture = TestBed.createComponent(AppComponent);
25
+ fixture.detectChanges();
26
+ const compiled = fixture.nativeElement as HTMLElement;
27
+ expect(compiled.querySelector('h1')?.textContent).toContain('Hello, qr-scanner-app');
28
+ });
29
+ });
@@ -0,0 +1,13 @@
1
+ import { Component } from '@angular/core';
2
+ import { RouterOutlet } from '@angular/router';
3
+ import { NgxCustomQrScannerComponent } from 'ngx-custom-qr-scanner';
4
+
5
+ @Component({
6
+ selector: 'app-root',
7
+ imports: [NgxCustomQrScannerComponent],
8
+ templateUrl: './app.component.html',
9
+ styleUrl: './app.component.css'
10
+ })
11
+ export class AppComponent {
12
+ title = 'qr-scanner-app';
13
+ }
@@ -0,0 +1,8 @@
1
+ import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2
+ import { provideRouter } from '@angular/router';
3
+
4
+ import { routes } from './app.routes';
5
+
6
+ export const appConfig: ApplicationConfig = {
7
+ providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
8
+ };
@@ -0,0 +1,3 @@
1
+ import { Routes } from '@angular/router';
2
+
3
+ export const routes: Routes = [];
@@ -0,0 +1,28 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+ import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from '@angular/platform-browser';
3
+
4
+ @Pipe({
5
+ name: 'safe',
6
+ standalone: true
7
+ })
8
+ export class SafePipe implements PipeTransform {
9
+
10
+ constructor(protected sanitizer: DomSanitizer) { }
11
+
12
+ public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
13
+ switch (type) {
14
+ case 'html':
15
+ return this.sanitizer.bypassSecurityTrustHtml(value);
16
+ case 'style':
17
+ return this.sanitizer.bypassSecurityTrustStyle(value);
18
+ case 'script':
19
+ return this.sanitizer.bypassSecurityTrustScript(value);
20
+ case 'url':
21
+ return this.sanitizer.bypassSecurityTrustUrl(value);
22
+ case 'resourceUrl':
23
+ return this.sanitizer.bypassSecurityTrustResourceUrl(value);
24
+ default:
25
+ throw new Error(`Invalid safe type specified: ${type}`);
26
+ }
27
+ }
28
+ }
package/src/index.html ADDED
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>QrScannerApp</title>
7
+ <base href="/">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
10
+ </head>
11
+
12
+ <body>
13
+ <app-root></app-root>
14
+ </body>
15
+
16
+ </html>
package/src/main.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { bootstrapApplication } from '@angular/platform-browser';
2
+ import { appConfig } from './app/app.config';
3
+ import { AppComponent } from './app/app.component';
4
+
5
+ bootstrapApplication(AppComponent, appConfig)
6
+ .catch((err) => console.error(err));
package/src/styles.css ADDED
@@ -0,0 +1 @@
1
+ /* You can add global styles to this file, and also import other style files */
@@ -0,0 +1,15 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "./out-tsc/app",
7
+ "types": []
8
+ },
9
+ "files": [
10
+ "src/main.ts"
11
+ ],
12
+ "include": [
13
+ "src/**/*.d.ts"
14
+ ]
15
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "compileOnSave": false,
5
+ "compilerOptions": {
6
+ "outDir": "./dist/out-tsc",
7
+ "strict": true,
8
+ "noImplicitOverride": true,
9
+ "noPropertyAccessFromIndexSignature": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "paths": {
13
+ "ngx-custom-qr-scanner": [
14
+ "./dist/ngx-custom-qr-scanner"
15
+ ]
16
+ },
17
+ "skipLibCheck": true,
18
+ "isolatedModules": true,
19
+ "esModuleInterop": true,
20
+ "experimentalDecorators": true,
21
+ "moduleResolution": "bundler",
22
+ "importHelpers": true,
23
+ "target": "ES2022",
24
+ "module": "ES2022"
25
+ },
26
+ "angularCompilerOptions": {
27
+ "enableI18nLegacyMessageIdFormat": false,
28
+ "strictInjectionParameters": true,
29
+ "strictInputAccessModifiers": true,
30
+ "strictTemplates": true
31
+ }
32
+ }
@@ -0,0 +1,15 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "./out-tsc/spec",
7
+ "types": [
8
+ "jasmine"
9
+ ]
10
+ },
11
+ "include": [
12
+ "src/**/*.spec.ts",
13
+ "src/**/*.d.ts"
14
+ ]
15
+ }