Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor-community/camera-preview

Package Overview
Dependencies
Maintainers
30
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/camera-preview - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

android/.gradle/4.10.1/fileChanges/last-build.bin

5

dist/esm/web.d.ts
import { WebPlugin } from "@capacitor/core";
import { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraPreviewFlashMode } from "./definitions";
export declare class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {
/**
* track which camera is used based on start options
* used in capture
*/
private isBackCamera;
constructor();

@@ -5,0 +10,0 @@ start(options: CameraPreviewOptions): Promise<{}>;

36

dist/esm/web.js

@@ -20,6 +20,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
navigator.mediaDevices.getUserMedia({
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
yield navigator.mediaDevices.getUserMedia({
audio: !options.disableAudio,
video: true
}).then((stream) => {
// Stop any existing stream so we can request media with different constraints based on user input
stream.getTracks().forEach((track) => track.stop());
}).catch(error => {
reject(error);
});

@@ -32,7 +37,19 @@ const video = document.getElementById("video");

videoElement.setAttribute("class", options.className || "");
videoElement.setAttribute("style", "-webkit-transform: scaleX(-1); transform: scaleX(-1);");
// Don't flip video feed if camera is rear facing
if (options.position !== 'rear') {
videoElement.setAttribute("style", "-webkit-transform: scaleX(-1); transform: scaleX(-1);");
}
parent.appendChild(videoElement);
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
// Not adding `{ audio: true }` since we only want video now
navigator.mediaDevices.getUserMedia({ video: true }).then(function (stream) {
const constraints = {
video: true,
};
if (options.position === 'rear') {
constraints.video = { facingMode: 'environment' };
this.isBackCamera = true;
}
else {
this.isBackCamera = false;
}
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
//video.src = window.URL.createObjectURL(stream);

@@ -50,3 +67,3 @@ videoElement.srcObject = stream;

}
});
}));
});

@@ -78,4 +95,7 @@ }

canvas.height = video.videoHeight;
context.translate(video.videoWidth, 0);
context.scale(-1, 1);
// flip horizontally back camera isn't used
if (!this.isBackCamera) {
context.translate(video.videoWidth, 0);
context.scale(-1, 1);
}
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);

@@ -82,0 +102,0 @@ resolve({

{
"name": "@capacitor-community/camera-preview",
"version": "1.2.0",
"version": "1.2.1",
"description": "Camera preview",

@@ -9,3 +9,3 @@ "main": "dist/esm/index.js",

"build": "npm run clean && tsc",
"clean": "rm -rf ./dist",
"clean": "rimraf './dist'",
"watch": "tsc --watch",

@@ -23,2 +23,3 @@ "prepublishOnly": "npm run build",

"@capacitor/ios": "latest",
"rimraf": "latest",
"typescript": "^3.2.4"

@@ -25,0 +26,0 @@ },

@@ -409,1 +409,3 @@ # Capacitor Camera Preview

A working example can be found at [Demo](https://github.com/capacitor-community/camera-preview/tree/master/demo)
To run the demo on your local network and access media devices, a secure context is needed. Add an `.env` file at the root of the demo folder with `HTTPS=true` to start react with HTTPS.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc