@newtonschool/react_proctoring_library 0.0.1 → 0.0.2

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 (65) hide show
  1. package/README.md +70 -66
  2. package/dist/assets/images/newton-school-logo.png +0 -0
  3. package/dist/assets/images/url-video-permission-highlight.png +0 -0
  4. package/dist/assets/images/vid-micro-permissions-given.png +0 -0
  5. package/dist/assets/images/vid-micro-permissions.png +0 -0
  6. package/dist/assets/videos/ask-permission.mp4 +0 -0
  7. package/dist/assets/videos/give-permissions.mp4 +0 -0
  8. package/dist/components/FullScreenPermission.js +84 -0
  9. package/dist/components/FullScreenTestInWebcam.js +22 -10
  10. package/dist/components/ProctorApp.js +92 -0
  11. package/dist/components/ResponseModal.js +24 -16
  12. package/dist/components/activity-tracker/index.js +144 -0
  13. package/dist/components/activity-tracker/index.scss +4 -0
  14. package/dist/components/full-screen-permission.scss +8 -0
  15. package/dist/components/index.js +31 -0
  16. package/dist/components/permissions/audio-video-permission.js +35 -0
  17. package/dist/components/permissions/audio-video-permission.scss +228 -0
  18. package/dist/components/permissions/blocked-permission.js +76 -0
  19. package/dist/components/permissions/full-screen-permission.js +43 -0
  20. package/dist/components/permissions/full-screen-permission.scss +8 -0
  21. package/dist/components/permissions/index.js +70 -0
  22. package/dist/components/permissions/index.scss +6 -0
  23. package/dist/components/permissions/initial-screen.js +52 -0
  24. package/dist/components/permissions/permission-body.js +53 -0
  25. package/dist/constants/defaults.js +38 -0
  26. package/dist/constants/text.js +56 -0
  27. package/dist/demo-code/README.md +70 -0
  28. package/dist/demo-code/package.json +38 -0
  29. package/dist/demo-code/public/favicon.ico +0 -0
  30. package/dist/demo-code/public/index.html +43 -0
  31. package/dist/demo-code/public/logo192.png +0 -0
  32. package/dist/demo-code/public/logo512.png +0 -0
  33. package/dist/demo-code/public/manifest.json +25 -0
  34. package/dist/demo-code/public/robots.txt +3 -0
  35. package/dist/demo-code/src/App.css +38 -0
  36. package/dist/demo-code/src/App.js +29 -0
  37. package/dist/demo-code/src/index.js +11 -0
  38. package/dist/hooks/index.js +39 -0
  39. package/dist/hooks/useAudioVideoPermission.js +96 -0
  40. package/dist/hooks/useAudioVideoPermissions.js +1 -0
  41. package/dist/hooks/useFullScreenData.js +55 -0
  42. package/dist/hooks/useFullScreenStatus.js +45 -0
  43. package/dist/hooks/usePageVisibility.js +31 -0
  44. package/dist/hooks/useTabSwitchCount.js +25 -0
  45. package/dist/hooks/useWebcamData.js +91 -0
  46. package/dist/index.js +5 -3
  47. package/dist/lib/index.js +19 -0
  48. package/dist/utils/ValidityChecks.js +1 -19
  49. package/dist/utils/arrayUtils.js +16 -0
  50. package/dist/utils/breachUtils.js +69 -0
  51. package/dist/utils/browserUtils.js +63 -0
  52. package/dist/utils/{GetBrowserDocumentProp.js → getBrowserDocumentProp.js} +0 -0
  53. package/dist/utils/getGlancePercentage.js +1 -43
  54. package/dist/utils/{GetIsDocumentHidden.js → getIsDocumentHidden.js} +2 -2
  55. package/dist/utils/index.js +49 -29
  56. package/dist/utils/localStorageUtils.js +33 -0
  57. package/dist/utils/webcamMicrophoneUtils.js +115 -0
  58. package/dist/utils/webcamUtils.js +79 -0
  59. package/package.json +55 -55
  60. package/dist/ProctorApp.js +0 -186
  61. package/dist/utils/TabVisibility.js +0 -32
  62. package/dist/utils/commonUtilConfigs.js +0 -21
  63. package/dist/utils/initialSetup.js +0 -15
  64. package/dist/utils/localStorageUtil.js +0 -27
  65. package/dist/utils/useFullScreenStatus.js +0 -45
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WATCHING_SCREEN = exports.VIDEO_UNSUPPORTED_IN_BROWSER = exports.USER_COUNT_LABEL = exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_HEADING = exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_DESC = exports.REQUEST_PERMISSION = exports.PERMISSION_VIDEO = exports.PERMISSION_TITLE = exports.PERMISSION_GENERIC = exports.PERMISSION_FULLSCREEN = exports.PERMISSION_AUDIO_VIDEO = exports.PERMISSION_AUDIO = exports.NO_CAMERA_AVAILABLE = exports.NO_AUDIO_DEVICE_AVAILABLE = exports.NOT_WATCHING_SCREEN = exports.MESSAGE = exports.FULLSCREEN_ERROR_MESSAGE = exports.DENY_FULLSCREEN = exports.CAMERA_UNAVAILABLE_INSECURE_CONN = exports.BROWSER_BLOCKED_PERMISSION_RESOLVED_RECHECK = exports.BROWSER_BLOCKED_PERMISSION_NEXT_STEP = exports.BROWSER_BLOCKED_PERMISSION_DIRECTION = exports.BROWSER_BLOCKED_PERMISSION_DIALOG = exports.BROWSER_BLOCKED_PERMISSION = exports.ALLOW_FULLSCREEN = void 0;
7
+ const WATCHING_SCREEN = "You are watching the screen";
8
+ exports.WATCHING_SCREEN = WATCHING_SCREEN;
9
+ const NOT_WATCHING_SCREEN = "You are not watching the screen";
10
+ exports.NOT_WATCHING_SCREEN = NOT_WATCHING_SCREEN;
11
+ const USER_COUNT_LABEL = "User count";
12
+ exports.USER_COUNT_LABEL = USER_COUNT_LABEL;
13
+ const PERMISSION_TITLE = "Permissions";
14
+ exports.PERMISSION_TITLE = PERMISSION_TITLE;
15
+ const MESSAGE = "This screen can only be accessed in fullscreen mode. Please allow us to switch your screen to fullscreen mode for continuous access of the screen.";
16
+ exports.MESSAGE = MESSAGE;
17
+ const FULLSCREEN_ERROR_MESSAGE = "This screen is only accessible in fullscreen mode";
18
+ exports.FULLSCREEN_ERROR_MESSAGE = FULLSCREEN_ERROR_MESSAGE;
19
+ const DENY_FULLSCREEN = "Deny";
20
+ exports.DENY_FULLSCREEN = DENY_FULLSCREEN;
21
+ const ALLOW_FULLSCREEN = "Switch to Fullscreen";
22
+ exports.ALLOW_FULLSCREEN = ALLOW_FULLSCREEN;
23
+ const NO_CAMERA_AVAILABLE = "No Camera available for use.";
24
+ exports.NO_CAMERA_AVAILABLE = NO_CAMERA_AVAILABLE;
25
+ const NO_AUDIO_DEVICE_AVAILABLE = "No audio device available for use";
26
+ exports.NO_AUDIO_DEVICE_AVAILABLE = NO_AUDIO_DEVICE_AVAILABLE;
27
+ const CAMERA_UNAVAILABLE_INSECURE_CONN = "Camera can only be used in secure connection. Please check that you are in https mode";
28
+ exports.CAMERA_UNAVAILABLE_INSECURE_CONN = CAMERA_UNAVAILABLE_INSECURE_CONN;
29
+ const VIDEO_UNSUPPORTED_IN_BROWSER = "This page requires a browser, such as Google Chrome or Firefox, that supports the video tag.";
30
+ exports.VIDEO_UNSUPPORTED_IN_BROWSER = VIDEO_UNSUPPORTED_IN_BROWSER;
31
+ const BROWSER_BLOCKED_PERMISSION = "It seems your browser is blocked from accessing your camera and microphone.";
32
+ exports.BROWSER_BLOCKED_PERMISSION = BROWSER_BLOCKED_PERMISSION;
33
+ const REQUEST_VIDEO_AUDIO_PERMISSIONS_HEADING = "To access this page, you will need to give us video and audio permissions";
34
+ exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_HEADING = REQUEST_VIDEO_AUDIO_PERMISSIONS_HEADING;
35
+ const REQUEST_VIDEO_AUDIO_PERMISSIONS_DESC = "Without these permissions, you won't be able to access the screen";
36
+ exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_DESC = REQUEST_VIDEO_AUDIO_PERMISSIONS_DESC;
37
+ const REQUEST_PERMISSION = "Request Permission";
38
+ exports.REQUEST_PERMISSION = REQUEST_PERMISSION;
39
+ const BROWSER_BLOCKED_PERMISSION_DIRECTION = "Somewhere near right corner of url bar you will find icon like below, please click it.";
40
+ exports.BROWSER_BLOCKED_PERMISSION_DIRECTION = BROWSER_BLOCKED_PERMISSION_DIRECTION;
41
+ const BROWSER_BLOCKED_PERMISSION_DIALOG = "It will open dialog box like the one shown below, please allow us the permissions.";
42
+ exports.BROWSER_BLOCKED_PERMISSION_DIALOG = BROWSER_BLOCKED_PERMISSION_DIALOG;
43
+ const BROWSER_BLOCKED_PERMISSION_NEXT_STEP = "Click on the button below, after completing above steps.";
44
+ exports.BROWSER_BLOCKED_PERMISSION_NEXT_STEP = BROWSER_BLOCKED_PERMISSION_NEXT_STEP;
45
+ const BROWSER_BLOCKED_PERMISSION_RESOLVED_RECHECK = "I've given permission, Check Again";
46
+ exports.BROWSER_BLOCKED_PERMISSION_RESOLVED_RECHECK = BROWSER_BLOCKED_PERMISSION_RESOLVED_RECHECK;
47
+ const PERMISSION_GENERIC = "This screen requires following permissions for continuous access. Without these permissions, you won't be able to access the screen.";
48
+ exports.PERMISSION_GENERIC = PERMISSION_GENERIC;
49
+ const PERMISSION_FULLSCREEN = "Please allow us to switch your screen to fullscreen mode.";
50
+ exports.PERMISSION_FULLSCREEN = PERMISSION_FULLSCREEN;
51
+ const PERMISSION_AUDIO_VIDEO = "Your browser or system settings have disallowed Microphone and Camera permissions. Please permit this website to access microphone and camera. Refresh after you've given the permission to access the screen";
52
+ exports.PERMISSION_AUDIO_VIDEO = PERMISSION_AUDIO_VIDEO;
53
+ const PERMISSION_VIDEO = "Your browser or system settings have disallowed Camera permissions. Please permit this website to access the camera. Refresh after you've given the permission to access the screen";
54
+ exports.PERMISSION_VIDEO = PERMISSION_VIDEO;
55
+ const PERMISSION_AUDIO = "Your browser or system settings have disallowed Microphone permissions. Please permit this website to access the microphone. Refresh after you've given the permission to access the screen";
56
+ exports.PERMISSION_AUDIO = PERMISSION_AUDIO;
@@ -0,0 +1,70 @@
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13
+
14
+ The page will reload when you make changes.\
15
+ You may also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35
+
36
+ If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39
+
40
+ You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
47
+
48
+ ### Code Splitting
49
+
50
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51
+
52
+ ### Analyzing the Bundle Size
53
+
54
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55
+
56
+ ### Making a Progressive Web App
57
+
58
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59
+
60
+ ### Advanced Configuration
61
+
62
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63
+
64
+ ### Deployment
65
+
66
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67
+
68
+ ### `npm run build` fails to minify
69
+
70
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "demo-code",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "@testing-library/jest-dom": "^5.16.1",
7
+ "@testing-library/react": "^12.1.2",
8
+ "@testing-library/user-event": "^13.5.0",
9
+ "react": "^17.0.2",
10
+ "react_proctoring_library": "0.0.6",
11
+ "react-dom": "^17.0.2",
12
+ "react-scripts": "5.0.0"
13
+ },
14
+ "scripts": {
15
+ "start": "react-scripts start",
16
+ "build": "react-scripts build",
17
+ "test": "react-scripts test",
18
+ "eject": "react-scripts eject"
19
+ },
20
+ "eslintConfig": {
21
+ "extends": [
22
+ "react-app",
23
+ "react-app/jest"
24
+ ]
25
+ },
26
+ "browserslist": {
27
+ "production": [
28
+ ">0.2%",
29
+ "not dead",
30
+ "not op_mini all"
31
+ ],
32
+ "development": [
33
+ "last 1 chrome version",
34
+ "last 1 firefox version",
35
+ "last 1 safari version"
36
+ ]
37
+ }
38
+ }
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
@@ -0,0 +1,25 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,38 @@
1
+ .App {
2
+ text-align: center;
3
+ }
4
+
5
+ .App-logo {
6
+ height: 40vmin;
7
+ pointer-events: none;
8
+ }
9
+
10
+ @media (prefers-reduced-motion: no-preference) {
11
+ .App-logo {
12
+ animation: App-logo-spin infinite 20s linear;
13
+ }
14
+ }
15
+
16
+ .App-header {
17
+ background-color: #282c34;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ justify-content: center;
23
+ font-size: calc(10px + 2vmin);
24
+ color: white;
25
+ }
26
+
27
+ .App-link {
28
+ color: #61dafb;
29
+ }
30
+
31
+ @keyframes App-logo-spin {
32
+ from {
33
+ transform: rotate(0deg);
34
+ }
35
+ to {
36
+ transform: rotate(360deg);
37
+ }
38
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react_proctoring_library = require("react_proctoring_library");
9
+
10
+ require("./App.css");
11
+
12
+ function Test(props) {
13
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "Proctoring Window"));
14
+ }
15
+
16
+ function App() {
17
+ const proctoringIdentifier = "unique-proctoring-identifier";
18
+ const fullScreenMessage = "This test can only be completed in Full Screen Mode, do you want to start this test?";
19
+ return /*#__PURE__*/React.createElement("div", {
20
+ className: "App"
21
+ }, /*#__PURE__*/React.createElement(_react_proctoring_library.ProctorApp, {
22
+ ProctoredComponent: Test,
23
+ proctoringIdentifier: proctoringIdentifier,
24
+ fullScreenMessage: fullScreenMessage
25
+ }));
26
+ }
27
+
28
+ var _default = App;
29
+ exports.default = _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _reactDom = _interopRequireDefault(require("react-dom"));
6
+
7
+ var _App = _interopRequireDefault(require("./App"));
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_react.default.StrictMode, null, /*#__PURE__*/_react.default.createElement(_App.default, null)), document.getElementById('root'));
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useAudioVideoPermissions", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _useAudioVideoPermissions.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "useFullscreenData", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _useFullScreenData.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "usePageVisibility", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _usePageVisibility.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "useTabSwitchCount", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _useTabSwitchCount.default;
28
+ }
29
+ });
30
+
31
+ var _useFullScreenData = _interopRequireDefault(require("./useFullScreenData"));
32
+
33
+ var _usePageVisibility = _interopRequireDefault(require("./usePageVisibility"));
34
+
35
+ var _useTabSwitchCount = _interopRequireDefault(require("./useTabSwitchCount"));
36
+
37
+ var _useAudioVideoPermissions = _interopRequireDefault(require("./useAudioVideoPermissions"));
38
+
39
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useAudioVideoPermissions;
7
+
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+
10
+ require("core-js/modules/es.promise.js");
11
+
12
+ var _react = require("react");
13
+
14
+ var text = _interopRequireWildcard(require("../../constants/text"));
15
+
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+
26
+ function useAudioVideoPermissions() {
27
+ const [errors, setErrors] = (0, _react.useState)({});
28
+ (0, _react.useEffect)(() => {
29
+ const isHTTPs = window.location.protocol === "https:";
30
+
31
+ if (!isHTTPs) {
32
+ setErrors(errors => _objectSpread(_objectSpread({}, errors), {}, {
33
+ isHTTPs: {
34
+ value: false,
35
+ message: text.CAMERA_UNAVAILABLE_INSECURE_CONN
36
+ }
37
+ }));
38
+ return;
39
+ }
40
+
41
+ if (window.navigator && window.navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
42
+ window.navigator.mediaDevices.enumerateDevices().then(devices => {
43
+ let hasVideoInputDevice = false;
44
+ let hasAudioInputDevice = false;
45
+ devices.forEach(device => {
46
+ if (device.kind === "videoinput") {
47
+ hasVideoInputDevice = true;
48
+ } else if (device.kind === "audioinput") {
49
+ hasAudioInputDevice = true;
50
+ }
51
+ });
52
+ return {
53
+ hasVideoInputDevice,
54
+ hasAudioInputDevice
55
+ };
56
+ }).then(hasDevice => {
57
+ if (!hasDevice.hasVideoInputDevice) {
58
+ setErrors(errors => _objectSpread(_objectSpread({}, errors), {}, {
59
+ hasVideoDevice: {
60
+ value: false,
61
+ message: text.NO_CAMERA_AVAILABLE
62
+ }
63
+ }));
64
+ }
65
+
66
+ if (!hasDevice.hasAudioInputDevice) {
67
+ setErrors(errors => _objectSpread(_objectSpread({}, errors), {}, {
68
+ hasAudioDevice: {
69
+ value: false,
70
+ message: text.NO_AUDIO_DEVICE_AVAILABLE
71
+ }
72
+ }));
73
+ }
74
+ });
75
+ }
76
+ }, []);
77
+ const [permissions, setPermissions] = (0, _react.useState)({
78
+ camera: {
79
+ hasPermission: false,
80
+ isBlocked: false
81
+ },
82
+ microphone: {
83
+ hasPermission: false,
84
+ isBlocked: false
85
+ }
86
+ });
87
+
88
+ const checkPermissions = async () => {
89
+ try {} catch (e) {
90
+ if (e.name === "PermissionDeniedError") {// TODO: set error here
91
+ }
92
+ }
93
+ };
94
+
95
+ return [permissions, setPermissions, errors];
96
+ }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useFullscreenData;
7
+
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+
10
+ var _react = require("react");
11
+
12
+ var _defaults = require("../constants/defaults");
13
+
14
+ var _utils = require("../utils");
15
+
16
+ const browserFullscreenElementProp = (0, _utils.getBrowserFullscreenElementProp)();
17
+
18
+ function useFullscreenData() {
19
+ const fullScreenElement = (0, _react.useRef)(document.documentElement);
20
+ const firstFullScreenDone = (0, _react.useRef)(false);
21
+ const [isFullscreen, setIsFullscreen] = (0, _react.useState)(document[browserFullscreenElementProp] != null);
22
+ const [fullScreenExitCount, setFullScreenExitCount] = (0, _react.useState)(_defaults.initialValues.fullScreenExitCount);
23
+ (0, _react.useEffect)(() => {
24
+ if (!isFullscreen && firstFullScreenDone.current) {
25
+ setFullScreenExitCount(fullScreenExitCount => fullScreenExitCount + 1);
26
+ }
27
+
28
+ if (!firstFullScreenDone.current) {
29
+ firstFullScreenDone.current = true;
30
+ }
31
+ }, [isFullscreen]);
32
+
33
+ const setFullscreen = () => {
34
+ if (!fullScreenElement || !fullScreenElement.current) {
35
+ return;
36
+ }
37
+
38
+ fullScreenElement.current.requestFullscreen().then(() => {
39
+ setIsFullscreen(document[browserFullscreenElementProp] != null);
40
+ }).catch(() => {
41
+ setIsFullscreen(false);
42
+ });
43
+ };
44
+
45
+ (0, _react.useEffect)(() => {
46
+ document.onfullscreenchange = () => setIsFullscreen(document[browserFullscreenElementProp] != null);
47
+
48
+ return () => document.onfullscreenchange = undefined;
49
+ }, []);
50
+ return {
51
+ isFullscreen,
52
+ setFullscreen,
53
+ fullScreenExitCount
54
+ };
55
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useFullscreenStatus;
7
+
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+
10
+ var _react = require("react");
11
+
12
+ function useFullscreenStatus(elRef) {
13
+ const [isFullscreen, setIsFullscreen] = (0, _react.useState)(document[getBrowserFullscreenElementProp()] != null);
14
+
15
+ const setFullscreen = () => {
16
+ if (!elRef || !elRef.current) {
17
+ return;
18
+ }
19
+
20
+ elRef.current.requestFullscreen().then(() => {
21
+ setIsFullscreen(document[getBrowserFullscreenElementProp()] != null);
22
+ }).catch(() => {
23
+ setIsFullscreen(false);
24
+ });
25
+ };
26
+
27
+ (0, _react.useEffect)(() => {
28
+ document.onfullscreenchange = () => setIsFullscreen(document[getBrowserFullscreenElementProp()] != null);
29
+
30
+ return () => document.onfullscreenchange = undefined;
31
+ }, []);
32
+ return [isFullscreen, setFullscreen];
33
+ }
34
+
35
+ function getBrowserFullscreenElementProp() {
36
+ if (typeof document.fullscreenElement !== "undefined") {
37
+ return "fullscreenElement";
38
+ } else if (typeof document.mozFullScreenElement !== "undefined") {
39
+ return "mozFullScreenElement";
40
+ } else if (typeof document.msFullscreenElement !== "undefined") {
41
+ return "msFullscreenElement";
42
+ } else if (typeof document.webkitFullscreenElement !== "undefined") {
43
+ return "webkitFullscreenElement";
44
+ }
45
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = usePageVisibility;
7
+
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+
10
+ var _react = require("react");
11
+
12
+ var _utils = require("../utils");
13
+
14
+ const visibilityChangeEvent = (0, _utils.getVisibilityChangeEventName)();
15
+
16
+ function usePageVisibility() {
17
+ const [isVisible, setIsVisible] = (0, _react.useState)((0, _utils.getIsDocumentVisible)());
18
+
19
+ const updateVisibility = () => {
20
+ setIsVisible((0, _utils.getIsDocumentVisible)());
21
+ };
22
+
23
+ (0, _react.useEffect)(() => {
24
+ updateVisibility();
25
+ document.addEventListener(visibilityChangeEvent, updateVisibility, false);
26
+ return () => {
27
+ document.removeEventListener(visibilityChangeEvent, updateVisibility);
28
+ };
29
+ }, []);
30
+ return isVisible;
31
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useTabSwitchCount;
7
+
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+
10
+ var _react = require("react");
11
+
12
+ var _defaults = require("../constants/defaults");
13
+
14
+ var _ = require(".");
15
+
16
+ function useTabSwitchCount() {
17
+ const isTabVisible = (0, _.usePageVisibility)();
18
+ const [tabSwitchCount, setTabSwitchCount] = (0, _react.useState)(_defaults.initialValues.tabSwitchCount);
19
+ (0, _react.useEffect)(() => {
20
+ if (!isTabVisible) {
21
+ setTabSwitchCount(tabSwitchCount => tabSwitchCount + 1);
22
+ }
23
+ }, [isTabVisible]);
24
+ return tabSwitchCount;
25
+ }