qrcode-reader-vue3 3.1.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/.browserslistrc +3 -3
  2. package/.editorconfig +18 -18
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +28 -28
  4. package/.github/copilot-instructions.md +209 -0
  5. package/.github/workflows/npm-publish.yml +15 -15
  6. package/.releaserc.yml +4 -4
  7. package/.travis.yml +26 -26
  8. package/CONTRIBUTING.md +23 -23
  9. package/LICENSE +21 -21
  10. package/README.md +194 -194
  11. package/babel.config.js +3 -3
  12. package/dist/QrcodeReaderVue3.common.js +15988 -13327
  13. package/dist/QrcodeReaderVue3.common.js.map +1 -1
  14. package/dist/QrcodeReaderVue3.umd.js +16152 -13482
  15. package/dist/QrcodeReaderVue3.umd.js.map +1 -1
  16. package/dist/QrcodeReaderVue3.umd.min.js +3 -1
  17. package/dist/QrcodeReaderVue3.umd.min.js.map +1 -1
  18. package/dist/demo.html +1 -8
  19. package/docs/.vuepress/components/DemoWrapper.vue +54 -54
  20. package/docs/.vuepress/components/demos/CustomTracking.vue +3 -2
  21. package/docs/.vuepress/components/demos/DecodeAll.vue +58 -58
  22. package/docs/.vuepress/components/demos/DragDrop.vue +80 -80
  23. package/docs/.vuepress/components/demos/Fullscreen.vue +115 -115
  24. package/docs/.vuepress/components/demos/LoadingIndicator.vue +61 -61
  25. package/docs/.vuepress/components/demos/ScanSameQrcodeMoreThanOnce.vue +78 -78
  26. package/docs/.vuepress/components/demos/SwitchCamera.vue +82 -82
  27. package/docs/.vuepress/components/demos/Torch.vue +64 -64
  28. package/docs/.vuepress/components/demos/Upload.vue +28 -28
  29. package/docs/.vuepress/components/demos/Validate.vue +118 -118
  30. package/docs/.vuepress/config.js +41 -41
  31. package/docs/.vuepress/public/checkmark.svg +1 -1
  32. package/docs/.vuepress/public/debug-memory-leak.html +102 -102
  33. package/docs/README.md +7 -7
  34. package/docs/api/QrcodeCapture.md +95 -95
  35. package/docs/api/QrcodeDropZone.md +117 -117
  36. package/docs/api/QrcodeStream.md +298 -298
  37. package/docs/demos/CustomTracking.md +13 -13
  38. package/docs/demos/DecodeAll.md +12 -12
  39. package/docs/demos/DragDrop.md +13 -13
  40. package/docs/demos/Fullscreen.md +13 -13
  41. package/docs/demos/LoadingIndicator.md +14 -14
  42. package/docs/demos/ScanSameQrcodeMoreThanOnce.md +17 -17
  43. package/docs/demos/Simple.md +14 -14
  44. package/docs/demos/SwitchCamera.md +12 -12
  45. package/docs/demos/Torch.md +15 -15
  46. package/docs/demos/Upload.md +16 -16
  47. package/docs/demos/Validate.md +13 -13
  48. package/eslint.config.js +49 -0
  49. package/package.json +33 -23
  50. package/src/components/QrcodeCapture.vue +31 -30
  51. package/src/components/QrcodeDropZone.vue +42 -42
  52. package/src/components/QrcodeStream.vue +28 -31
  53. package/src/index.ts +44 -0
  54. package/src/misc/{camera.js → camera.ts} +79 -21
  55. package/src/misc/{errors.js → errors.ts} +25 -25
  56. package/src/misc/scanner.ts +149 -0
  57. package/src/misc/{shimGetUserMedia.js → shimGetUserMedia.ts} +28 -28
  58. package/src/misc/util.ts +35 -0
  59. package/src/mixins/CommonAPI.vue +9 -4
  60. package/src/shims-vue.d.ts +9 -0
  61. package/src/types/index.d.ts +43 -0
  62. package/src/types/vue-qrcode-reader.d.ts +32 -4
  63. package/src/types/webrtc-adapter.d.ts +25 -0
  64. package/tests/misc/util.test.ts +72 -0
  65. package/tsconfig.json +35 -0
  66. package/vitest.config.ts +10 -0
  67. package/vue.config.js +30 -7
  68. package/.eslintrc.js +0 -25
  69. package/src/index.js +0 -32
  70. package/src/misc/scanner.js +0 -112
  71. package/src/misc/util.js +0 -15
