@capgo/camera-preview 6.1.5 → 6.1.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type CameraPosition = \"rear\" | \"front\";\nexport interface CameraPreviewOptions {\n /** Parent element to attach the video preview element to (applicable to the web platform only) */\n parent?: string;\n /** Class name to add to the video preview element (applicable to the web platform only) */\n className?: string;\n /** The preview width in pixels, default window.screen.width */\n width?: number;\n /** The preview height in pixels, default window.screen.height */\n height?: number;\n /** The x origin, default 0 (applicable to the android and ios platforms only) */\n x?: number;\n /** The y origin, default 0 (applicable to the android and ios platforms only) */\n y?: number;\n /** Brings your html in front of your preview, default false (applicable to the android only) */\n toBack?: boolean;\n /** The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) */\n paddingBottom?: number;\n /** Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) */\n rotateWhenOrientationChanged?: boolean;\n /** Choose the camera to use 'front' or 'rear', default 'front' */\n position?: CameraPosition | string;\n /** Defaults to false - Capture images to a file and return the file path instead of returning base64 encoded data */\n storeToFile?: boolean;\n /** Defaults to false - Android Only - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) */\n disableExifHeaderStripping?: boolean;\n /** Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device **/\n enableHighResolution?: boolean;\n /** Defaults to false - Web only - Disables audio stream to prevent permission requests and output switching */\n disableAudio?: boolean;\n /** Android Only - Locks device orientation when camera is showing. */\n lockAndroidOrientation?: boolean;\n /** Defaults to false - Android and Web only. Set if camera preview can change opacity. */\n enableOpacity?: boolean;\n /** Defaults to false - Android only. Set if camera preview will support pinch to zoom. */\n enableZoom?: boolean;\n}\nexport interface CameraPreviewPictureOptions {\n /** The picture height, optional, default 0 (Device default) */\n height?: number;\n /** The picture width, optional, default 0 (Device default) */\n width?: number;\n /** The picture quality, 0 - 100, default 85 */\n quality?: number;\n /** The picture format, jpeg or png, default jpeg on `Web`.\n *\n * quality has no effect on png */\n format?: PictureFormat;\n}\n\nexport type PictureFormat = \"jpeg\" | \"png\";\n\nexport interface CameraSampleOptions {\n /** The picture quality, 0 - 100, default 85 */\n quality?: number;\n}\n\nexport type CameraPreviewFlashMode =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"red-eye\"\n | \"torch\";\n\nexport interface CameraOpacityOptions {\n /** The percent opacity to set for camera view, default 1 */\n opacity?: number;\n}\n\nexport interface CameraPreviewPlugin {\n /**\n * Start the camera preview instance.\n * @param {CameraPreviewOptions} options the options to start the camera preview with\n * @returns {Promise<void>} an Promise that resolves when the instance is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<void>;\n /**\n * Stop the camera preview instance.\n * @returns {Promise<void>} an Promise that resolves when the instance is stopped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stop(): Promise<void>;\n /**\n * Switch camera.\n * @param {CameraPreviewOptions} options the options to switch the camera with\n * @returns {Promise<void>} an Promise that resolves when the camera is switched\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n capture(options: CameraPreviewPictureOptions): Promise<{ value: string }>;\n /**\n * Capture a sample image.\n * @param {CameraSampleOptions} options the options to capture the sample image with\n * @returns {Promise<string>} an Promise that resolves with the sample image as a base64 encoded string\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n /**\n * Get supported flash modes.\n * @returns {Promise<CameraPreviewFlashMode[]>} an Promise that resolves with the supported flash modes\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n /**\n * Get horizontal field of view.\n * @returns {Promise<any>} an Promise that resolves with the horizontal field of view\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: any;\n }>;\n /**\n * Set flash mode.\n * @param options the options to set the flash mode with\n * @returns {Promise<void>} an Promise that resolves when the flash mode is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setFlashMode(options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void>;\n /**\n * Flip camera.\n * @returns {Promise<void>} an Promise that resolves when the camera is flipped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n flip(): Promise<void>;\n /**\n * Set opacity.\n * @param {CameraOpacityOptions} options the options to set the camera opacity with\n * @returns {Promise<void>} an Promise that resolves when the camera color effect is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n /**\n * Stop recording video.\n * @param {CameraPreviewOptions} options the options to stop recording video with\n * @returns {Promise<void>} an Promise that resolves when the camera zoom is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<void>;\n /**\n * Start recording video.\n * @param {CameraPreviewOptions} options the options to start recording video with\n * @returns {Promise<void>} an Promise that resolves when the video recording is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type CameraPosition = 'rear' | 'front'\nexport interface CameraPreviewOptions {\n /** Parent element to attach the video preview element to (applicable to the web platform only) */\n parent?: string\n /** Class name to add to the video preview element (applicable to the web platform only) */\n className?: string\n /** The preview width in pixels, default window.screen.width */\n width?: number\n /** The preview height in pixels, default window.screen.height */\n height?: number\n /** The x origin, default 0 (applicable to the android and ios platforms only) */\n x?: number\n /** The y origin, default 0 (applicable to the android and ios platforms only) */\n y?: number\n /** Brings your html in front of your preview, default false (applicable to the android only) */\n toBack?: boolean\n /** The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) */\n paddingBottom?: number\n /** Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) */\n rotateWhenOrientationChanged?: boolean\n /** Choose the camera to use 'front' or 'rear', default 'front' */\n position?: CameraPosition | string\n /** Defaults to false - Capture images to a file and return the file path instead of returning base64 encoded data */\n storeToFile?: boolean\n /** Defaults to false - Android Only - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) */\n disableExifHeaderStripping?: boolean\n /** Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device */\n enableHighResolution?: boolean\n /** Defaults to false - Web only - Disables audio stream to prevent permission requests and output switching */\n disableAudio?: boolean\n /** Android Only - Locks device orientation when camera is showing. */\n lockAndroidOrientation?: boolean\n /** Defaults to false - Android and Web only. Set if camera preview can change opacity. */\n enableOpacity?: boolean\n /** Defaults to false - Android only. Set if camera preview will support pinch to zoom. */\n enableZoom?: boolean\n}\nexport interface CameraPreviewPictureOptions {\n /** The picture height, optional, default 0 (Device default) */\n height?: number\n /** The picture width, optional, default 0 (Device default) */\n width?: number\n /** The picture quality, 0 - 100, default 85 */\n quality?: number\n /**\n * The picture format, jpeg or png, default jpeg on `Web`.\n *\n * quality has no effect on png\n */\n format?: PictureFormat\n}\n\nexport type PictureFormat = 'jpeg' | 'png'\n\nexport interface CameraSampleOptions {\n /** The picture quality, 0 - 100, default 85 */\n quality?: number\n}\n\nexport type CameraPreviewFlashMode =\n | 'off'\n | 'on'\n | 'auto'\n | 'red-eye'\n | 'torch'\n\nexport interface CameraOpacityOptions {\n /** The percent opacity to set for camera view, default 1 */\n opacity?: number\n}\n\nexport interface CameraPreviewPlugin {\n /**\n * Start the camera preview instance.\n * @param {CameraPreviewOptions} options the options to start the camera preview with\n * @returns {Promise<void>} an Promise that resolves when the instance is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n start: (options: CameraPreviewOptions) => Promise<void>\n /**\n * Stop the camera preview instance.\n * @returns {Promise<void>} an Promise that resolves when the instance is stopped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stop: () => Promise<void>\n /**\n * Switch camera.\n * @param {CameraPreviewOptions} options the options to switch the camera with\n * @returns {Promise<void>} an Promise that resolves when the camera is switched\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n capture: (options: CameraPreviewPictureOptions) => Promise<{ value: string }>\n /**\n * Capture a sample image.\n * @param {CameraSampleOptions} options the options to capture the sample image with\n * @returns {Promise<string>} an Promise that resolves with the sample image as a base64 encoded string\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n captureSample: (options: CameraSampleOptions) => Promise<{ value: string }>\n /**\n * Get supported flash modes.\n * @returns {Promise<CameraPreviewFlashMode[]>} an Promise that resolves with the supported flash modes\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getSupportedFlashModes: () => Promise<{\n result: CameraPreviewFlashMode[]\n }>\n /**\n * Get horizontal field of view.\n * @returns {Promise<any>} an Promise that resolves with the horizontal field of view\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getHorizontalFov: () => Promise<{\n result: any\n }>\n /**\n * Set flash mode.\n * @param options the options to set the flash mode with\n * @returns {Promise<void>} an Promise that resolves when the flash mode is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setFlashMode: (options: {\n flashMode: CameraPreviewFlashMode | string\n }) => Promise<void>\n /**\n * Flip camera.\n * @returns {Promise<void>} an Promise that resolves when the camera is flipped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n flip: () => Promise<void>\n /**\n * Set opacity.\n * @param {CameraOpacityOptions} options the options to set the camera opacity with\n * @returns {Promise<void>} an Promise that resolves when the camera color effect is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setOpacity: (options: CameraOpacityOptions) => Promise<void>\n /**\n * Stop recording video.\n * @param {CameraPreviewOptions} options the options to stop recording video with\n * @returns {Promise<void>} an Promise that resolves when the camera zoom is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stopRecordVideo: () => Promise<void>\n /**\n * Start recording video.\n * @param {CameraPreviewOptions} options the options to start recording video with\n * @returns {Promise<void>} an Promise that resolves when the video recording is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n startRecordVideo: (options: CameraPreviewOptions) => Promise<void>\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { CameraPreviewPlugin } from "./definitions";
1
+ import type { CameraPreviewPlugin } from './definitions';
2
2
  declare const CameraPreview: CameraPreviewPlugin;
