capacitor-camera-module 0.0.3 → 0.0.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.
package/README.md CHANGED
@@ -13,12 +13,13 @@ npx cap sync
13
13
 
14
14
  <docgen-index>
15
15
 
16
- * [`echo(...)`](#echo)
17
16
  * [`echo(...)`](#echo)
18
17
  * [`checkPermission()`](#checkpermission)
19
18
  * [`requestPermission()`](#requestpermission)
20
19
  * [`checkAndRequestPermission()`](#checkandrequestpermission)
21
20
  * [`getCameraCapabilities()`](#getcameracapabilities)
21
+ * [`startPreview()`](#startpreview)
22
+ * [`stopPreview()`](#stoppreview)
22
23
  * [Interfaces](#interfaces)
23
24
 
24
25
  </docgen-index>
@@ -41,21 +42,6 @@ echo(options: { value: string; }) => Promise<{ value: string; }>
41
42
  --------------------
42
43
 
43
44
 
44
- ### echo(...)
45
-
46
- ```typescript
47
- echo(options: { value: string; }) => Promise<{ value: string; }>
48
- ```
49
-
50
- | Param | Type |
51
- | ------------- | ------------------------------- |
52
- | **`options`** | <code>{ value: string; }</code> |
53
-
54
- **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
55
-
56
- --------------------
57
-
58
-
59
45
  ### checkPermission()
60
46
 
61
47
  ```typescript
@@ -100,6 +86,24 @@ getCameraCapabilities() => Promise<CameraCapabilities>
100
86
  --------------------
101
87
 
102
88
 
89
+ ### startPreview()
90
+
91
+ ```typescript
92
+ startPreview() => Promise<void>
93
+ ```
94
+
95
+ --------------------
96
+
97
+
98
+ ### stopPreview()
99
+
100
+ ```typescript
101
+ stopPreview() => Promise<void>
102
+ ```
103
+
104
+ --------------------
105
+
106
+
103
107
  ### Interfaces
104
108
 
105
109
 
@@ -58,4 +58,9 @@ dependencies {
58
58
 
59
59
  implementation 'androidx.activity:activity:1.7.0'
60
60
  implementation 'androidx.fragment:fragment:1.5.7'
61
+
62
+ implementation "androidx.camera:camera-camera2:1.3.2"
63
+ implementation "androidx.camera:camera-lifecycle:1.3.2"
64
+ implementation "androidx.camera:camera-view:1.3.2"
65
+ }
61
66
  }
@@ -8,5 +8,6 @@
8
8
  <uses-feature android:name="android.hardware.camera" android:required="false" />
9
9
  <uses-feature android:name="android.hardware.camera.front" android:required="false" />
10
10
  <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
11
+ <uses-feature android:name="android.hardware.camera.any" android:required="false" />
11
12
 
12
13
  </manifest>
@@ -1,21 +1,19 @@
1
1
  package com.eddieagvictoria.cameramodule;
2
2
 
3
3
  import android.Manifest;
4
- import android.content.pm.PackageManager;
5
4
  import android.os.Build;
5
+ import android.content.pm.PackageManager;
6
6
 
7
- import androidx.activity.result.ActivityResultCallback;
8
- import androidx.activity.result.ActivityResultLauncher;
9
- import androidx.activity.result.contract.ActivityResultContracts;
10
- import androidx.appcompat.app.AppCompatActivity;
11
7
  import androidx.core.content.ContextCompat;
12
8
 
13
9
  import com.getcapacitor.JSObject;
14
10
  import com.getcapacitor.Plugin;
15
11
  import com.getcapacitor.PluginCall;
16
12
  import com.getcapacitor.PluginMethod;
13
+ import com.getcapacitor.PermissionState;
17
14
  import com.getcapacitor.annotation.CapacitorPlugin;
18
15
  import com.getcapacitor.annotation.Permission;
16
+ import com.getcapacitor.annotation.PermissionCallback;
19
17
 
20
18
  @CapacitorPlugin(
21
19
  name = "CameraModule",
@@ -28,12 +26,10 @@ import com.getcapacitor.annotation.Permission;
28
26
  )
29
27
  public class CameraModulePlugin extends Plugin {
30
28
 
31
- private static final String CAMERA_PERMISSION = Manifest.permission.CAMERA;
32
- private PluginCall pendingPermissionCall = null;
33
-
34
29
  @Override
35
30
  public void load() {
36
31
  super.load();
32
+ getBridge().getWebView().setBackgroundColor(0x00000000);
37
33
  }
38
34
 
39
35
  @PluginMethod
@@ -48,104 +44,143 @@ public class CameraModulePlugin extends Plugin {
48
44
  public void checkPermission(PluginCall call) {
49
45
  JSObject ret = new JSObject();
50
46
 
51
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
52
- int permissionStatus = ContextCompat.checkSelfPermission(
53
- getContext(),
54
- CAMERA_PERMISSION
55
- );
56
-
57
- boolean granted = permissionStatus == PackageManager.PERMISSION_GRANTED;
58
-
59
- ret.put("granted", granted);
60
-
61
- if (granted) {
62
- ret.put("status", "granted");
63
- } else {
64
- if (getActivity() instanceof AppCompatActivity) {
65
- boolean shouldShowRationale = ((AppCompatActivity) getActivity())
66
- .shouldShowRequestPermissionRationale(CAMERA_PERMISSION);
67
-
68
- if (shouldShowRationale) {
69
- ret.put("status", "prompt-with-rationale");
70
- } else {
71
- ret.put("status", "prompt");
72
- }
73
- } else {
74
- ret.put("status", "denied");
75
- }
76
- }
77
-
78
- ret.put("details", "Android SDK " + Build.VERSION.SDK_INT);
79
-
80
- } else {
81
- // Para versiones anteriores a Android 6.0
47
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
82
48
  ret.put("granted", true);
83
49
  ret.put("status", "granted");
84
50
  ret.put("details", "Pre-Marshmallow, granted at install");
51
+ call.resolve(ret);
52
+ return;
85
53
  }
86
54
 
55
+ boolean granted =
56
+ ContextCompat.checkSelfPermission(
57
+ getContext(),
58
+ Manifest.permission.CAMERA
59
+ ) == PackageManager.PERMISSION_GRANTED;
60
+
61
+ ret.put("granted", granted);
62
+ ret.put("status", granted ? "granted" : "prompt");
63
+ ret.put("details", "Android SDK " + Build.VERSION.SDK_INT);
64
+
87
65
  call.resolve(ret);
88
66
  }
89
67
 
90
68
  @PluginMethod
91
69
  public void requestPermission(PluginCall call) {
92
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
93
- pendingPermissionCall = call;
94
-
95
- // Registrar el callback para el permiso
96
- ActivityResultLauncher<String> requestPermissionLauncher =
97
- ((AppCompatActivity) getActivity())
98
- .registerForActivityResult(
99
- new ActivityResultContracts.RequestPermission(),
100
- isGranted -> {
101
- if (pendingPermissionCall != null) {
102
- JSObject result = new JSObject();
103
- result.put("granted", isGranted);
104
- result.put("status", isGranted ? "granted" : "denied");
105
- result.put("details", "Permission request completed");
106
-
107
- pendingPermissionCall.resolve(result);
108
- pendingPermissionCall = null;
109
- }
110
- }
111
- );
112
-
113
- // Solicitar el permiso
114
- requestPermissionLauncher.launch(CAMERA_PERMISSION);
115
-
70
+ if (getPermissionState("camera") != PermissionState.GRANTED) {
71
+ requestPermissionForAlias("camera", call, "cameraPermissionCallback");
116
72
  } else {
117
- // Para versiones anteriores
118
73
  JSObject ret = new JSObject();
119
74
  ret.put("granted", true);
120
75
  ret.put("status", "granted");
121
- ret.put("details", "Pre-Marshmallow, auto-granted");
76
+ ret.put("details", "Already granted");
122
77
  call.resolve(ret);
123
78
  }
124
79
  }
125
80
 
81
+ @PermissionCallback
82
+ private void cameraPermissionCallback(PluginCall call) {
83
+ JSObject ret = new JSObject();
84
+ boolean granted = getPermissionState("camera") == PermissionState.GRANTED;
85
+
86
+ ret.put("granted", granted);
87
+ ret.put("status", granted ? "granted" : "denied");
88
+ ret.put("details", "Permission request completed");
89
+
90
+ call.resolve(ret);
91
+ }
92
+
126
93
  @PluginMethod
127
94
  public void checkAndRequestPermission(PluginCall call) {
128
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
129
- int permissionStatus = ContextCompat.checkSelfPermission(
130
- getContext(),
131
- CAMERA_PERMISSION
132
- );
133
-
134
- if (permissionStatus == PackageManager.PERMISSION_GRANTED) {
135
- JSObject ret = new JSObject();
136
- ret.put("granted", true);
137
- ret.put("status", "granted");
138
- ret.put("details", "Already granted");
139
- call.resolve(ret);
140
- } else {
141
- requestPermission(call);
142
- }
143
- } else {
95
+ if (getPermissionState("camera") == PermissionState.GRANTED) {
144
96
  JSObject ret = new JSObject();
145
97
  ret.put("granted", true);
146
98
  ret.put("status", "granted");
147
- ret.put("details", "Pre-Marshmallow, auto-granted");
99
+ ret.put("details", "Already granted");
148
100
  call.resolve(ret);
101
+ } else {
102
+ requestPermission(call);
149
103
  }
150
104
  }
151
- }
105
+
106
+ @PluginMethod
107
+ public void getCameraCapabilities(PluginCall call) {
108
+ JSObject ret = new JSObject();
109
+
110
+ boolean hasCamera = getContext()
111
+ .getPackageManager()
112
+ .hasSystemFeature("android.hardware.camera.any");
113
+
114
+ ret.put("hasCamera", hasCamera);
115
+ ret.put("isSecureContext", true);
116
+ ret.put("userAgent", "Android");
117
+
118
+ call.resolve(ret);
119
+ }
120
+
121
+
122
+ //Camera
123
+ @PluginMethod
124
+ public void startPreview(PluginCall call) {
125
+ getActivity().runOnUiThread(() -> {
126
+ previewView = new PreviewView(getContext());
127
+ previewView.setLayoutParams(
128
+ new FrameLayout.LayoutParams(
129
+ FrameLayout.LayoutParams.MATCH_PARENT,
130
+ FrameLayout.LayoutParams.MATCH_PARENT
131
+ )
132
+ );
133
+
134
+ ViewGroup rootView = (ViewGroup) getActivity().getWindow().getDecorView();
135
+ rootView.addView(previewView, 0);
136
+
137
+ startCamera();
138
+
139
+ call.resolve();
140
+ });
141
+ }
142
+
143
+ private void startCamera() {
144
+ ListenableFuture<ProcessCameraProvider> cameraProviderFuture =
145
+ ProcessCameraProvider.getInstance(getContext());
146
+
147
+ cameraProviderFuture.addListener(() -> {
148
+ try {
149
+ cameraProvider = cameraProviderFuture.get();
150
+
151
+ Preview preview = new Preview.Builder().build();
152
+ preview.setSurfaceProvider(previewView.getSurfaceProvider());
153
+
154
+ cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA;
155
+
156
+ cameraProvider.unbindAll();
157
+ cameraProvider.bindToLifecycle(
158
+ getActivity(),
159
+ cameraSelector,
160
+ preview
161
+ );
162
+ } catch (Exception e) {
163
+ e.printStackTrace();
164
+ }
165
+ }, ContextCompat.getMainExecutor(getContext()));
166
+ }
167
+
168
+ @PluginMethod
169
+ public void stopPreview(PluginCall call) {
170
+ getActivity().runOnUiThread(() -> {
171
+ if (cameraProvider != null) {
172
+ cameraProvider.unbindAll();
173
+ }
174
+
175
+ if (previewView != null) {
176
+ ViewGroup rootView = (ViewGroup) previewView.getParent();
177
+ rootView.removeView(previewView);
178
+ previewView = null;
179
+ }
180
+
181
+ call.resolve();
182
+ });
183
+ }
184
+
185
+
186
+ }
package/dist/docs.json CHANGED
@@ -5,22 +5,6 @@
5
5
  "docs": "",
6
6
  "tags": [],
7
7
  "methods": [
8
- {
9
- "name": "echo",
10
- "signature": "(options: { value: string; }) => Promise<{ value: string; }>",
11
- "parameters": [
12
- {
13
- "name": "options",
14
- "docs": "",
15
- "type": "{ value: string; }"
16
- }
17
- ],
18
- "returns": "Promise<{ value: string; }>",
19
- "tags": [],
20
- "docs": "",
21
- "complexTypes": [],
22
- "slug": "echo"
23
- },
24
8
  {
25
9
  "name": "echo",
26
10
  "signature": "(options: { value: string; }) => Promise<{ value: string; }>",
@@ -84,6 +68,26 @@
84
68
  "CameraCapabilities"
85
69
  ],
86
70
  "slug": "getcameracapabilities"
71
+ },
72
+ {
73
+ "name": "startPreview",
74
+ "signature": "() => Promise<void>",
75
+ "parameters": [],
76
+ "returns": "Promise<void>",
77
+ "tags": [],
78
+ "docs": "",
79
+ "complexTypes": [],
80
+ "slug": "startpreview"
81
+ },
82
+ {
83
+ "name": "stopPreview",
84
+ "signature": "() => Promise<void>",
85
+ "parameters": [],
86
+ "returns": "Promise<void>",
87
+ "tags": [],
88
+ "docs": "",
89
+ "complexTypes": [],
90
+ "slug": "stoppreview"
87
91
  }
88
92
  ],
89
93
  "properties": []
@@ -1,9 +1,4 @@
1
1
  export interface CameraModulePlugin {
2
- echo(options: {
3
- value: string;
4
- }): Promise<{
5
- value: string;
6
- }>;
7
2
  echo(options: {
8
3
  value: string;
9
4
  }): Promise<{
@@ -13,6 +8,8 @@ export interface CameraModulePlugin {
13
8
  requestPermission(): Promise<PermissionStatus>;
14
9
  checkAndRequestPermission(): Promise<PermissionStatus>;
15
10
  getCameraCapabilities(): Promise<CameraCapabilities>;
11
+ startPreview(): Promise<void>;
12
+ stopPreview(): Promise<void>;
16
13
  }
17
14
  export interface PermissionStatus {
18
15
  granted: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CameraModulePlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n\n echo(options: { value: string }): Promise<{ value: string }>;\n\n checkPermission(): Promise<PermissionStatus>;\n\n requestPermission(): Promise<PermissionStatus>;\n\n checkAndRequestPermission(): Promise<PermissionStatus>;\n\n getCameraCapabilities(): Promise<CameraCapabilities>;\n}\n\nexport interface PermissionStatus {\n granted: boolean;\n status: 'granted' | 'denied' | 'prompt' | 'prompt-with-rationale' | 'limited';\n details?: string;\n}\n\n\nexport interface CameraCapabilities {\n hasCamera: boolean;\n isSecureContext: boolean;\n userAgent: string;\n}"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CameraModulePlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n\n checkPermission(): Promise<PermissionStatus>;\n\n requestPermission(): Promise<PermissionStatus>;\n\n checkAndRequestPermission(): Promise<PermissionStatus>;\n\n getCameraCapabilities(): Promise<CameraCapabilities>;\n\n startPreview(): Promise<void>;\n\n stopPreview(): Promise<void>;\n\n}\n\nexport interface PermissionStatus {\n granted: boolean;\n status: 'granted' | 'denied' | 'prompt' | 'prompt-with-rationale' | 'limited';\n details?: string;\n}\n\n\nexport interface CameraCapabilities {\n hasCamera: boolean;\n isSecureContext: boolean;\n userAgent: string;\n}"]}
package/dist/esm/web.d.ts CHANGED
@@ -14,4 +14,6 @@ export declare class CameraModuleWeb extends WebPlugin implements CameraModulePl
14
14
  isSecureContext: boolean;
15
15
  userAgent: string;
16
16
  }>;
17
+ startPreview(): Promise<void>;
18
+ stopPreview(): Promise<void>;
17
19
  }
package/dist/esm/web.js CHANGED
@@ -152,5 +152,12 @@ export class CameraModuleWeb extends WebPlugin {
152
152
  userAgent: navigator.userAgent,
153
153
  };
154
154
  }
155
+ //Camera Preview
156
+ async startPreview() {
157
+ console.warn('[CameraModule] startPreview is not supported on web');
158
+ }
159
+ async stopPreview() {
160
+ console.warn('[CameraModule] stopPreview is not supported on web');
161
+ }
155
162
  }
156
163
  //# 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;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,eAAe;;QACnB,+EAA+E;QAC/E,MAAM,eAAe,GAAG,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,YAAY,0CAAE,gBAAgB,CAAA,CAAC;QACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,YAAY,0CAAE,YAAY,CAAA,CAAC,CAAC,YAAY;QAE7E,IAAI,CAAC,eAAe,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1C,MAAM,IAAI,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC;YAChE,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;YAE9E,gCAAgC;YAChC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9B,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,QAAQ;oBAChB,OAAO,EAAE,yBAAyB;iBACnC,CAAC;YACJ,CAAC;YAED,8DAA8D;YAC9D,MAAM,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AC;QAED,OAAO;YACL,SAAS;YACT,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,SAAS,EAAE,SAAS,CAAC,SAAS;SAC/B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CameraModulePlugin, PermissionStatus } from './definitions';\n\nexport class CameraModuleWeb extends WebPlugin implements CameraModulePlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n\n async checkPermission(): Promise<PermissionStatus> {\n // Verificar disponibilidad de APIs - usando prefijo _ para variables no usadas\n const hasMediaDevices = !!navigator.mediaDevices?.enumerateDevices;\n const _hasGetUserMedia = !!navigator.mediaDevices?.getUserMedia; // Prefijo _\n\n if (!hasMediaDevices || !_hasGetUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n\n // No hay dispositivos de cámara\n if (videoDevices.length === 0) {\n return {\n granted: false,\n status: 'denied',\n details: 'No camera devices found',\n };\n }\n\n // Verificar si algún dispositivo tiene label (indica permiso)\n const hasPermission = videoDevices.some((device) => device.label && device.label.trim() !== '');\n\n // Determinar estado más preciso\n let status: PermissionStatus['status'] = 'denied';\n if (hasPermission) {\n status = 'granted';\n } else {\n // En web, sin intentar getUserMedia, asumimos que es la primera vez\n status = 'prompt';\n }\n\n return {\n granted: hasPermission,\n status,\n details: `Found ${videoDevices.length} camera device(s)`,\n };\n } catch (error: any) {\n console.error('Error checking camera permission:', error);\n return {\n granted: false,\n status: 'denied',\n details: error.message || 'Unknown error',\n };\n }\n }\n\n async requestPermission(): Promise<PermissionStatus> {\n // Verificar getUserMedia específicamente para este método\n if (!navigator.mediaDevices?.getUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n\n try {\n // Intentar acceder a la cámara con configuración mínima\n const stream = await navigator.mediaDevices.getUserMedia({\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: { ideal: 'environment' },\n },\n audio: false,\n });\n\n // Limpiar recursos inmediatamente\n stream.getTracks().forEach((track) => {\n track.stop();\n });\n\n return {\n granted: true,\n status: 'granted',\n details: 'Permission granted successfully',\n };\n } catch (error: any) {\n console.error('Error requesting camera permission:', error);\n\n // Manejo específico de errores\n let status: PermissionStatus['status'] = 'denied';\n let details = error.message || 'Unknown error';\n\n if (error.name === 'NotAllowedError') {\n status = 'denied';\n details = 'User denied camera access';\n } else if (error.name === 'NotFoundError') {\n status = 'denied';\n details = 'No camera found';\n } else if (error.name === 'NotReadableError') {\n status = 'denied';\n details = 'Camera is already in use';\n } else if (error.name === 'OverconstrainedError') {\n status = 'denied';\n details = 'Camera constraints cannot be met';\n } else if (error.name === 'SecurityError') {\n status = 'denied';\n details = 'Camera access blocked by browser security settings';\n } else if (error.name === 'TypeError') {\n status = 'denied';\n details = 'Invalid constraints specified';\n }\n\n return {\n granted: false,\n status,\n details,\n };\n }\n }\n\n async checkAndRequestPermission(): Promise<PermissionStatus> {\n try {\n // Primero verificar el estado actual\n const currentStatus = await this.checkPermission();\n\n // Si ya tiene permiso, retornar inmediatamente\n if (currentStatus.granted) {\n return currentStatus;\n }\n\n // Si no tiene permiso, solicitar\n return await this.requestPermission();\n } catch (error) {\n console.error('Error in checkAndRequestPermission:', error);\n return {\n granted: false,\n status: 'denied',\n details: 'Failed to check or request permission',\n };\n }\n }\n\n // Método adicional para verificar soporte de características\n async getCameraCapabilities(): Promise<{\n hasCamera: boolean;\n isSecureContext: boolean;\n userAgent: string;\n }> {\n const hasMediaDevices = !!navigator.mediaDevices?.enumerateDevices;\n const hasGetUserMedia = !!navigator.mediaDevices?.getUserMedia;\n\n let hasCamera = false;\n\n if (hasMediaDevices || hasGetUserMedia) {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n hasCamera = devices.some((device) => device.kind === 'videoinput');\n } catch {\n hasCamera = false;\n }\n }\n\n return {\n hasCamera,\n isSecureContext: window.isSecureContext,\n userAgent: navigator.userAgent,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,eAAe;;QACnB,+EAA+E;QAC/E,MAAM,eAAe,GAAG,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,YAAY,0CAAE,gBAAgB,CAAA,CAAC;QACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,YAAY,0CAAE,YAAY,CAAA,CAAC,CAAC,YAAY;QAE7E,IAAI,CAAC,eAAe,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1C,MAAM,IAAI,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC;YAChE,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;YAE9E,gCAAgC;YAChC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9B,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,QAAQ;oBAChB,OAAO,EAAE,yBAAyB;iBACnC,CAAC;YACJ,CAAC;YAED,8DAA8D;YAC9D,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,MAA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S;SAC/B,CAAC;IACJ,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,YAAY;QAChB,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CameraModulePlugin, PermissionStatus } from './definitions';\n\nexport class CameraModuleWeb extends WebPlugin implements CameraModulePlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n\n async checkPermission(): Promise<PermissionStatus> {\n // Verificar disponibilidad de APIs - usando prefijo _ para variables no usadas\n const hasMediaDevices = !!navigator.mediaDevices?.enumerateDevices;\n const _hasGetUserMedia = !!navigator.mediaDevices?.getUserMedia; // Prefijo _\n\n if (!hasMediaDevices || !_hasGetUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n\n // No hay dispositivos de cámara\n if (videoDevices.length === 0) {\n return {\n granted: false,\n status: 'denied',\n details: 'No camera devices found',\n };\n }\n\n // Verificar si algún dispositivo tiene label (indica permiso)\n const hasPermission = videoDevices.some((device) => device.label && device.label.trim() !== '');\n\n // Determinar estado más preciso\n let status: PermissionStatus['status'] = 'denied';\n if (hasPermission) {\n status = 'granted';\n } else {\n // En web, sin intentar getUserMedia, asumimos que es la primera vez\n status = 'prompt';\n }\n\n return {\n granted: hasPermission,\n status,\n details: `Found ${videoDevices.length} camera device(s)`,\n };\n } catch (error: any) {\n console.error('Error checking camera permission:', error);\n return {\n granted: false,\n status: 'denied',\n details: error.message || 'Unknown error',\n };\n }\n }\n\n async requestPermission(): Promise<PermissionStatus> {\n // Verificar getUserMedia específicamente para este método\n if (!navigator.mediaDevices?.getUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n\n try {\n // Intentar acceder a la cámara con configuración mínima\n const stream = await navigator.mediaDevices.getUserMedia({\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: { ideal: 'environment' },\n },\n audio: false,\n });\n\n // Limpiar recursos inmediatamente\n stream.getTracks().forEach((track) => {\n track.stop();\n });\n\n return {\n granted: true,\n status: 'granted',\n details: 'Permission granted successfully',\n };\n } catch (error: any) {\n console.error('Error requesting camera permission:', error);\n\n // Manejo específico de errores\n let status: PermissionStatus['status'] = 'denied';\n let details = error.message || 'Unknown error';\n\n if (error.name === 'NotAllowedError') {\n status = 'denied';\n details = 'User denied camera access';\n } else if (error.name === 'NotFoundError') {\n status = 'denied';\n details = 'No camera found';\n } else if (error.name === 'NotReadableError') {\n status = 'denied';\n details = 'Camera is already in use';\n } else if (error.name === 'OverconstrainedError') {\n status = 'denied';\n details = 'Camera constraints cannot be met';\n } else if (error.name === 'SecurityError') {\n status = 'denied';\n details = 'Camera access blocked by browser security settings';\n } else if (error.name === 'TypeError') {\n status = 'denied';\n details = 'Invalid constraints specified';\n }\n\n return {\n granted: false,\n status,\n details,\n };\n }\n }\n\n async checkAndRequestPermission(): Promise<PermissionStatus> {\n try {\n // Primero verificar el estado actual\n const currentStatus = await this.checkPermission();\n\n // Si ya tiene permiso, retornar inmediatamente\n if (currentStatus.granted) {\n return currentStatus;\n }\n\n // Si no tiene permiso, solicitar\n return await this.requestPermission();\n } catch (error) {\n console.error('Error in checkAndRequestPermission:', error);\n return {\n granted: false,\n status: 'denied',\n details: 'Failed to check or request permission',\n };\n }\n }\n\n // Método adicional para verificar soporte de características\n async getCameraCapabilities(): Promise<{\n hasCamera: boolean;\n isSecureContext: boolean;\n userAgent: string;\n }> {\n const hasMediaDevices = !!navigator.mediaDevices?.enumerateDevices;\n const hasGetUserMedia = !!navigator.mediaDevices?.getUserMedia;\n\n let hasCamera = false;\n\n if (hasMediaDevices || hasGetUserMedia) {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n hasCamera = devices.some((device) => device.kind === 'videoinput');\n } catch {\n hasCamera = false;\n }\n }\n\n return {\n hasCamera,\n isSecureContext: window.isSecureContext,\n userAgent: navigator.userAgent,\n };\n }\n\n //Camera Preview\n async startPreview(): Promise<void> {\n console.warn('[CameraModule] startPreview is not supported on web');\n }\n\n async stopPreview(): Promise<void> {\n console.warn('[CameraModule] stopPreview is not supported on web');\n }\n}\n"]}
@@ -159,6 +159,13 @@ class CameraModuleWeb extends core.WebPlugin {
159
159
  userAgent: navigator.userAgent,
160
160
  };
161
161
  }
162
+ //Camera Preview
163
+ async startPreview() {
164
+ console.warn('[CameraModule] startPreview is not supported on web');
165
+ }
166
+ async stopPreview() {
167
+ console.warn('[CameraModule] stopPreview is not supported on web');
168
+ }
162
169
  }
163
170
 
164
171
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraModule = registerPlugin('CameraModule', {\n web: () => import('./web').then((m) => new m.CameraModuleWeb()),\n});\nexport * from './definitions';\nexport { CameraModule };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraModuleWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async checkPermission() {\n var _a, _b;\n // Verificar disponibilidad de APIs - usando prefijo _ para variables no usadas\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const _hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia); // Prefijo _\n if (!hasMediaDevices || !_hasGetUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n // No hay dispositivos de cámara\n if (videoDevices.length === 0) {\n return {\n granted: false,\n status: 'denied',\n details: 'No camera devices found',\n };\n }\n // Verificar si algún dispositivo tiene label (indica permiso)\n const hasPermission = videoDevices.some((device) => device.label && device.label.trim() !== '');\n // Determinar estado más preciso\n let status = 'denied';\n if (hasPermission) {\n status = 'granted';\n }\n else {\n // En web, sin intentar getUserMedia, asumimos que es la primera vez\n status = 'prompt';\n }\n return {\n granted: hasPermission,\n status,\n details: `Found ${videoDevices.length} camera device(s)`,\n };\n }\n catch (error) {\n console.error('Error checking camera permission:', error);\n return {\n granted: false,\n status: 'denied',\n details: error.message || 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n // Verificar getUserMedia específicamente para este método\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n // Intentar acceder a la cámara con configuración mínima\n const stream = await navigator.mediaDevices.getUserMedia({\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: { ideal: 'environment' },\n },\n audio: false,\n });\n // Limpiar recursos inmediatamente\n stream.getTracks().forEach((track) => {\n track.stop();\n });\n return {\n granted: true,\n status: 'granted',\n details: 'Permission granted successfully',\n };\n }\n catch (error) {\n console.error('Error requesting camera permission:', error);\n // Manejo específico de errores\n let status = 'denied';\n let details = error.message || 'Unknown error';\n if (error.name === 'NotAllowedError') {\n status = 'denied';\n details = 'User denied camera access';\n }\n else if (error.name === 'NotFoundError') {\n status = 'denied';\n details = 'No camera found';\n }\n else if (error.name === 'NotReadableError') {\n status = 'denied';\n details = 'Camera is already in use';\n }\n else if (error.name === 'OverconstrainedError') {\n status = 'denied';\n details = 'Camera constraints cannot be met';\n }\n else if (error.name === 'SecurityError') {\n status = 'denied';\n details = 'Camera access blocked by browser security settings';\n }\n else if (error.name === 'TypeError') {\n status = 'denied';\n details = 'Invalid constraints specified';\n }\n return {\n granted: false,\n status,\n details,\n };\n }\n }\n async checkAndRequestPermission() {\n try {\n // Primero verificar el estado actual\n const currentStatus = await this.checkPermission();\n // Si ya tiene permiso, retornar inmediatamente\n if (currentStatus.granted) {\n return currentStatus;\n }\n // Si no tiene permiso, solicitar\n return await this.requestPermission();\n }\n catch (error) {\n console.error('Error in checkAndRequestPermission:', error);\n return {\n granted: false,\n status: 'denied',\n details: 'Failed to check or request permission',\n };\n }\n }\n // Método adicional para verificar soporte de características\n async getCameraCapabilities() {\n var _a, _b;\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia);\n let hasCamera = false;\n if (hasMediaDevices || hasGetUserMedia) {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n hasCamera = devices.some((device) => device.kind === 'videoinput');\n }\n catch (_c) {\n hasCamera = false;\n }\n }\n return {\n hasCamera,\n isSecureContext: window.isSecureContext,\n userAgent: navigator.userAgent,\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;AACpC,QAAQ,OAAO,OAAO;AACtB,IAAI;AACJ,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,EAAE,EAAE,EAAE;AAClB;AACA,QAAQ,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,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Ae,EAAE,MAAM,CAAC,eAAe;AACnD,YAAY,SAAS,EAAE,SAAS,CAAC,SAAS;AAC1C,SAAS;AACT,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraModule = registerPlugin('CameraModule', {\n web: () => import('./web').then((m) => new m.CameraModuleWeb()),\n});\nexport * from './definitions';\nexport { CameraModule };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraModuleWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async checkPermission() {\n var _a, _b;\n // Verificar disponibilidad de APIs - usando prefijo _ para variables no usadas\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const _hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia); // Prefijo _\n if (!hasMediaDevices || !_hasGetUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n // No hay dispositivos de cámara\n if (videoDevices.length === 0) {\n return {\n granted: false,\n status: 'denied',\n details: 'No camera devices found',\n };\n }\n // Verificar si algún dispositivo tiene label (indica permiso)\n const hasPermission = videoDevices.some((device) => device.label && device.label.trim() !== '');\n // Determinar estado más preciso\n let status = 'denied';\n if (hasPermission) {\n status = 'granted';\n }\n else {\n // En web, sin intentar getUserMedia, asumimos que es la primera vez\n status = 'prompt';\n }\n return {\n granted: hasPermission,\n status,\n details: `Found ${videoDevices.length} camera device(s)`,\n };\n }\n catch (error) {\n console.error('Error checking camera permission:', error);\n return {\n granted: false,\n status: 'denied',\n details: error.message || 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n // Verificar getUserMedia específicamente para este método\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n // Intentar acceder a la cámara con configuración mínima\n const stream = await navigator.mediaDevices.getUserMedia({\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: { ideal: 'environment' },\n },\n audio: false,\n });\n // Limpiar recursos inmediatamente\n stream.getTracks().forEach((track) => {\n track.stop();\n });\n return {\n granted: true,\n status: 'granted',\n details: 'Permission granted successfully',\n };\n }\n catch (error) {\n console.error('Error requesting camera permission:', error);\n // Manejo específico de errores\n let status = 'denied';\n let details = error.message || 'Unknown error';\n if (error.name === 'NotAllowedError') {\n status = 'denied';\n details = 'User denied camera access';\n }\n else if (error.name === 'NotFoundError') {\n status = 'denied';\n details = 'No camera found';\n }\n else if (error.name === 'NotReadableError') {\n status = 'denied';\n details = 'Camera is already in use';\n }\n else if (error.name === 'OverconstrainedError') {\n status = 'denied';\n details = 'Camera constraints cannot be met';\n }\n else if (error.name === 'SecurityError') {\n status = 'denied';\n details = 'Camera access blocked by browser security settings';\n }\n else if (error.name === 'TypeError') {\n status = 'denied';\n details = 'Invalid constraints specified';\n }\n return {\n granted: false,\n status,\n details,\n };\n }\n }\n async checkAndRequestPermission() {\n try {\n // Primero verificar el estado actual\n const currentStatus = await this.checkPermission();\n // Si ya tiene permiso, retornar inmediatamente\n if (currentStatus.granted) {\n return currentStatus;\n }\n // Si no tiene permiso, solicitar\n return await this.requestPermission();\n }\n catch (error) {\n console.error('Error in checkAndRequestPermission:', error);\n return {\n granted: false,\n status: 'denied',\n details: 'Failed to check or request permission',\n };\n }\n }\n // Método adicional para verificar soporte de características\n async getCameraCapabilities() {\n var _a, _b;\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia);\n let hasCamera = false;\n if (hasMediaDevices || hasGetUserMedia) {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n hasCamera = devices.some((device) => device.kind === 'videoinput');\n }\n catch (_c) {\n hasCamera = false;\n }\n }\n return {\n hasCamera,\n isSecureContext: window.isSecureContext,\n userAgent: navigator.userAgent,\n };\n }\n //Camera Preview\n async startPreview() {\n console.warn('[CameraModule] startPreview is not supported on web');\n }\n async stopPreview() {\n console.warn('[CameraModule] stopPreview is not supported on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;AACpC,QAAQ,OAAO,OAAO;AACtB,IAAI;AACJ,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,EAAE,EAAE,EAAE;AAClB;AACA,QAAQ,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC;AAC1H,QAAQ,MAAM,gBAAgB,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;AACxH,QAAQ,IAAI,CAAC,eAAe,IAAI,CAAC,gBAAgB,EAAE;AACnD,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,4CAA4C,CAAC;AAChF,QAAQ;AACR,QAAQ,IAAI;AACZ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158,6 +158,13 @@ var capacitorCameraModule = (function (exports, core) {
158
158
  userAgent: navigator.userAgent,
159
159
  };
160
160
  }
161
+ //Camera Preview
162
+ async startPreview() {
163
+ console.warn('[CameraModule] startPreview is not supported on web');
164
+ }
165
+ async stopPreview() {
166
+ console.warn('[CameraModule] stopPreview is not supported on web');
167
+ }
161
168
  }
162
169
 
163
170
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraModule = registerPlugin('CameraModule', {\n web: () => import('./web').then((m) => new m.CameraModuleWeb()),\n});\nexport * from './definitions';\nexport { CameraModule };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraModuleWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async checkPermission() {\n var _a, _b;\n // Verificar disponibilidad de APIs - usando prefijo _ para variables no usadas\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const _hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia); // Prefijo _\n if (!hasMediaDevices || !_hasGetUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n // No hay dispositivos de cámara\n if (videoDevices.length === 0) {\n return {\n granted: false,\n status: 'denied',\n details: 'No camera devices found',\n };\n }\n // Verificar si algún dispositivo tiene label (indica permiso)\n const hasPermission = videoDevices.some((device) => device.label && device.label.trim() !== '');\n // Determinar estado más preciso\n let status = 'denied';\n if (hasPermission) {\n status = 'granted';\n }\n else {\n // En web, sin intentar getUserMedia, asumimos que es la primera vez\n status = 'prompt';\n }\n return {\n granted: hasPermission,\n status,\n details: `Found ${videoDevices.length} camera device(s)`,\n };\n }\n catch (error) {\n console.error('Error checking camera permission:', error);\n return {\n granted: false,\n status: 'denied',\n details: error.message || 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n // Verificar getUserMedia específicamente para este método\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n // Intentar acceder a la cámara con configuración mínima\n const stream = await navigator.mediaDevices.getUserMedia({\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: { ideal: 'environment' },\n },\n audio: false,\n });\n // Limpiar recursos inmediatamente\n stream.getTracks().forEach((track) => {\n track.stop();\n });\n return {\n granted: true,\n status: 'granted',\n details: 'Permission granted successfully',\n };\n }\n catch (error) {\n console.error('Error requesting camera permission:', error);\n // Manejo específico de errores\n let status = 'denied';\n let details = error.message || 'Unknown error';\n if (error.name === 'NotAllowedError') {\n status = 'denied';\n details = 'User denied camera access';\n }\n else if (error.name === 'NotFoundError') {\n status = 'denied';\n details = 'No camera found';\n }\n else if (error.name === 'NotReadableError') {\n status = 'denied';\n details = 'Camera is already in use';\n }\n else if (error.name === 'OverconstrainedError') {\n status = 'denied';\n details = 'Camera constraints cannot be met';\n }\n else if (error.name === 'SecurityError') {\n status = 'denied';\n details = 'Camera access blocked by browser security settings';\n }\n else if (error.name === 'TypeError') {\n status = 'denied';\n details = 'Invalid constraints specified';\n }\n return {\n granted: false,\n status,\n details,\n };\n }\n }\n async checkAndRequestPermission() {\n try {\n // Primero verificar el estado actual\n const currentStatus = await this.checkPermission();\n // Si ya tiene permiso, retornar inmediatamente\n if (currentStatus.granted) {\n return currentStatus;\n }\n // Si no tiene permiso, solicitar\n return await this.requestPermission();\n }\n catch (error) {\n console.error('Error in checkAndRequestPermission:', error);\n return {\n granted: false,\n status: 'denied',\n details: 'Failed to check or request permission',\n };\n }\n }\n // Método adicional para verificar soporte de características\n async getCameraCapabilities() {\n var _a, _b;\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia);\n let hasCamera = false;\n if (hasMediaDevices || hasGetUserMedia) {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n hasCamera = devices.some((device) => device.kind === 'videoinput');\n }\n catch (_c) {\n hasCamera = false;\n }\n }\n return {\n hasCamera,\n isSecureContext: window.isSecureContext,\n userAgent: navigator.userAgent,\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IACpC,QAAQ,OAAO,OAAO;IACtB,IAAI;IACJ,IAAI,MAAM,eAAe,GAAG;IAC5B,QAAQ,IAAI,EAAE,EAAE,EAAE;IAClB;IACA,QAAQ,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC;IAC1H,QAAQ,MAAM,gBAAgB,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;IACxH,QAAQ,IAAI,CAAC,eAAe,IAAI,CAAC,gBAAgB,EAAE;IACnD,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,4CA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AAO,EAAE,KAAK;IAC9B,gBAAgB,MAAM,EAAE,QAAQ;IAChC,gBAAgB,OAAO,EAAE,uCAAuC;IAChE,aAAa;IACb,QAAQ;IACR,IAAI;IACJ;IACA,IAAI,MAAM,qBAAqB,GAAG;IAClC,QAAQ,IAAI,EAAE,EAAE,EAAE;IAClB,QAAQ,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC;IAC1H,QAAQ,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC;IACtH,QAAQ,IAAI,SAAS,GAAG,KAAK;IAC7B,QAAQ,IAAI,eAAe,IAAI,eAAe,EAAE;IAChD,YAAY,IAAI;IAChB,gBAAgB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE;IAC/E,gBAAgB,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;IAClF,YAAY;IACZ,YAAY,OAAO,EAAE,EAAE;IACvB,gBAAgB,SAAS,GAAG,KAAK;IACjC,YAAY;IACZ,QAAQ;IACR,QAAQ,OAAO;IACf,YAAY,SAAS;IACrB,YAAY,eAAe,EAAE,MAAM,CAAC,eAAe;IACnD,YAAY,SAAS,EAAE,SAAS,CAAC,SAAS;IAC1C,SAAS;IACT,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraModule = registerPlugin('CameraModule', {\n web: () => import('./web').then((m) => new m.CameraModuleWeb()),\n});\nexport * from './definitions';\nexport { CameraModule };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraModuleWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async checkPermission() {\n var _a, _b;\n // Verificar disponibilidad de APIs - usando prefijo _ para variables no usadas\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const _hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia); // Prefijo _\n if (!hasMediaDevices || !_hasGetUserMedia) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n const videoDevices = devices.filter((device) => device.kind === 'videoinput');\n // No hay dispositivos de cámara\n if (videoDevices.length === 0) {\n return {\n granted: false,\n status: 'denied',\n details: 'No camera devices found',\n };\n }\n // Verificar si algún dispositivo tiene label (indica permiso)\n const hasPermission = videoDevices.some((device) => device.label && device.label.trim() !== '');\n // Determinar estado más preciso\n let status = 'denied';\n if (hasPermission) {\n status = 'granted';\n }\n else {\n // En web, sin intentar getUserMedia, asumimos que es la primera vez\n status = 'prompt';\n }\n return {\n granted: hasPermission,\n status,\n details: `Found ${videoDevices.length} camera device(s)`,\n };\n }\n catch (error) {\n console.error('Error checking camera permission:', error);\n return {\n granted: false,\n status: 'denied',\n details: error.message || 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n // Verificar getUserMedia específicamente para este método\n if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {\n throw this.unavailable('Camera API no disponible en este navegador');\n }\n try {\n // Intentar acceder a la cámara con configuración mínima\n const stream = await navigator.mediaDevices.getUserMedia({\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: { ideal: 'environment' },\n },\n audio: false,\n });\n // Limpiar recursos inmediatamente\n stream.getTracks().forEach((track) => {\n track.stop();\n });\n return {\n granted: true,\n status: 'granted',\n details: 'Permission granted successfully',\n };\n }\n catch (error) {\n console.error('Error requesting camera permission:', error);\n // Manejo específico de errores\n let status = 'denied';\n let details = error.message || 'Unknown error';\n if (error.name === 'NotAllowedError') {\n status = 'denied';\n details = 'User denied camera access';\n }\n else if (error.name === 'NotFoundError') {\n status = 'denied';\n details = 'No camera found';\n }\n else if (error.name === 'NotReadableError') {\n status = 'denied';\n details = 'Camera is already in use';\n }\n else if (error.name === 'OverconstrainedError') {\n status = 'denied';\n details = 'Camera constraints cannot be met';\n }\n else if (error.name === 'SecurityError') {\n status = 'denied';\n details = 'Camera access blocked by browser security settings';\n }\n else if (error.name === 'TypeError') {\n status = 'denied';\n details = 'Invalid constraints specified';\n }\n return {\n granted: false,\n status,\n details,\n };\n }\n }\n async checkAndRequestPermission() {\n try {\n // Primero verificar el estado actual\n const currentStatus = await this.checkPermission();\n // Si ya tiene permiso, retornar inmediatamente\n if (currentStatus.granted) {\n return currentStatus;\n }\n // Si no tiene permiso, solicitar\n return await this.requestPermission();\n }\n catch (error) {\n console.error('Error in checkAndRequestPermission:', error);\n return {\n granted: false,\n status: 'denied',\n details: 'Failed to check or request permission',\n };\n }\n }\n // Método adicional para verificar soporte de características\n async getCameraCapabilities() {\n var _a, _b;\n const hasMediaDevices = !!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.enumerateDevices);\n const hasGetUserMedia = !!((_b = navigator.mediaDevices) === null || _b === void 0 ? void 0 : _b.getUserMedia);\n let hasCamera = false;\n if (hasMediaDevices || hasGetUserMedia) {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n hasCamera = devices.some((device) => device.kind === 'videoinput');\n }\n catch (_c) {\n hasCamera = false;\n }\n }\n return {\n hasCamera,\n isSecureContext: window.isSecureContext,\n userAgent: navigator.userAgent,\n };\n }\n //Camera Preview\n async startPreview() {\n console.warn('[CameraModule] startPreview is not supported on web');\n }\n async stopPreview() {\n console.warn('[CameraModule] stopPreview is not supported on web');\n }\n}\n//# sourceM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AAE,CAAC,gBAAgB,CAAC;IAC1H,QAAQ,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC;IACtH,QAAQ,IAAI,SAAS,GAAG,KAAK;IAC7B,QAAQ,IAAI,eAAe,IAAI,eAAe,EAAE;IAChD,YAAY,IAAI;IAChB,gBAAgB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE;IAC/E,gBAAgB,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;IAClF,YAAY;IACZ,YAAY,OAAO,EAAE,EAAE;IACvB,gBAAgB,SAAS,GAAG,KAAK;IACjC,YAAY;IACZ,QAAQ;IACR,QAAQ,OAAO;IACf,YAAY,SAAS;IACrB,YAAY,eAAe,EAAE,MAAM,CAAC,eAAe;IACnD,YAAY,SAAS,EAAE,SAAS,CAAC,SAAS;IAC1C,SAAS;IACT,IAAI;IACJ;IACA,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC;IAC3E,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC;IAC1E,IAAI;IACJ;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-camera-module",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "description": "Plugin to request permissiones view camera take phots",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",