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,13 +1,13 @@
1
- # Decode by Drag&Drop
2
-
3
- With the `QrcodeDropZone` component you can also drag-and-drop images that
4
- should be scanned. Use it as a standalone feature or as a fallback for desktop
5
- users.
6
-
7
- <ClientOnly>
8
- <DemoWrapper component="DragDrop" />
9
- </ClientOnly>
10
-
11
- ### Source
12
-
13
- <<< @/docs/.vuepress/components/demos/DragDrop.vue
1
+ # Decode by Drag&Drop
2
+
3
+ With the `QrcodeDropZone` component you can also drag-and-drop images that
4
+ should be scanned. Use it as a standalone feature or as a fallback for desktop
5
+ users.
6
+
7
+ <ClientOnly>
8
+ <DemoWrapper component="DragDrop" />
9
+ </ClientOnly>
10
+
11
+ ### Source
12
+
13
+ <<< @/docs/.vuepress/components/demos/DragDrop.vue
@@ -1,13 +1,13 @@
1
- # Fullscreen
2
-
3
- `QrcodeStream` always covers the entire space available.
4
- Not more, not less.
5
- So to go fullscreen, simply put the component in a wrapper element that occupies the entire screen.
6
-
7
- <ClientOnly>
8
- <DemoWrapper component="Fullscreen" />
9
- </ClientOnly>
10
-
11
- ### Source
12
-
13
- <<< @/docs/.vuepress/components/demos/Fullscreen.vue
1
+ # Fullscreen
2
+
3
+ `QrcodeStream` always covers the entire space available.
4
+ Not more, not less.
5
+ So to go fullscreen, simply put the component in a wrapper element that occupies the entire screen.
6
+
7
+ <ClientOnly>
8
+ <DemoWrapper component="Fullscreen" />
9
+ </ClientOnly>
10
+
11
+ ### Source
12
+
13
+ <<< @/docs/.vuepress/components/demos/Fullscreen.vue
@@ -1,14 +1,14 @@
1
- # Show Loading Indicator
2
-
3
- There is some delay between mounting the component and the camera stream
4
- becoming visible. Listen for the `init` event to show a loading indicator.
5
-
6
- Push the button below to force destroy and re-create the component.
7
-
8
- <ClientOnly>
9
- <DemoWrapper component="LoadingIndicator" />
10
- </ClientOnly>
11
-
12
- ### Source
13
-
14
- <<< @/docs/.vuepress/components/demos/LoadingIndicator.vue
1
+ # Show Loading Indicator
2
+
3
+ There is some delay between mounting the component and the camera stream
4
+ becoming visible. Listen for the `init` event to show a loading indicator.
5
+
6
+ Push the button below to force destroy and re-create the component.
7
+
8
+ <ClientOnly>
9
+ <DemoWrapper component="LoadingIndicator" />
10
+ </ClientOnly>
11
+
12
+ ### Source
13
+
14
+ <<< @/docs/.vuepress/components/demos/LoadingIndicator.vue
@@ -1,17 +1,17 @@
1
- # Scan Same QR Code More Than Once
2
-
3
- You might have noticed that scanning the same QR code again doesn't work.
4
- The thing is when a QR code is in the view of your the camera it's decoded multiple times a second.
5
- You don't want to be flooded with decode events that often though.
6
- That's why the last decoded QR code is "cached" and an event is only emitted, when the decoded content changes.
7
-
8
- However this cache is reset when you change the `camera` prop.
9
- We can exploit that to scan same QR codes multiple times in a row.
10
-
11
- <ClientOnly>
12
- <DemoWrapper component="ScanSameQrcodeMoreThanOnce" />
13
- </ClientOnly>
14
-
15
- ### Source
16
-
17
- <<< @/docs/.vuepress/components/demos/ScanSameQrcodeMoreThanOnce.vue
1
+ # Scan Same QR Code More Than Once
2
+
3
+ You might have noticed that scanning the same QR code again doesn't work.
4
+ The thing is when a QR code is in the view of your the camera it's decoded multiple times a second.
5
+ You don't want to be flooded with decode events that often though.
6
+ That's why the last decoded QR code is "cached" and an event is only emitted, when the decoded content changes.
7
+
8
+ However this cache is reset when you change the `camera` prop.
9
+ We can exploit that to scan same QR codes multiple times in a row.
10
+
11
+ <ClientOnly>
12
+ <DemoWrapper component="ScanSameQrcodeMoreThanOnce" />
13
+ </ClientOnly>
14
+
15
+ ### Source
16
+
17
+ <<< @/docs/.vuepress/components/demos/ScanSameQrcodeMoreThanOnce.vue
@@ -1,14 +1,14 @@
1
- # Simple
2
-
3
- All other demos on this page utilize [single-file components](https://vuejs.org/v2/guide/single-file-components.html).
4
- To use them in your project you need a bundler like webpack.
5
-
6
- For simpler example that works without a build step and right in the browser, checkout this:
7
-
8
-
9
- <p class="codepen" data-height="265" data-theme-id="light" data-default-tab="js,result" data-user="gruhn" data-slug-hash="rNxQPay" style="height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="rNxQPay">
10
- <span>See the Pen <a href="https://codepen.io/gruhn/pen/rNxQPay">
11
- rNxQPay</a> by Niklas (<a href="https://codepen.io/gruhn">@gruhn</a>)
12
- on <a href="https://codepen.io">CodePen</a>.</span>
13
- </p>
14
- <script async src="https://static.codepen.io/assets/embed/ei.js"></script>
1
+ # Simple
2
+
3
+ All other demos on this page utilize [single-file components](https://vuejs.org/v2/guide/single-file-components.html).
4
+ To use them in your project you need a bundler like webpack.
5
+
6
+ For simpler example that works without a build step and right in the browser, checkout this:
7
+
8
+
9
+ <p class="codepen" data-height="265" data-theme-id="light" data-default-tab="js,result" data-user="gruhn" data-slug-hash="rNxQPay" style="height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="rNxQPay">
10
+ <span>See the Pen <a href="https://codepen.io/gruhn/pen/rNxQPay">
11
+ rNxQPay</a> by Niklas (<a href="https://codepen.io/gruhn">@gruhn</a>)
12
+ on <a href="https://codepen.io">CodePen</a>.</span>
13
+ </p>
14
+ <script async src="https://static.codepen.io/assets/embed/ei.js"></script>
@@ -1,12 +1,12 @@
1
- # Switch to Front Camera
2
-
3
- You can also allow users to choose the front or rear camera on their
4
- device.
5
-
6
- <ClientOnly>
7
- <DemoWrapper component="SwitchCamera" />
8
- </ClientOnly>
9
-
10
- ### Source
11
-
12
- <<< @/docs/.vuepress/components/demos/SwitchCamera.vue
1
+ # Switch to Front Camera
2
+
3
+ You can also allow users to choose the front or rear camera on their
4
+ device.
5
+
6
+ <ClientOnly>
7
+ <DemoWrapper component="SwitchCamera" />
8
+ </ClientOnly>
9
+
10
+ ### Source
11
+
12
+ <<< @/docs/.vuepress/components/demos/SwitchCamera.vue
@@ -1,15 +1,15 @@
1
- # Torch (Flashlight)
2
-
3
- In low-light conditions you might want to make use of the cameras flashlight.
4
- Using the `torch` prop, you can turn the flashlight on/off.
5
- Note that support is inconsistent across devices and browers.
6
-
7
- Feature sponsored by [aeschbacher.ch](https://aeschbacher.ch)
8
-
9
- <ClientOnly>
10
- <DemoWrapper component="Torch" />
11
- </ClientOnly>
12
-
13
- ### Source
14
-
15
- <<< @/docs/.vuepress/components/demos/Torch.vue
1
+ # Torch (Flashlight)
2
+
3
+ In low-light conditions you might want to make use of the cameras flashlight.
4
+ Using the `torch` prop, you can turn the flashlight on/off.
5
+ Note that support is inconsistent across devices and browers.
6
+
7
+ Feature sponsored by [aeschbacher.ch](https://aeschbacher.ch)
8
+
9
+ <ClientOnly>
10
+ <DemoWrapper component="Torch" />
11
+ </ClientOnly>
12
+
13
+ ### Source
14
+
15
+ <<< @/docs/.vuepress/components/demos/Torch.vue
@@ -1,16 +1,16 @@
1
- # Decode by Upload
2
-
3
- Finally, with `QrcodeCapture` comes another component which allows image scanning via classic file upload.
4
- If you are on mobile and your browser supports it,
5
- your are not prompted with a file dialog but with your camera.
6
- So you can directly take the picture to be uploaded.
7
-
8
- Note that nothing is actually uploaded. Everything is happening client-side.
9
-
10
- <ClientOnly>
11
- <DemoWrapper component="Upload" />
12
- </ClientOnly>
13
-
14
- ### Source
15
-
16
- <<< @/docs/.vuepress/components/demos/Upload.vue
1
+ # Decode by Upload
2
+
3
+ Finally, with `QrcodeCapture` comes another component which allows image scanning via classic file upload.
4
+ If you are on mobile and your browser supports it,
5
+ your are not prompted with a file dialog but with your camera.
6
+ So you can directly take the picture to be uploaded.
7
+
8
+ Note that nothing is actually uploaded. Everything is happening client-side.
9
+
10
+ <ClientOnly>
11
+ <DemoWrapper component="Upload" />
12
+ </ClientOnly>
13
+
14
+ ### Source
15
+
16
+ <<< @/docs/.vuepress/components/demos/Upload.vue
@@ -1,13 +1,13 @@
1
- # Pause & Validate
2
-
3
- By turning off the camera you can process each scanned QR-code one at a time.
4
- The last received frame is still displayed so it just looks like the stream is
5
- paused.
6
-
7
- <ClientOnly>
8
- <DemoWrapper component="Validate" />
9
- </ClientOnly>
10
-
11
- ### Source
12
-
13
- <<< @/docs/.vuepress/components/demos/Validate.vue
1
+ # Pause & Validate
2
+
3
+ By turning off the camera you can process each scanned QR-code one at a time.
4
+ The last received frame is still displayed so it just looks like the stream is
5
+ paused.
6
+
7
+ <ClientOnly>
8
+ <DemoWrapper component="Validate" />
9
+ </ClientOnly>
10
+
11
+ ### Source
12
+
13
+ <<< @/docs/.vuepress/components/demos/Validate.vue
@@ -0,0 +1,49 @@
1
+ const { FlatCompat } = require("@eslint/eslintrc");
2
+ const js = require("@eslint/js");
3
+
4
+ const compat = new FlatCompat({
5
+ baseDirectory: __dirname,
6
+ recommendedConfig: js.configs.recommended,
7
+ });
8
+
9
+ module.exports = [
10
+ ...compat.config({
11
+ root: true,
12
+ env: {
13
+ node: true,
14
+ browser: true,
15
+ },
16
+ extends: ["plugin:vue/essential", "eslint:recommended"],
17
+ parser: "vue-eslint-parser",
18
+ parserOptions: {
19
+ parser: "@typescript-eslint/parser",
20
+ ecmaVersion: 2020,
21
+ sourceType: "module",
22
+ },
23
+ plugins: ["@typescript-eslint"],
24
+ rules: {
25
+ "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
26
+ "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
27
+ "@typescript-eslint/no-explicit-any": "warn",
28
+ "vue/multi-word-component-names": "off",
29
+ },
30
+ overrides: [
31
+ {
32
+ files: [
33
+ "**/__tests__/*.{j,t}s?(x)",
34
+ "**/tests/unit/**/*.spec.{j,t}s?(x)",
35
+ ],
36
+ env: {
37
+ mocha: true,
38
+ },
39
+ },
40
+ {
41
+ files: ["**/*.{ts,tsx,vue}", "src/**/*.ts"],
42
+ rules: {
43
+ "no-undef": "off",
44
+ "no-unused-vars": "off",
45
+ },
46
+ },
47
+ ],
48
+ }),
49
+ ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qrcode-reader-vue3",
3
3
  "description": "A set of Vue.js components for detecting and decoding QR codes.",
4
- "version": "3.1.3",
4
+ "version": "4.1.0",
5
5
  "author": {
6
6
  "name": "Niklas Gruhn",
7
7
  "email": "niklas@gruhn.me"
@@ -14,6 +14,7 @@
14
14
  "homepage": "https://scholtz.github.io/qrcode-reader-vue3",
15
15
  "main": "dist/QrcodeReaderVue3.common.js",
16
16
  "unpkg": "dist/QrcodeReaderVue3.umd.min.js",
17
+ "types": "dist/types/index.d.ts",
17
18
  "keywords": [
18
19
  "vue",
19
20
  "vuejs",
@@ -27,39 +28,48 @@
27
28
  "scripts": {
28
29
  "dev": "vuepress dev docs",
29
30
  "build:docs": "vuepress build docs",
30
- "build": "vue-cli-service build --target lib --name QrcodeReaderVue3 src/index.js",
31
- "lint": "vue-cli-service lint"
31
+ "build": "vue-cli-service build --target lib --name QrcodeReaderVue3 src/index.ts && npm run postbuild",
32
+ "postbuild": "mkdir -p dist/types && cp src/types/index.d.ts dist/types/ && cp src/types/vue-qrcode-reader.d.ts dist/types/",
33
+ "lint": "eslint --ext .js,.ts,.vue .",
34
+ "test": "vitest run"
32
35
  },
33
36
  "dependencies": {
34
- "barcode-detector": "^0.7",
35
- "callforth": "^0.4",
36
- "core-js": "^3",
37
+ "barcode-detector": "^3.0.8",
38
+ "core-js": "^3.47.0",
37
39
  "vue": "^3",
38
- "webrtc-adapter": "^7"
40
+ "webrtc-adapter": "^9.0.3"
39
41
  },
40
42
  "devDependencies": {
41
- "@vue/cli-plugin-babel": "latest",
42
- "@vue/cli-plugin-eslint": "latest",
43
- "@vue/cli-service": "latest",
44
- "@vue/eslint-config-prettier": "latest",
45
- "babel-eslint": "latest",
46
- "eslint": "latest",
47
- "eslint-plugin-prettier": "latest",
48
- "eslint-plugin-vue": "latest",
49
- "husky": "latest",
50
- "lint-staged": "latest",
51
- "prettier": "latest",
52
- "semantic-release": "latest",
53
- "vue-template-compiler": "latest",
43
+ "@types/jsdom": "^27.0.0",
44
+ "@types/node": "^22.19.3",
45
+ "@typescript-eslint/eslint-plugin": "^8.21.0",
46
+ "@typescript-eslint/parser": "^8.21.0",
47
+ "@vue/cli-plugin-babel": "^5.0.9",
48
+ "@vue/cli-plugin-eslint": "^5.0.9",
49
+ "@vue/cli-plugin-typescript": "^5.0.9",
50
+ "@vue/cli-service": "^5.0.9",
54
51
  "@vue/compiler-sfc": "latest",
55
- "postcss": "latest"
52
+ "@vue/eslint-config-prettier": "^10.2.0",
53
+ "@vue/eslint-config-typescript": "^14.6.0",
54
+ "eslint": "^9.39.2",
55
+ "eslint-plugin-prettier": "^5.5.4",
56
+ "eslint-plugin-vue": "^10.6.2",
57
+ "husky": "^9.1.7",
58
+ "jsdom": "^27.3.0",
59
+ "lint-staged": "^16.2.7",
60
+ "postcss": "^8.5.6",
61
+ "prettier": "^3.7.4",
62
+ "semantic-release": "^24.2.9",
63
+ "typescript": "~5.6.3",
64
+ "vitest": "^4.0.16",
65
+ "vue-template-compiler": "^2.7.16"
56
66
  },
57
67
  "gitHooks": {
58
68
  "pre-commit": "lint-staged"
59
69
  },
60
70
  "lint-staged": {
61
- "*.{js,jsx,vue}": [
62
- "vue-cli-service lint",
71
+ "*.{js,jsx,ts,tsx,vue}": [
72
+ "eslint --fix",
63
73
  "git add"
64
74
  ]
65
75
  }
@@ -1,30 +1,31 @@
1
- <template lang="html">
2
- <input
3
- @change="onChangeInput"
4
- type="file"
5
- name="image"
6
- accept="image/*"
7
- capture="environment"
8
- multiple
9
- />
10
- </template>
11
-
12
- <script>
13
- import { processFile } from "../misc/scanner.js";
14
- import CommonAPI from "../mixins/CommonAPI.vue";
15
-
16
- export default {
17
- name: "qrcode-capture",
18
-
19
- mixins: [CommonAPI],
20
-
21
- methods: {
22
- onChangeInput(event) {
23
- const files = [...event.target.files];
24
- const resultPromises = files.map(processFile);
25
-
26
- resultPromises.forEach(this.onDetect);
27
- },
28
- },
29
- };
30
- </script>
1
+ <template lang="html">
2
+ <input
3
+ @change="onChangeInput"
4
+ type="file"
5
+ name="image"
6
+ accept="image/*"
7
+ capture="environment"
8
+ multiple
9
+ />
10
+ </template>
11
+
12
+ <script lang="ts">
13
+ import { processFile } from "../misc/scanner";
14
+ import CommonAPI from "../mixins/CommonAPI.vue";
15
+
16
+ export default {
17
+ name: "qrcode-capture",
18
+
19
+ mixins: [CommonAPI],
20
+
21
+ methods: {
22
+ onChangeInput(event: Event) {
23
+ const target = event.target as HTMLInputElement;
24
+ const files = [...(target.files || [])];
25
+ const resultPromises = files.map(processFile);
26
+
27
+ resultPromises.forEach(this.onDetect);
28
+ },
29
+ },
30
+ };
31
+ </script>
@@ -1,42 +1,42 @@
1
- <template lang="html">
2
- <div
3
- @drop.prevent.stop="onDrop"
4
- @dragenter.prevent.stop="onDragOver(true)"
5
- @dragleave.prevent.stop="onDragOver(false)"
6
- @dragover.prevent.stop
7
- >
8
- <slot></slot>
9
- </div>
10
- </template>
11
-
12
- <script>
13
- import { processFile, processUrl } from "../misc/scanner.js";
14
- import CommonAPI from "../mixins/CommonAPI.vue";
15
-
16
- export default {
17
- name: "qrcode-drop-zone",
18
-
19
- mixins: [CommonAPI],
20
-
21
- methods: {
22
- onDragOver(isDraggingOver) {
23
- this.$emit("dragover", isDraggingOver);
24
- },
25
-
26
- onDrop({ dataTransfer }) {
27
- this.onDragOver(false);
28
-
29
- const droppedFiles = [...dataTransfer.files];
30
- const droppedUrl = dataTransfer.getData("text/uri-list");
31
-
32
- droppedFiles.forEach((file) => {
33
- this.onDetect(processFile(file));
34
- });
35
-
36
- if (droppedUrl !== "") {
37
- this.onDetect(processUrl(droppedUrl));
38
- }
39
- },
40
- },
41
- };
42
- </script>
1
+ <template lang="html">
2
+ <div
3
+ @drop.prevent.stop="onDrop"
4
+ @dragenter.prevent.stop="onDragOver(true)"
5
+ @dragleave.prevent.stop="onDragOver(false)"
6
+ @dragover.prevent.stop
7
+ >
8
+ <slot></slot>
9
+ </div>
10
+ </template>
11
+
12
+ <script lang="ts">
13
+ import { processFile, processUrl } from "../misc/scanner";
14
+ import CommonAPI from "../mixins/CommonAPI.vue";
15
+
16
+ export default {
17
+ name: "qrcode-drop-zone",
18
+
19
+ mixins: [CommonAPI],
20
+
21
+ methods: {
22
+ onDragOver(isDraggingOver: boolean) {
23
+ this.$emit("dragover", isDraggingOver);
24
+ },
25
+
26
+ onDrop({ dataTransfer }: DragEvent) {
27
+ this.onDragOver(false);
28
+
29
+ const droppedFiles = [...(dataTransfer?.files || [])];
30
+ const droppedUrl = dataTransfer?.getData("text/uri-list") || "";
31
+
32
+ droppedFiles.forEach((file) => {
33
+ this.onDetect(processFile(file));
34
+ });
35
+
36
+ if (droppedUrl !== "") {
37
+ this.onDetect(processUrl(droppedUrl));
38
+ }
39
+ },
40
+ },
41
+ };
42
+ </script>