3
- export * from "./definitions";
3
+ export * from './definitions';
4
4
  export { CameraPreview };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { registerPlugin } from "@capacitor/core";
2
- const CameraPreview = registerPlugin("CameraPreview", {
3
- web: () => import("./web").then((m) => new m.CameraPreviewWeb()),
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const CameraPreview = registerPlugin('CameraPreview', {
3
+ web: () => import('./web').then(m => new m.CameraPreviewWeb()),
4
4
  });
5
- export * from "./definitions";
5
+ export * from './definitions';
6
6
  export { CameraPreview };
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\n\nimport type { CameraPreviewPlugin } from \"./definitions\";\n\nconst CameraPreview = registerPlugin<CameraPreviewPlugin>(\"CameraPreview\", {\n web: () => import(\"./web\").then((m) => new m.CameraPreviewWeb()),\n});\n\nexport * from \"./definitions\";\nexport { CameraPreview };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIhD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CAC/D,CAAC,CAAA;AAEF,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,CAAA","sourcesContent":["import { registerPlugin } from '@capacitor/core'\n\nimport type { CameraPreviewPlugin } from './definitions'\n\nconst CameraPreview = registerPlugin<CameraPreviewPlugin>('CameraPreview', {\n web: () => import('./web').then(m => new m.CameraPreviewWeb()),\n})\n\nexport * from './definitions'\nexport { CameraPreview }\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { WebPlugin } from "@capacitor/core";
2
- import type { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewFlashMode, CameraSampleOptions, CameraOpacityOptions, CameraPreviewPlugin } from "./definitions";
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { CameraOpacityOptions, CameraPreviewFlashMode, CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraSampleOptions } from './definitions';
3
3
  export declare class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {
4
4
  /**
5
5
  * track which camera is used based on start options
package/dist/esm/web.js CHANGED
@@ -1,9 +1,9 @@
1
- import { WebPlugin } from "@capacitor/core";
1
+ import { WebPlugin } from '@capacitor/core';
2
2
  export class CameraPreviewWeb extends WebPlugin {
3
3
  constructor() {
4
4
  super({
5
- name: "CameraPreview",
6
- platforms: ["web"],
5
+ name: 'CameraPreview',
6
+ platforms: ['web'],
7
7
  });
8
8
  }
9
9
  async start(options) {
@@ -15,30 +15,30 @@ export class CameraPreviewWeb extends WebPlugin {
15
15
  })
16
16
  .then((stream) => {
17
17
  // Stop any existing stream so we can request media with different constraints based on user input
18
- stream.getTracks().forEach((track) => track.stop());
18
+ stream.getTracks().forEach(track => track.stop());
19
19
  })
20
20
  .catch((error) => {
21
21
  Promise.reject(error);
22
22
  });
23
- const video = document.getElementById("video");
23
+ const video = document.getElementById('video');
24
24
  const parent = document.getElementById(options.parent);
25
25
  if (!video) {
26
- const videoElement = document.createElement("video");
27
- videoElement.id = "video";
28
- videoElement.setAttribute("class", options.className || "");
26
+ const videoElement = document.createElement('video');
27
+ videoElement.id = 'video';
28
+ videoElement.setAttribute('class', options.className || '');
29
29
  // Don't flip video feed if camera is rear facing
30
- if (options.position !== "rear") {
31
- videoElement.setAttribute("style", "-webkit-transform: scaleX(-1); transform: scaleX(-1);");
30
+ if (options.position !== 'rear') {
31
+ videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');
32
32
  }
33
33
  const userAgent = navigator.userAgent.toLowerCase();
34
- const isSafari = userAgent.includes("safari") && !userAgent.includes("chrome");
34
+ const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
35
35
  // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful
36
36
  // Without these attributes videoElement.play() will throw a NotAllowedError
37
37
  // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari
38
38
  if (isSafari) {
39
- videoElement.setAttribute("autoplay", "true");
40
- videoElement.setAttribute("muted", "true");
41
- videoElement.setAttribute("playsinline", "true");
39
+ videoElement.setAttribute('autoplay', 'true');
40
+ videoElement.setAttribute('muted', 'true');
41
+ videoElement.setAttribute('playsinline', 'true');
42
42
  }
43
43
  parent.appendChild(videoElement);
44
44
  if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {
@@ -48,45 +48,45 @@ export class CameraPreviewWeb extends WebPlugin {
48
48
  height: { ideal: options.height },
49
49
  },
50
50
  };
51
- if (options.position === "rear") {
52
- constraints.video.facingMode =
53
- "environment";
51
+ if (options.position === 'rear') {
52
+ constraints.video.facingMode
53
+ = 'environment';
54
54
  this.isBackCamera = true;
55
55
  }
56
56
  else {
57
57
  this.isBackCamera = false;
58
58
  }
59
+ // eslint-disable-next-line ts/no-this-alias
59
60
  const self = this;
60
- await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
61
- if (document.getElementById("video")) {
62
- //video.src = window.URL.createObjectURL(stream);
61
+ await navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
62
+ if (document.getElementById('video')) {
63
+ // video.src = window.URL.createObjectURL(stream);
63
64
  videoElement.srcObject = stream;
64
65
  videoElement.play();
65
66
  Promise.resolve({});
66
67
  }
67
68
  else {
68
69
  self.stopStream(stream);
69
- Promise.reject({ message: "camera already stopped" });
70
+ Promise.reject(new Error('camera already stopped'));
70
71
  }
71
72
  }, (err) => {
72
- Promise.reject(err);
73
+ Promise.reject(new Error(err));
73
74
  });
74
75
  }
75
76
  }
76
77
  else {
77
- Promise.reject({ message: "camera already started" });
78
+ Promise.reject(new Error('camera already started'));
78
79
  }
79
80
  }
80
81
  stopStream(stream) {
81
82
  if (stream) {
82
83
  const tracks = stream.getTracks();
83
- for (const track of tracks) {
84
+ for (const track of tracks)
84
85
  track.stop();
85
- }
86
86
  }
87
87
  }
88
88
  async stop() {
89
- const video = document.getElementById("video");
89
+ const video = document.getElementById('video');
90
90
  if (video) {
91
91
  video.pause();
92
92
  this.stopStream(video.srcObject);
@@ -95,16 +95,16 @@ export class CameraPreviewWeb extends WebPlugin {
95
95
  }
96
96
  async capture(options) {
97
97
  return new Promise((resolve, reject) => {
98
- const video = document.getElementById("video");
98
+ const video = document.getElementById('video');
99
99
  if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {
100
- reject({ message: "camera is not running" });
100
+ reject(new Error('camera is not running'));
101
101
  return;
102
102
  }
103
103
  // video.width = video.offsetWidth;
104
104
  let base64EncodedImage;
105
105
  if (video && video.videoWidth > 0 && video.videoHeight > 0) {
106
- const canvas = document.createElement("canvas");
107
- const context = canvas.getContext("2d");
106
+ const canvas = document.createElement('canvas');
107
+ const context = canvas.getContext('2d');
108
108
  canvas.width = video.videoWidth;
109
109
  canvas.height = video.videoHeight;
110
110
  // flip horizontally back camera isn't used
@@ -113,15 +113,15 @@ export class CameraPreviewWeb extends WebPlugin {
113
113
  context.scale(-1, 1);
114
114
  }
115
115
  context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
116
- if ((options.format || "jpeg") === "jpeg") {
116
+ if ((options.format || 'jpeg') === 'jpeg') {
117
117
  base64EncodedImage = canvas
118
- .toDataURL("image/jpeg", (options.quality || 85) / 100.0)
119
- .replace("data:image/jpeg;base64,", "");
118
+ .toDataURL('image/jpeg', (options.quality || 85) / 100.0)
119
+ .replace('data:image/jpeg;base64,', '');
120
120
  }
121
121
  else {
122
122
  base64EncodedImage = canvas
123
- .toDataURL("image/png")
124
- .replace("data:image/png;base64,", "");
123
+ .toDataURL('image/png')
124
+ .replace('data:image/png;base64,', '');
125
125
  }
126
126
  }
127
127
  resolve({
@@ -133,28 +133,27 @@ export class CameraPreviewWeb extends WebPlugin {
133
133
  return this.capture(_options);
134
134
  }
135
135
  async stopRecordVideo() {
136
- throw new Error("stopRecordVideo not supported under the web platform");
136
+ throw new Error('stopRecordVideo not supported under the web platform');
137
137
  }
138
138
  async startRecordVideo(_options) {
139
- throw new Error("startRecordVideo not supported under the web platform");
139
+ throw new Error('startRecordVideo not supported under the web platform');
140
140
  }
141
141
  async getSupportedFlashModes() {
142
- throw new Error("getSupportedFlashModes not supported under the web platform");
142
+ throw new Error('getSupportedFlashModes not supported under the web platform');
143
143
  }
144
144
  async getHorizontalFov() {
145
- throw new Error("getHorizontalFov not supported under the web platform");
145
+ throw new Error('getHorizontalFov not supported under the web platform');
146
146
  }
147
147
  async setFlashMode(_options) {
148
- throw new Error("setFlashMode not supported under the web platform" + _options);
148
+ throw new Error(`setFlashMode not supported under the web platform${_options}`);
149
149
  }
150
150
  async flip() {
151
- throw new Error("flip not supported under the web platform");
151
+ throw new Error('flip not supported under the web platform');
152
152
  }
153
153
  async setOpacity(_options) {
154
- const video = document.getElementById("video");
155
- if (!!video && !!_options["opacity"]) {
156
- video.style.setProperty("opacity", _options["opacity"].toString());
157
- }
154
+ const video = document.getElementById('video');
155
+ if (!!video && !!_options.opacity)
156
+ video.style.setProperty('opacity', _options.opacity.toString());
158
157
  }
159
158
  }
160
159
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAO7C;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,KAAK,CAAC;SACnB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA6B;;QACvC,MAAM,SAAS,CAAC,YAAY;aACzB,YAAY,CAAC;YACZ,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;YAC5B,KAAK,EAAE,IAAI;SACZ,CAAC;aACD,IAAI,CAAC,CAAC,MAAmB,EAAE,EAAE;YAC5B,kGAAkG;YAClG,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;QAEL,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,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C,UAAU,CAAC,QAA8B;QAC7C,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAqB,CAAC;QACnE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n CameraPreviewOptions,\n CameraPreviewPictureOptions,\n CameraPreviewFlashMode,\n CameraSampleOptions,\n CameraOpacityOptions,\n CameraPreviewPlugin,\n} from \"./definitions\";\n\nexport class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {\n /**\n * track which camera is used based on start options\n * used in capture\n */\n private isBackCamera: boolean;\n\n constructor() {\n super({\n name: \"CameraPreview\",\n platforms: [\"web\"],\n });\n }\n\n async start(options: CameraPreviewOptions): Promise<void> {\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream: MediaStream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n Promise.reject(error);\n });\n\n const video = document.getElementById(\"video\");\n const parent = document.getElementById(options.parent);\n\n if (!video) {\n const videoElement = document.createElement(\"video\");\n videoElement.id = \"video\";\n videoElement.setAttribute(\"class\", options.className || \"\");\n\n // Don't flip video feed if camera is rear facing\n if (options.position !== \"rear\") {\n videoElement.setAttribute(\n \"style\",\n \"-webkit-transform: scaleX(-1); transform: scaleX(-1);\",\n );\n }\n\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari =\n userAgent.includes(\"safari\") && !userAgent.includes(\"chrome\");\n\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute(\"autoplay\", \"true\");\n videoElement.setAttribute(\"muted\", \"true\");\n videoElement.setAttribute(\"playsinline\", \"true\");\n }\n\n parent.appendChild(videoElement);\n\n if (navigator?.mediaDevices?.getUserMedia) {\n const constraints: MediaStreamConstraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n\n if (options.position === \"rear\") {\n (constraints.video as MediaTrackConstraints).facingMode =\n \"environment\";\n this.isBackCamera = true;\n } else {\n this.isBackCamera = false;\n }\n\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(\n function (stream) {\n if (document.getElementById(\"video\")) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n } else {\n self.stopStream(stream);\n Promise.reject({ message: \"camera already stopped\" });\n }\n },\n (err) => {\n Promise.reject(err);\n },\n );\n }\n } else {\n Promise.reject({ message: \"camera already started\" });\n }\n }\n\n private stopStream(stream: any) {\n if (stream) {\n const tracks = stream.getTracks();\n\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n\n async stop(): Promise<any> {\n const video = document.getElementById(\"video\") as HTMLVideoElement;\n if (video) {\n video.pause();\n\n this.stopStream(video.srcObject);\n\n video.remove();\n }\n }\n\n async capture(options: CameraPreviewPictureOptions): Promise<any> {\n return new Promise((resolve, reject) => {\n const video = document.getElementById(\"video\") as HTMLVideoElement;\n if (!video?.srcObject) {\n reject({ message: \"camera is not running\" });\n return;\n }\n\n // video.width = video.offsetWidth;\n\n let base64EncodedImage;\n\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n\n if ((options.format || \"jpeg\") === \"jpeg\") {\n base64EncodedImage = canvas\n .toDataURL(\"image/jpeg\", (options.quality || 85) / 100.0)\n .replace(\"data:image/jpeg;base64,\", \"\");\n } else {\n base64EncodedImage = canvas\n .toDataURL(\"image/png\")\n .replace(\"data:image/png;base64,\", \"\");\n }\n }\n\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n\n async captureSample(_options: CameraSampleOptions): Promise<any> {\n return this.capture(_options);\n }\n\n async stopRecordVideo(): Promise<any> {\n throw new Error(\"stopRecordVideo not supported under the web platform\");\n }\n\n async startRecordVideo(_options: CameraPreviewOptions): Promise<any> {\n throw new Error(\"startRecordVideo not supported under the web platform\");\n }\n\n async getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }> {\n throw new Error(\n \"getSupportedFlashModes not supported under the web platform\",\n );\n }\n\n async getHorizontalFov(): Promise<{\n result: any;\n }> {\n throw new Error(\"getHorizontalFov not supported under the web platform\");\n }\n\n async setFlashMode(_options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void> {\n throw new Error(\n \"setFlashMode not supported under the web platform\" + _options,\n );\n }\n\n async flip(): Promise<void> {\n throw new Error(\"flip not supported under the web platform\");\n }\n\n async setOpacity(_options: CameraOpacityOptions): Promise<any> {\n const video = document.getElementById(\"video\") as HTMLVideoElement;\n if (!!video && !!_options[\"opacity\"]) {\n video.style.setProperty(\"opacity\", _options[\"opacity\"].toString());\n }\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAW3C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAO7C;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,KAAK,CAAC;SACnB,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA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Q,CAAC,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;IACzE,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAA8B;QACnD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;IAC1E,CAAC;IAED,KAAK,CAAC,sBAAsB;QAG1B,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAA;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB;QAGpB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAA;IAC1E,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAElB;QACC,MAAM,IAAI,KAAK,CACb,oDAAoD,QAAQ,EAAE,CAC/D,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA8B;QAC7C,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAqB,CAAA;QAClE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO;YAC/B,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IACnE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core'\n\nimport type {\n CameraOpacityOptions,\n CameraPreviewFlashMode,\n CameraPreviewOptions,\n CameraPreviewPictureOptions,\n CameraPreviewPlugin,\n CameraSampleOptions,\n} from './definitions'\n\nexport class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {\n /**\n * track which camera is used based on start options\n * used in capture\n */\n private isBackCamera: boolean\n\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n })\n }\n\n async start(options: CameraPreviewOptions): Promise<void> {\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream: MediaStream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach(track => track.stop())\n })\n .catch((error) => {\n Promise.reject(error)\n })\n\n const video = document.getElementById('video')\n const parent = document.getElementById(options.parent)\n\n if (!video) {\n const videoElement = document.createElement('video')\n videoElement.id = 'video'\n videoElement.setAttribute('class', options.className || '')\n\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute(\n 'style',\n '-webkit-transform: scaleX(-1); transform: scaleX(-1);',\n )\n }\n\n const userAgent = navigator.userAgent.toLowerCase()\n const isSafari\n = userAgent.includes('safari') && !userAgent.includes('chrome')\n\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true')\n videoElement.setAttribute('muted', 'true')\n videoElement.setAttribute('playsinline', 'true')\n }\n\n parent.appendChild(videoElement)\n\n if (navigator?.mediaDevices?.getUserMedia) {\n const constraints: MediaStreamConstraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n }\n\n if (options.position === 'rear') {\n (constraints.video as MediaTrackConstraints).facingMode\n = 'environment'\n this.isBackCamera = true\n }\n else {\n this.isBackCamera = false\n }\n\n // eslint-disable-next-line ts/no-this-alias\n const self = this\n await navigator.mediaDevices.getUserMedia(constraints).then(\n (stream) => {\n if (document.getElementById('video')) {\n // video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream\n videoElement.play()\n Promise.resolve({})\n }\n else {\n self.stopStream(stream)\n Promise.reject(new Error('camera already stopped'))\n }\n },\n (err) => {\n Promise.reject(new Error(err))\n },\n )\n }\n }\n else {\n Promise.reject(new Error('camera already started'))\n }\n }\n\n private stopStream(stream: any) {\n if (stream) {\n const tracks = stream.getTracks()\n\n for (const track of tracks) track.stop()\n }\n }\n\n async stop(): Promise<any> {\n const video = document.getElementById('video') as HTMLVideoElement\n if (video) {\n video.pause()\n\n this.stopStream(video.srcObject)\n\n video.remove()\n }\n }\n\n async capture(options: CameraPreviewPictureOptions): Promise<any> {\n return new Promise((resolve, reject) => {\n const video = document.getElementById('video') as HTMLVideoElement\n if (!video?.srcObject) {\n reject(new Error('camera is not running'))\n return\n }\n\n // video.width = video.offsetWidth;\n\n let base64EncodedImage\n\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement('canvas')\n const context = canvas.getContext('2d')\n canvas.width = video.videoWidth\n canvas.height = video.videoHeight\n\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0)\n context.scale(-1, 1)\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight)\n\n if ((options.format || 'jpeg') === 'jpeg') {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', (options.quality || 85) / 100.0)\n .replace('data:image/jpeg;base64,', '')\n }\n else {\n base64EncodedImage = canvas\n .toDataURL('image/png')\n .replace('data:image/png;base64,', '')\n }\n }\n\n resolve({\n value: base64EncodedImage,\n })\n })\n }\n\n async captureSample(_options: CameraSampleOptions): Promise<any> {\n return this.capture(_options)\n }\n\n async stopRecordVideo(): Promise<any> {\n throw new Error('stopRecordVideo not supported under the web platform')\n }\n\n async startRecordVideo(_options: CameraPreviewOptions): Promise<any> {\n throw new Error('startRecordVideo not supported under the web platform')\n }\n\n async getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[]\n }> {\n throw new Error(\n 'getSupportedFlashModes not supported under the web platform',\n )\n }\n\n async getHorizontalFov(): Promise<{\n result: any\n }> {\n throw new Error('getHorizontalFov not supported under the web platform')\n }\n\n async setFlashMode(_options: {\n flashMode: CameraPreviewFlashMode | string\n }): Promise<void> {\n throw new Error(\n `setFlashMode not supported under the web platform${_options}`,\n )\n }\n\n async flip(): Promise<void> {\n throw new Error('flip not supported under the web platform')\n }\n\n async setOpacity(_options: CameraOpacityOptions): Promise<any> {\n const video = document.getElementById('video') as HTMLVideoElement\n if (!!video && !!_options.opacity)\n video.style.setProperty('opacity', _options.opacity.toString())\n }\n}\n"]}
@@ -2,15 +2,15 @@
2
2
 
3
3
  var core = require('@capacitor/core');
4
4
 
5
- const CameraPreview = core.registerPlugin("CameraPreview", {
6
- web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CameraPreviewWeb()),
5
+ const CameraPreview = core.registerPlugin('CameraPreview', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CameraPreviewWeb()),
7
7
  });
8
8
 
9
9
  class CameraPreviewWeb extends core.WebPlugin {
10
10
  constructor() {
11
11
  super({
12
- name: "CameraPreview",
13
- platforms: ["web"],
12
+ name: 'CameraPreview',
13
+ platforms: ['web'],
14
14
  });
15
15
  }
16
16
  async start(options) {
@@ -22,30 +22,30 @@ class CameraPreviewWeb extends core.WebPlugin {
22
22
  })
23
23
  .then((stream) => {
24
24
  // Stop any existing stream so we can request media with different constraints based on user input
25
- stream.getTracks().forEach((track) => track.stop());
25
+ stream.getTracks().forEach(track => track.stop());
26
26
  })
27
27
  .catch((error) => {
28
28
  Promise.reject(error);
29
29
  });
30
- const video = document.getElementById("video");
30
+ const video = document.getElementById('video');
31
31
  const parent = document.getElementById(options.parent);
32
32
  if (!video) {
33
- const videoElement = document.createElement("video");
34
- videoElement.id = "video";
35
- videoElement.setAttribute("class", options.className || "");
33
+ const videoElement = document.createElement('video');
34
+ videoElement.id = 'video';
35
+ videoElement.setAttribute('class', options.className || '');
36
36
  // Don't flip video feed if camera is rear facing
37
- if (options.position !== "rear") {
38
- videoElement.setAttribute("style", "-webkit-transform: scaleX(-1); transform: scaleX(-1);");
37
+ if (options.position !== 'rear') {
38
+ videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');
39
39
  }
40
40
  const userAgent = navigator.userAgent.toLowerCase();
41
- const isSafari = userAgent.includes("safari") && !userAgent.includes("chrome");
41
+ const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
42
42
  // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful
43
43
  // Without these attributes videoElement.play() will throw a NotAllowedError
44
44
  // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari
45
45
  if (isSafari) {
46
- videoElement.setAttribute("autoplay", "true");
47
- videoElement.setAttribute("muted", "true");
48
- videoElement.setAttribute("playsinline", "true");
46
+ videoElement.setAttribute('autoplay', 'true');
47
+ videoElement.setAttribute('muted', 'true');
48
+ videoElement.setAttribute('playsinline', 'true');
49
49
  }
50
50
  parent.appendChild(videoElement);
51
51
  if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {
@@ -55,45 +55,45 @@ class CameraPreviewWeb extends core.WebPlugin {
55
55
  height: { ideal: options.height },
56
56
  },
57
57
  };
58
- if (options.position === "rear") {
59
- constraints.video.facingMode =
60
- "environment";
58
+ if (options.position === 'rear') {
59
+ constraints.video.facingMode
60
+ = 'environment';
61
61
  this.isBackCamera = true;
62
62
  }
63
63
  else {
64
64
  this.isBackCamera = false;
65
65
  }
66
+ // eslint-disable-next-line ts/no-this-alias
66
67
  const self = this;
67
- await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
68
- if (document.getElementById("video")) {
69
- //video.src = window.URL.createObjectURL(stream);
68
+ await navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
69
+ if (document.getElementById('video')) {
70
+ // video.src = window.URL.createObjectURL(stream);
70
71
  videoElement.srcObject = stream;
71
72
  videoElement.play();
72
73
  Promise.resolve({});
73
74
  }
74
75
  else {
75
76
  self.stopStream(stream);
76
- Promise.reject({ message: "camera already stopped" });
77
+ Promise.reject(new Error('camera already stopped'));
77
78
  }
78
79
  }, (err) => {
79
- Promise.reject(err);
80
+ Promise.reject(new Error(err));
80
81
  });
81
82
  }
82
83
  }
83
84
  else {
84
- Promise.reject({ message: "camera already started" });
85
+ Promise.reject(new Error('camera already started'));
85
86
  }
86
87
  }
87
88
  stopStream(stream) {
88
89
  if (stream) {
89
90
  const tracks = stream.getTracks();
90
- for (const track of tracks) {
91
+ for (const track of tracks)
91
92
  track.stop();
92
- }
93
93
  }
94
94
  }
95
95
  async stop() {
96
- const video = document.getElementById("video");
96
+ const video = document.getElementById('video');
97
97
  if (video) {
98
98
  video.pause();
99
99
  this.stopStream(video.srcObject);
@@ -102,16 +102,16 @@ class CameraPreviewWeb extends core.WebPlugin {
102
102
  }
103
103
  async capture(options) {
104
104
  return new Promise((resolve, reject) => {
105
- const video = document.getElementById("video");
105
+ const video = document.getElementById('video');
106
106
  if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {
107
- reject({ message: "camera is not running" });
107
+ reject(new Error('camera is not running'));
108
108
  return;
109
109
  }
110
110
  // video.width = video.offsetWidth;
111
111
  let base64EncodedImage;
112
112
  if (video && video.videoWidth > 0 && video.videoHeight > 0) {
113
- const canvas = document.createElement("canvas");
114
- const context = canvas.getContext("2d");
113
+ const canvas = document.createElement('canvas');
114
+ const context = canvas.getContext('2d');
115
115
  canvas.width = video.videoWidth;
116
116
  canvas.height = video.videoHeight;
117
117
  // flip horizontally back camera isn't used
@@ -120,15 +120,15 @@ class CameraPreviewWeb extends core.WebPlugin {
120
120
  context.scale(-1, 1);
121
121
  }
122
122
  context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
123
- if ((options.format || "jpeg") === "jpeg") {
123
+ if ((options.format || 'jpeg') === 'jpeg') {
124
124
  base64EncodedImage = canvas
125
- .toDataURL("image/jpeg", (options.quality || 85) / 100.0)
126
- .replace("data:image/jpeg;base64,", "");
125
+ .toDataURL('image/jpeg', (options.quality || 85) / 100.0)
126
+ .replace('data:image/jpeg;base64,', '');
127
127
  }
128
128
  else {
129
129
  base64EncodedImage = canvas
130
- .toDataURL("image/png")
131
- .replace("data:image/png;base64,", "");
130
+ .toDataURL('image/png')
131
+ .replace('data:image/png;base64,', '');
132
132
  }
133
133
  }
134
134
  resolve({
@@ -140,28 +140,27 @@ class CameraPreviewWeb extends core.WebPlugin {
140
140
  return this.capture(_options);
141
141
  }
142
142
  async stopRecordVideo() {
143
- throw new Error("stopRecordVideo not supported under the web platform");
143
+ throw new Error('stopRecordVideo not supported under the web platform');
144
144
  }
145
145
  async startRecordVideo(_options) {
146
- throw new Error("startRecordVideo not supported under the web platform");
146
+ throw new Error('startRecordVideo not supported under the web platform');
147
147
  }
148
148
  async getSupportedFlashModes() {
149
- throw new Error("getSupportedFlashModes not supported under the web platform");
149
+ throw new Error('getSupportedFlashModes not supported under the web platform');
150
150
  }
151
151
  async getHorizontalFov() {
152
- throw new Error("getHorizontalFov not supported under the web platform");
152
+ throw new Error('getHorizontalFov not supported under the web platform');
153
153
  }
154
154
  async setFlashMode(_options) {
155
- throw new Error("setFlashMode not supported under the web platform" + _options);
155
+ throw new Error(`setFlashMode not supported under the web platform${_options}`);
156
156
  }
157
157
  async flip() {
158
- throw new Error("flip not supported under the web platform");
158
+ throw new Error('flip not supported under the web platform');
159
159
  }
160
160
  async setOpacity(_options) {
161
- const video = document.getElementById("video");
162
- if (!!video && !!_options["opacity"]) {
163
- video.style.setProperty("opacity", _options["opacity"].toString());
164
- }
161
+ const video = document.getElementById('video');
162
+ if (!!video && !!_options.opacity)
163
+ video.style.setProperty('opacity', _options.opacity.toString());
165
164
  }
166
165
  }
167
166
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst CameraPreview = registerPlugin(\"CameraPreview\", {\n web: () => import(\"./web\").then((m) => new m.CameraPreviewWeb()),\n});\nexport * from \"./definitions\";\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super({\n name: \"CameraPreview\",\n platforms: [\"web\"],\n });\n }\n async start(options) {\n var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n Promise.reject(error);\n });\n const video = document.getElementById(\"video\");\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement(\"video\");\n videoElement.id = \"video\";\n videoElement.setAttribute(\"class\", options.className || \"\");\n // Don't flip video feed if camera is rear facing\n if (options.position !== \"rear\") {\n videoElement.setAttribute(\"style\", \"-webkit-transform: scaleX(-1); transform: scaleX(-1);\");\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes(\"safari\") && !userAgent.includes(\"chrome\");\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute(\"autoplay\", \"true\");\n videoElement.setAttribute(\"muted\", \"true\");\n videoElement.setAttribute(\"playsinline\", \"true\");\n }\n parent.appendChild(videoElement);\n if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === \"rear\") {\n constraints.video.facingMode =\n \"environment\";\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n if (document.getElementById(\"video\")) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject({ message: \"camera already stopped\" });\n }\n }, (err) => {\n Promise.reject(err);\n });\n }\n }\n else {\n Promise.reject({ message: \"camera already started\" });\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n async stop() {\n const video = document.getElementById(\"video\");\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById(\"video\");\n if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {\n reject({ message: \"camera is not running\" });\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n if ((options.format || \"jpeg\") === \"jpeg\") {\n base64EncodedImage = canvas\n .toDataURL(\"image/jpeg\", (options.quality || 85) / 100.0)\n .replace(\"data:image/jpeg;base64,\", \"\");\n }\n else {\n base64EncodedImage = canvas\n .toDataURL(\"image/png\")\n .replace(\"data:image/png;base64,\", \"\");\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async stopRecordVideo() {\n throw new Error(\"stopRecordVideo not supported under the web platform\");\n }\n async startRecordVideo(_options) {\n throw new Error(\"startRecordVideo not supported under the web platform\");\n }\n async getSupportedFlashModes() {\n throw new Error(\"getSupportedFlashModes not supported under the web platform\");\n }\n async getHorizontalFov() {\n throw new Error(\"getHorizontalFov not supported under the web platform\");\n }\n async setFlashMode(_options) {\n throw new Error(\"setFlashMode not supported under the web platform\" + _options);\n }\n async flip() {\n throw new Error(\"flip not supported under the web platform\");\n }\n async setOpacity(_options) {\n const video = document.getElementById(\"video\");\n if (!!video && !!_options[\"opacity\"]) {\n video.style.setProperty(\"opacity\", _options[\"opacity\"].toString());\n }\n }\n}\n//# sourceMapp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IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,MAAM,sBAAsB,GAAG;AACnC,QAAQ,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;AACvF,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;AACjC,QAAQ,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,QAAQ,CAAC,CAAC;AACxF,KAAK;AACL,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;AACrE,KAAK;AACL,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACvD,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC9C,YAAY,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC/E,SAAS;AACT,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then(m => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n });\n }\n async start(options) {\n var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach(track => track.stop());\n })\n .catch((error) => {\n Promise.reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode\n = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n // eslint-disable-next-line ts/no-this-alias\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then((stream) => {\n if (document.getElementById('video')) {\n // video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject(new Error('camera already stopped'));\n }\n }, (err) => {\n Promise.reject(new Error(err));\n });\n }\n }\n else {\n Promise.reject(new Error('camera already started'));\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks)\n track.stop();\n }\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById('video');\n if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {\n reject(new Error('camera is not running'));\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n if ((options.format || 'jpeg') === 'jpeg') {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', (options.quality || 85) / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas\n .toDataURL('image/png')\n .replace('data:image/png;base64,', '');\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async stopRecordVideo() {\n throw new Error('stopRecordVideo not supported under the web platform');\n }\n async startRecordVideo(_options) {\n throw new Error('startRecordVideo not supported under the web platform');\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async getHorizontalFov() {\n throw new Error('getHorizontalFov not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error(`setFlashMode not supported under the web platform${_options}`);\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options.opacity)\n video.style.setProperty('opacity', _options.opacity.toString());\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,gBAAgB,EAAE,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