├── CONTRIBUTING.md
├── .browserslistrc
├── src
├── index.ts
├── components
│ ├── media-device-kind.ts
│ ├── resolution.ts
│ └── Camera.vue
├── main.ts
├── shims-vue.d.ts
└── App.vue
├── babel.config.js
├── public
├── favicon.ico
└── index.html
├── .prettierrc
├── .gitignore
├── .github
└── workflows
│ ├── publish.yml
│ ├── build.yml
│ └── codeql-analysis.yml
├── .eslintrc.js
├── rollup.config.js
├── tsconfig.json
├── LICENSE
├── package.json
└── README.md
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | All contributions are welcome.
2 |
--------------------------------------------------------------------------------
/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 1%
2 | last 2 versions
3 | not dead
4 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import Camera from "./components/Camera.vue";
2 | export default Camera;
3 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ["@vue/cli-plugin-babel/preset"],
3 | };
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BastiaanJansen/simple-vue-camera/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/src/components/media-device-kind.ts:
--------------------------------------------------------------------------------
1 | export type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput";
2 |
--------------------------------------------------------------------------------
/src/components/resolution.ts:
--------------------------------------------------------------------------------
1 | export interface Resolution {
2 | width: number;
3 | height: number;
4 | }
5 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from "vue";
2 | import App from "./App.vue";
3 |
4 | createApp(App).mount("#app");
5 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "es5",
3 | "tabWidth": 4,
4 | "semi": true,
5 | "singleQuote": false,
6 | "endOfLine": "auto"
7 | }
8 |
--------------------------------------------------------------------------------
/src/shims-vue.d.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | declare module '*.vue' {
3 | import type { DefineComponent } from 'vue'
4 | const component: DefineComponent<{}, {}, any>
5 | export default component
6 | }
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | push:
5 | tags:
6 | - "*"
7 |
8 | jobs:
9 | publish:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v1
13 | - uses: actions/setup-node@v1
14 | with:
15 | node-version: 10
16 | - run: npm install
17 | - run: npm run build-lib
18 | - uses: JS-DevTools/npm-publish@v1
19 | with:
20 | token: ${{ secrets.NPM_TOKEN }}
21 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true,
5 | },
6 | extends: [
7 | "plugin:vue/vue3-essential",
8 | "eslint:recommended",
9 | "@vue/typescript/recommended",
10 | "@vue/prettier",
11 | "@vue/prettier/@typescript-eslint",
12 | ],
13 | parserOptions: {
14 | ecmaVersion: 2020,
15 | },
16 | ignorePatterns: ["dist"],
17 | rules: {
18 | "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
19 | "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
20 | "css.lint.unknownAtRules": 0,
21 | },
22 | };
23 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import vue from "rollup-plugin-vue";
2 | import ts from "rollup-plugin-typescript2";
3 | import postcss from "rollup-plugin-postcss";
4 | import pkg from "./package.json";
5 |
6 | function createEntry(options) {
7 | const config = {
8 | input: "./src/index.ts",
9 | external: ["vue"],
10 | output: {
11 | exports: "default",
12 | file: options.file,
13 | format: options.format,
14 | name: "SimpleVueCamera",
15 | },
16 | plugins: [
17 | vue({
18 | css: true,
19 | compileTemplate: true,
20 | }),
21 | ts(),
22 | postcss(),
23 | ],
24 | };
25 |
26 | return config;
27 | }
28 |
29 | export default [
30 | createEntry({
31 | file: pkg.main,
32 | format: "umd",
33 | }),
34 | ];
35 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | pull_request:
5 | branches: [main, dev]
6 | push:
7 | branches: [main, dev]
8 |
9 | jobs:
10 | run-build:
11 | name: Build application
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - name: Check out Git repository
16 | uses: actions/checkout@v2
17 |
18 | - name: Set up Node.js
19 | uses: actions/setup-node@v1
20 | with:
21 | node-version: 12
22 |
23 | - name: Cache node modules
24 | uses: actions/cache@v2
25 | with:
26 | path: node_modules
27 | key: node-modules-${{ hashFiles('package-lock.json') }}
28 |
29 | - name: Install Node.js dependencies
30 | if: steps.node-cache.outputs.cache-hit != 'true'
31 | run: npm install
32 |
33 | - name: Build app
34 | run: npm run build
35 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "esnext",
5 | "strict": true,
6 | "jsx": "preserve",
7 | "importHelpers": true,
8 | "moduleResolution": "node",
9 | "skipLibCheck": true,
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "sourceMap": true,
13 | "baseUrl": ".",
14 | "types": ["webpack-env"],
15 | "paths": {
16 | "@/*": ["src/*"]
17 | },
18 | "lib": ["esnext", "dom", "dom.iterable", "scripthost"],
19 | "declaration": true,
20 | "declarationDir": "dist"
21 | },
22 | "include": [
23 | "src/**/*.ts",
24 | "src/**/*.tsx",
25 | "src/**/*.vue",
26 | "tests/**/*.ts",
27 | "tests/**/*.tsx",
28 | "src/components/index.js",
29 | "index.ts",
30 | "types/types.d.ts",
31 | "src/index.ts"
32 | ],
33 | "exclude": ["node_modules"]
34 | }
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Bastiaan Jansen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "simple-vue-camera",
3 | "version": "1.1.3",
4 | "private": false,
5 | "main": "./dist/simple-vue-camera.umd.js",
6 | "types": "dist",
7 | "author": {
8 | "name": "Bastiaan Jansen",
9 | "email": "Bastiaanj7@outlook.com"
10 | },
11 | "files": [
12 | "dist",
13 | "README.md"
14 | ],
15 | "keywords": [
16 | "vue",
17 | "vuejs",
18 | "vue-camera",
19 | "camera-component",
20 | "camera",
21 | "webcam"
22 | ],
23 | "license": "MIT",
24 | "scripts": {
25 | "serve": "vue-cli-service serve",
26 | "build": "vue-cli-service build",
27 | "lint": "vue-cli-service lint",
28 | "build-lib": "rollup -c rollup.config.js"
29 | },
30 | "repository": {
31 | "type": "git",
32 | "url": "https://github.com/BastiaanJansen/simple-vue-camera"
33 | },
34 | "description": "A simple to use, but extensive, camera component for Vue 3 with Typescript support to create great camera experiences.",
35 | "dependencies": {},
36 | "devDependencies": {
37 | "@typescript-eslint/eslint-plugin": "^4.18.0",
38 | "@typescript-eslint/parser": "^4.18.0",
39 | "@vue/cli-plugin-babel": "~4.5.0",
40 | "@vue/cli-plugin-eslint": "~4.5.0",
41 | "@vue/cli-plugin-typescript": "~4.5.0",
42 | "@vue/cli-service": "~4.5.0",
43 | "@vue/compiler-sfc": "^3.0.0",
44 | "@vue/eslint-config-prettier": "^6.0.0",
45 | "@vue/eslint-config-typescript": "^7.0.0",
46 | "autoprefixer": "^9.8.6",
47 | "core-js": "^3.6.5",
48 | "css-loader": "^6.2.0",
49 | "eslint": "^6.7.2",
50 | "eslint-plugin-prettier": "^3.3.1",
51 | "eslint-plugin-vue": "^7.0.0",
52 | "postcss": "^8.3.6",
53 | "prettier": "^2.2.1",
54 | "rollup": "^2.56.2",
55 | "rollup-plugin-ignore-import": "^1.3.2",
56 | "rollup-plugin-import-css": "^3.0.0",
57 | "rollup-plugin-node-resolve": "^5.2.0",
58 | "rollup-plugin-postcss": "^4.0.1",
59 | "rollup-plugin-typescript2": "^0.30.0",
60 | "rollup-plugin-vue": "^6.0.0",
61 | "style-loader": "^3.2.1",
62 | "typescript": "~4.1.5",
63 | "webpack": "^4.39.3",
64 | "vue": "^3"
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ main ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ main ]
20 | schedule:
21 | - cron: '36 22 * * 0'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | strategy:
33 | fail-fast: false
34 | matrix:
35 | language: [ 'javascript' ]
36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37 | # Learn more:
38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39 |
40 | steps:
41 | - name: Checkout repository
42 | uses: actions/checkout@v2
43 |
44 | # Initializes the CodeQL tools for scanning.
45 | - name: Initialize CodeQL
46 | uses: github/codeql-action/init@v1
47 | with:
48 | languages: ${{ matrix.language }}
49 | # If you wish to specify custom queries, you can do so here or in a config file.
50 | # By default, queries listed here will override any specified in a config file.
51 | # Prefix the list here with "+" to use these queries and those in the config file.
52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main
53 |
54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55 | # If this step fails, then you should remove it and run the build manually (see below)
56 | - name: Autobuild
57 | uses: github/codeql-action/autobuild@v1
58 |
59 | # ℹ️ Command-line programs to run using the OS shell.
60 | # 📚 https://git.io/JvXDl
61 |
62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63 | # and modify them (or add more) to build your code if your project
64 | # uses a compiled language
65 |
66 | #- run: |
67 | # make bootstrap
68 | # make release
69 |
70 | - name: Perform CodeQL Analysis
71 | uses: github/codeql-action/analyze@v1
72 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | logEvent('error: ' + error)"
8 | >
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
31 |
32 |
33 |
93 |
94 |
100 |
--------------------------------------------------------------------------------
/src/components/Camera.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
186 |
187 |
211 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Simple Vue Camera
2 |
3 | [](https://www.codacy.com/gh/BastiaanJansen/simple-vue-camera/dashboard?utm_source=github.com&utm_medium=referral&utm_content=BastiaanJansen/simple-vue-camera&utm_campaign=Badge_Grade)
4 | 
5 | 
6 |
7 | A simple to use, but extensive, camera component for Vue 3 with Typescript support to create great camera experiences like this:
8 |
9 | [](https://media.giphy.com/media/UuAkrsLaxI5AXDwJuQ/giphy.gif)
10 |
11 | By default, this component does not render any UI elements on top of the video feed, so you can style it and make it your own.
12 |
13 | ## Table of Contents
14 |
15 | - [Installation](#installation)
16 | - [Usage](#usage)
17 | - [Basics](#basics)
18 | - [Snapshots](#snapshots)
19 | - [Camera](#camera)
20 | - [Component information](#component-information)
21 |
22 | ## Installation
23 |
24 | Install Simple Vue Camera with NPM:
25 |
26 | ```
27 | npm install simple-vue-camera
28 | ```
29 |
30 | or, with Yarn:
31 |
32 | ```
33 | yarn add simple-vue-camera
34 | ```
35 |
36 | After installation, you can register the `Camera` component globally in `main.ts`:
37 |
38 | ```ts
39 | import { createApp } from "vue";
40 | import App from "./App.vue";
41 | import Camera from "simple-vue-camera";
42 |
43 | createApp(App).component("camera", Camera).mount("#app");
44 | ```
45 |
46 | or, register it to a specific component:
47 |
48 | ```vue
49 |