├── .editorconfig
├── .github
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
└── ISSUE_TEMPLATE.md
├── .gitignore
├── .huskyrc.json
├── .npmignore
├── .npmrc
├── CHANGELOG.md
├── LICENSE
├── README.md
├── angular.json
├── package.json
├── projects
├── ngx-qrcode-demo
│ ├── browserslist
│ ├── e2e
│ │ ├── protractor.conf.js
│ │ ├── src
│ │ │ ├── app.e2e-spec.ts
│ │ │ └── app.po.ts
│ │ └── tsconfig.json
│ ├── karma.conf.js
│ ├── src
│ │ ├── app
│ │ │ ├── app.component.html
│ │ │ ├── app.component.scss
│ │ │ ├── app.component.spec.ts
│ │ │ ├── app.component.ts
│ │ │ └── app.module.ts
│ │ ├── assets
│ │ │ └── .gitkeep
│ │ ├── environments
│ │ │ ├── environment.prod.ts
│ │ │ └── environment.ts
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── main.ts
│ │ ├── polyfills.ts
│ │ ├── styles.scss
│ │ └── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── tslint.json
└── ngx-qrcode
│ ├── README.md
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── package.json
│ ├── src
│ ├── lib
│ │ ├── qrcode.component.spec.ts
│ │ ├── qrcode.component.ts
│ │ ├── qrcode.constants.ts
│ │ ├── qrcode.module.ts
│ │ └── qrcode.types.ts
│ ├── public-api.ts
│ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.lib.prod.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── tsconfig.json
├── tslint.json
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
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 |
14 | [*.md]
15 | max_line_length = off
16 | trim_trailing_whitespace = false
17 |
--------------------------------------------------------------------------------
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team.
59 | All complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | When contributing to this repository, please first discuss the change you wish to make via issue,
4 | email, or any other method with the owners of this repository before making a change.
5 |
6 | Please note we have a code of conduct, please follow it in all your interactions with the project.
7 |
8 | ## Pull Request Process
9 |
10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11 | build.
12 | 2. Update the README.md with details of changes to the interface, this includes new environment
13 | variables, exposed ports, useful file locations and container parameters.
14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this
15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16 | 4. If a Pull Request contains acceptable changes that positively contribute to the project, it will be merged
17 | once reviewed by any of the project's authorized developer(s).
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
6 |
7 | ## I'm submitting a...
8 |
9 |
10 | [ ] Regression (a behavior that used to work and stopped working in a new release)
11 | [ ] Bug report
12 | [ ] Feature request
13 | [ ] Documentation issue or request
14 |
15 |
16 | ## Current behavior
17 |
18 |
19 |
20 | ## Expected behavior
21 |
22 |
23 |
24 | ## Minimal reproduction of the problem with instructions
25 |
29 |
30 | ## What is the motivation / use case for changing the behavior?
31 |
32 |
33 |
34 | ## Environment
35 |
36 |
37 | Angular version: X.Y.Z
38 |
39 |
40 | Your version of `@techiediaries/ngx-qrcode`:
41 |
42 |
43 | Browser:
44 | - [ ] Chrome (desktop) version XX
45 | - [ ] Chrome (Android) version XX
46 | - [ ] Chrome (iOS) version XX
47 | - [ ] Firefox version XX
48 | - [ ] Safari (desktop) version XX
49 | - [ ] Safari (iOS) version XX
50 | - [ ] IE version XX
51 | - [ ] Edge version XX
52 |
53 | For Tooling issues:
54 | - Node version: XX
55 | - Platform:
56 |
57 | Others:
58 |
59 |
60 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 | # Only exists if Bazel was run
8 | /bazel-out
9 |
10 | # dependencies
11 | /node_modules
12 |
13 | # profiling files
14 | chrome-profiler-events*.json
15 | speed-measure-plugin*.json
16 |
17 | # IDEs and editors
18 | /.idea
19 | .project
20 | .classpath
21 | .c9/
22 | *.launch
23 | .settings/
24 | *.sublime-workspace
25 |
26 | # IDE - VSCode
27 | .vscode/*
28 | !.vscode/settings.json
29 | !.vscode/tasks.json
30 | !.vscode/launch.json
31 | !.vscode/extensions.json
32 | .history/*
33 |
34 | # misc
35 | /.sass-cache
36 | /connect.lock
37 | /coverage
38 | /libpeerconnection.log
39 | npm-debug.log
40 | yarn-error.log
41 | testem.log
42 | /typings
43 |
44 | # System Files
45 | .DS_Store
46 | Thumbs.db
47 |
--------------------------------------------------------------------------------
/.huskyrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "hooks": {
3 | "pre-commit": "yarn lint",
4 | "commit-msg": "commitlint --env HUSKY_GIT_PARAMS --extends \"@commitlint/config-angular\""
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Node
2 | node_modules/*
3 | npm-debug.log
4 |
5 | # DO NOT IGNORE TYPESCRIPT FILES FOR NPM
6 | # TypeScript
7 | # *.js
8 | # *.map
9 | # *.d.ts
10 |
11 | # JetBrains
12 | .idea
13 | .project
14 | .settings
15 | .idea/*
16 | *.iml
17 |
18 | # VS Code
19 | .vscode/*
20 |
21 | # Windows
22 | Thumbs.db
23 | Desktop.ini
24 |
25 | # Mac
26 | .DS_Store
27 | **/.DS_Store
28 |
29 | # Ngc generated files
30 | **/*.ngfactory.ts
31 |
32 | # Library files
33 | src/*
34 | build/*
35 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | tag-version-prefix=""
2 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # [9.1.0](https://github.com/techiediaries/ngx-qrcode/compare/9.0.0...9.1.0) (2020-08-11)
2 |
3 |
4 | ### Code Refactoring
5 |
6 | * **packaging:** rename NPM to @techiediaries/ngx-qrcode ([932d26d](https://github.com/techiediaries/ngx-qrcode/commit/932d26da164d44fe056db11f927198aae54860b7)), closes [#47](https://github.com/techiediaries/ngx-qrcode/issues/47)
7 |
8 |
9 | ### Features
10 |
11 | * **changelog:** add changelog generation ([0e962ca](https://github.com/techiediaries/ngx-qrcode/commit/0e962ca3567cbd4560926a43c9fe6739abc71525))
12 |
13 |
14 | ### BREAKING CHANGES
15 |
16 | * **packaging:** rename this package, @techiediaries/ngx-qrcode must be used instead
17 |
18 |
19 |
20 |
21 | # 9.0.0 (2020-04-28)
22 |
23 |
24 | ### Bug Fixes
25 |
26 | * **core:** Remove the alt attribute when undefined.
27 |
28 | ### Features
29 |
30 | * **lib:** support for angular v9
31 | * **core:** Create unit tests with 100% of code coverage
32 | * **core:** Fix lint
33 |
34 | ### Refactor
35 |
36 | * **core:** Create types, constants and enums to type component inputs.
37 |
38 | ### BREAKING CHANGES
39 |
40 | * **lib:** Rename properties to follow angular style guide
41 |
42 | Before:
43 | ```
44 | [qrc-element-type]
45 | [qrc-class]
46 | [qrc-alt]
47 | [qrc-value]
48 | [qrc-version]
49 | [qrc-errorCorrectionLevel]
50 | [qrc-margin]
51 | [qrc-scale]
52 | [qrc-width]
53 | [qrc-colorDark]
54 | [qrc-colorLight]
55 | ```
56 |
57 | After:
58 | ```
59 | [elementType]
60 | [cssClass]
61 | [alt]
62 | [value]
63 | [version]
64 | [errorCorrectionLevel]
65 | [margin]
66 | [scale]
67 | [width]
68 | [colorDark]
69 | [colorLight]
70 | ```
71 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Techiediaries
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # @techiediaries/ngx-qrcode
2 |
3 | ```diff
4 | ! ⚠️ WARNING: The NPM package ngx-qrcode2 has been deprecated. Use @techiediaries/ngx-qrcode instead.
5 | ```
6 |
7 | `@techiediaries/ngx-qrcode` An Angular Component library for Generating QR (Quick Response ) Codes.
8 |
9 | You can use the `@techiediaries/ngx-qrcode` to easily generate QR codes inside your Angular 6 or Ionic 3 applications
10 |
11 | >QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached. A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to efficiently store data; extensions may also be used. [Source](https://en.wikipedia.org/wiki/QR_code)
12 |
13 |
14 | > Note: Make sure to check [10xdev.space](https://10xdev.space/) for career growth, money making tips and learning paths for developers.
15 |
16 |
17 | ## How to install @techiediaries/ngx-qrcode?
18 |
19 | To use ngx-qrcode in your project, install it via npm or yarn:
20 |
21 | ```bash
22 | $ npm install @techiediaries/ngx-qrcode --save
23 | or
24 | $ yarn add @techiediaries/ngx-qrcode
25 | ```
26 |
27 | ## How to use @techiediaries/ngx-qrcode?
28 |
29 | For a complete and detailed tutorial on how to use this library. See:
30 |
31 | [How to Generate QR Codes In Angular 4+ Applications ](https://www.techiediaries.com/generate-qrcodes-angular)
32 |
33 |
34 | Import `NgxQRCodeModule` from `@techiediaries/ngx-qrcode` into your `app.module.ts`:
35 |
36 | ```ts
37 | import { BrowserModule } from '@angular/platform-browser';
38 | import { NgModule } from '@angular/core';
39 | import { NgxQRCodeModule } from '@techiediaries/ngx-qrcode';
40 |
41 | import { AppComponent } from './app.component';
42 |
43 |
44 | @NgModule({
45 | declarations: [
46 | AppComponent
47 | ],
48 | imports: [
49 | BrowserModule,
50 | NgxQRCodeModule
51 | ],
52 | providers: [],
53 | bootstrap: [AppComponent]
54 | })
55 | export class AppModule { }
56 | ```
57 |
58 |
59 | Once the library has been imported, you can use the ngx-qrcode component in your Angular application.
60 |
61 | In `app.component.html`, add:
62 | ```html
63 |
64 |
65 |
66 | @techiediaries/ngx-qrcode demo
67 |
68 |
69 |
70 |
75 |
76 |
77 | ```
78 | In `app.component.ts`, add:
79 |
80 | ```ts
81 | import { Component } from '@angular/core';
82 |
83 | @Component({
84 | selector: 'app-root',
85 | templateUrl: './app.component.html',
86 | styleUrls: ['./app.component.css']
87 | })
88 | export class AppComponent {
89 | title = 'app';
90 | elementType = 'url';
91 | value = 'Techiediaries';
92 | }
93 | ```
94 |
95 | # Contributing
96 | Please see [Contributing Guidelines](.github/CONTRIBUTING.md).
97 |
98 | ## How to develop @techiediaries/ngx-qrcode?
99 |
100 | To generate all `*.js`, `*.d.ts` and `*.metadata.json` files:
101 |
102 | ```bash
103 | $ npm run build
104 | or
105 | $ yarn build
106 |
107 | ```
108 |
109 | To lint all `*.ts` files:
110 |
111 | ```bash
112 | $ npm run lint
113 | or
114 | $ yarn lint
115 | ```
116 |
117 | ## How to run unit tests?
118 |
119 | In development mode:
120 |
121 | ```bash
122 | $ npm run test:watch ngx-qrcode
123 | or
124 | $ yarn test:watch ngx-qrcode
125 | ```
126 | Add `--codeCoverage` option to see code coverage in `coverage` folder.
127 |
128 | ## How to publish libraries?
129 |
130 | ```bash
131 | $ npm run lib:publish
132 | or
133 | $ yarn lib:publish
134 | ```
135 |
136 | # Code of Conduct
137 | Please see [Code of Conduct](.github/CODE_OF_CONDUCT.md).
138 |
139 | ## License
140 | [MIT](/LICENSE) © [Techiediaries](mailto:techiediaries9@gmail.com)
141 |
142 | ## Troubleshoots
143 |
144 | With Angular CLI 8.X.X you should add this lines to polyfills.ts
145 |
146 | ```typescript
147 | // Needed by Buffer needed by QRCode
148 | // tslint:disable-next-line:no-string-literal
149 | (window as any)['global'] = window;
150 | ```
151 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "ngx-qrcode": {
7 | "projectType": "library",
8 | "root": "projects/ngx-qrcode",
9 | "sourceRoot": "projects/ngx-qrcode/src",
10 | "prefix": "lib",
11 | "architect": {
12 | "build": {
13 | "builder": "@angular-devkit/build-ng-packagr:build",
14 | "options": {
15 | "tsConfig": "projects/ngx-qrcode/tsconfig.lib.json",
16 | "project": "projects/ngx-qrcode/ng-package.json"
17 | },
18 | "configurations": {
19 | "production": {
20 | "tsConfig": "projects/ngx-qrcode/tsconfig.lib.prod.json"
21 | }
22 | }
23 | },
24 | "test": {
25 | "builder": "@angular-devkit/build-angular:karma",
26 | "options": {
27 | "main": "projects/ngx-qrcode/src/test.ts",
28 | "tsConfig": "projects/ngx-qrcode/tsconfig.spec.json",
29 | "karmaConfig": "projects/ngx-qrcode/karma.conf.js"
30 | }
31 | },
32 | "lint": {
33 | "builder": "@angular-devkit/build-angular:tslint",
34 | "options": {
35 | "tsConfig": [
36 | "projects/ngx-qrcode/tsconfig.lib.json",
37 | "projects/ngx-qrcode/tsconfig.spec.json"
38 | ],
39 | "exclude": [
40 | "**/node_modules/**"
41 | ]
42 | }
43 | }
44 | }
45 | },
46 | "ngx-qrcode-demo": {
47 | "projectType": "application",
48 | "schematics": {
49 | "@schematics/angular:component": {
50 | "style": "scss"
51 | }
52 | },
53 | "root": "projects/ngx-qrcode-demo",
54 | "sourceRoot": "projects/ngx-qrcode-demo/src",
55 | "prefix": "app",
56 | "architect": {
57 | "build": {
58 | "builder": "@angular-devkit/build-angular:browser",
59 | "options": {
60 | "outputPath": "dist/ngx-qrcode-demo",
61 | "index": "projects/ngx-qrcode-demo/src/index.html",
62 | "main": "projects/ngx-qrcode-demo/src/main.ts",
63 | "polyfills": "projects/ngx-qrcode-demo/src/polyfills.ts",
64 | "tsConfig": "projects/ngx-qrcode-demo/tsconfig.app.json",
65 | "aot": true,
66 | "assets": [
67 | "projects/ngx-qrcode-demo/src/favicon.ico",
68 | "projects/ngx-qrcode-demo/src/assets"
69 | ],
70 | "styles": [
71 | "projects/ngx-qrcode-demo/src/styles.scss"
72 | ],
73 | "scripts": []
74 | },
75 | "configurations": {
76 | "production": {
77 | "fileReplacements": [
78 | {
79 | "replace": "projects/ngx-qrcode-demo/src/environments/environment.ts",
80 | "with": "projects/ngx-qrcode-demo/src/environments/environment.prod.ts"
81 | }
82 | ],
83 | "optimization": true,
84 | "outputHashing": "all",
85 | "sourceMap": false,
86 | "extractCss": true,
87 | "namedChunks": false,
88 | "extractLicenses": true,
89 | "vendorChunk": false,
90 | "buildOptimizer": true,
91 | "budgets": [
92 | {
93 | "type": "initial",
94 | "maximumWarning": "2mb",
95 | "maximumError": "5mb"
96 | },
97 | {
98 | "type": "anyComponentStyle",
99 | "maximumWarning": "6kb",
100 | "maximumError": "10kb"
101 | }
102 | ]
103 | }
104 | }
105 | },
106 | "serve": {
107 | "builder": "@angular-devkit/build-angular:dev-server",
108 | "options": {
109 | "browserTarget": "ngx-qrcode-demo:build"
110 | },
111 | "configurations": {
112 | "production": {
113 | "browserTarget": "ngx-qrcode-demo:build:production"
114 | }
115 | }
116 | },
117 | "extract-i18n": {
118 | "builder": "@angular-devkit/build-angular:extract-i18n",
119 | "options": {
120 | "browserTarget": "ngx-qrcode-demo:build"
121 | }
122 | },
123 | "test": {
124 | "builder": "@angular-devkit/build-angular:karma",
125 | "options": {
126 | "main": "projects/ngx-qrcode-demo/src/test.ts",
127 | "polyfills": "projects/ngx-qrcode-demo/src/polyfills.ts",
128 | "tsConfig": "projects/ngx-qrcode-demo/tsconfig.spec.json",
129 | "karmaConfig": "projects/ngx-qrcode-demo/karma.conf.js",
130 | "assets": [
131 | "projects/ngx-qrcode-demo/src/favicon.ico",
132 | "projects/ngx-qrcode-demo/src/assets"
133 | ],
134 | "styles": [
135 | "projects/ngx-qrcode-demo/src/styles.scss"
136 | ],
137 | "scripts": []
138 | }
139 | },
140 | "lint": {
141 | "builder": "@angular-devkit/build-angular:tslint",
142 | "options": {
143 | "tsConfig": [
144 | "projects/ngx-qrcode-demo/tsconfig.app.json",
145 | "projects/ngx-qrcode-demo/tsconfig.spec.json",
146 | "projects/ngx-qrcode-demo/e2e/tsconfig.json"
147 | ],
148 | "exclude": [
149 | "**/node_modules/**"
150 | ]
151 | }
152 | },
153 | "e2e": {
154 | "builder": "@angular-devkit/build-angular:protractor",
155 | "options": {
156 | "protractorConfig": "projects/ngx-qrcode-demo/e2e/protractor.conf.js",
157 | "devServerTarget": "ngx-qrcode-demo:serve"
158 | },
159 | "configurations": {
160 | "production": {
161 | "devServerTarget": "ngx-qrcode-demo:serve:production"
162 | }
163 | }
164 | }
165 | }
166 | }},
167 | "cli": {
168 | "analytics": "3cbdf0e5-4793-407d-9c3d-8769136e76cf"
169 | },
170 | "defaultProject": "ngx-qrcode"
171 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@techiediaries/ngx-qrcode",
3 | "version": "9.1.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve ngx-qrcode-demo",
7 | "build": "ng build --prod",
8 | "build:demo": "ng build ngx-qrcode-demo --prod",
9 | "test": "ng test --watch=false",
10 | "test:watch": "ng test --watch=true",
11 | "lint": "ng lint",
12 | "e2e": "ng e2e",
13 | "copy:readme": "copyfiles README.md ./dist/ngx-qrcode",
14 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
15 | "github-releaser": "conventional-github-releaser -p angular",
16 | "lib:package": "yarn build && yarn copy:readme",
17 | "prelib:publish": "yarn lib:package",
18 | "lib:publish": "cd ./dist/ngx-qrcode && yarn publish --access=public",
19 | "tags": "yarn tag list @techiediaries/ngx-qrcode"
20 | },
21 | "repository": {
22 | "type": "git",
23 | "url": "git+https://github.com/techiediaries/ngx-qrcode.git"
24 | },
25 | "author": "Ahmed Bouchefra ",
26 | "license": "MIT",
27 | "bugs": {
28 | "url": "https://github.com/techiediaries/ngx-qrcode/issues"
29 | },
30 | "private": true,
31 | "dependencies": {
32 | "@angular/animations": "~9.1.12",
33 | "@angular/common": "~9.1.12",
34 | "@angular/compiler": "~9.1.12",
35 | "@angular/core": "~9.1.12",
36 | "@angular/forms": "~9.1.12",
37 | "@angular/platform-browser": "~9.1.12",
38 | "@angular/platform-browser-dynamic": "~9.1.12",
39 | "@angular/router": "~9.1.12",
40 | "qrcode": "^1.4.4",
41 | "rxjs": "~6.5.4",
42 | "tslib": "^1.13.0",
43 | "zone.js": "~0.10.3"
44 | },
45 | "devDependencies": {
46 | "@angular-devkit/build-angular": "~0.901.12",
47 | "@angular-devkit/build-ng-packagr": "~0.901.12",
48 | "@angular/cli": "~9.1.12",
49 | "@angular/compiler-cli": "~9.1.12",
50 | "@angular/language-service": "~9.1.12",
51 | "@commitlint/cli": "^9.1.1",
52 | "@commitlint/config-angular": "^9.1.1",
53 | "@types/jasmine": "~3.5.12",
54 | "@types/jasminewd2": "~2.0.8",
55 | "@types/node": "^14.0.27",
56 | "codelyzer": "^5.2.2",
57 | "conventional-changelog-cli": "^2.0.34",
58 | "conventional-github-releaser": "^3.1.5",
59 | "copyfiles": "^2.3.0",
60 | "husky": "^4.2.5",
61 | "jasmine-core": "~3.6.0",
62 | "jasmine-spec-reporter": "~5.0.2",
63 | "karma": "~5.1.1",
64 | "karma-chrome-launcher": "~3.1.0",
65 | "karma-coverage-istanbul-reporter": "~3.0.3",
66 | "karma-jasmine": "~3.3.1",
67 | "karma-jasmine-html-reporter": "^1.5.4",
68 | "ng-packagr": "^9.1.5",
69 | "protractor": "~7.0.0",
70 | "ts-node": "~8.10.2",
71 | "tslint": "~6.1.3",
72 | "typescript": "~3.8.3"
73 | },
74 | "engines": {
75 | "node": ">=12.14.1",
76 | "yarn": ">=1.22.4"
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/browserslist:
--------------------------------------------------------------------------------
1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 |
5 | # You can see what browsers were selected by your queries by running:
6 | # npx browserslist
7 |
8 | > 0.5%
9 | last 2 versions
10 | Firefox ESR
11 | not dead
12 | not IE 9-11 # For IE 9-11 support, remove 'not'.
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 | // Protractor configuration file, see link for more information
3 | // https://github.com/angular/protractor/blob/master/lib/config.ts
4 |
5 | const { SpecReporter } = require('jasmine-spec-reporter');
6 |
7 | /**
8 | * @type { import("protractor").Config }
9 | */
10 | exports.config = {
11 | allScriptsTimeout: 11000,
12 | specs: [
13 | './src/**/*.e2e-spec.ts'
14 | ],
15 | capabilities: {
16 | browserName: 'chrome'
17 | },
18 | directConnect: true,
19 | baseUrl: 'http://localhost:4200/',
20 | framework: 'jasmine',
21 | jasmineNodeOpts: {
22 | showColors: true,
23 | defaultTimeoutInterval: 30000,
24 | print: function() {}
25 | },
26 | onPrepare() {
27 | require('ts-node').register({
28 | project: require('path').join(__dirname, './tsconfig.json')
29 | });
30 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
31 | }
32 | };
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 | import { browser, logging } from 'protractor';
3 |
4 | describe('workspace-project App', () => {
5 | let page: AppPage;
6 |
7 | beforeEach(() => {
8 | page = new AppPage();
9 | });
10 |
11 | it('should display welcome message', () => {
12 | page.navigateTo();
13 | expect(page.getTitleText()).toEqual('ngx-qrcode-demo app is running!');
14 | });
15 |
16 | afterEach(async () => {
17 | // Assert that there are no errors emitted from the browser
18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19 | expect(logs).not.toContain(jasmine.objectContaining({
20 | level: logging.Level.SEVERE,
21 | } as logging.Entry));
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo(): Promise {
5 | return browser.get(browser.baseUrl) as Promise;
6 | }
7 |
8 | getTitleText(): Promise {
9 | return element(by.css('app-root .content span')).getText() as Promise;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/e2e/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../../coverage/ngx-qrcode-demo'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false,
30 | restartOnFileChange: true
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 | {{ title }} app is running!
3 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/app/app.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techiediaries/ngx-qrcode/b07dd62da445a3a3a38d2fd21d5d7890aad7553e/projects/ngx-qrcode-demo/src/app/app.component.scss
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, TestBed } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
4 |
5 | import { AppComponent } from './app.component';
6 |
7 | describe('AppComponent', () => {
8 | beforeEach(async(() => {
9 | TestBed.configureTestingModule({
10 | imports: [
11 | RouterTestingModule
12 | ],
13 | declarations: [
14 | AppComponent
15 | ],
16 | schemas: [
17 | CUSTOM_ELEMENTS_SCHEMA
18 | ]
19 | }).compileComponents();
20 | }));
21 |
22 | it('should create the app', () => {
23 | const fixture = TestBed.createComponent(AppComponent);
24 | const app = fixture.componentInstance;
25 | expect(app).toBeTruthy();
26 | });
27 |
28 | it(`should have as title 'ngx-qrcode-demo'`, () => {
29 | const fixture = TestBed.createComponent(AppComponent);
30 | const app = fixture.componentInstance;
31 | expect(app.title).toEqual('ngx-qrcode-demo');
32 | });
33 |
34 | it('should render title', () => {
35 | const fixture = TestBed.createComponent(AppComponent);
36 | fixture.detectChanges();
37 | const compiled = fixture.nativeElement;
38 | expect(compiled.querySelector('.content span').textContent).toContain('ngx-qrcode-demo app is running!');
39 | });
40 | });
41 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { NgxQrcodeElementTypes, NgxQrcodeErrorCorrectionLevels } from '@techiediaries/ngx-qrcode';
3 |
4 | @Component({
5 | selector: 'app-root',
6 | templateUrl: './app.component.html',
7 | styleUrls: ['./app.component.scss']
8 | })
9 | export class AppComponent {
10 | title = 'ngx-qrcode-demo';
11 | elementType = NgxQrcodeElementTypes.URL;
12 | correctionLevel = NgxQrcodeErrorCorrectionLevels.LOW;
13 | value = 'Techiediaries';
14 | }
15 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { NgxQRCodeModule } from '@techiediaries/ngx-qrcode';
5 |
6 | import { AppComponent } from './app.component';
7 |
8 | @NgModule({
9 | declarations: [
10 | AppComponent
11 | ],
12 | imports: [
13 | BrowserModule,
14 | NgxQRCodeModule
15 | ],
16 | providers: [],
17 | bootstrap: [AppComponent]
18 | })
19 | export class AppModule {
20 | }
21 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techiediaries/ngx-qrcode/b07dd62da445a3a3a38d2fd21d5d7890aad7553e/projects/ngx-qrcode-demo/src/assets/.gitkeep
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techiediaries/ngx-qrcode/b07dd62da445a3a3a38d2fd21d5d7890aad7553e/projects/ngx-qrcode-demo/src/favicon.ico
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NgxQrcodeDemo
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 |
61 | /***************************************************************************************************
62 | * APPLICATION IMPORTS
63 | */
64 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: {
11 | context(path: string, deep?: boolean, filter?: RegExp): {
12 | keys(): string[];
13 | (id: string): T;
14 | };
15 | };
16 |
17 | // First, initialize the Angular testing environment.
18 | getTestBed().initTestEnvironment(
19 | BrowserDynamicTestingModule,
20 | platformBrowserDynamicTesting()
21 | );
22 | // Then we find all the tests.
23 | const context = require.context('./', true, /\.spec\.ts$/);
24 | // And load the modules.
25 | context.keys().map(context);
26 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/app",
5 | "types": [],
6 | "paths": {
7 | "@techiediaries/ngx-qrcode": [
8 | "projects/ngx-qrcode/src/public-api.ts"
9 | ]
10 | }
11 | },
12 | "files": [
13 | "src/main.ts",
14 | "src/polyfills.ts"
15 | ],
16 | "include": [
17 | "src/**/*.d.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ],
9 | "paths": {
10 | "@techiediaries/ngx-qrcode": [
11 | "projects/ngx-qrcode/src/public-api.ts"
12 | ]
13 | }
14 | },
15 | "files": [
16 | "src/test.ts",
17 | "src/polyfills.ts"
18 | ],
19 | "include": [
20 | "src/**/*.spec.ts",
21 | "src/**/*.d.ts"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode-demo/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/README.md:
--------------------------------------------------------------------------------
1 | # NgxQrcode
2 |
3 | This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.2.
4 |
5 | ## Code scaffolding
6 |
7 | Run `ng generate component component-name --project ngx-qrcode` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-qrcode`.
8 | > Note: Don't forget to add `--project ngx-qrcode` or else it will be added to the default project in your `angular.json` file.
9 |
10 | ## Build
11 |
12 | Run `ng build ngx-qrcode` to build the project. The build artifacts will be stored in the `dist/` directory.
13 |
14 | ## Publishing
15 |
16 | After building your library with `ng build ngx-qrcode`, go to the dist folder `cd dist/ngx-qrcode` and run `npm publish`.
17 |
18 | ## Running unit tests
19 |
20 | Run `ng test ngx-qrcode` to execute the unit tests via [Karma](https://karma-runner.github.io).
21 |
22 | ## Further help
23 |
24 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
25 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../../coverage/ngx-qrcode'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false,
30 | restartOnFileChange: true
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/ng-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/ngx-qrcode",
4 | "lib": {
5 | "entryFile": "src/public-api.ts",
6 | "umdModuleIds": {
7 | "qrcode": "QRCode"
8 | }
9 | },
10 | "whitelistedNonPeerDependencies": [
11 | "qrcode"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@techiediaries/ngx-qrcode",
3 | "version": "9.0.1",
4 | "description": "An Angular component for generating QRCodes",
5 | "homepage": "https://github.com/techiediaries/ngx-qrcode",
6 | "private": false,
7 | "repository": {
8 | "type": "git",
9 | "url": "https://github.com/techiediaries/ngx-qrcode"
10 | },
11 | "author": {
12 | "name": "Ahmed Bouchefra",
13 | "email": "techiediaries9@gmail.com"
14 | },
15 | "keywords": [
16 | "ng",
17 | "ngx",
18 | "ngx-qrcode",
19 | "qrcode",
20 | "angular",
21 | "angular2",
22 | "angular 2",
23 | "angular4",
24 | "angular 4",
25 | "angular5",
26 | "angular 5",
27 | "angular6",
28 | "angular 6",
29 | "angular7",
30 | "angular 7",
31 | "angular8",
32 | "angular 8",
33 | "angular9",
34 | "angular 9"
35 | ],
36 | "license": "MIT",
37 | "bugs": {
38 | "url": "https://github.com/techiediaries/ngx-qrcode/issues"
39 | },
40 | "dependencies": {
41 | "qrcode": "^1.4.4",
42 | "tslib": "^1.10.0"
43 | },
44 | "peerDependencies": {
45 | "@angular/common": ">=6.0.0 || <=10.0.0",
46 | "@angular/core": ">=6.0.0 || <=10.0.0"
47 | },
48 | "engines": {
49 | "node": ">=10.0.0"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/src/lib/qrcode.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 | import { Component, ViewChild } from '@angular/core';
3 |
4 | import QRCode from 'qrcode';
5 |
6 | import { QrcodeComponent } from './qrcode.component';
7 | import { DEFAULT_VALUES } from './qrcode.constants';
8 | import { NgxQrcodeElementTypes } from './qrcode.types';
9 |
10 | describe('QrcodeComponent', () => {
11 | let component: TestHostComponent;
12 | let qrcodeComponent: QrcodeComponent;
13 | let fixture: ComponentFixture;
14 | let toDataURLSpy: jasmine.Spy;
15 | let toCanvasSpy: jasmine.Spy;
16 | const IMAGE_SRC = 'imgSrc';
17 |
18 | beforeEach(async(() => {
19 | TestBed.configureTestingModule({
20 | declarations: [QrcodeComponent, TestHostComponent]
21 | })
22 | .compileComponents();
23 |
24 | toDataURLSpy = spyOn(QRCode, 'toDataURL').and.returnValue(Promise.resolve(IMAGE_SRC));
25 | toCanvasSpy = spyOn(QRCode, 'toCanvas').and.returnValue(Promise.resolve(null));
26 | }));
27 |
28 | beforeEach(() => {
29 | fixture = TestBed.createComponent(TestHostComponent);
30 | component = fixture.componentInstance;
31 | fixture.detectChanges();
32 | qrcodeComponent = component.qrcodeComponent;
33 | });
34 |
35 | it('should create', () => {
36 | expect(qrcodeComponent).toBeTruthy();
37 | });
38 |
39 | describe('when has no value', () => {
40 | beforeEach(() => {
41 | component.value = null;
42 | fixture.detectChanges();
43 | });
44 |
45 | it('should not render nothing', () => {
46 | expect(qrcodeComponent.qrcElement.nativeElement.childNodes.length).toBe(0);
47 | });
48 | });
49 |
50 | describe('when elementType is url', () => {
51 | beforeEach(() => {
52 | component.elementType = NgxQrcodeElementTypes.URL;
53 | });
54 |
55 | it('should render img element', done => {
56 | fixture.detectChanges();
57 | fixture.whenStable().then(() => {
58 | expect(qrcodeComponent.qrcElement.nativeElement.childNodes[0].tagName.toLowerCase()).toBe('img');
59 | done();
60 | });
61 | });
62 |
63 | it('should not render img alt attribute by default', done => {
64 | const defaultAlt = '';
65 | fixture.detectChanges();
66 | fixture.whenStable().then(() => {
67 | const imageElement = qrcodeComponent.qrcElement.nativeElement.childNodes[0];
68 | expect(imageElement.alt).toBe(defaultAlt);
69 | done();
70 | });
71 | });
72 |
73 | it('should render img alt attribute when defined', done => {
74 | const alt = 'hello alt';
75 | component.alt = alt;
76 | fixture.detectChanges();
77 | fixture.whenStable().then(() => {
78 | const imageElement = qrcodeComponent.qrcElement.nativeElement.childNodes[0];
79 | expect(imageElement.alt).toBe(alt);
80 | done();
81 | });
82 | });
83 |
84 | it('should catch QRCode error and have no children', done => {
85 | fixture.whenStable().then(() => {
86 | toDataURLSpy.and.returnValue(Promise.reject('error in toDataURL'));
87 | component.cssClass = 'fire change detection';
88 | fixture.detectChanges();
89 | const renderSpy = spyOn(qrcodeComponent, 'renderElement');
90 | const removeSpy = spyOn(qrcodeComponent, 'removeElementChildren');
91 | fixture.whenStable().then(() => {
92 | expect(renderSpy).not.toHaveBeenCalled();
93 | expect(removeSpy).toHaveBeenCalled();
94 | done();
95 | });
96 | });
97 | });
98 | });
99 |
100 | describe('when elementType is canvas', () => {
101 | beforeEach(() => {
102 | component.elementType = NgxQrcodeElementTypes.CANVAS;
103 | });
104 |
105 | it('should render a canvas element', done => {
106 | fixture.detectChanges();
107 | fixture.whenStable().then(() => {
108 | expect(qrcodeComponent.qrcElement.nativeElement.childNodes[0].tagName.toLowerCase()).toBe('canvas');
109 | done();
110 | });
111 | });
112 |
113 | it('should catch QRCode error and have no children', done => {
114 | fixture.whenStable().then(() => {
115 | toCanvasSpy.and.returnValue(Promise.reject('error in toCanvas'));
116 | fixture.detectChanges();
117 | const renderSpy = spyOn(qrcodeComponent, 'renderElement');
118 | const removeSpy = spyOn(qrcodeComponent, 'removeElementChildren');
119 | fixture.whenStable().then(() => {
120 | expect(renderSpy).not.toHaveBeenCalled();
121 | expect(removeSpy).toHaveBeenCalled();
122 | done();
123 | });
124 | });
125 | });
126 | });
127 | });
128 |
129 | @Component({
130 | template: `
131 | `
132 | })
133 | class TestHostComponent {
134 | @ViewChild('qrcodeComponent') qrcodeComponent: QrcodeComponent;
135 | elementType = DEFAULT_VALUES.elementType;
136 | cssClass = DEFAULT_VALUES.cssClass;
137 | alt;
138 | value = DEFAULT_VALUES.value;
139 | }
140 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/src/lib/qrcode.component.ts:
--------------------------------------------------------------------------------
1 | import { ChangeDetectionStrategy, Component, ElementRef, Input, OnChanges, Renderer2, ViewChild } from '@angular/core';
2 |
3 | import QRCode from 'qrcode';
4 |
5 | import { NgxQrcodeElementTypes } from './qrcode.types';
6 | import { DEFAULT_VALUES } from './qrcode.constants';
7 |
8 | @Component({
9 | selector: 'ngx-qrcode',
10 | template: `
`,
11 | changeDetection: ChangeDetectionStrategy.OnPush
12 | })
13 | export class QrcodeComponent implements OnChanges {
14 |
15 | @Input() elementType = DEFAULT_VALUES.elementType;
16 | @Input() cssClass = DEFAULT_VALUES.cssClass;
17 | @Input() alt: string;
18 | @Input() value = DEFAULT_VALUES.value;
19 | @Input() version = DEFAULT_VALUES.version;
20 | @Input() errorCorrectionLevel = DEFAULT_VALUES.errorCorrectionLevel;
21 | @Input() margin = DEFAULT_VALUES.margin;
22 | @Input() scale = DEFAULT_VALUES.scale;
23 | @Input() width = DEFAULT_VALUES.width;
24 | @Input() colorDark = DEFAULT_VALUES.colorDark;
25 | @Input() colorLight = DEFAULT_VALUES.colorLight;
26 |
27 | @ViewChild('qrcElement') qrcElement: ElementRef;
28 |
29 | constructor(private renderer: Renderer2) {
30 | }
31 |
32 | ngOnChanges() {
33 | this.createQRCode();
34 | }
35 |
36 | createQRCode() {
37 | if (!this.value) {
38 | return;
39 | }
40 |
41 | let element: Element;
42 |
43 | switch (this.elementType) {
44 |
45 | case NgxQrcodeElementTypes.CANVAS:
46 | element = this.renderer.createElement('canvas');
47 | this.toCanvas(element).then(() => {
48 | this.renderElement(element);
49 | }).catch(e => {
50 | this.removeElementChildren();
51 | console.error(e);
52 | });
53 | break;
54 | default:
55 | element = this.renderer.createElement('img');
56 | this.toDataURL().then((src: string) => {
57 | element.setAttribute('src', src);
58 | if (this.alt) {
59 | element.setAttribute('alt', this.alt);
60 | }
61 | this.renderElement(element);
62 | }).catch(e => {
63 | this.removeElementChildren();
64 | console.error(e);
65 | });
66 | }
67 | }
68 |
69 | private toDataURL(): Promise {
70 | return QRCode.toDataURL(this.value,
71 | {
72 | version: this.version,
73 | errorCorrectionLevel: this.errorCorrectionLevel,
74 | margin: this.margin,
75 | scale: this.scale,
76 | width: this.width,
77 | color: {
78 | dark: this.colorDark,
79 | light: this.colorLight
80 | }
81 | });
82 | }
83 |
84 | private toCanvas(canvas): Promise {
85 | return QRCode.toCanvas(canvas, this.value, {
86 | version: this.version,
87 | errorCorrectionLevel: this.errorCorrectionLevel,
88 | margin: this.margin,
89 | scale: this.scale,
90 | width: this.width,
91 | color: {
92 | dark: this.colorDark,
93 | light: this.colorLight
94 | }
95 | });
96 | }
97 |
98 | private renderElement(element): void {
99 | this.removeElementChildren();
100 | this.renderer.appendChild(this.qrcElement.nativeElement, element);
101 | }
102 |
103 | private removeElementChildren(): void {
104 | for (const node of this.qrcElement.nativeElement.childNodes) {
105 | this.renderer.removeChild(this.qrcElement.nativeElement, node);
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/src/lib/qrcode.constants.ts:
--------------------------------------------------------------------------------
1 | import { NgxQrcodeElementTypes, NgxQrcodeErrorCorrectionLevels, NgxQrcodeVersionType } from './qrcode.types';
2 |
3 | export const DEFAULT_VALUES = {
4 | elementType: NgxQrcodeElementTypes.URL,
5 | cssClass: 'qrcode',
6 | value: 'https://www.techiediaries.com',
7 | version: '' as NgxQrcodeVersionType,
8 | errorCorrectionLevel: NgxQrcodeErrorCorrectionLevels.MEDIUM,
9 | margin: 4,
10 | scale: 4,
11 | width: 10,
12 | colorDark: '#000',
13 | colorLight: '#FFF'
14 | };
15 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/src/lib/qrcode.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { QrcodeComponent } from './qrcode.component';
4 |
5 | @NgModule({
6 | declarations: [QrcodeComponent],
7 | exports: [QrcodeComponent]
8 | })
9 | export class NgxQRCodeModule {
10 | }
11 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/src/lib/qrcode.types.ts:
--------------------------------------------------------------------------------
1 | export enum NgxQrcodeElementTypes {
2 | URL = 'url',
3 | IMG = 'img',
4 | CANVAS = 'canvas'
5 | }
6 |
7 | export enum NgxQrcodeErrorCorrectionLevels {
8 | LOW = 'L',
9 | MEDIUM = 'M',
10 | QUARTILE = 'Q',
11 | HIGH = 'H'
12 | }
13 |
14 | export type NgxQrcodeVersionType =
15 | '1'
16 | | '2'
17 | | '3'
18 | | '4'
19 | | '5'
20 | | '6'
21 | | '7'
22 | | '8'
23 | | '9'
24 | | '10'
25 | | '11'
26 | | '12'
27 | | '13'
28 | | '14'
29 | | '15'
30 | | '16'
31 | | '17'
32 | | '18'
33 | | '19'
34 | | '20'
35 | | '21'
36 | | '22'
37 | | '23'
38 | | '24'
39 | | '25'
40 | | '26'
41 | | '27'
42 | | '28'
43 | | '29'
44 | | '30'
45 | | '31'
46 | | '32'
47 | | '33'
48 | | '34'
49 | | '35'
50 | | '36'
51 | | '37'
52 | | '38'
53 | | '39'
54 | | '40'
55 | | '';
56 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/src/public-api.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Public API Surface of ngx-qrcode
3 | */
4 |
5 | export * from './lib/qrcode.types';
6 | export * from './lib/qrcode.component';
7 | export * from './lib/qrcode.module';
8 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone';
4 | import 'zone.js/dist/zone-testing';
5 | import { getTestBed } from '@angular/core/testing';
6 | import {
7 | BrowserDynamicTestingModule,
8 | platformBrowserDynamicTesting
9 | } from '@angular/platform-browser-dynamic/testing';
10 |
11 | declare const require: {
12 | context(path: string, deep?: boolean, filter?: RegExp): {
13 | keys(): string[];
14 | (id: string): T;
15 | };
16 | };
17 |
18 | // First, initialize the Angular testing environment.
19 | getTestBed().initTestEnvironment(
20 | BrowserDynamicTestingModule,
21 | platformBrowserDynamicTesting()
22 | );
23 | // Then we find all the tests.
24 | const context = require.context('./', true, /\.spec\.ts$/);
25 | // And load the modules.
26 | context.keys().map(context);
27 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/lib",
5 | "target": "es2015",
6 | "declaration": true,
7 | "inlineSources": true,
8 | "types": [],
9 | "lib": [
10 | "dom",
11 | "es2018"
12 | ]
13 | },
14 | "angularCompilerOptions": {
15 | "skipTemplateCodegen": true,
16 | "strictMetadataEmit": true,
17 | "enableResourceInlining": true
18 | },
19 | "exclude": [
20 | "src/test.ts",
21 | "**/*.spec.ts"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/tsconfig.lib.prod.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.lib.json",
3 | "angularCompilerOptions": {
4 | "enableIvy": false
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts"
12 | ],
13 | "include": [
14 | "**/*.spec.ts",
15 | "**/*.d.ts"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/projects/ngx-qrcode/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "ngx",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "ngx",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "downlevelIteration": true,
9 | "experimentalDecorators": true,
10 | "module": "esnext",
11 | "moduleResolution": "node",
12 | "importHelpers": true,
13 | "target": "es2015",
14 | "lib": [
15 | "es2018",
16 | "dom"
17 | ],
18 | "paths": {
19 | "@techiediaries/ngx-qrcode": [
20 | "dist/ngx-qrcode"
21 | ]
22 | }
23 | },
24 | "angularCompilerOptions": {
25 | "fullTemplateTypeCheck": true,
26 | "strictInjectionParameters": true
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:recommended",
3 | "rulesDirectory": [
4 | "codelyzer"
5 | ],
6 | "rules": {
7 | "align": {
8 | "options": [
9 | "parameters",
10 | "statements"
11 | ]
12 | },
13 | "array-type": false,
14 | "arrow-return-shorthand": true,
15 | "curly": true,
16 | "deprecation": {
17 | "severity": "warning"
18 | },
19 | "eofline": true,
20 | "import-blacklist": [
21 | true,
22 | "rxjs/Rx"
23 | ],
24 | "import-spacing": true,
25 | "indent": {
26 | "options": [
27 | "spaces"
28 | ]
29 | },
30 | "max-classes-per-file": false,
31 | "max-line-length": [
32 | true,
33 | 140
34 | ],
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-console": [
47 | true,
48 | "debug",
49 | "info",
50 | "time",
51 | "timeEnd",
52 | "trace"
53 | ],
54 | "no-empty": false,
55 | "no-inferrable-types": [
56 | true,
57 | "ignore-params"
58 | ],
59 | "no-non-null-assertion": true,
60 | "no-redundant-jsdoc": true,
61 | "no-switch-case-fall-through": true,
62 | "no-var-requires": false,
63 | "object-literal-key-quotes": [
64 | true,
65 | "as-needed"
66 | ],
67 | "quotemark": [
68 | true,
69 | "single"
70 | ],
71 | "semicolon": {
72 | "options": [
73 | "always"
74 | ]
75 | },
76 | "space-before-function-paren": {
77 | "options": {
78 | "anonymous": "never",
79 | "asyncArrow": "always",
80 | "constructor": "never",
81 | "method": "never",
82 | "named": "never"
83 | }
84 | },
85 | "typedef-whitespace": {
86 | "options": [
87 | {
88 | "call-signature": "nospace",
89 | "index-signature": "nospace",
90 | "parameter": "nospace",
91 | "property-declaration": "nospace",
92 | "variable-declaration": "nospace"
93 | },
94 | {
95 | "call-signature": "onespace",
96 | "index-signature": "onespace",
97 | "parameter": "onespace",
98 | "property-declaration": "onespace",
99 | "variable-declaration": "onespace"
100 | }
101 | ]
102 | },
103 | "variable-name": {
104 | "options": [
105 | "ban-keywords",
106 | "check-format",
107 | "allow-pascal-case"
108 | ]
109 | },
110 | "whitespace": {
111 | "options": [
112 | "check-branch",
113 | "check-decl",
114 | "check-operator",
115 | "check-separator",
116 | "check-type",
117 | "check-typecast"
118 | ]
119 | },
120 | "component-class-suffix": true,
121 | "contextual-lifecycle": true,
122 | "directive-class-suffix": true,
123 | "no-conflicting-lifecycle": true,
124 | "no-host-metadata-property": true,
125 | "no-input-rename": true,
126 | "no-inputs-metadata-property": true,
127 | "no-output-native": true,
128 | "no-output-on-prefix": true,
129 | "no-output-rename": true,
130 | "no-outputs-metadata-property": true,
131 | "template-banana-in-box": true,
132 | "template-no-negated-async": true,
133 | "use-lifecycle-interface": true,
134 | "use-pipe-transform-interface": true
135 | }
136 | }
137 |
--------------------------------------------------------------------------------