package/.browserslistrc CHANGED
@@ -1,3 +1,3 @@
1
- > 1%
2
- last 2 versions
3
- ie >= 10
1
+ > 1%
2
+ last 2 versions
3
+ ie >= 10
package/.editorconfig CHANGED
@@ -1,18 +1,18 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = space
5
- indent_size = 2
6
- trim_trailing_whitespace = true
7
- end_of_line = lf
8
- insert_final_newline = true
9
-
10
- [docs/rules/linebreak-style.md]
11
- end_of_line = disabled
12
-
13
- [{docs/rules/{indent.md,no-mixed-spaces-and-tabs.md}]
14
- indent_style = disabled
15
- indent_size = disabled
16
-
17
- [docs/rules/no-trailing-spaces.md]
18
- trim_trailing_whitespace = false
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ trim_trailing_whitespace = true
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+
10
+ [docs/rules/linebreak-style.md]
11
+ end_of_line = disabled
12
+
13
+ [{docs/rules/{indent.md,no-mixed-spaces-and-tabs.md}]
14
+ indent_style = disabled
15
+ indent_size = disabled
16
+
17
+ [docs/rules/no-trailing-spaces.md]
18
+ trim_trailing_whitespace = false
@@ -1,28 +1,28 @@
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. Can you reproduce this issue with [one of the demos](https://scholtz.github.io/qrcode-reader-vue3/demos/DecodeAll.html)?
12
-
13
- **To Reproduce**
14
- Please provide a link to a minimal reproduction of the bug. For example on jsFiddle, CodePen, etc. Please don't attach a ZIP file with your entire code base. I know this is additional effort but if it takes too much time to reproduce your issue you'll likely won't get help at all.
15
-
16
- **Screenshots**
17
- If applicable, add screenshots to help explain your problem.
18
-
19
- **Desktop (please complete the following information):**
20
- - OS: [e.g. iOS]
21
- - Browser [e.g. chrome, safari]
22
- - Version [e.g. 22]
23
-
24
- **Smartphone (please complete the following information):**
25
- - Device: [e.g. iPhone6]
26
- - OS: [e.g. iOS8.1]
27
- - Browser [e.g. stock browser, safari]
28
- - Version [e.g. 22]
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. Can you reproduce this issue with [one of the demos](https://scholtz.github.io/qrcode-reader-vue3/demos/DecodeAll.html)?
12
+
13
+ **To Reproduce**
14
+ Please provide a link to a minimal reproduction of the bug. For example on jsFiddle, CodePen, etc. Please don't attach a ZIP file with your entire code base. I know this is additional effort but if it takes too much time to reproduce your issue you'll likely won't get help at all.
15
+
16
+ **Screenshots**
17
+ If applicable, add screenshots to help explain your problem.
18
+
19
+ **Desktop (please complete the following information):**
20
+ - OS: [e.g. iOS]
21
+ - Browser [e.g. chrome, safari]
22
+ - Version [e.g. 22]
23
+
24
+ **Smartphone (please complete the following information):**
25
+ - Device: [e.g. iPhone6]
26
+ - OS: [e.g. iOS8.1]
27
+ - Browser [e.g. stock browser, safari]
28
+ - Version [e.g. 22]
@@ -0,0 +1,209 @@
1
+ # Copilot Instructions for qrcode-reader-vue3
2
+
3
+ ## Project Overview
4
+
5
+ **This is a TypeScript-based Vue 3 component library** for detecting and decoding QR codes in the browser. The library provides three main components:
6
+ - `QrcodeStream`: Accesses device camera for continuous QR code scanning
7
+ - `QrcodeDropZone`: Drag-and-drop interface for QR code image decoding
8
+ - `QrcodeCapture`: File upload field for QR code scanning
9
+
10
+ ## Development Setup
11
+
12
+ ### Prerequisites
13
+ - Node.js (version 16 or higher recommended)
14
+ - npm package manager
15
+
16
+ ### Getting Started
17
+ ```bash
18
+ # Install dependencies (use --legacy-peer-deps if needed)
19
+ npm install --legacy-peer-deps
20
+
21
+ # Start development server with local demo page
22
+ npm run dev
23
+
24
+ # Build the library for production
25
+ npm run build
26
+
27
+ # Run linter
28
+ npm run lint
29
+ ```
30
+
31
+ ## Code Style and Conventions
32
+
33
+ ### TypeScript Standards
34
+ - **This project uses TypeScript** for all source files
35
+ - All `.ts` files should have proper type annotations
36
+ - Vue components should use `<script lang="ts">` for TypeScript support
37
+ - Avoid using `any` type unless absolutely necessary
38
+ - Export types for public APIs so consumers can use them
39
+ - Type definitions are located in `src/types/`
40
+
41
+ ### Vue 3 Standards
42
+ - This is a Vue 3 project - use Composition API or Options API consistently with existing code
43
+ - All components are located in `src/components/`
44
+ - Use kebab-case for component references in templates
45
+ - Follow responsive design principles - components should adapt to different screen sizes
46
+
47
+ ### Code Formatting
48
+ - **Prettier** is used for code formatting
49
+ - **ESLint** is configured for linting Vue and TypeScript files
50
+ - Pre-commit hooks automatically lint staged files
51
+ - Run `npm run lint` to check and fix code style issues
52
+
53
+ ### File Structure
54
+ ```
55
+ src/
56
+ ├── components/ # Vue components (with TypeScript)
57
+ ├── mixins/ # Shared Vue mixins (with TypeScript)
58
+ ├── misc/ # Utility functions and helpers (TypeScript)
59
+ ├── types/ # Type definitions and constants (TypeScript .d.ts files)
60
+ ├── index.ts # Main entry point (TypeScript)
61
+ └── shims-vue.d.ts # Vue TypeScript shims
62
+ ```
63
+
64
+ ## TypeScript Guidelines
65
+
66
+ ### When Writing TypeScript Code
67
+ 1. Always define interfaces for complex objects
68
+ 2. Use proper types for function parameters and return values
69
+ 3. Leverage TypeScript's type inference when types are obvious
70
+ 4. Create type definitions for third-party libraries that lack them
71
+ 5. Export types that consumers of the library might need
72
+
73
+ ### Example TypeScript Patterns
74
+ ```typescript
75
+ // Define interfaces for data structures
76
+ interface QRCodeResult {
77
+ content: string | null;
78
+ location: QRCodeLocation | null;
79
+ }
80
+
81
+ // Use proper function types
82
+ export function processFile(file: File): Promise<QRCodeResult> {
83
+ // implementation
84
+ }
85
+
86
+ // Type component props properly
87
+ export interface QrcodeStreamProps {
88
+ camera?: 'auto' | 'rear' | 'front' | 'off';
89
+ torch?: boolean;
90
+ }
91
+ ```
92
+
93
+ ## Testing and Quality
94
+
95
+ ### Before Submitting Changes
96
+ 1. Run `npm run lint` to ensure code style compliance
97
+ 2. Run `npm run build` to verify the library builds successfully and type definitions are generated
98
+ 3. Test changes using the development server (`npm run dev`)
99
+ 4. Ensure changes work across different browsers (Chrome, Firefox, Safari)
100
+
101
+ ### Browser Support Considerations
102
+ - Components rely on WebRTC and camera access APIs
103
+ - HTTPS is required for camera access (except localhost)
104
+ - Not all QR code types are supported (e.g., Model 1 QR codes, color-inverted codes)
105
+
106
+ ## Commit Message Conventions
107
+
108
+ **CRITICAL**: This project uses [semantic-release](https://github.com/semantic-release/semantic-release) with Angular Commit Message Conventions. Version numbers are automatically determined from commit messages.
109
+
110
+ ### Format
111
+ ```
112
+ <type>(<scope>): <subject>
113
+ ```
114
+
115
+ ### Types
116
+ - **feat**: A new feature (triggers minor version bump)
117
+ - **fix**: A bug fix (triggers patch version bump)
118
+ - **docs**: Documentation only changes
119
+ - **style**: Changes that don't affect code meaning (white-space, formatting)
120
+ - **refactor**: Code changes that neither fix bugs nor add features
121
+ - **perf**: Performance improvements
122
+ - **test**: Adding or updating tests
123
+ - **chore**: Changes to build process or auxiliary tools
124
+
125
+ ### Examples
126
+ ```
127
+ feat(QrcodeStream): add support for custom camera constraints
128
+ fix(QrcodeCapture): resolve file upload issue on iOS Safari
129
+ docs(README): update installation instructions
130
+ ```
131
+
132
+ ### Breaking Changes
133
+ For breaking changes, add `BREAKING CHANGE:` in the commit body to trigger a major version bump.
134
+
135
+ ## Component Development Guidelines
136
+
137
+ ### When Adding or Modifying Components
138
+ 1. Keep components focused and single-purpose
139
+ 2. Emit events for decoded QR codes and errors
140
+ 3. Provide clear error messages for troubleshooting
141
+ 4. Ensure components are accessible and responsive
142
+ 5. Follow existing patterns in `src/components/`
143
+
144
+ ### Props and Events
145
+ - Use descriptive prop names with clear types
146
+ - Document all props and events
147
+ - Follow Vue 3 prop validation patterns
148
+ - Emit events in kebab-case
149
+
150
+ ## Dependencies
151
+
152
+ ### Core Dependencies
153
+ - **Vue 3**: UI framework
154
+ - **barcode-detector**: QR code detection/decoding
155
+ - **callforth**: Async function orchestration
156
+ - **webrtc-adapter**: WebRTC polyfills for cross-browser compatibility
157
+
158
+ ### Adding New Dependencies
159
+ - Minimize new dependencies when possible
160
+ - Prefer well-maintained, actively developed packages
161
+ - Check bundle size impact using bundlephobia.com
162
+ - Document why the dependency is needed
163
+
164
+ ## Common Tasks for Copilot
165
+
166
+ ### Good Task Examples
167
+ - Bug fixes in existing components
168
+ - Adding prop validation or improving error messages
169
+ - Documentation updates
170
+ - Accessibility improvements
171
+ - Code style and linting fixes
172
+ - Performance optimizations
173
+
174
+ ### Tasks Requiring Human Review
175
+ - Breaking API changes
176
+ - Major refactoring across multiple components
177
+ - Changes to build configuration
178
+ - Security-sensitive code
179
+ - Camera permission handling logic
180
+
181
+ ## Troubleshooting
182
+
183
+ ### Camera Access Issues
184
+ - Verify HTTPS is being used (or localhost)
185
+ - Check browser permissions
186
+ - Review `init` event errors
187
+ - Test on the demo page first
188
+
189
+ ### Build Issues
190
+ - Clear `node_modules` and run `npm install` again
191
+ - Check Node.js version compatibility
192
+ - Verify all dependencies are installed
193
+
194
+ ## Additional Resources
195
+
196
+ - [Live Demos](https://scholtz.github.io/qrcode-reader-vue3/demos/DecodeAll.html)
197
+ - [API Reference](https://scholtz.github.io/qrcode-reader-vue3/api/QrcodeStream.html)
198
+ - [Original vue-qrcode-reader (Vue 2)](https://github.com/gruhn/vue-qrcode-reader)
199
+
200
+ ## Notes for AI Assistants
201
+
202
+ When working on issues:
203
+ 1. Read and understand the full issue description before making changes
204
+ 2. Test changes locally using `npm run dev`
205
+ 3. Run linter and build before submitting
206
+ 4. Follow the Angular commit message convention
207
+ 5. Keep changes minimal and focused on the specific issue
208
+ 6. Preserve existing code style and patterns
209
+ 7. Update documentation if API changes are made
@@ -1,15 +1,15 @@
1
- on: push
2
-
3
- jobs:
4
- publish:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - uses: actions/checkout@v1
8
- - uses: actions/setup-node@v1
9
- with:
10
- node-version: 10
11
- - run: npm install
12
- - run: npm run-script build
13
- - uses: JS-DevTools/npm-publish@v1
14
- with:
15
- token: ${{ secrets.NPM_TOKEN }}
1
+ on: push
2
+
3
+ jobs:
4
+ publish:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v1
8
+ - uses: actions/setup-node@v1
9
+ with:
10
+ node-version: 10
11
+ - run: npm install
12
+ - run: npm run-script build
13
+ - uses: JS-DevTools/npm-publish@v1
14
+ with:
15
+ token: ${{ secrets.NPM_TOKEN }}
package/.releaserc.yml CHANGED
@@ -1,4 +1,4 @@
1
- branches:
2
- - name: master
3
- - name: beta
4
- prerelease: true
1
+ branches:
2
+ - name: master
3
+ - name: beta
4
+ prerelease: true
package/.travis.yml CHANGED
@@ -1,26 +1,26 @@
1
- language: node_js
2
- node_js: lts/*
3
-
4
- install:
5
- - npm install
6
-
7
- script:
8
- - npm run build
9
- - npm run build:docs
10
-
11
- cache: npm
12
-
13
- deploy:
14
- - provider: script
15
- skip_cleanup: true
16
- on:
17
- all_branches: true
18
- condition: $TRAVIS_BRANCH =~ ^(master|beta)$
19
- script: npx semantic-release
20
- - provider: pages
21
- skip_cleanup: true
22
- keep_history: true
23
- github_token: $GH_TOKEN
24
- on:
25
- branch: master
26
- local_dir: docs/.vuepress/dist
1
+ language: node_js
2
+ node_js: lts/*
3
+
4
+ install:
5
+ - npm install
6
+
7
+ script:
8
+ - npm run build
9
+ - npm run build:docs
10
+
11
+ cache: npm
12
+
13
+ deploy:
14
+ - provider: script
15
+ skip_cleanup: true
16
+ on:
17
+ all_branches: true
18
+ condition: $TRAVIS_BRANCH =~ ^(master|beta)$
19
+ script: npx semantic-release
20
+ - provider: pages
21
+ skip_cleanup: true
22
+ keep_history: true
23
+ github_token: $GH_TOKEN
24
+ on:
25
+ branch: master
26
+ local_dir: docs/.vuepress/dist
package/CONTRIBUTING.md CHANGED
@@ -1,23 +1,23 @@
1
- Your contributions are welcome.
2
- Don't hesitate to open an issue if you have trouble.
3
-
4
- ### Setup Dev Environment
5
-
6
- Clone the repository and run
7
-
8
- ```
9
- npm install
10
- ```
11
-
12
- We use a locally served version of the [demo page](https://scholtz.github.io/qrcode-reader-vue3/demos/DecodeAll.html) during development.
13
- To get that started run
14
-
15
- ```
16
- npm run dev
17
- ```
18
-
19
- ### Commit Messages
20
-
21
- The version number of releases is automatically determined form commit messages.
22
- This only works if we follow [Angular Commit Message Conventions](https://github.com/semantic-release/semantic-release#commit-message-format).
23
-
1
+ Your contributions are welcome.
2
+ Don't hesitate to open an issue if you have trouble.
3
+
4
+ ### Setup Dev Environment
5
+
6
+ Clone the repository and run
7
+
8
+ ```
9
+ npm install
10
+ ```
11
+
12
+ We use a locally served version of the [demo page](https://scholtz.github.io/qrcode-reader-vue3/demos/DecodeAll.html) during development.
13
+ To get that started run
14
+
15
+ ```
16
+ npm run dev
17
+ ```
18
+
19
+ ### Commit Messages
20
+
21
+ The version number of releases is automatically determined form commit messages.
22
+ This only works if we follow [Angular Commit Message Conventions](https://github.com/semantic-release/semantic-release#commit-message-format).
23
+
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Niklas Gruhn
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Niklas Gruhn
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.