@uppy/webcam
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0
@@ -7,3 +7,3 @@ "use strict"; | ||
module.exports = props => { | ||
module.exports = () => { | ||
return h("svg", { | ||
@@ -10,0 +10,0 @@ "aria-hidden": "true", |
"use strict"; | ||
var _class, _temp; | ||
var _class, _enableMirror, _temp; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; } | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; } | ||
const { | ||
@@ -15,4 +21,2 @@ h | ||
const Translator = require('@uppy/utils/lib/Translator'); | ||
const getFileTypeExtension = require('@uppy/utils/lib/getFileTypeExtension'); | ||
@@ -79,6 +83,12 @@ | ||
module.exports = (_temp = _class = class Webcam extends UIPlugin { | ||
module.exports = (_temp = (_enableMirror = /*#__PURE__*/_classPrivateFieldLooseKey("enableMirror"), _class = class Webcam extends UIPlugin { | ||
// eslint-disable-next-line global-require | ||
// enableMirror is used to toggle mirroring, for instance when discarding the video, | ||
// while `opts.mirror` is used to remember the initial user setting | ||
constructor(uppy, opts) { | ||
super(uppy, opts); | ||
Object.defineProperty(this, _enableMirror, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.mediaDevices = getMediaDevices(); | ||
@@ -147,2 +157,3 @@ this.supportsUserMedia = !!this.mediaDevices; // eslint-disable-next-line no-restricted-globals | ||
this.title = this.i18n('pluginNameCamera'); | ||
_classPrivateFieldLooseBase(this, _enableMirror)[_enableMirror] = this.opts.mirror; | ||
this.install = this.install.bind(this); | ||
@@ -227,3 +238,7 @@ this.setPluginState = this.setPluginState.bind(this); | ||
this.webcamActive = true; | ||
this.opts.mirror = true; | ||
if (this.opts.mirror) { | ||
_classPrivateFieldLooseBase(this, _enableMirror)[_enableMirror] = true; | ||
} | ||
const constraints = this.getConstraints(options && options.deviceId ? options.deviceId : null); | ||
@@ -373,3 +388,3 @@ this.hasCameraCheck().then(hasCamera => { | ||
}); | ||
this.opts.mirror = false; | ||
_classPrivateFieldLooseBase(this, _enableMirror)[_enableMirror] = false; | ||
} catch (err) { | ||
@@ -395,3 +410,7 @@ // Logging the error, exept restrictions, which is handled in Core | ||
}); | ||
this.opts.mirror = true; | ||
if (this.opts.mirror) { | ||
_classPrivateFieldLooseBase(this, _enableMirror)[_enableMirror] = true; | ||
} | ||
this.capturedMediaFile = null; | ||
@@ -413,16 +432,30 @@ } | ||
stop() { | ||
async stop() { | ||
if (this.stream) { | ||
this.stream.getAudioTracks().forEach(track => { | ||
track.stop(); | ||
const audioTracks = this.stream.getAudioTracks(); | ||
const videoTracks = this.stream.getVideoTracks(); | ||
audioTracks.concat(videoTracks).forEach(track => track.stop()); | ||
} | ||
if (this.recorder) { | ||
await new Promise(resolve => { | ||
this.recorder.addEventListener('stop', resolve, { | ||
once: true | ||
}); | ||
this.recorder.stop(); | ||
if (this.opts.showRecordingLength) { | ||
clearInterval(this.recordingLengthTimer); | ||
} | ||
}); | ||
this.stream.getVideoTracks().forEach(track => { | ||
track.stop(); | ||
}); | ||
} | ||
this.recordingChunks = null; | ||
this.recorder = null; | ||
this.webcamActive = false; | ||
this.stream = null; | ||
this.setPluginState({ | ||
recordedVideo: null | ||
recordedVideo: null, | ||
isRecording: false, | ||
recordingLengthSeconds: 0 | ||
}); | ||
@@ -607,3 +640,3 @@ } | ||
recording: webcamState.isRecording, | ||
mirror: this.opts.mirror, | ||
mirror: _classPrivateFieldLooseBase(this, _enableMirror)[_enableMirror], | ||
src: this.stream | ||
@@ -654,9 +687,10 @@ })); | ||
uninstall() { | ||
if (this.stream) { | ||
this.stop(); | ||
} | ||
this.stop(); | ||
this.unmount(); | ||
} | ||
}, _class.VERSION = "2.0.0-alpha.0", _temp); | ||
onUnmount() { | ||
this.stop(); | ||
} | ||
}), _class.VERSION = "2.0.0", _temp); |
{ | ||
"name": "@uppy/webcam", | ||
"description": "Uppy plugin that takes photos or records videos using the device's camera.", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -29,3 +29,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@uppy/utils": "^4.0.0-alpha.0", | ||
"@uppy/utils": "^4.0.0", | ||
"preact": "^10.5.13" | ||
@@ -36,3 +36,3 @@ }, | ||
}, | ||
"gitHead": "113b627dd0ef5aa5d198dc309dda05da2117dfe5" | ||
"gitHead": "ab771cbe1cd87affd87c97bc983b19058e2e72bd" | ||
} |
const { h } = require('preact') | ||
module.exports = (props) => { | ||
module.exports = () => { | ||
return ( | ||
@@ -5,0 +5,0 @@ <svg aria-hidden="true" focusable="false" fill="#0097DC" width="66" height="55" viewBox="0 0 66 55"> |
const { h } = require('preact') | ||
const { UIPlugin } = require('@uppy/core') | ||
const Translator = require('@uppy/utils/lib/Translator') | ||
const getFileTypeExtension = require('@uppy/utils/lib/getFileTypeExtension') | ||
@@ -57,2 +56,6 @@ const mimeTypes = require('@uppy/utils/lib/mimeTypes') | ||
// enableMirror is used to toggle mirroring, for instance when discarding the video, | ||
// while `opts.mirror` is used to remember the initial user setting | ||
#enableMirror | ||
constructor (uppy, opts) { | ||
@@ -116,2 +119,4 @@ super(uppy, opts) | ||
this.#enableMirror = this.opts.mirror | ||
this.install = this.install.bind(this) | ||
@@ -202,4 +207,7 @@ this.setPluginState = this.setPluginState.bind(this) | ||
this.webcamActive = true | ||
this.opts.mirror = true | ||
if (this.opts.mirror) { | ||
this.#enableMirror = true | ||
} | ||
const constraints = this.getConstraints(options && options.deviceId ? options.deviceId : null) | ||
@@ -350,3 +358,3 @@ | ||
}) | ||
this.opts.mirror = false | ||
this.#enableMirror = false | ||
} catch (err) { | ||
@@ -370,3 +378,7 @@ // Logging the error, exept restrictions, which is handled in Core | ||
this.setPluginState({ recordedVideo: null }) | ||
this.opts.mirror = true | ||
if (this.opts.mirror) { | ||
this.#enableMirror = true | ||
} | ||
this.capturedMediaFile = null | ||
@@ -388,15 +400,30 @@ } | ||
stop () { | ||
async stop () { | ||
if (this.stream) { | ||
this.stream.getAudioTracks().forEach((track) => { | ||
track.stop() | ||
const audioTracks = this.stream.getAudioTracks() | ||
const videoTracks = this.stream.getVideoTracks() | ||
audioTracks.concat(videoTracks).forEach((track) => track.stop()) | ||
} | ||
if (this.recorder) { | ||
await new Promise((resolve) => { | ||
this.recorder.addEventListener('stop', resolve, { once: true }) | ||
this.recorder.stop() | ||
if (this.opts.showRecordingLength) { | ||
clearInterval(this.recordingLengthTimer) | ||
} | ||
}) | ||
this.stream.getVideoTracks().forEach((track) => { | ||
track.stop() | ||
}) | ||
} | ||
this.recordingChunks = null | ||
this.recorder = null | ||
this.webcamActive = false | ||
this.stream = null | ||
this.setPluginState({ | ||
recordedVideo: null, | ||
isRecording: false, | ||
recordingLengthSeconds: 0, | ||
}) | ||
@@ -576,3 +603,3 @@ } | ||
recording={webcamState.isRecording} | ||
mirror={this.opts.mirror} | ||
mirror={this.#enableMirror} | ||
src={this.stream} | ||
@@ -621,8 +648,9 @@ /> | ||
uninstall () { | ||
if (this.stream) { | ||
this.stop() | ||
} | ||
this.stop() | ||
this.unmount() | ||
} | ||
onUnmount () { | ||
this.stop() | ||
} | ||
} |
@@ -11,3 +11,2 @@ import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core' | ||
export interface WebcamOptions extends PluginOptions { | ||
replaceTargetContent?: boolean | ||
target?: PluginTarget | ||
@@ -14,0 +13,0 @@ onBeforeSnapshot?: () => Promise<void> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
141867
2080
0
1
Updated@uppy/utils@^4.0.0