├── .all-contributorsrc
├── .babelrc
├── .circleci
└── config.yml
├── .codacy.yml
├── .github
├── FUNDING.yml
└── ISSUE_TEMPLATE
│ ├── FUNDING.yml
│ ├── bug_report.md
│ ├── compatibility-issue.md
│ ├── feature_request.md
│ └── question.md
├── .gitignore
├── .npmignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── changelog.md
├── compatibility.md
├── examples
├── electron
│ └── README.md
├── html5
│ ├── README.md
│ └── index.html
├── lit
│ ├── README.md
│ ├── index.html
│ ├── qrcode-scanner.js
│ └── qrcode-scanner.ts
└── vuejs
│ ├── README.md
│ ├── index.html
│ └── style.css
├── experimental.md
├── minified
├── html5-qrcode.min.js
└── readme.md
├── package-lock.json
├── package.json
├── scripts
├── build-webpack.bat
├── build-webpack.sh
├── test-run.bat
├── test-run.sh
├── webpack_append_data.js
└── webpack_append_data.min.js
├── src
├── camera
│ ├── core-impl.ts
│ ├── core.ts
│ ├── factories.ts
│ ├── permissions.ts
│ └── retriever.ts
├── code-decoder.ts
├── core.ts
├── experimental-features.ts
├── html5-qrcode-scanner.ts
├── html5-qrcode.ts
├── image-assets.ts
├── index.ts
├── native-bar-code-detector.ts
├── state-manager.ts
├── storage.ts
├── strings.ts
├── ui.ts
├── ui
│ └── scanner
│ │ ├── base.ts
│ │ ├── camera-selection-ui.ts
│ │ ├── camera-zoom-ui.ts
│ │ ├── file-selection-ui.ts
│ │ ├── scan-type-selector.ts
│ │ └── torch-button.ts
├── utils.ts
└── zxing-html5-qrcode-decoder.ts
├── tests
├── README.md
├── core.test.ts
└── ui
│ └── scanner
│ ├── base.test.ts
│ ├── camera-selection-ui.test.ts
│ ├── camera-zoom-ui.test.ts
│ ├── file-selection-ui.test.ts
│ ├── scan-type-selector.test.ts
│ └── torch-button.test.ts
├── third_party
├── zxing-js.umd.d.ts
└── zxing-js.umd.js
├── tsconfig.json
├── tsconfig.lib-cjs.json
├── tsconfig.lib-es2015.json
├── tsconfig.lib-esm.json
├── tsconfig.lib-esnext.json
├── tsconfig.test.json
└── webpack.config.js
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "files": ["README.md"],
3 | "imageSize": 100,
4 | "contributorsPerLine": 7,
5 | "contributorsSortAlphabetically": false,
6 | "badgeTemplate": "[](#contributors)",
7 | "contributorTemplate": "\">\" width=\"<%= options.imageSize %>px;\" alt=\"\"/> <%= contributor.name %>",
8 | "types": {
9 | "custom": {
10 | "symbol": "🔭",
11 | "description": "A custom contribution type.",
12 | "link": "[<%= symbol %>](<%= url %> \"<%= description %>\"),"
13 | }
14 | },
15 | "skipCi": "true",
16 | "contributors": []
17 | }
18 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": ["@babel/plugin-proposal-class-properties"],
3 | "presets": ["@babel/preset-env"]
4 | }
5 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # This config is equivalent to both the '.circleci/extended/orb-free.yml' and the base '.circleci/config.yml'
2 | version: 2.1
3 |
4 | # Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
5 | # See: https://circleci.com/docs/2.0/orb-intro/
6 | orbs:
7 | node: circleci/node@4.7
8 |
9 | # Invoke jobs via workflows
10 | # See: https://circleci.com/docs/2.0/configuration-reference/#workflows
11 | workflows:
12 | sample: # This is the name of the workflow, feel free to change it to better match your workflow.
13 | # Inside the workflow, you define the jobs you want to run.
14 | jobs:
15 | - node/test:
16 | # This is the node version to use for the `cimg/node` tag
17 | # Relevant tags can be found on the CircleCI Developer Hub
18 | # https://circleci.com/developer/images/image/cimg/node
19 | version: '16.10'
20 | # If you are using yarn, change the line below from "npm" to "yarn"
21 | pkg-manager: npm
22 |
--------------------------------------------------------------------------------
/.codacy.yml:
--------------------------------------------------------------------------------
1 | ---
2 | exclude_paths:
3 | - ".github/**"
4 | - "assets/**"
5 | - "dist/**"
6 | - "node_modules/**"
7 | - "third_party/**"
8 | - "changelog.md"
9 | - "CODE_OF_CONDUCT.md"
10 | - "scripts/**"
11 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: mebjas
2 | ko_fi: minhazav
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: mebjas
2 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/compatibility-issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Compatibility Issue
3 | about: Report compatibility issue for a certain browser
4 | title: Compatibility - [OS] [Browser] - [What is not working]
5 | labels: compatibility
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 | - What is not working and what is expected.
13 |
14 | **Describe the browser:**
15 | - OS: [e.g. iOS, Android, MacOs or Windows]
16 | - Browser [e.g. chrome, safari, edge, firefox]
17 | - Version [e.g. 22]
18 |
19 | **Screenshots**
20 | If applicable, add screenshots to help explain your problem.
21 |
22 | **Additional context**
23 | Add any other context about the problem here.
24 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[Feature Request] One liner for the request"
5 | labels: enhancement, ferature-request
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: Ask a question about html5-qrcode library to the authors
4 | title: '[Question]'
5 | labels: 'stackoverflow-question'
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the Question**
11 | A clear and concise description of what the question is.
12 |
13 | **Link to stackoverflow**
14 | Please raise this question in [stackoverflow.com](https://stackoverflow.com/questions/ask) for faster answer and add the link here.
15 |
16 | **Context about your web application**
17 | Where are you using this and how. It'd be helpful if you provide your usage code example
18 |
19 | ```js
20 | // Code example here.
21 | ```
22 |
23 | **Optional, Environment (please complete the following information):**
24 | - Device: [e.g. iPhone6]
25 | - OS: [e.g. iOS]
26 | - Browser [e.g. chrome, safari]
27 | - Version [e.g. 22]
28 |
29 | **Additional context**
30 | Add any other context about the problem here.
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | package-lock.json
4 | .vscode/
5 | dist/
6 | src/*.d.ts
7 | src/*/*.d.ts
8 | src/*/*/*.d.ts
9 | docs/
10 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | test/
2 | node_modules/
3 | transpiled/
4 | html5-qrcode.js
5 | assets/
6 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant 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, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and 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 at minhazav@gmail.com. All
59 | 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 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [2020] [MINHAZ ]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Html5-QRCode
2 |
3 | ## Important - Looking for new owners for this project.
4 |
5 | If interested, please reach out at `minhazav@gmail.com`.
6 |
7 | ## Html5-QRCode
8 |
9 | > **Important** The project is in maintenance mode until further notice. The author shall not be able to make any bug fixes or improvements for the time-being. Pull requests also won't be merged for the timebeing. If you have a fork you can maintain - please share the details to minhazav@gmail.com. I am happy to advertise them here!
10 | > Ok to use the project as is. Example: [scanapp.org](https://scanapp.org).
11 |
12 | ## Lightweight & cross platform QR Code and Bar code scanning library for the web
13 |
14 | Use this lightweight library to easily / quickly integrate QR code, bar code, and other common code scanning capabilities to your web application.
15 |
16 | ## Key highlights
17 | - 🔲 Support scanning [different types of bar codes and QR codes](#supported-code-formats).
18 |
19 | - 🖥 Supports [different platforms](#supported-platforms) be it Android, IOS, MacOs, Windows or Linux
20 |
21 | - 🌐 Supports [different browsers](#supported-platforms) like Chrome, Firefox, Safari, Edge, Opera ...
22 |
23 | - 📷 Supports scanning with camera as well as local files
24 |
25 | - ➡️ Comes with an [end to end library with UI](#easy-mode---with-end-to-end-scanner-user-interface) as well as a [low level library to build your own UI with](#pro-mode---if-you-want-to-implement-your-own-user-interface).
26 |
27 | - 🔦 Supports customisations like [flash/torch support](#showtorchbuttonifsupported---boolean--undefined), zooming etc.
28 |
29 |
30 | Supports two kinds of APIs
31 |
32 | - `Html5QrcodeScanner` — End-to-end scanner with UI, integrate with less than ten lines of code.
33 |
34 | - `Html5Qrcode` — Powerful set of APIs you can use to build your UI without worrying about camera setup, handling permissions, reading codes, etc.
35 |
36 | > Support for scanning local files on the device is a new addition and helpful for the web browser which does not support inline web-camera access in smartphones. **Note:** This doesn't upload files to any server — everything is done locally.
37 |
38 | [](https://dl.circleci.com/status-badge/redirect/gh/mebjas/html5-qrcode/tree/master) [](https://github.com/mebjas/html5-qrcode/issues) [](https://github.com/mebjas/html5-qrcode/releases)  [](https://www.codacy.com/gh/mebjas/html5-qrcode/dashboard?utm_source=github.com&utm_medium=referral&utm_content=mebjas/html5-qrcode&utm_campaign=Badge_Grade) [](https://gitter.im/html5-qrcode/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
39 |
40 |  [](https://www.npmjs.com/package/html5-qrcode) [](https://bit.ly/3CZiASv)
41 |
42 | | | |
43 | | -- | -- |
44 | | _Demo at [scanapp.org](https://scanapp.org)_ | _Demo at [qrcode.minhazav.dev](https://qrcode.minhazav.dev) - **Scanning different types of codes**_ |
45 |
46 | ## We need your help!
47 |
48 | 
49 | Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See [list of sponsered feature requests here](https://github.com/mebjas/html5-qrcode/wiki/Feature-request-sponsorship-goals#feature-requests).
50 |
51 | [](https://ko-fi.com/L3L84G0C8)
52 |
53 | ## Documentation
54 |
55 | The documentation for this project has been moved to [scanapp.org/html5-qrcode-docs](https://scanapp.org/html5-qrcode-docs/).
56 |
57 | - [Getting started](https://scanapp.org/html5-qrcode-docs/docs/intro)
58 | - [Supported frameworks](https://scanapp.org/html5-qrcode-docs/docs/supported_frameworks)
59 | - [Supported 1D and 2D Code formats](https://scanapp.org/html5-qrcode-docs/docs/supported_code_formats)
60 | - [Detailed API documentation](https://scanapp.org/html5-qrcode-docs/docs/apis)
61 |
62 | ## Supported platforms
63 |
64 | We are working continuously on adding support for more and more platforms. If you find a platform or a browser where the library is not working, please feel free to file an issue. Check the [demo link](https://blog.minhazav.dev/research/html5-qrcode.html) to test it out.
65 |
66 | **Legends**
67 | -  Means full support — inline webcam and file based
68 | -  Means partial support — only file based, webcam in progress
69 |
70 | ### PC / Mac
71 |
72 | | Firefox | Chrome | Safari | Opera | Edge
73 | | --------- | --------- | --------- | --------- | ------- |
74 | || | |  | 
75 |
76 | ### Android
77 |
78 | | Chrome | Firefox | Edge | Opera | Opera Mini | UC
79 | | --------- | --------- | --------- | --------- | --------- | --------- |
80 | || | | |  | 
81 |
82 | ### IOS
83 |
84 | | Safari | Chrome | Firefox | Edge
85 | | --------- | --------- | --------- | --------- |
86 | || * | * | 
87 |
88 |
89 | > \* Supported for IOS versions >= 15.1
90 | >
91 | > Before version 15.1, Webkit for IOS is used by Chrome, Firefox, and other browsers in IOS and they do not have webcam permissions yet. There is an ongoing issue on fixing the support for iOS - [issue/14](https://github.com/mebjas/html5-qrcode/issues/14)
92 |
93 | ### Framework support
94 | The library can be easily used with several other frameworks, I have been adding examples for a few of them and would continue to add more.
95 |
96 | || | | |
97 | | -------- | -------- | -------- | -------- | -------- |
98 | | [Html5](./examples/html5) | [VueJs](./examples/vuejs) | [ElectronJs](./examples/electron) | [React](https://github.com/scanapp-org/html5-qrcode-react) | [Lit](./examples/lit)
99 |
100 | ### Supported Code formats
101 | Code scanning is dependent on [Zxing-js](https://github.com/zxing-js/library) library. We will be working on top of it to add support for more types of code scanning. If you feel a certain type of code would be helpful to have, please file a feature request.
102 |
103 | | Code | Example |
104 | | ---- | ----- |
105 | | QR Code | |
106 | | AZTEC | |
107 | | CODE_39| |
108 | | CODE_93| |
109 | | CODE_128| |
110 | | ITF| |
111 | | EAN_13| |
112 | | EAN_8| |
113 | | PDF_417| |
114 | | UPC_A| |
115 | | UPC_E| |
116 | | DATA_MATRIX| |
117 | | MAXICODE*| |
118 | | RSS_14*| |
119 | | RSS_EXPANDED*| |
120 |
121 | > *Formats are not supported by our experimental integration with native
122 | > BarcodeDetector API integration ([Read more](/experimental.md)).
123 |
124 | ## Description - [View Demo](https://blog.minhazav.dev/research/html5-qrcode.html)
125 |
126 | > See an end to end scanner experience at [scanapp.org](https://scanapp.org).
127 |
128 | This is a cross-platform JavaScript library to integrate QR code, bar codes & a few other types of code scanning capabilities to your applications running on HTML5 compatible browser.
129 |
130 | Supports:
131 | - Querying camera on the device (with user permissions)
132 | - Rendering live camera feed, with easy to use user interface for scanning
133 | - Supports scanning a different kind of QR codes, bar codes and other formats
134 | - Supports selecting image files from the device for scanning codes
135 |
136 | ## How to use
137 |
138 | Find detailed guidelines on how to use this library on [scanapp.org/html5-qrcode-docs](https://scanapp.org/html5-qrcode-docs/docs/intro).
139 |
140 | ## Demo
141 |
142 | _Scan this image or visit [blog.minhazav.dev/research/html5-qrcode.html](https://blog.minhazav.dev/research/html5-qrcode.html)_
143 |
144 | ### For more information
145 | Check these articles on how to use this library:
146 |
147 | - [QR and barcode scanner using HTML and JavaScript](https://minhazav.medium.com/qr-and-barcode-scanner-using-html-and-javascript-2cdc937f793d)
148 | - [HTML5 QR Code scanning — launched v1.0.1 without jQuery dependency and refactored Promise based APIs](https://blog.minhazav.dev/HTML5-QR-Code-scanning-launched-v1.0.1/).
149 | - [HTML5 QR Code scanning with JavaScript — Support for scanning the local file and using default camera added (v1.0.5)](https://blog.minhazav.dev/HTML5-QR-Code-scanning-support-for-local-file-and-default-camera/)
150 |
151 | ## Screenshots
152 | 
153 | _Figure: Screenshot from Google Chrome running on MacBook Pro_
154 |
155 | ## Documentation
156 | Find the full API documentation at [scanapp.org/html5-qrcode-docs/docs/apis](https://scanapp.org/html5-qrcode-docs/docs/apis).
157 |
158 | ### Extra optional `configuration` in `start()` method
159 | Configuration object that can be used to configure both the scanning behavior and the user interface (UI). Most of the fields have default properties that will be used unless a different value is provided. If you do not want to override anything, you can just pass in an empty object `{}`.
160 |
161 | #### `fps` — Integer, Example = 10
162 | A.K.A frame per second, the default value for this is 2, but it can be increased to get faster scanning. Increasing too high value could affect performance. Value `>1000` will simply fail.
163 |
164 | #### `qrbox` — `QrDimensions` or `QrDimensionFunction` (Optional), Example = `{ width: 250, height: 250 }`
165 | Use this property to limit the region of the viewfinder you want to use for scanning. The rest of the viewfinder would be shaded. For example, by passing config `{ qrbox : { width: 250, height: 250 } }`, the screen will look like:
166 |
167 |
168 |
169 | This can be used to set a rectangular scanning area with config like:
170 |
171 | ```js
172 | let config = { qrbox : { width: 400, height: 150 } }
173 | ```
174 |
175 | This config also accepts a function of type
176 | ```ts
177 | /**
178 | * A function that takes in the width and height of the video stream
179 | * and returns QrDimensions.
180 | *
181 | * Viewfinder refers to the video showing camera stream.
182 | */
183 | type QrDimensionFunction =
184 | (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions;
185 | ```
186 |
187 | This allows you to set dynamic QR box dimensions based on the video dimensions. See this blog article for example: [Setting dynamic QR box size in Html5-qrcode - ScanApp blog](https://scanapp.org/blog/2022/01/09/setting-dynamic-qr-box-size-in-html5-qrcode.html)
188 |
189 | > This might be desirable for bar code scanning.
190 |
191 | If this value is not set, no shaded QR box will be rendered and the scanner will scan the entire area of video stream.
192 |
193 | #### `aspectRatio` — Float, Example 1.777778 for 16:9 aspect ratio
194 | Use this property to render the video feed in a certain aspect ratio. Passing a nonstandard aspect ratio like `100000:1` could lead to the video feed not even showing up. Ideal values can be:
195 | | Value | Aspect Ratio | Use Case |
196 | | ----- | ------------ | -------- |
197 | |1.333334 | 4:3 | Standard camera aspect ratio |
198 | |1.777778 | 16:9 | Full screen, cinematic |
199 | |1.0 | 1:1 | Square view |
200 |
201 | If you do not pass any value, the whole viewfinder would be used for scanning.
202 | **Note**: this value has to be smaller than the width and height of the `QR code HTML element`.
203 |
204 | #### `disableFlip` — Boolean (Optional), default = false
205 | By default, the scanner can scan for horizontally flipped QR Codes. This also enables scanning QR code using the front camera on mobile devices which are sometimes mirrored. This is `false` by default and I recommend changing this only if:
206 | - You are sure that the camera feed cannot be mirrored (Horizontally flipped)
207 | - You are facing performance issues with this enabled.
208 |
209 | Here's an example of a normal and mirrored QR Code
210 | | Normal QR Code | Mirrored QR Code |
211 | | ----- | ---- |
212 | | | |
213 |
214 | #### `rememberLastUsedCamera` — Boolean (Optional), default = true
215 | If `true` the last camera used by the user and weather or not permission was granted would be remembered in the local storage. If the user has previously granted permissions — the request permission option in the UI will be skipped and the last selected camera would be launched automatically for scanning.
216 |
217 | If `true` the library shall remember if the camera permissions were previously
218 | granted and what camera was last used. If the permissions is already granted for
219 | "camera", QR code scanning will automatically * start for previously used camera.
220 |
221 | #### `supportedScanTypes` - `Array | []`
222 | > This is only supported for `Html5QrcodeScanner`.
223 |
224 | Default = `[Html5QrcodeScanType.SCAN_TYPE_CAMERA, Html5QrcodeScanType.SCAN_TYPE_FILE]`
225 |
226 | This field can be used to:
227 | - Limit support to either of `Camera` or `File` based scan.
228 | - Change default scan type.
229 |
230 | How to use:
231 |
232 | ```js
233 | function onScanSuccess(decodedText, decodedResult) {
234 | // handle the scanned code as you like, for example:
235 | console.log(`Code matched = ${decodedText}`, decodedResult);
236 | }
237 |
238 | let config = {
239 | fps: 10,
240 | qrbox: {width: 100, height: 100},
241 | rememberLastUsedCamera: true,
242 | // Only support camera scan type.
243 | supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA]
244 | };
245 |
246 | let html5QrcodeScanner = new Html5QrcodeScanner(
247 | "reader", config, /* verbose= */ false);
248 | html5QrcodeScanner.render(onScanSuccess);
249 | ```
250 |
251 | For file based scan only choose:
252 | ```js
253 | supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_FILE]
254 | ```
255 |
256 | For supporting both as it is today, you can ignore this field or set as:
257 | ```js
258 | supportedScanTypes: [
259 | Html5QrcodeScanType.SCAN_TYPE_CAMERA,
260 | Html5QrcodeScanType.SCAN_TYPE_FILE]
261 | ```
262 |
263 | To set the file based scan as defult change the order:
264 | ```js
265 | supportedScanTypes: [
266 | Html5QrcodeScanType.SCAN_TYPE_FILE,
267 | Html5QrcodeScanType.SCAN_TYPE_CAMERA]
268 | ```
269 |
270 | #### `showTorchButtonIfSupported` - `boolean | undefined`
271 | > This is only supported for `Html5QrcodeScanner`.
272 |
273 | If `true` the rendered UI will have button to turn flash on or off based on device + browser support. The value is `false` by default.
274 |
275 | ### Scanning only specific formats
276 | By default, both camera stream and image files are scanned against all the
277 | supported code formats. Both `Html5QrcodeScanner` and `Html5Qrcode` classes can
278 | be configured to only support a subset of supported formats. Supported formats
279 | are defined in
280 | [enum Html5QrcodeSupportedFormats](https://github.com/mebjas/html5-qrcode/blob/master/src/core.ts#L14).
281 |
282 | ```ts
283 | enum Html5QrcodeSupportedFormats {
284 | QR_CODE = 0,
285 | AZTEC,
286 | CODABAR,
287 | CODE_39,
288 | CODE_93,
289 | CODE_128,
290 | DATA_MATRIX,
291 | MAXICODE,
292 | ITF,
293 | EAN_13,
294 | EAN_8,
295 | PDF_417,
296 | RSS_14,
297 | RSS_EXPANDED,
298 | UPC_A,
299 | UPC_E,
300 | UPC_EAN_EXTENSION,
301 | }
302 | ```
303 |
304 | I recommend using this only if you need to explicitly omit support for certain
305 | formats or want to reduce the number of scans done per second for performance
306 | reasons.
307 |
308 | #### Scanning only QR code with `Html5Qrcode`
309 | ```js
310 | const html5QrCode = new Html5Qrcode(
311 | "reader", { formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ] });
312 | const qrCodeSuccessCallback = (decodedText, decodedResult) => {
313 | /* handle success */
314 | };
315 | const config = { fps: 10, qrbox: { width: 250, height: 250 } };
316 |
317 | // If you want to prefer front camera
318 | html5QrCode.start({ facingMode: "user" }, config, qrCodeSuccessCallback);
319 | ```
320 |
321 | #### Scanning only QR code and UPC codes with `Html5QrcodeScanner`
322 | ```js
323 | function onScanSuccess(decodedText, decodedResult) {
324 | // Handle the scanned code as you like, for example:
325 | console.log(`Code matched = ${decodedText}`, decodedResult);
326 | }
327 |
328 | const formatsToSupport = [
329 | Html5QrcodeSupportedFormats.QR_CODE,
330 | Html5QrcodeSupportedFormats.UPC_A,
331 | Html5QrcodeSupportedFormats.UPC_E,
332 | Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION,
333 | ];
334 | const html5QrcodeScanner = new Html5QrcodeScanner(
335 | "reader",
336 | {
337 | fps: 10,
338 | qrbox: { width: 250, height: 250 },
339 | formatsToSupport: formatsToSupport
340 | },
341 | /* verbose= */ false);
342 | html5QrcodeScanner.render(onScanSuccess);
343 | ```
344 |
345 | ## Experimental features
346 | The library now supports some experimental features which are supported in the
347 | library but not recommended for production usage either due to limited testing
348 | done or limited compatibility for underlying APIs used. Read more about it [here](/experimental.md).
349 | Some experimental features include:
350 | - [Support for BarcodeDetector JavaScript API](/experimental.md)
351 |
352 | ## How to modify and build
353 | 1. Code changes should only be made to [/src](./src) only.
354 |
355 | 2. Run `npm install` to install all dependencies.
356 |
357 | 3. Run `npm run-script build` to build JavaScript output. The output JavaScript distribution is built to [/dist/html5-qrcode.min.js](./dist/html5-qrcode.min.js). If you are developing on Windows OS, run `npm run-script build-windows`.
358 |
359 | 4. Testing
360 | - Run `npm test`
361 | - Run the tests before sending a pull request, all tests should run.
362 | - Please add tests for new behaviors sent in PR.
363 |
364 | 5. Send a pull request
365 | - Include code changes only to `./src`. **Do not change `./dist` manually.**
366 | - In the pull request add a comment like
367 | ```text
368 | @all-contributors please add @mebjas for this new feature or tests
369 | ```
370 | - For calling out your contributions, the bot will update the contributions file.
371 | - Code will be built & published by the author in batches.
372 |
373 | ## How to contribute
374 | You can contribute to the project in several ways:
375 |
376 | - File issue ticket for any observed bug or compatibility issue with the project.
377 | - File feature request for missing features.
378 | - Take open bugs or feature request and work on it and send a Pull Request.
379 | - Write unit tests for existing codebase (which is not covered by tests today). **Help wanted on this** - [read more](./tests).
380 |
381 | ## Support 💖
382 |
383 | This project would not be possible without all of our fantastic contributors and [sponsors](https://github.com/sponsors/mebjas). If you'd like to support the maintenance and upkeep of this project you can [donate via GitHub Sponsors](https://github.com/sponsors/mebjas).
384 |
385 | **Sponsor the project for priortising feature requests / bugs relevant to you**. (Depends on scope of ask and bandwidth of the contributors).
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 | Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See [list of sponsered feature requests here](https://github.com/mebjas/html5-qrcode/wiki/Feature-request-sponsorship-goals#feature-requests).
394 |
395 | Also, huge thanks to following organizations for non monitery sponsorships
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 | ## Credits
407 | The decoder used for the QR code reading is from `Zxing-js` https://github.com/zxing-js/library
408 |
--------------------------------------------------------------------------------
/compatibility.md:
--------------------------------------------------------------------------------
1 | # Compatibility list for tested device
2 |
3 | **THIS IS WORK IN PROGRESS**: If you have tested the library to work with a different device please
4 | send a pull request.
5 |
6 | ## Android
7 | | Device | Android OS | Browser | Inline scanning | File Scanning | Known issues |
8 | | --- | --- | --- | --- | --- | --- |
9 | | One Plus 6T | 10.0 | Chrome 81.0 |  | | - |
10 |
11 | ## IOS
12 |
13 | | Device | ISO | Browser | Inline scanning | File Scanning | Known issues |
14 | | --- | --- | --- | --- | --- | --- |
15 | | IPhone 11 | 13.4 | Safari 13.1 | | | Not working |
16 | | IPhone XS | 13.4 | Safari 13.1 |  | | - |
17 |
--------------------------------------------------------------------------------
/examples/electron/README.md:
--------------------------------------------------------------------------------
1 | # html5-qrcode with electron
2 |
3 | [www.electronjs.org](https://https://www.electronjs.org/) | `Support Level` = `Strong`
4 |
5 | ## How to build a `electronjs` app using `html5-qrcode`
6 |
7 | ### Download the latest library
8 | You can download this from [Github release page](https://github.com/mebjas/html5-qrcode/releases) or [npm](https://www.npmjs.com/package/html5-qrcode). And include this in `index.html`.
9 |
10 | ```html
11 |
12 | ```
13 |
14 | ### And include the `html` placeholder
15 | ```html
16 |
17 | ```
18 |
19 | ### And `javascript` initialization
20 | ```js
21 | function onScanSuccess(decodedText, decodedResult) {
22 | // Handle on success condition with the decoded message.
23 | console.log(`Scan result ${decodedText}`, decodedResult);
24 | }
25 | var html5QrcodeScanner = new Html5QrcodeScanner(
26 | "reader", { fps: 10, qrbox: 250 });
27 | html5QrcodeScanner.render(onScanSuccess);
28 | ```
29 |
30 | ## Run the app
31 | ```cmd
32 | npm start
33 | ```
--------------------------------------------------------------------------------
/examples/html5/README.md:
--------------------------------------------------------------------------------
1 | # html5-qrcode without any external frameworks
2 |
3 | ## Include the js library in your project
4 | ```html
5 |
6 | ```
7 |
8 | ## Add a placeholder in html
9 | ```html
10 |
11 |
12 | ```
13 |
14 | ## Init in javascript
15 |
16 | ```js
17 | var resultContainer = document.getElementById('qr-reader-results');
18 | var lastResult, countResults = 0;
19 |
20 | function onScanSuccess(decodedText, decodedResult) {
21 | if (decodedText !== lastResult) {
22 | ++countResults;
23 | lastResult = decodedText;
24 | // Handle on success condition with the decoded message.
25 | console.log(`Scan result ${decodedText}`, decodedResult);
26 | }
27 | }
28 |
29 | var html5QrcodeScanner = new Html5QrcodeScanner(
30 | "qr-reader", { fps: 10, qrbox: 250 });
31 | html5QrcodeScanner.render(onScanSuccess);
32 | ```
33 |
--------------------------------------------------------------------------------
/examples/html5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Html-Qrcode Demo
4 |
5 |
6 |
7 |
8 |
9 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/lit/README.md:
--------------------------------------------------------------------------------
1 | # html5-qrcode with lit
2 |
3 |
4 | [lit.dev](https://lit.dev/)
5 |
6 | ## How to create a `lit` component for `html5-qrcode`
7 |
8 | ### Create the component in JavaScript
9 |
10 | ```js
11 | import { html, css, LitElement } from "https://unpkg.com/lit?module";
12 | import { Html5QrcodeScanner } from "https://unpkg.com/html5-qrcode?module";
13 |
14 | export class QRCodeScanner extends LitElement {
15 | render() {
16 | return html`
17 |
18 |
24 |
25 |
26 |
27 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/examples/vuejs/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0; /* no unit */
3 | padding: 0; /* no unit */
4 | }
5 |
6 | .header {
7 | padding: 10px;
8 | background: black;
9 | color: white;
10 | }
11 |
12 | .section {
13 | padding: auto;
14 | }
15 |
--------------------------------------------------------------------------------
/experimental.md:
--------------------------------------------------------------------------------
1 | # Experimental features
2 | Some of the features that are supported by the library but not officially
3 | recommended to be used across devices. If you find any of the features useful,
4 | please feel free to use them at your own risk, they are configurable in the
5 | library. In future, based on the support level and compatibility, some of
6 | these features will get upgraded to general feature list.
7 |
8 | ## Using experimental native BarcodeDetector API
9 |
10 | > **Update** This config has now been graduated to `Html5QrcodeConfigs` and deprecated from experimental config. This feature is now enabled by default.
11 |
12 | ### performance
13 |
14 | Native scanning library seems to be giving better performance for scanning QR
15 | codes than with Zxing library.
16 |
17 | | Device | With ZXing | With BarcodeDecoder |
18 | |--|--|--|
19 | | Macbook Pro 16, Google Chrome | 21 ms | 10 ms|
20 | | Pixel 4 Google Chrome | 56 ms | 23 ms |
21 | | Pixel 4a Google Chrome | 92 ms| 47.3 ms |
22 | | (low end) Android Device Google Chrome | 373 ms | 77.5 ms|
23 |
24 | Not supported on:
25 | - Macbook Pro 16, Safari (macOS Big Sur)
26 |
27 | ### More references
28 | - [https://web.dev/shape-detection/#barcodedetector](https://web.dev/shape-detection/#barcodedetector)
29 |
--------------------------------------------------------------------------------
/minified/readme.md:
--------------------------------------------------------------------------------
1 | # Generated code, do not modify manually.
2 |
3 | - All files in this directory are minified from source code in the project hosted at [src](../src).
4 | - Generated files should be supported in all major browsers.
5 |
6 | ## [deprecation notice]
7 | Its not recommended to use the minified script from this directory directly. These contain the script based on top of the tree and may not have been tested for production.
8 |
9 | ### Recommended ways to use
10 | #### Using directly in browser without any loader
11 | If you are not using any loader, you can get the latest UMD javascript code in production from [https://unpkg.com/html5-qrcode](https://unpkg.com/html5-qrcode).
12 |
13 | ```js
14 |