Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update react and some other dependencies #36

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'prettier',
'plugin:prettier/recommended',
],
parserOptions: {
Expand Down
9 changes: 5 additions & 4 deletions example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended"
],
parserOptions: {
ecmaVersion: 2018,
Expand Down
28,722 changes: 17,063 additions & 11,659 deletions example/package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"private": true,
"homepage": "https://purple-technology.github.io/react-camera-pro",
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.2.0",
"styled-components": "^4.4.1"
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"styled-components": "^5.2.1"
},
"devDependencies": {
"@types/jest": "^24.0.23",
"@types/node": "^12.12.14",
"@types/react": "^16.9.13",
"@types/react-dom": "^16.9.4",
"@types/styled-components": "^4.4.0",
"@types/styled-components": "^5.0.0",
"gh-pages": "^2.1.1",
"typescript": "^3.7.2"
},
Expand Down
8 changes: 4 additions & 4 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const App = () => {
useEffect(() => {
(async () => {
const devices = await navigator.mediaDevices.enumerateDevices();
const videoDevices = devices.filter(i => i.kind == 'videoinput');
const videoDevices = devices.filter((i) => i.kind == 'videoinput');
setDevices(videoDevices);
})();
});
Expand All @@ -155,7 +155,7 @@ const App = () => {
<Camera
ref={camera}
aspectRatio="cover"
numberOfCamerasCallback={i => setNumberOfCameras(i)}
numberOfCamerasCallback={(i) => setNumberOfCameras(i)}
videoSourceDeviceId={activeDeviceId}
errorMessages={{
noCameraAccessible: 'No camera device accessible. Please connect your camera or try a different browser.',
Expand All @@ -168,11 +168,11 @@ const App = () => {
)}
<Control>
<select
onChange={event => {
onChange={(event) => {
setActiveDeviceId(event.target.value);
}}
>
{devices.map(d => (
{devices.map((d) => (
<option key={d.deviceId} value={d.deviceId}>
{d.label}
</option>
Expand Down
18 changes: 9 additions & 9 deletions example/src/Camera/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ var Camera = React.forwardRef(function (_a, ref) {
}, [numberOfCameras]);
useImperativeHandle(ref, function () { return ({
takePhoto: function () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var _a, _b, _c, _d;
if (numberOfCameras < 1) {
throw new Error(errorMessages.noCameraAccessible);
}
if ((_a = canvas) === null || _a === void 0 ? void 0 : _a.current) {
var playerWidth = ((_c = (_b = player) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.videoWidth) || 1280;
var playerHeight = ((_e = (_d = player) === null || _d === void 0 ? void 0 : _d.current) === null || _e === void 0 ? void 0 : _e.videoHeight) || 720;
if (canvas === null || canvas === void 0 ? void 0 : canvas.current) {
var playerWidth = ((_a = player === null || player === void 0 ? void 0 : player.current) === null || _a === void 0 ? void 0 : _a.videoWidth) || 1280;
var playerHeight = ((_b = player === null || player === void 0 ? void 0 : player.current) === null || _b === void 0 ? void 0 : _b.videoHeight) || 720;
var playerAR = playerWidth / playerHeight;
var canvasWidth = ((_g = (_f = container) === null || _f === void 0 ? void 0 : _f.current) === null || _g === void 0 ? void 0 : _g.offsetWidth) || 1280;
var canvasHeight = ((_j = (_h = container) === null || _h === void 0 ? void 0 : _h.current) === null || _j === void 0 ? void 0 : _j.offsetHeight) || 1280;
var canvasWidth = ((_c = container === null || container === void 0 ? void 0 : container.current) === null || _c === void 0 ? void 0 : _c.offsetWidth) || 1280;
var canvasHeight = ((_d = container === null || container === void 0 ? void 0 : container.current) === null || _d === void 0 ? void 0 : _d.offsetHeight) || 1280;
var canvasAR = canvasWidth / canvasHeight;
var sX = void 0, sY = void 0, sW = void 0, sH = void 0;
if (playerAR > canvasAR) {
Expand All @@ -85,7 +85,7 @@ var Camera = React.forwardRef(function (_a, ref) {
canvas.current.width = sW;
canvas.current.height = sH;
var context = canvas.current.getContext('2d');
if (context && ((_k = player) === null || _k === void 0 ? void 0 : _k.current)) {
if (context && (player === null || player === void 0 ? void 0 : player.current)) {
context.drawImage(player.current, sX, sY, sW, sH, 0, 0, sW, sH);
}
var imgData = canvas.current.toDataURL('image/jpeg');
Expand Down Expand Up @@ -134,7 +134,7 @@ var Camera = React.forwardRef(function (_a, ref) {
});
Camera.displayName = 'Camera';
var initCameraStream = function (stream, setStream, currentFacingMode, videoSourceDeviceId, setNumberOfCameras, setNotSupported, setPermissionDenied) {
var _a, _b;
var _a;
// stop any active streams in the window
if (stream) {
stream.getTracks().forEach(function (track) {
Expand All @@ -150,7 +150,7 @@ var initCameraStream = function (stream, setStream, currentFacingMode, videoSour
height: { ideal: 1920 },
},
};
if ((_b = (_a = navigator) === null || _a === void 0 ? void 0 : _a.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia) {
if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {
navigator.mediaDevices
.getUserMedia(constraints)
.then(function (stream) {
Expand Down
27 changes: 10 additions & 17 deletions example/src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const isLocalhost = Boolean(
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
);

export function register(config) {
Expand All @@ -43,7 +41,7 @@ export function register(config) {
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
'worker. To learn more, visit https://bit.ly/CRA-PWA',
);
});
} else {
Expand All @@ -57,7 +55,7 @@ export function register(config) {
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
Expand All @@ -71,7 +69,7 @@ function registerValidSW(swUrl, config) {
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
);

// Execute callback
Expand All @@ -93,23 +91,20 @@ function registerValidSW(swUrl, config) {
};
};
})
.catch(error => {
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}

function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
if (response.status === 404 || (contentType != null && contentType.indexOf('javascript') === -1)) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
Expand All @@ -120,15 +115,13 @@ function checkValidServiceWorker(swUrl, config) {
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
console.log('No internet connection found. App is running in offline mode.');
});
}

export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister();
});
}
Expand Down
Loading