UNPKG

seeso

Version:

Eye tracking module for browser and node.js

1,380 lines (1,330 loc) 449 kB
/******/ var __webpack_modules__ = ({ /***/ "./lib/polyfil/ImageCapture-polyfil.js": /*!*********************************************!*\ !*** ./lib/polyfil/ImageCapture-polyfil.js ***! \*********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable */ /** * MediaStream ImageCapture polyfill * * @license * Copyright 2018 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var CustomImageCapture = /*#__PURE__*/function () { /** * TODO https://www.w3.org/TR/image-capture/#constructors * * @param {MediaStreamTrack} videoStreamTrack - A MediaStreamTrack of the 'video' kind */ function CustomImageCapture(videoStreamTrack) { var _this = this; _classCallCheck(this, CustomImageCapture); if (videoStreamTrack.kind !== 'video') throw new DOMException('NotSupportedError'); this._videoStreamTrack = videoStreamTrack; if (!('readyState' in this._videoStreamTrack)) { // Polyfill for Firefox this._videoStreamTrack.readyState = 'live'; } // MediaStream constructor not available until Chrome 55 - https://www.chromestatus.com/feature/5912172546752512 this._previewStream = new MediaStream([videoStreamTrack]); this.videoElement = document.createElement('video'); this.videoElementPlaying = new Promise(function (resolve) { _this.videoElement.addEventListener('playing', resolve); }); if (HTMLMediaElement) { this.videoElement.srcObject = this._previewStream; // Safari 11 doesn't allow use of createObjectURL for MediaStream } else { this.videoElement.src = URL.createObjectURL(this._previewStream); } this.videoElement.muted = true; this.videoElement.setAttribute('playsinline', ''); // Required by Safari on iOS 11. See https://webkit.org/blog/6784 this.videoElement.play(); this.canvasElement = document.createElement('canvas'); // TODO Firefox has https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas this.canvas2dContext = this.canvasElement.getContext('2d'); } /** * https://w3c.github.io/mediacapture-image/index.html#dom-imagecapture-videostreamtrack * @return {MediaStreamTrack} The MediaStreamTrack passed into the constructor */ _createClass(CustomImageCapture, [{ key: "videoStreamTrack", get: function get() { return this._videoStreamTrack; } /** * Implements https://www.w3.org/TR/image-capture/#dom-imagecapture-getphotocapabilities * @return {Promise<PhotoCapabilities>} Fulfilled promise with * [PhotoCapabilities](https://www.w3.org/TR/image-capture/#idl-def-photocapabilities) * object on success, rejected promise on failure */ }, { key: "getPhotoCapabilities", value: function getPhotoCapabilities() { return new Promise(function executorGPC(resolve, reject) { // TODO see https://github.com/w3c/mediacapture-image/issues/97 var MediaSettingsRange = { current: 0, min: 0, max: 0 }; resolve({ exposureCompensation: MediaSettingsRange, exposureMode: 'none', fillLightMode: 'none', focusMode: 'none', imageHeight: MediaSettingsRange, imageWidth: MediaSettingsRange, iso: MediaSettingsRange, redEyeReduction: false, whiteBalanceMode: 'none', zoom: MediaSettingsRange }); reject(new DOMException('OperationError')); }); } /** * Implements https://www.w3.org/TR/image-capture/#dom-imagecapture-setoptions * @param {Object} photoSettings - Photo settings dictionary, https://www.w3.org/TR/image-capture/#idl-def-photosettings * @return {Promise<void>} Fulfilled promise on success, rejected promise on failure */ }, { key: "setOptions", value: function setOptions() { var photoSettings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return new Promise(function executorSO(resolve, reject) { // TODO }); } /** * TODO * Implements https://www.w3.org/TR/image-capture/#dom-imagecapture-takephoto * @return {Promise<Blob>} Fulfilled promise with [Blob](https://www.w3.org/TR/FileAPI/#blob) * argument on success; rejected promise on failure */ }, { key: "takePhoto", value: function takePhoto() { var self = this; return new Promise(function executorTP(resolve, reject) { // `If the readyState of the MediaStreamTrack provided in the constructor is not live, // return a promise rejected with a new DOMException whose name is "InvalidStateError".` if (self._videoStreamTrack.readyState !== 'live') { return reject(new DOMException('InvalidStateError')); } self.videoElementPlaying.then(function () { try { self.canvasElement.width = self.videoElement.videoWidth; self.canvasElement.height = self.videoElement.videoHeight; self.canvas2dContext.drawImage(self.videoElement, 0, 0); self.canvasElement.toBlob(resolve); } catch (error) { reject(new DOMException('UnknownError')); } }); }); } /** * Implements https://www.w3.org/TR/image-capture/#dom-imagecapture-grabframe * @return {Promise<ImageBitmap>} Fulfilled promise with * [ImageBitmap](https://www.w3.org/TR/html51/webappapis.html#webappapis-images) * argument on success; rejected promise on failure */ }, { key: "grabFrame", value: function grabFrame() { var self = this; return new Promise(function executorGF(resolve, reject) { // `If the readyState of the MediaStreamTrack provided in the constructor is not live, // return a promise rejected with a new DOMException whose name is "InvalidStateError".` if (self._videoStreamTrack.readyState !== 'live') { return reject(new DOMException('InvalidStateError')); } self.videoElementPlaying.then(function () { try { self.canvasElement.width = self.videoElement.videoWidth; self.canvasElement.height = self.videoElement.videoHeight; self.canvas2dContext.drawImage(self.videoElement, 0, 0); // TODO polyfill https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmapFactories/createImageBitmap for IE resolve(window.createImageBitmap(self.canvasElement)); } catch (error) { reject(new DOMException('UnknownError')); } }); }); } }, { key: "grabFrameAsImageData", value: function grabFrameAsImageData() { var _this2 = this; return new Promise(function (resolve, reject) { if (_this2._videoStreamTrack.readyState !== 'live') { return reject(new DOMException('InvalidStateError')); } _this2.videoElementPlaying.then(function () { try { var _this2$canvas2dContex, _this2$canvas2dContex2; _this2.canvasElement.width = _this2.videoElement.videoWidth; _this2.canvasElement.height = _this2.videoElement.videoHeight; (_this2$canvas2dContex = _this2.canvas2dContext) === null || _this2$canvas2dContex === void 0 || _this2$canvas2dContex.drawImage(_this2.videoElement, 0, 0); var imageData = (_this2$canvas2dContex2 = _this2.canvas2dContext) === null || _this2$canvas2dContex2 === void 0 ? void 0 : _this2$canvas2dContex2.getImageData(0, 0, _this2.canvasElement.width, _this2.canvasElement.height); if (imageData) { resolve(imageData); } else { reject(new DOMException('UnknownError')); } } catch (error) { reject(new DOMException('UnknownError')); } }); }); } }]); return CustomImageCapture; }(); ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CustomImageCapture); /***/ }), /***/ "./lib/setting/index.js": /*!******************************!*\ !*** ./lib/setting/index.js ***! \******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CALIBRATION_REGION_RATIO: () => (/* binding */ CALIBRATION_REGION_RATIO), /* harmony export */ DEBUG_INTERVAL_TIME_MS: () => (/* binding */ DEBUG_INTERVAL_TIME_MS), /* harmony export */ INTERVAL_TIME_MS: () => (/* binding */ INTERVAL_TIME_MS), /* harmony export */ MAX_FPS: () => (/* binding */ MAX_FPS), /* harmony export */ SEESO_VERSION: () => (/* binding */ SEESO_VERSION), /* harmony export */ getCalibrationServiceUrl: () => (/* binding */ getCalibrationServiceUrl), /* harmony export */ getServerUrl: () => (/* binding */ getServerUrl) /* harmony export */ }); /* eslint-disable */ // export const SEESO_VERSION = `${VERSION}`; var SEESO_VERSION = "2.5.2"; var MAX_FPS = 30; var INTERVAL_TIME_MS = 1000 / MAX_FPS; var DEBUG_INTERVAL_TIME_MS = 1000; var CALIBRATION_REGION_RATIO = 0.90; var getServerUrl = function getServerUrl() { return 'https://console.seeso.io'; }; var getCalibrationServiceUrl = function getCalibrationServiceUrl() { return 'https://calibration.seeso.io/#/service'; }; /***/ }), /***/ "./lib/type/calibration-accuracy-type.js": /*!***********************************************!*\ !*** ./lib/type/calibration-accuracy-type.js ***! \***********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CalibrationAccuracyCriteria: () => (/* binding */ CalibrationAccuracyCriteria) /* harmony export */ }); var CalibrationAccuracyCriteria = Object.freeze({ DEFAULT: 0, LOW: 1, HIGH: 2 }); /***/ }), /***/ "./lib/type/calibration-data.js": /*!**************************************!*\ !*** ./lib/type/calibration-data.js ***! \**************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CalibrationData: () => (/* binding */ CalibrationData) /* harmony export */ }); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } var CalibrationData = /*#__PURE__*/function () { function CalibrationData(input) { _classCallCheck(this, CalibrationData); if (typeof input === "string") { this.constructFromString(input); } else { this.constructFromCalibrationInput(input); } } _createClass(CalibrationData, [{ key: "constructFromString", value: function constructFromString(jsonString) { var calibrationData = JSON.parse(jsonString); var vector = calibrationData.vector, vectorLength = calibrationData.vectorLength, isCameraOnTop = calibrationData.isCameraOnTop, cameraX = calibrationData.cameraX, monitorInch = calibrationData.monitorInch, faceDistance = calibrationData.faceDistance; this.vector = vector; this.vectorLength = vectorLength; this.isCameraOnTop = isCameraOnTop; this.cameraX = cameraX; this.monitorInch = monitorInch; this.faceDistance = faceDistance; } }, { key: "constructFromCalibrationInput", value: function constructFromCalibrationInput(input) { this.vector = input.vector; //b64 string this.vectorLength = input.vectorLength; //b64 길이 this.isCameraOnTop = input.isCameraOnTop; this.cameraX = input.cameraX; this.monitorInch = input.monitorInch; this.faceDistance = input.faceDistance; } }, { key: "to_string", value: function to_string() { return JSON.stringify(this); } }]); return CalibrationData; }(); /***/ }), /***/ "./lib/type/camera-configuration.js": /*!******************************************!*\ !*** ./lib/type/camera-configuration.js ***! \******************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var CameraConfiguration = /*#__PURE__*/_createClass( /** * * @param {string} deviceName * @param {string} modelName * @param {number} resolutionWidth * @param {number} resolutionHeight * @param {number} ppiX * @param {number} ppiY * @param {number} screenOriginX * @param {number} screenOriginY * @param {number} fov * @param {boolean} cameraOnLongerAxis */ function CameraConfiguration(deviceName, modelName, resolutionWidth, resolutionHeight, ppiX, ppiY, screenOriginX, screenOriginY, fov, cameraOnLongerAxis) { _classCallCheck(this, CameraConfiguration); this.deviceName = deviceName; this.modelName = modelName; this.resolutionWidth = resolutionWidth; this.resolutionHeight = resolutionHeight; this.ppiX = ppiX; this.ppiY = ppiY; this.screenOriginX = screenOriginX; this.screenOriginY = screenOriginY; this.fov = fov; this.cameraOnLongerAxis = cameraOnLongerAxis; }); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CameraConfiguration); /***/ }), /***/ "./lib/type/color-format.js": /*!**********************************!*\ !*** ./lib/type/color-format.js ***! \**********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ColorFormat: () => (/* binding */ ColorFormat) /* harmony export */ }); var ColorFormat = Object.freeze({ NV12: 1, NV21: 2, RGB: 3, BGRA: 4, RGBA: 5, ELSE: 6 }); /***/ }), /***/ "./lib/type/error-type.js": /*!********************************!*\ !*** ./lib/type/error-type.js ***! \********************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ InitializationErrorType: () => (/* binding */ InitializationErrorType) /* harmony export */ }); var InitializationErrorType = Object.freeze({ ERROR_NONE: 0, ERROR_INIT: 1, ERROR_CAMERA_PERMISSION: 2, AUTH_INVALID_KEY: 3, /* 3 */ // 잘못된 키(없는 키) AUTH_INVALID_ENV_USED_DEV_IN_PROD: 4, /* 4 */ // dev 키를 prod 에서 사용함 AUTH_INVALID_ENV_USED_PROD_IN_DEV: 5, /* 5 */ // prod 키를 dev 에서 사용함 AUTH_INVALID_PACKAGE_NAME: 6, /* 6 */ // 잘못된 패키지 이름 AUTH_INVALID_APP_SIGNATURE: 7, /* 7 */ // 잘못된 앱 서명 AUTH_EXCEEDED_FREE_TIER: 8, /* 8 */ // 무료 사용량 초과 AUTH_DEACTIVATED_KEY: 9, /* 9 */ // 비 활성화 된 키 AUTH_INVALID_ACCESS: 10, /* 10 */ // 잘못된 접근(ip 차단, 암호화/복호화 실패, 검증 무시 등); 상세한 정보 제공 하지 않음 AUTH_UNKNOWN_ERROR: 11, /* 11 */ // 서버 에서 처리해 주지 못 한 에러 AUTH_SERVER_ERROR: 12, /* 12 */ // 서버 내부 에러 (timeout 등) AUTH_CANNOT_FIND_HOST: 13, /* 13 */ // 인터넷 연결 안되거나 잘못된 주소 AUTH_WRONG_LOCAL_TIME: 14, /* 14 */ // 기기와 서버의 시간 차이가 큰 경우 AUTH_INVALID_KEY_FORMAT: 15, /* 15 */ // 잘못된 라이센스 키 포맷 AUTH_EXPIRED_KEY: 16 /* 16 */ // 만료된 키 (로컬 인증 전용) }); /***/ }), /***/ "./lib/type/face-info.js": /*!*******************************!*\ !*** ./lib/type/face-info.js ***! \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var FaceInfo = /*#__PURE__*/_createClass( /** * * @param {number} timestamp * @param {number} score * @param {number} left * @param {number} top * @param {number} right * @param {number} bottom * @param {number} pitch * @param {number} yaw * @param {number} centerX * @param {number} centerY * @param {number} centerZ */ function FaceInfo(timestamp, score, left, top, right, bottom, pitch, yaw, centerX, centerY, centerZ) { _classCallCheck(this, FaceInfo); this.timestamp = timestamp; this.score = score; this.left = left; this.top = top; this.right = right; this.bottom = bottom; this.pitch = pitch; this.yaw = yaw; this.centerX = centerX; this.centerY = centerY; this.centerZ = centerZ; }); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (FaceInfo); /***/ }), /***/ "./lib/type/gaze-info.js": /*!*******************************!*\ !*** ./lib/type/gaze-info.js ***! \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ EyeMovementState: () => (/* binding */ EyeMovementState), /* harmony export */ TrackingState: () => (/* binding */ TrackingState), /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TrackingState = Object.freeze({ SUCCESS: 0, LOW_CONFIDENCE: 1, UNSUPPORTED: 2, FACE_MISSING: 3 }); var EyeMovementState = Object.freeze({ FIXATION: 0, SACCADE: 2, UNKNOWN: 3 }); var GazeInfo = /*#__PURE__*/_createClass( /** * * @param {number} timestamp * @param {number} x * @param {number} y * @param {number} fixationX * @param {number} fixationY * @param {number} leftOpenness * @param {number} rightOpenness * @param {TrackingState} trackingState * @param {EyeMovementState} eyemovementState */ function GazeInfo(timestamp, x, y, fixationX, fixationY, leftOpenness, rightOpenness, trackingState, eyemovementState) { _classCallCheck(this, GazeInfo); this.timestamp = timestamp; this.x = x; this.y = y; this.fixationX = fixationX; this.fixationY = fixationY; this.leftOpenness = leftOpenness; this.rightOpenness = rightOpenness; this.trackingState = trackingState; this.eyemovementState = eyemovementState; }); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (GazeInfo); /***/ }), /***/ "./lib/type/user-status-option.js": /*!****************************************!*\ !*** ./lib/type/user-status-option.js ***! \****************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } var UserStatusOptions = Object.freeze({ STATUS_ATTENTION: 1, STATUS_BLINK: 2, STATUS_DROWSINESS: 3 }); var UserStatusOption = /*#__PURE__*/function () { /** * * @param {number} isUseAttention * @param {number} isUseBlink * @param {number} isUseDrowsiness */ function UserStatusOption(isUseAttention, isUseBlink, isUseDrowsiness) { _classCallCheck(this, UserStatusOption); this.isUseAttention = isUseAttention; this.isUseBlink = isUseBlink; this.isUseDrowsiness = isUseDrowsiness; } _createClass(UserStatusOption, [{ key: "getUserStatusOptions", value: function getUserStatusOptions() { var list = []; if (this.isUseAttention) { list.push(UserStatusOptions.STATUS_ATTENTION); } if (this.isUseBlink) { list.push(UserStatusOptions.STATUS_BLINK); } if (this.isUseDrowsiness) { list.push(UserStatusOptions.STATUS_DROWSINESS); } return list; } }]); return UserStatusOption; }(); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (UserStatusOption); /***/ }), /***/ "./lib/utils/CameraConfigurationUtil.js": /*!**********************************************!*\ !*** ./lib/utils/CameraConfigurationUtil.js ***! \**********************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ checkAndroid: () => (/* binding */ checkAndroid), /* harmony export */ checkTablet: () => (/* binding */ checkTablet), /* harmony export */ checkiOS: () => (/* binding */ checkiOS), /* harmony export */ loadCameraConfiguration: () => (/* binding */ loadCameraConfiguration), /* harmony export */ requestMobileDevice: () => (/* binding */ requestMobileDevice), /* harmony export */ saveCameraConfiguration: () => (/* binding */ saveCameraConfiguration) /* harmony export */ }); /* harmony import */ var _type_camera_configuration__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../type/camera-configuration */ "./lib/type/camera-configuration.js"); /* harmony import */ var ua_parser_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ua-parser-js */ "./node_modules/ua-parser-js/src/main/ua-parser.mjs"); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } var baseURL = "https://9150tyvbm0.execute-api.ap-northeast-2.amazonaws.com/dev"; var requestAndroid = "/api/v4/web/android"; var requestiOS = "/api/v4/web/ios"; var postDeviceInfoURL = "/api/v4/deviceinfo"; /** * Function to save CameraConfiguration array to localStorage * @param {string} key * @param {CameraConfiguration[]} cameraConfigs */ function saveCameraConfiguration(key, cameraConfigs) { if (cameraConfigs == null || key == null) { return; } var cameraConfigsJson = JSON.stringify(cameraConfigs.map(function (cameraConfig) { return { deviceName: cameraConfig.deviceName, modelName: cameraConfig.modelName, resolution_width: cameraConfig.resolutionWidth, resolution_height: cameraConfig.resolutionHeight, ppiX: cameraConfig.ppiX, ppiY: cameraConfig.ppiY, screenOriginX: cameraConfig.screenOriginX, screenOriginY: cameraConfig.screenOriginY, fov: cameraConfig.fov, cameraOnLongerAxis: cameraConfig.cameraOnLongerAxis }; })); localStorage.setItem(key, cameraConfigsJson); } /** * Function to get CameraConfiguration array from localStorage * @param {string} key * @returns {CameraConfiguration[]} */ function loadCameraConfiguration(key) { var cameraConfigsJson = localStorage.getItem(key); if (cameraConfigsJson === null) { return []; } else { var cameraConfigs = JSON.parse(cameraConfigsJson); return cameraConfigs.map(function (cameraConfig) { return new _type_camera_configuration__WEBPACK_IMPORTED_MODULE_0__["default"](cameraConfig.deviceName, cameraConfig.modelName, cameraConfig.resolution_width, cameraConfig.resolution_height, cameraConfig.ppiX, cameraConfig.ppiY, cameraConfig.screenOriginX, cameraConfig.screenOriginY, cameraConfig.fov, cameraConfig.cameraOnLongerAxis); }); } } function checkAndroid() { return _checkAndroid.apply(this, arguments); } function _checkAndroid() { _checkAndroid = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { var ua, parser, os; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: ua = navigator.userAgent; parser = new ua_parser_js__WEBPACK_IMPORTED_MODULE_1__.UAParser(ua); os = parser.getOS(); if (!(os.name == "Android")) { _context.next = 5; break; } return _context.abrupt("return", true); case 5: return _context.abrupt("return", false); case 6: case "end": return _context.stop(); } }, _callee); })); return _checkAndroid.apply(this, arguments); } function checkiOS() { return _checkiOS.apply(this, arguments); } function _checkiOS() { _checkiOS = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { var parser, os; return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: parser = new ua_parser_js__WEBPACK_IMPORTED_MODULE_1__.UAParser(navigator.userAgent); os = parser.getOS(); if (!(os.name === 'iOS' || os.name === 'iPadOS')) { _context2.next = 4; break; } return _context2.abrupt("return", true); case 4: return _context2.abrupt("return", false); case 5: case "end": return _context2.stop(); } }, _callee2); })); return _checkiOS.apply(this, arguments); } function getAndroidDeviceName() { return _getAndroidDeviceName.apply(this, arguments); } function _getAndroidDeviceName() { _getAndroidDeviceName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { var parser, device, modelName, vendor, hint, hintModelName; return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: parser = new ua_parser_js__WEBPACK_IMPORTED_MODULE_1__.UAParser(); device = parser