camera.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. import { h, Build, forceUpdate } from '@stencil/core';
  2. import './imagecapture';
  3. export class CameraPWA {
  4. constructor() {
  5. // Whether the device has multiple cameras (front/back)
  6. this.hasMultipleCameras = false;
  7. // Whether the device has flash support
  8. this.hasFlash = false;
  9. // Flash modes for camera
  10. this.flashModes = [];
  11. // Current flash mode
  12. this.flashMode = 'off';
  13. this.handlePickFile = (_e) => {
  14. };
  15. this.handleShutterClick = (_e) => {
  16. console.debug('shutter click');
  17. this.capture();
  18. };
  19. this.handleRotateClick = (_e) => {
  20. this.rotate();
  21. };
  22. this.handleClose = (_e) => {
  23. this.handlePhoto && this.handlePhoto(null);
  24. };
  25. this.handleFlashClick = (_e) => {
  26. this.cycleFlash();
  27. };
  28. this.handleCancelPhoto = (_e) => {
  29. const track = this.stream && this.stream.getTracks()[0];
  30. let c = track && track.getConstraints();
  31. this.photo = null;
  32. this.photoSrc = null;
  33. if (c) {
  34. this.initCamera({
  35. video: {
  36. facingMode: c.facingMode
  37. }
  38. });
  39. }
  40. else {
  41. this.initCamera();
  42. }
  43. };
  44. this.handleAcceptPhoto = (_e) => {
  45. this.handlePhoto && this.handlePhoto(this.photo);
  46. };
  47. this.handleFileInputChange = async (e) => {
  48. const input = e.target;
  49. const file = input.files[0];
  50. try {
  51. const orientation = await this.getOrientation(file);
  52. console.debug('Got orientation', orientation);
  53. this.photoOrientation = orientation;
  54. }
  55. catch (e) {
  56. }
  57. this.handlePhoto && this.handlePhoto(file);
  58. };
  59. this.handleVideoMetadata = (e) => {
  60. console.debug('Video metadata', e);
  61. };
  62. this.facingMode = 'user';
  63. this.handlePhoto = undefined;
  64. this.hidePicker = false;
  65. this.handleNoDeviceError = undefined;
  66. this.noDevicesText = 'No camera found';
  67. this.noDevicesButtonText = 'Choose image';
  68. this.photo = undefined;
  69. this.photoSrc = undefined;
  70. this.showShutterOverlay = false;
  71. this.flashIndex = 0;
  72. this.hasCamera = null;
  73. this.rotation = 0;
  74. this.deviceError = null;
  75. }
  76. async componentDidLoad() {
  77. if (Build.isServer) {
  78. return;
  79. }
  80. this.defaultConstraints = {
  81. video: {
  82. facingMode: this.facingMode
  83. }
  84. };
  85. // Figure out how many cameras we have
  86. await this.queryDevices();
  87. // Initialize the camera
  88. await this.initCamera();
  89. }
  90. disconnectedCallback() {
  91. this.stopStream();
  92. this.photoSrc && URL.revokeObjectURL(this.photoSrc);
  93. }
  94. hasImageCapture() {
  95. return 'ImageCapture' in window;
  96. }
  97. /**
  98. * Query the list of connected devices and figure out how many video inputs we have.
  99. */
  100. async queryDevices() {
  101. try {
  102. const devices = await navigator.mediaDevices.enumerateDevices();
  103. const videoDevices = devices.filter(d => d.kind == 'videoinput');
  104. this.hasCamera = !!videoDevices.length;
  105. this.hasMultipleCameras = videoDevices.length > 1;
  106. }
  107. catch (e) {
  108. this.deviceError = e;
  109. }
  110. }
  111. async initCamera(constraints) {
  112. if (!constraints) {
  113. constraints = this.defaultConstraints;
  114. }
  115. try {
  116. const stream = await navigator.mediaDevices.getUserMedia(Object.assign({ video: true, audio: false }, constraints));
  117. this.initStream(stream);
  118. }
  119. catch (e) {
  120. this.deviceError = e;
  121. this.handleNoDeviceError && this.handleNoDeviceError(e);
  122. }
  123. }
  124. async initStream(stream) {
  125. this.stream = stream;
  126. this.videoElement.srcObject = stream;
  127. if (this.hasImageCapture()) {
  128. this.imageCapture = new window.ImageCapture(stream.getVideoTracks()[0]);
  129. await this.initPhotoCapabilities(this.imageCapture);
  130. }
  131. else {
  132. this.deviceError = 'No image capture';
  133. this.handleNoDeviceError && this.handleNoDeviceError();
  134. }
  135. // Always re-render
  136. forceUpdate(this.el);
  137. }
  138. async initPhotoCapabilities(imageCapture) {
  139. const c = await imageCapture.getPhotoCapabilities();
  140. if (c.fillLightMode && c.fillLightMode.length > 1) {
  141. this.flashModes = c.fillLightMode.map(m => m);
  142. // Try to recall the current flash mode
  143. if (this.flashMode) {
  144. this.flashMode = this.flashModes[this.flashModes.indexOf(this.flashMode)] || 'off';
  145. this.flashIndex = this.flashModes.indexOf(this.flashMode) || 0;
  146. }
  147. else {
  148. this.flashIndex = 0;
  149. }
  150. }
  151. }
  152. stopStream() {
  153. if (this.videoElement) {
  154. this.videoElement.srcObject = null;
  155. }
  156. this.stream && this.stream.getTracks().forEach(track => track.stop());
  157. }
  158. async capture() {
  159. if (this.hasImageCapture()) {
  160. try {
  161. const photo = await this.imageCapture.takePhoto({
  162. fillLightMode: this.flashModes.length > 1 ? this.flashMode : undefined
  163. });
  164. await this.flashScreen();
  165. this.promptAccept(photo);
  166. }
  167. catch (e) {
  168. console.error('Unable to take photo!', e);
  169. }
  170. }
  171. this.stopStream();
  172. }
  173. async promptAccept(photo) {
  174. this.photo = photo;
  175. const orientation = await this.getOrientation(photo);
  176. console.debug('Got orientation', orientation);
  177. this.photoOrientation = orientation;
  178. if (orientation) {
  179. switch (orientation) {
  180. case 1:
  181. case 2:
  182. this.rotation = 0;
  183. break;
  184. case 3:
  185. case 4:
  186. this.rotation = 180;
  187. break;
  188. case 5:
  189. case 6:
  190. this.rotation = 90;
  191. break;
  192. case 7:
  193. case 8:
  194. this.rotation = 270;
  195. break;
  196. }
  197. }
  198. this.photoSrc = URL.createObjectURL(photo);
  199. }
  200. getOrientation(file) {
  201. return new Promise(resolve => {
  202. const reader = new FileReader();
  203. reader.onload = (event) => {
  204. const view = new DataView(event.target.result);
  205. if (view.getUint16(0, false) !== 0xFFD8) {
  206. return resolve(-2);
  207. }
  208. const length = view.byteLength;
  209. let offset = 2;
  210. while (offset < length) {
  211. const marker = view.getUint16(offset, false);
  212. offset += 2;
  213. if (marker === 0xFFE1) {
  214. if (view.getUint32(offset += 2, false) !== 0x45786966) {
  215. return resolve(-1);
  216. }
  217. const little = view.getUint16(offset += 6, false) === 0x4949;
  218. offset += view.getUint32(offset + 4, little);
  219. const tags = view.getUint16(offset, little);
  220. offset += 2;
  221. for (let i = 0; i < tags; i++) {
  222. if (view.getUint16(offset + (i * 12), little) === 0x0112) {
  223. return resolve(view.getUint16(offset + (i * 12) + 8, little));
  224. }
  225. }
  226. }
  227. else if ((marker & 0xFF00) !== 0xFF00) {
  228. break;
  229. }
  230. else {
  231. offset += view.getUint16(offset, false);
  232. }
  233. }
  234. return resolve(-1);
  235. };
  236. reader.readAsArrayBuffer(file.slice(0, 64 * 1024));
  237. });
  238. }
  239. rotate() {
  240. this.stopStream();
  241. const track = this.stream && this.stream.getTracks()[0];
  242. if (!track) {
  243. return;
  244. }
  245. let c = track.getConstraints();
  246. let facingMode = c.facingMode;
  247. if (!facingMode) {
  248. let c = track.getCapabilities();
  249. if (c.facingMode) {
  250. facingMode = c.facingMode[0];
  251. }
  252. }
  253. if (facingMode === 'environment') {
  254. this.initCamera({
  255. video: {
  256. facingMode: 'user'
  257. }
  258. });
  259. }
  260. else {
  261. this.initCamera({
  262. video: {
  263. facingMode: 'environment'
  264. }
  265. });
  266. }
  267. }
  268. setFlashMode(mode) {
  269. console.debug('New flash mode: ', mode);
  270. this.flashMode = mode;
  271. }
  272. cycleFlash() {
  273. if (this.flashModes.length > 0) {
  274. this.flashIndex = (this.flashIndex + 1) % this.flashModes.length;
  275. this.setFlashMode(this.flashModes[this.flashIndex]);
  276. }
  277. }
  278. async flashScreen() {
  279. return new Promise((resolve, _reject) => {
  280. this.showShutterOverlay = true;
  281. setTimeout(() => {
  282. this.showShutterOverlay = false;
  283. resolve();
  284. }, 100);
  285. });
  286. }
  287. iconExit() {
  288. return `data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' enable-background='new 0 0 512 512' xml:space='preserve'%3E%3Cg id='Icon_5_'%3E%3Cg%3E%3Cpath fill='%23FFFFFF' d='M402.2,134L378,109.8c-1.6-1.6-4.1-1.6-5.7,0L258.8,223.4c-1.6,1.6-4.1,1.6-5.7,0L139.6,109.8 c-1.6-1.6-4.1-1.6-5.7,0L109.8,134c-1.6,1.6-1.6,4.1,0,5.7l113.5,113.5c1.6,1.6,1.6,4.1,0,5.7L109.8,372.4c-1.6,1.6-1.6,4.1,0,5.7 l24.1,24.1c1.6,1.6,4.1,1.6,5.7,0l113.5-113.5c1.6-1.6,4.1-1.6,5.7,0l113.5,113.5c1.6,1.6,4.1,1.6,5.7,0l24.1-24.1 c1.6-1.6,1.6-4.1,0-5.7L288.6,258.8c-1.6-1.6-1.6-4.1,0-5.7l113.5-113.5C403.7,138.1,403.7,135.5,402.2,134z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E`;
  289. }
  290. iconPhotos() {
  291. return (h("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '512', height: '512', viewBox: '0 0 512 512' }, h("path", { d: 'M450.29,112H142c-34,0-62,27.51-62,61.33V418.67C80,452.49,108,480,142,480H450c34,0,62-26.18,62-60V173.33C512,139.51,484.32,112,450.29,112Zm-77.15,61.34a46,46,0,1,1-46.28,46A46.19,46.19,0,0,1,373.14,173.33Zm-231.55,276c-17,0-29.86-13.75-29.86-30.66V353.85l90.46-80.79a46.54,46.54,0,0,1,63.44,1.83L328.27,337l-113,112.33ZM480,418.67a30.67,30.67,0,0,1-30.71,30.66H259L376.08,333a46.24,46.24,0,0,1,59.44-.16L480,370.59Z' }), h("path", { d: 'M384,32H64A64,64,0,0,0,0,96V352a64.11,64.11,0,0,0,48,62V152a72,72,0,0,1,72-72H446A64.11,64.11,0,0,0,384,32Z' })));
  292. }
  293. iconConfirm() {
  294. return `data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' enable-background='new 0 0 512 512' xml:space='preserve'%3E%3Ccircle fill='%232CD865' cx='256' cy='256' r='256'/%3E%3Cg id='Icon_1_'%3E%3Cg%3E%3Cg%3E%3Cpath fill='%23FFFFFF' d='M208,301.4l-55.4-55.5c-1.5-1.5-4-1.6-5.6-0.1l-23.4,22.3c-1.6,1.6-1.7,4.1-0.1,5.7l81.6,81.4 c3.1,3.1,8.2,3.1,11.3,0l171.8-171.7c1.6-1.6,1.6-4.2-0.1-5.7l-23.4-22.3c-1.6-1.5-4.1-1.5-5.6,0.1L213.7,301.4 C212.1,303,209.6,303,208,301.4z'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E`;
  295. }
  296. iconReverseCamera() {
  297. return `data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' enable-background='new 0 0 512 512' xml:space='preserve'%3E%3Cg%3E%3Cpath fill='%23FFFFFF' d='M352,0H160C72,0,0,72,0,160v192c0,88,72,160,160,160h192c88,0,160-72,160-160V160C512,72,440,0,352,0z M356.7,365.8l-3.7,3.3c-27,23.2-61.4,35.9-96.8,35.9c-72.4,0-135.8-54.7-147-125.6c-0.3-1.9-2-3.3-3.9-3.3H64 c-3.3,0-5.2-3.8-3.2-6.4l61.1-81.4c1.6-2.1,4.7-2.1,6.4-0.1l63.3,81.4c2,2.6,0.2,6.5-3.2,6.5h-40.6c-2.5,0-4.5,2.4-3.9,4.8 c11.5,51.5,59.2,90.6,112.4,90.6c26.4,0,51.8-9.7,73.7-27.9l3.1-2.5c1.6-1.3,3.9-1.1,5.3,0.3l18.5,18.6 C358.5,361.6,358.4,364.3,356.7,365.8z M451.4,245.6l-61,83.5c-1.6,2.2-4.8,2.2-6.4,0.1l-63.3-83.3c-2-2.6-0.1-6.4,3.2-6.4h40.8 c2.5,0,4.4-2.3,3.9-4.8c-5.1-24.2-17.8-46.5-36.5-63.7c-21.2-19.4-48.2-30.1-76-30.1c-26.5,0-52.6,9.7-73.7,27.3l-3.1,2.5 c-1.6,1.3-3.9,1.2-5.4-0.3l-18.5-18.5c-1.6-1.6-1.5-4.3,0.2-5.9l3.5-3.1c27-23.2,61.4-35.9,96.8-35.9c38,0,73.9,13.7,101.2,38.7 c23.2,21.1,40.3,55.2,45.7,90.1c0.3,1.9,1.9,3.4,3.9,3.4h41.3C451.4,239.2,453.3,243,451.4,245.6z'/%3E%3C/g%3E%3C/svg%3E`;
  298. }
  299. iconRetake() {
  300. return `data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' enable-background='new 0 0 512 512' xml:space='preserve'%3E%3Ccircle fill='%23727A87' cx='256' cy='256' r='256'/%3E%3Cg id='Icon_5_'%3E%3Cg%3E%3Cpath fill='%23FFFFFF' d='M394.2,142L370,117.8c-1.6-1.6-4.1-1.6-5.7,0L258.8,223.4c-1.6,1.6-4.1,1.6-5.7,0L147.6,117.8 c-1.6-1.6-4.1-1.6-5.7,0L117.8,142c-1.6,1.6-1.6,4.1,0,5.7l105.5,105.5c1.6,1.6,1.6,4.1,0,5.7L117.8,364.4c-1.6,1.6-1.6,4.1,0,5.7 l24.1,24.1c1.6,1.6,4.1,1.6,5.7,0l105.5-105.5c1.6-1.6,4.1-1.6,5.7,0l105.5,105.5c1.6,1.6,4.1,1.6,5.7,0l24.1-24.1 c1.6-1.6,1.6-4.1,0-5.7L288.6,258.8c-1.6-1.6-1.6-4.1,0-5.7l105.5-105.5C395.7,146.1,395.7,143.5,394.2,142z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E`;
  301. }
  302. iconFlashOff() {
  303. return `data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' style='enable-background:new 0 0 512 512;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M498,483.7L42.3,28L14,56.4l149.8,149.8L91,293.8c-2.5,3-0.1,7.2,3.9,7.2h143.9c1.6,0,2.7,1.3,2.4,2.7 L197.6,507c-1,4.4,5.8,6.9,8.9,3.2l118.6-142.8L469.6,512L498,483.7z'/%3E%3Cpath class='st0' d='M449,218.2c2.5-3,0.1-7.2-3.9-7.2H301.2c-1.6,0-2.7-1.3-2.4-2.7L342.4,5c1-4.4-5.8-6.9-8.9-3.2L214.9,144.6 l161.3,161.3L449,218.2z'/%3E%3C/g%3E%3C/svg%3E`;
  304. }
  305. iconFlashOn() {
  306. return `data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' style='enable-background:new 0 0 512 512;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Cpath class='st0' d='M287.2,211c-1.6,0-2.7-1.3-2.4-2.7L328.4,5c1-4.4-5.8-6.9-8.9-3.2L77,293.8c-2.5,3-0.1,7.2,3.9,7.2h143.9 c1.6,0,2.7,1.3,2.4,2.7L183.6,507c-1,4.4,5.8,6.9,8.9,3.2l242.5-292c2.5-3,0.1-7.2-3.9-7.2L287.2,211L287.2,211z'/%3E%3C/svg%3E`;
  307. }
  308. iconFlashAuto() {
  309. return `data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' style='enable-background:new 0 0 512 512;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23FFFFFF;%7D%0A%3C/style%3E%3Cpath class='st0' d='M287.2,211c-1.6,0-2.7-1.3-2.4-2.7L328.4,5c1-4.4-5.8-6.9-8.9-3.2L77,293.8c-2.5,3-0.1,7.2,3.9,7.2h143.9 c1.6,0,2.7,1.3,2.4,2.7L183.6,507c-1,4.4,5.8,6.9,8.9,3.2l242.5-292c2.5-3,0.1-7.2-3.9-7.2L287.2,211L287.2,211z'/%3E%3Cg%3E%3Cpath class='st0' d='M321.3,186l74-186H438l74,186h-43.5l-11.9-32.5h-80.9l-12,32.5H321.3z M415.8,47.9l-27.2,70.7h54.9l-27.2-70.7 H415.8z'/%3E%3C/g%3E%3C/svg%3E`;
  310. }
  311. render() {
  312. // const acceptStyles = { transform: `rotate(${-this.rotation}deg)` };
  313. const acceptStyles = {};
  314. return (h("div", { class: "camera-wrapper" }, h("div", { class: "camera-header" }, h("section", { class: "items" }, h("div", { class: "item close", onClick: e => this.handleClose(e) }, h("img", { src: this.iconExit() })), h("div", { class: "item flash", onClick: e => this.handleFlashClick(e) }, this.flashModes.length > 0 && (h("div", null, this.flashMode == 'off' ? h("img", { src: this.iconFlashOff() }) : '', this.flashMode == 'auto' ? h("img", { src: this.iconFlashAuto() }) : '', this.flashMode == 'flash' ? h("img", { src: this.iconFlashOn() }) : ''))))), (this.hasCamera === false || !!this.deviceError) && (h("div", { class: "no-device" }, h("h2", null, this.noDevicesText), h("label", { htmlFor: "_pwa-elements-camera-input" }, this.noDevicesButtonText), h("input", { type: "file", id: "_pwa-elements-camera-input", onChange: this.handleFileInputChange, accept: "image/*", class: "select-file-button" }))), this.photoSrc ? (h("div", { class: "accept" }, h("div", { class: "accept-image", style: Object.assign({ backgroundImage: `url(${this.photoSrc})` }, acceptStyles) }))) : (h("div", { class: "camera-video" }, this.showShutterOverlay && (h("div", { class: "shutter-overlay" })), this.hasImageCapture() ? (h("video", { ref: (el) => this.videoElement = el, onLoadedMetaData: this.handleVideoMetadata, autoplay: true, playsinline: true })) : (h("canvas", { ref: (el) => this.canvasElement = el, width: "100%", height: "100%" })), h("canvas", { class: "offscreen-image-render", ref: e => this.offscreenCanvas = e, width: "100%", height: "100%" }))), this.hasCamera && (h("div", { class: "camera-footer" }, !this.photo ? ([
  315. !this.hidePicker && (h("div", { class: "pick-image", onClick: this.handlePickFile }, h("label", { htmlFor: "_pwa-elements-file-pick" }, this.iconPhotos()), h("input", { type: "file", id: "_pwa-elements-file-pick", onChange: this.handleFileInputChange, accept: "image/*", class: "pick-image-button" }))),
  316. h("div", { class: "shutter", onClick: this.handleShutterClick }, h("div", { class: "shutter-button" })),
  317. h("div", { class: "rotate", onClick: this.handleRotateClick }, h("img", { src: this.iconReverseCamera() })),
  318. ]) : (h("section", { class: "items" }, h("div", { class: "item accept-cancel", onClick: e => this.handleCancelPhoto(e) }, h("img", { src: this.iconRetake() })), h("div", { class: "item accept-use", onClick: e => this.handleAcceptPhoto(e) }, h("img", { src: this.iconConfirm() }))))))));
  319. }
  320. static get is() { return "pwa-camera"; }
  321. static get encapsulation() { return "shadow"; }
  322. static get originalStyleUrls() {
  323. return {
  324. "$": ["camera.css"]
  325. };
  326. }
  327. static get styleUrls() {
  328. return {
  329. "$": ["camera.css"]
  330. };
  331. }
  332. static get assetsDirs() { return ["icons"]; }
  333. static get properties() {
  334. return {
  335. "facingMode": {
  336. "type": "string",
  337. "mutable": false,
  338. "complexType": {
  339. "original": "string",
  340. "resolved": "string",
  341. "references": {}
  342. },
  343. "required": false,
  344. "optional": false,
  345. "docs": {
  346. "tags": [],
  347. "text": ""
  348. },
  349. "attribute": "facing-mode",
  350. "reflect": false,
  351. "defaultValue": "'user'"
  352. },
  353. "handlePhoto": {
  354. "type": "unknown",
  355. "mutable": false,
  356. "complexType": {
  357. "original": "(photo: Blob) => void",
  358. "resolved": "(photo: Blob) => void",
  359. "references": {
  360. "Blob": {
  361. "location": "global"
  362. }
  363. }
  364. },
  365. "required": false,
  366. "optional": false,
  367. "docs": {
  368. "tags": [],
  369. "text": ""
  370. }
  371. },
  372. "hidePicker": {
  373. "type": "boolean",
  374. "mutable": false,
  375. "complexType": {
  376. "original": "boolean",
  377. "resolved": "boolean",
  378. "references": {}
  379. },
  380. "required": false,
  381. "optional": false,
  382. "docs": {
  383. "tags": [],
  384. "text": ""
  385. },
  386. "attribute": "hide-picker",
  387. "reflect": false,
  388. "defaultValue": "false"
  389. },
  390. "handleNoDeviceError": {
  391. "type": "unknown",
  392. "mutable": false,
  393. "complexType": {
  394. "original": "(e?: any) => void",
  395. "resolved": "(e?: any) => void",
  396. "references": {}
  397. },
  398. "required": false,
  399. "optional": false,
  400. "docs": {
  401. "tags": [],
  402. "text": ""
  403. }
  404. },
  405. "noDevicesText": {
  406. "type": "string",
  407. "mutable": false,
  408. "complexType": {
  409. "original": "string",
  410. "resolved": "string",
  411. "references": {}
  412. },
  413. "required": false,
  414. "optional": false,
  415. "docs": {
  416. "tags": [],
  417. "text": ""
  418. },
  419. "attribute": "no-devices-text",
  420. "reflect": false,
  421. "defaultValue": "'No camera found'"
  422. },
  423. "noDevicesButtonText": {
  424. "type": "string",
  425. "mutable": false,
  426. "complexType": {
  427. "original": "string",
  428. "resolved": "string",
  429. "references": {}
  430. },
  431. "required": false,
  432. "optional": false,
  433. "docs": {
  434. "tags": [],
  435. "text": ""
  436. },
  437. "attribute": "no-devices-button-text",
  438. "reflect": false,
  439. "defaultValue": "'Choose image'"
  440. }
  441. };
  442. }
  443. static get states() {
  444. return {
  445. "photo": {},
  446. "photoSrc": {},
  447. "showShutterOverlay": {},
  448. "flashIndex": {},
  449. "hasCamera": {},
  450. "rotation": {},
  451. "deviceError": {}
  452. };
  453. }
  454. static get elementRef() { return "el"; }
  455. }