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
@@ -1,61 +1,61 @@
1
- <template>
2
- <div>
3
- <button @click="reload">Destroy And Re-Create Component</button>
4
-
5
- <qrcode-stream @init="onInit" v-if="!destroyed">
6
- <div class="loading-indicator" v-if="loading">
7
- Loading...
8
- </div>
9
- </qrcode-stream>
10
- </div>
11
- </template>
12
-
13
- <script>
14
- import { QrcodeStream } from '../../../../src'
15
-
16
- export default {
17
-
18
- components: { QrcodeStream },
19
-
20
- data () {
21
- return {
22
- loading: false,
23
- destroyed: false
24
- }
25
- },
26
-
27
- methods: {
28
- async onInit (promise) {
29
- this.loading = true
30
-
31
- try {
32
- await promise
33
- } catch (error) {
34
- console.error(error)
35
- } finally {
36
- this.loading = false
37
- }
38
- },
39
-
40
- async reload () {
41
- this.destroyed = true
42
-
43
- await this.$nextTick()
44
-
45
- this.destroyed = false
46
- }
47
- }
48
- }
49
- </script>
50
-
51
- <style scoped>
52
- button {
53
- margin-bottom: 20px;
54
- }
55
-
56
- .loading-indicator {
57
- font-weight: bold;
58
- font-size: 2rem;
59
- text-align: center;
60
- }
61
- </style>
1
+ <template>
2
+ <div>
3
+ <button @click="reload">Destroy And Re-Create Component</button>
4
+
5
+ <qrcode-stream @init="onInit" v-if="!destroyed">
6
+ <div class="loading-indicator" v-if="loading">
7
+ Loading...
8
+ </div>
9
+ </qrcode-stream>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import { QrcodeStream } from '../../../../src'
15
+
16
+ export default {
17
+
18
+ components: { QrcodeStream },
19
+
20
+ data () {
21
+ return {
22
+ loading: false,
23
+ destroyed: false
24
+ }
25
+ },
26
+
27
+ methods: {
28
+ async onInit (promise) {
29
+ this.loading = true
30
+
31
+ try {
32
+ await promise
33
+ } catch (error) {
34
+ console.error(error)
35
+ } finally {
36
+ this.loading = false
37
+ }
38
+ },
39
+
40
+ async reload () {
41
+ this.destroyed = true
42
+
43
+ await this.$nextTick()
44
+
45
+ this.destroyed = false
46
+ }
47
+ }
48
+ }
49
+ </script>
50
+
51
+ <style scoped>
52
+ button {
53
+ margin-bottom: 20px;
54
+ }
55
+
56
+ .loading-indicator {
57
+ font-weight: bold;
58
+ font-size: 2rem;
59
+ text-align: center;
60
+ }
61
+ </style>
@@ -1,78 +1,78 @@
1
- <template>
2
- <div>
3
- <p class="decode-result">Last result: <b>{{ result }}</b></p>
4
-
5
-
6
- <qrcode-stream :camera="camera" @decode="onDecode" @init="onInit">
7
- <div v-show="showScanConfirmation" class="scan-confirmation">
8
- <img :src="$withBase('/checkmark.svg')" alt="Checkmark" width="128px" />
9
- </div>
10
- </qrcode-stream>
11
- </div>
12
- </template>
13
-
14
- <script>
15
- import { QrcodeStream } from '../../../../src'
16
-
17
- export default {
18
-
19
- components: { QrcodeStream },
20
-
21
- data () {
22
- return {
23
- camera: 'auto',
24
- result: null,
25
- showScanConfirmation: false
26
- }
27
- },
28
-
29
- methods: {
30
-
31
- async onInit (promise) {
32
- try {
33
- await promise
34
- } catch (e) {
35
- console.error(e)
36
- } finally {
37
- this.showScanConfirmation = this.camera === "off"
38
- }
39
- },
40
-
41
- async onDecode (content) {
42
- this.result = content
43
-
44
- this.pause()
45
- await this.timeout(500)
46
- this.unpause()
47
- },
48
-
49
- unpause () {
50
- this.camera = 'auto'
51
- },
52
-
53
- pause () {
54
- this.camera = 'off'
55
- },
56
-
57
- timeout (ms) {
58
- return new Promise(resolve => {
59
- window.setTimeout(resolve, ms)
60
- })
61
- }
62
- }
63
- }
64
- </script>
65
-
66
- <style scoped>
67
- .scan-confirmation {
68
- position: absolute;
69
- width: 100%;
70
- height: 100%;
71
-
72
- background-color: rgba(255, 255, 255, .8);
73
-
74
- display: flex;
75
- flex-flow: row nowrap;
76
- justify-content: center;
77
- }
78
- </style>
1
+ <template>
2
+ <div>
3
+ <p class="decode-result">Last result: <b>{{ result }}</b></p>
4
+
5
+
6
+ <qrcode-stream :camera="camera" @decode="onDecode" @init="onInit">
7
+ <div v-show="showScanConfirmation" class="scan-confirmation">
8
+ <img :src="$withBase('/checkmark.svg')" alt="Checkmark" width="128px" />
9
+ </div>
10
+ </qrcode-stream>
11
+ </div>
12
+ </template>
13
+
14
+ <script>
15
+ import { QrcodeStream } from '../../../../src'
16
+
17
+ export default {
18
+
19
+ components: { QrcodeStream },
20
+
21
+ data () {
22
+ return {
23
+ camera: 'auto',
24
+ result: null,
25
+ showScanConfirmation: false
26
+ }
27
+ },
28
+
29
+ methods: {
30
+
31
+ async onInit (promise) {
32
+ try {
33
+ await promise
34
+ } catch (e) {
35
+ console.error(e)
36
+ } finally {
37
+ this.showScanConfirmation = this.camera === "off"
38
+ }
39
+ },
40
+
41
+ async onDecode (content) {
42
+ this.result = content
43
+
44
+ this.pause()
45
+ await this.timeout(500)
46
+ this.unpause()
47
+ },
48
+
49
+ unpause () {
50
+ this.camera = 'auto'
51
+ },
52
+
53
+ pause () {
54
+ this.camera = 'off'
55
+ },
56
+
57
+ timeout (ms) {
58
+ return new Promise(resolve => {
59
+ window.setTimeout(resolve, ms)
60
+ })
61
+ }
62
+ }
63
+ }
64
+ </script>
65
+
66
+ <style scoped>
67
+ .scan-confirmation {
68
+ position: absolute;
69
+ width: 100%;
70
+ height: 100%;
71
+
72
+ background-color: rgba(255, 255, 255, .8);
73
+
74
+ display: flex;
75
+ flex-flow: row nowrap;
76
+ justify-content: center;
77
+ }
78
+ </style>
@@ -1,82 +1,82 @@
1
- <template>
2
- <div>
3
- <p class="error" v-if="noFrontCamera">
4
- You don't seem to have a front camera on your device
5
- </p>
6
-
7
- <p class="error" v-if="noRearCamera">
8
- You don't seem to have a rear camera on your device
9
- </p>
10
-
11
- <qrcode-stream :camera="camera" @init="onInit">
12
- <button @click="switchCamera">
13
- <img :src="$withBase('/camera-switch.svg')" alt="switch camera">
14
- </button>
15
- </qrcode-stream>
16
- </div>
17
- </template>
18
-
19
- <script>
20
- import { QrcodeStream } from '../../../../src'
21
-
22
- export default {
23
-
24
- components: { QrcodeStream },
25
-
26
- data () {
27
- return {
28
- camera: 'rear',
29
-
30
- noRearCamera: false,
31
- noFrontCamera: false
32
- }
33
- },
34
-
35
- methods: {
36
- switchCamera () {
37
- switch (this.camera) {
38
- case 'front':
39
- this.camera = 'rear'
40
- break
41
- case 'rear':
42
- this.camera = 'front'
43
- break
44
- }
45
- },
46
-
47
- async onInit (promise) {
48
- try {
49
- await promise
50
- } catch (error) {
51
- const triedFrontCamera = this.camera === 'front'
52
- const triedRearCamera = this.camera === 'rear'
53
-
54
- const cameraMissingError = error.name === 'OverconstrainedError'
55
-
56
- if (triedRearCamera && cameraMissingError) {
57
- this.noRearCamera = true
58
- }
59
-
60
- if (triedFrontCamera && cameraMissingError) {
61
- this.noFrontCamera = true
62
- }
63
-
64
- console.error(error)
65
- }
66
- }
67
- }
68
- }
69
- </script>
70
-
71
- <style scoped>
72
- button {
73
- position: absolute;
74
- left: 10px;
75
- top: 10px;
76
- }
77
-
78
- .error {
79
- color: red;
80
- font-weight: bold;
81
- }
82
- </style>
1
+ <template>
2
+ <div>
3
+ <p class="error" v-if="noFrontCamera">
4
+ You don't seem to have a front camera on your device
5
+ </p>
6
+
7
+ <p class="error" v-if="noRearCamera">
8
+ You don't seem to have a rear camera on your device
9
+ </p>
10
+
11
+ <qrcode-stream :camera="camera" @init="onInit">
12
+ <button @click="switchCamera">
13
+ <img :src="$withBase('/camera-switch.svg')" alt="switch camera">
14
+ </button>
15
+ </qrcode-stream>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ import { QrcodeStream } from '../../../../src'
21
+
22
+ export default {
23
+
24
+ components: { QrcodeStream },
25
+
26
+ data () {
27
+ return {
28
+ camera: 'rear',
29
+
30
+ noRearCamera: false,
31
+ noFrontCamera: false
32
+ }
33
+ },
34
+
35
+ methods: {
36
+ switchCamera () {
37
+ switch (this.camera) {
38
+ case 'front':
39
+ this.camera = 'rear'
40
+ break
41
+ case 'rear':
42
+ this.camera = 'front'
43
+ break
44
+ }
45
+ },
46
+
47
+ async onInit (promise) {
48
+ try {
49
+ await promise
50
+ } catch (error) {
51
+ const triedFrontCamera = this.camera === 'front'
52
+ const triedRearCamera = this.camera === 'rear'
53
+
54
+ const cameraMissingError = error.name === 'OverconstrainedError'
55
+
56
+ if (triedRearCamera && cameraMissingError) {
57
+ this.noRearCamera = true
58
+ }
59
+
60
+ if (triedFrontCamera && cameraMissingError) {
61
+ this.noFrontCamera = true
62
+ }
63
+
64
+ console.error(error)
65
+ }
66
+ }
67
+ }
68
+ }
69
+ </script>
70
+
71
+ <style scoped>
72
+ button {
73
+ position: absolute;
74
+ left: 10px;
75
+ top: 10px;
76
+ }
77
+
78
+ .error {
79
+ color: red;
80
+ font-weight: bold;
81
+ }
82
+ </style>
@@ -1,64 +1,64 @@
1
- <template>
2
- <div>
3
- <p v-if="torchNotSupported" class="error">
4
- Torch not supported for active camera
5
- </p>
6
-
7
- <qrcode-stream :torch="torchActive" @init="onInit">
8
- <button @click="torchActive = !torchActive" :disabled="torchNotSupported">
9
- <img :src="$withBase(icon)" alt="toggle torch">
10
- </button>
11
- </qrcode-stream>
12
- </div>
13
- </template>
14
-
15
- <script>
16
- import { QrcodeStream } from '../../../../src'
17
-
18
- export default {
19
-
20
- components: { QrcodeStream },
21
-
22
- data () {
23
- return {
24
- torchActive: false,
25
- torchNotSupported: false
26
- }
27
- },
28
-
29
- computed: {
30
- icon() {
31
- if (this.torchActive)
32
- return '/flash-off.svg'
33
- else
34
- return '/flash-on.svg'
35
- }
36
- },
37
-
38
- methods: {
39
- async onInit (promise) {
40
- try {
41
- const { capabilities } = await promise
42
-
43
- console.log(capabilities);
44
-
45
- this.torchNotSupported = !capabilities.torch
46
- } catch (error) {
47
- console.error(error)
48
- }
49
- }
50
- }
51
- }
52
- </script>
53
-
54
- <style scoped>
55
- button {
56
- position: absolute;
57
- left: 10px;
58
- top: 10px;
59
- }
60
- .error {
61
- color: red;
62
- font-weight: bold;
63
- }
64
- </style>
1
+ <template>
2
+ <div>
3
+ <p v-if="torchNotSupported" class="error">
4
+ Torch not supported for active camera
5
+ </p>
6
+
7
+ <qrcode-stream :torch="torchActive" @init="onInit">
8
+ <button @click="torchActive = !torchActive" :disabled="torchNotSupported">
9
+ <img :src="$withBase(icon)" alt="toggle torch">
10
+ </button>
11
+ </qrcode-stream>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ import { QrcodeStream } from '../../../../src'
17
+
18
+ export default {
19
+
20
+ components: { QrcodeStream },
21
+
22
+ data () {
23
+ return {
24
+ torchActive: false,
25
+ torchNotSupported: false
26
+ }
27
+ },
28
+
29
+ computed: {
30
+ icon() {
31
+ if (this.torchActive)
32
+ return '/flash-off.svg'
33
+ else
34
+ return '/flash-on.svg'
35
+ }
36
+ },
37
+
38
+ methods: {
39
+ async onInit (promise) {
40
+ try {
41
+ const { capabilities } = await promise
42
+
43
+ console.log(capabilities);
44
+
45
+ this.torchNotSupported = !capabilities.torch
46
+ } catch (error) {
47
+ console.error(error)
48
+ }
49
+ }
50
+ }
51
+ }
52
+ </script>
53
+
54
+ <style scoped>
55
+ button {
56
+ position: absolute;
57
+ left: 10px;
58
+ top: 10px;
59
+ }
60
+ .error {
61
+ color: red;
62
+ font-weight: bold;
63
+ }
64
+ </style>
@@ -1,28 +1,28 @@
1
- <template>
2
- <div>
3
- <p class="decode-result">Last result: <b>{{ result }}</b></p>
4
-
5
- <qrcode-capture @decode="onDecode" />
6
- </div>
7
- </template>
8
-
9
- <script>
10
- import { QrcodeCapture } from '../../../../src'
11
-
12
- export default {
13
-
14
- components: { QrcodeCapture },
15
-
16
- data () {
17
- return {
18
- result: ''
19
- }
20
- },
21
-
22
- methods: {
23
- onDecode (result) {
24
- this.result = result
25
- }
26
- }
27
- }
28
- </script>
1
+ <template>
2
+ <div>
3
+ <p class="decode-result">Last result: <b>{{ result }}</b></p>
4
+
5
+ <qrcode-capture @decode="onDecode" />
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ import { QrcodeCapture } from '../../../../src'
11
+
12
+ export default {
13
+
14
+ components: { QrcodeCapture },
15
+
16
+ data () {
17
+ return {
18
+ result: ''
19
+ }
20
+ },
21
+
22
+ methods: {
23
+ onDecode (result) {
24
+ this.result = result
25
+ }
26
+ }
27
+ }
28
+ </script>