@jaak.ai/stamps 1.0.0-dev.15 → 1.0.0-dev.16

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
@@ -264,6 +264,10 @@ El `document-detector` es un componente web que utiliza tecnología de reconocim
264
264
  - **Captura de imágenes**: Guarda imágenes del documento, rostro y firma cuando están disponibles.
265
265
  - **Interfaz personalizable**: Permite adaptar la apariencia y comportamiento a las necesidades de tu aplicación.
266
266
  - **Eventos detallados**: Proporciona eventos para cada etapa del proceso de escaneo.
267
+ - **Modo dinámico**: Optimiza automáticamente el rendimiento según el dispositivo (escritorio o móvil).
268
+ - **Filtros de calidad ajustables**: Controla la rigurosidad de los filtros de desenfoque y brillo.
269
+ - **Traducciones personalizables**: Permite personalizar todos los mensajes mostrados al usuario.
270
+ - **Capacidad de reinicio**: Facilita reiniciar el componente sin necesidad de recargarlo.
267
271
 
268
272
  ### Ciclo de Vida del Componente
269
273
 
@@ -287,9 +291,20 @@ El `document-detector` es un componente web que utiliza tecnología de reconocim
287
291
  license-key="TU_CLAVE_DE_LICENCIA">
288
292
  </document-detector>
289
293
 
290
- <!-- O usando la propiedad config -->
294
+ <!-- O usando la propiedad config con opciones avanzadas -->
291
295
  <document-detector
292
- config='{"key": "TU_CLAVE_DE_LICENCIA"}'>
296
+ config='{
297
+ "key": "TU_CLAVE_DE_LICENCIA",
298
+ "dynamicMode": true,
299
+ "strictMode": true,
300
+ "translation": {
301
+ "front": "Escanea el frente de tu documento",
302
+ "back": "Ahora escanea el reverso",
303
+ "changeSide": "Voltea el documento",
304
+ "cameraFeedbackBlur": "El documento está borroso",
305
+ "cameraFeedbackGlare": "Evita el reflejo en el documento"
306
+ }
307
+ }'>
293
308
  </document-detector>
294
309
  ```
295
310
 
@@ -307,15 +322,30 @@ detector.addEventListener('status', (event) => {
307
322
  case 'INITIALIZING':
308
323
  console.log('El detector se está inicializando');
309
324
  break;
310
- case 'READY':
311
- console.log('El detector está listo para escanear');
312
- break;
313
325
  case 'RECORDING':
314
326
  console.log('La cámara está activa y grabando');
315
327
  break;
328
+ case 'FRONT_SIDE_DETECTION':
329
+ console.log('Detectando el frente del documento');
330
+ break;
331
+ case 'BACK_SIDE_DETECTION':
332
+ console.log('Detectando el reverso del documento');
333
+ break;
334
+ case 'DOCUMENT_DETECTED':
335
+ console.log('Documento detectado correctamente');
336
+ break;
337
+ case 'CHANGE_SIDE':
338
+ console.log('Es necesario voltear el documento');
339
+ break;
316
340
  case 'RESULTS_SUCCESS':
317
341
  console.log('Se han obtenido resultados exitosamente');
318
342
  break;
343
+ case 'RESULTS_EMPTY':
344
+ console.log('No se encontraron datos en el documento');
345
+ break;
346
+ case 'DETECTION_FAILED':
347
+ console.log('Falló la detección del documento');
348
+ break;
319
349
  case 'ERROR':
320
350
  console.log('Ha ocurrido un error en el detector');
321
351
  break;
@@ -356,6 +386,8 @@ function escanearDesdeImagen(archivo) {
356
386
  // Reiniciar el componente (útil cuando se necesita resetear el estado)
357
387
  function reiniciarEscaneo() {
358
388
  detector.restartComponent();
389
+ // El método restartComponent reinicia internamente el componente y vuelve a iniciar
390
+ // el escaneo por cámara automáticamente, sin necesidad de llamar a startCameraScan()
359
391
  }
360
392
 
361
393
  // Ejemplo de uso con un input de archivo
@@ -393,7 +425,31 @@ document-detector::part(mb-camera-video) {
393
425
  | Propiedad | Tipo | Descripción |
394
426
  |--------------------------|-------------------------------------------|--------------------------------------------|
395
427
  | `license-key` | string | Clave de licencia para el SDK |
396
- | `config` | { key: string } | Configuración del componente (incluye la clave de licencia) |
428
+ | `config` | object | Configuración del componente (ver detalle abajo) |
429
+
430
+ #### Objeto de configuración (`config`)
431
+
432
+ | Propiedad | Tipo | Descripción |
433
+ |--------------------------|-------------------------------------------|--------------------------------------------|
434
+ | `key` | string | Clave de licencia para el SDK |
435
+ | `dynamicMode` | boolean | Cuando está activado, utiliza la variante completa del SDK en escritorio y la ligera en móviles |
436
+ | `strictMode` | boolean | Controla los filtros de desenfoque y brillo. Cuando está activado, se aplican filtros más estrictos |
437
+ | `translation` | object | Configuración de traducciones personalizadas (ver detalle abajo) |
438
+
439
+ #### Objeto de traducción (`config.translation`)
440
+
441
+ | Propiedad | Tipo | Descripción |
442
+ |--------------------------------|-------------------------------------------|--------------------------------------------|
443
+ | `front` | string | Mensaje para escanear el frente del documento |
444
+ | `back` | string | Mensaje para escanear el reverso del documento |
445
+ | `changeSide` | string | Mensaje para voltear el documento |
446
+ | `adjustAngle` | string | Mensaje para ajustar el ángulo del documento |
447
+ | `cameraFeedbackBlur` | string | Mensaje cuando el documento está borroso |
448
+ | `cameraFeedbackFacePhotoCovered`| string | Mensaje cuando la foto de la cara está cubierta |
449
+ | `cameraFeedbackGlare` | string | Mensaje cuando hay deslumbramiento en el documento |
450
+ | `cameraFeedbackWrongSide` | string | Mensaje cuando se muestra el lado incorrecto del documento |
451
+ | `moveCloser` | string | Mensaje para acercar el documento |
452
+ | `moveFarther` | string | Mensaje para alejar el documento |
397
453
 
398
454
  ### Eventos
399
455
 
@@ -426,13 +482,18 @@ document-detector::part(mb-camera-video) {
426
482
 
427
483
  ```typescript
428
484
  enum StatusDocumentDetector {
429
- INITIALIZING = "INITIALIZING",
430
- READY = "READY",
431
485
  RECORDING = "RECORDING",
486
+ ERROR = "ERROR",
432
487
  RUNNING = "RUNNING",
488
+ INITIALIZING = "INITIALIZING",
489
+ FRONT_SIDE_DETECTION = "FRONT_SIDE_DETECTION",
490
+ BACK_SIDE_DETECTION = "BACK_SIDE_DETECTION",
491
+ DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
492
+ DOCUMENT_DETECTED = "DOCUMENT_DETECTED",
493
+ CHANGE_SIDE = "CHANGE_SIDE",
433
494
  RESULTS_SUCCESS = "RESULTS_SUCCESS",
434
- DETECTION_FAILED = "DETECTION_FAILED",
435
- ERROR = "ERROR"
495
+ RESULTS_EMPTY = "RESULTS_EMPTY",
496
+ DETECTION_FAILED = "DETECTION_FAILED"
436
497
  }
437
498
  ```
438
499
 
@@ -6124,7 +6124,7 @@ const DocumentDetector = class {
6124
6124
  };
6125
6125
  this.ready = {
6126
6126
  emit: (data) => {
6127
- this.status.emit(StatusDocumentDetector.INITIALIZING);
6127
+ this.status.emit(StatusDocumentDetector.RECORDING);
6128
6128
  return undefined;
6129
6129
  }
6130
6130
  };
@@ -6143,13 +6143,12 @@ const DocumentDetector = class {
6143
6143
  };
6144
6144
  this.feedback = {
6145
6145
  emit: (data) => {
6146
- console.log(data);
6147
6146
  return undefined;
6148
6147
  }
6149
6148
  };
6150
6149
  this.cameraScanStarted = {
6151
6150
  emit: () => {
6152
- this.status.emit(StatusDocumentDetector.RECORDING);
6151
+ this.status.emit(StatusDocumentDetector.FRONT_SIDE_DETECTION);
6153
6152
  return undefined;
6154
6153
  }
6155
6154
  };
@@ -6217,6 +6216,7 @@ const DocumentDetector = class {
6217
6216
  this.mbComponentEl.setUiState(state);
6218
6217
  }
6219
6218
  async startCameraScan() {
6219
+ this.status.emit(StatusDocumentDetector.INITIALIZING);
6220
6220
  this.mbComponentEl.startCameraScan();
6221
6221
  }
6222
6222
  async startImageScan(file) {
@@ -6340,7 +6340,7 @@ const DocumentDetector = class {
6340
6340
  }, onFeedback: (ev) => {
6341
6341
  this.feedbackEl.show(ev.detail);
6342
6342
  this.feedback.emit(ev.detail);
6343
- }, onScanSuccess: (ev) => this.scanSuccess.emit(ev.detail), onReady: (ev) => this.ready.emit(ev.detail), onCameraScanStarted: (ev) => this.cameraScanStarted.emit(ev.detail), onImageScanStarted: (ev) => this.imageScanStarted.emit(ev.detail), onScanError: (ev) => this.scanError.emit(ev.detail), onScanAborted: (ev) => this.scanAborted.emit(ev.detail) })), index.h("mb-feedback", { dir: this.hostEl.getAttribute("dir"), visible: !this.hideFeedback, ref: (el) => (this.feedbackEl = el) }))));
6343
+ }, onScanSuccess: (ev) => this.scanSuccess.emit(ev.detail), onReady: (ev) => this.ready.emit(ev.detail), onCameraScanStarted: (ev) => this.cameraScanStarted.emit(ev.detail), onImageScanStarted: (ev) => this.imageScanStarted.emit(ev.detail), onScanError: (ev) => this.scanError.emit(ev.detail), onScanAborted: (ev) => this.scanAborted.emit(ev.detail), onStatus: (ev) => this.status.emit(ev.detail) })), index.h("mb-feedback", { dir: this.hostEl.getAttribute("dir"), visible: !this.hideFeedback, ref: (el) => (this.feedbackEl = el) }))));
6344
6344
  }
6345
6345
  get hostEl() { return index.getElement(this); }
6346
6346
  static get watchers() { return {
@@ -6988,6 +6988,7 @@ const MbComponent = class {
6988
6988
  this.imageScanStarted = index.createEvent(this, "imageScanStarted", 7);
6989
6989
  this.scanAborted = index.createEvent(this, "scanAborted", 7);
6990
6990
  this.setIsCameraActive = index.createEvent(this, "setIsCameraActive", 7);
6991
+ this.status = index.createEvent(this, "status", 7);
6991
6992
  this.screens = {
6992
6993
  action: null,
6993
6994
  error: null,
@@ -7377,9 +7378,11 @@ const MbComponent = class {
7377
7378
  break;
7378
7379
  case RecognitionStatus.DetectionStatusFail:
7379
7380
  this.cameraExperience.setState(CameraExperienceState.Default, this.isBackSide);
7381
+ this.status.emit(StatusDocumentDetector.DOCUMENT_NOT_FOUND);
7380
7382
  break;
7381
7383
  case RecognitionStatus.DetectionStatusSuccess:
7382
7384
  this.detectionSuccessLock = true;
7385
+ this.status.emit(StatusDocumentDetector.DOCUMENT_DETECTED);
7383
7386
  window.setTimeout(() => {
7384
7387
  if (this.detectionSuccessLock) {
7385
7388
  this.cameraExperience.setState(CameraExperienceState.Detection);
@@ -7523,6 +7526,8 @@ const MbComponent = class {
7523
7526
  break;
7524
7527
  // handle flipping of other documents
7525
7528
  case RecognitionStatus.OnFirstSideResult:
7529
+ this.status.emit(StatusDocumentDetector.CHANGE_SIDE);
7530
+ this.status.emit(StatusDocumentDetector.BACK_SIDE_DETECTION);
7526
7531
  this.sdkService.videoRecognizer.pauseRecognition();
7527
7532
  window.setTimeout(async () => {
7528
7533
  if (this.areHelpScreensOpen) {
@@ -39,7 +39,7 @@ export class DocumentDetector {
39
39
  };
40
40
  this.ready = {
41
41
  emit: (data) => {
42
- this.status.emit(StatusDocumentDetector.INITIALIZING);
42
+ this.status.emit(StatusDocumentDetector.RECORDING);
43
43
  return undefined;
44
44
  }
45
45
  };
@@ -58,13 +58,12 @@ export class DocumentDetector {
58
58
  };
59
59
  this.feedback = {
60
60
  emit: (data) => {
61
- console.log(data);
62
61
  return undefined;
63
62
  }
64
63
  };
65
64
  this.cameraScanStarted = {
66
65
  emit: () => {
67
- this.status.emit(StatusDocumentDetector.RECORDING);
66
+ this.status.emit(StatusDocumentDetector.FRONT_SIDE_DETECTION);
68
67
  return undefined;
69
68
  }
70
69
  };
@@ -132,6 +131,7 @@ export class DocumentDetector {
132
131
  this.mbComponentEl.setUiState(state);
133
132
  }
134
133
  async startCameraScan() {
134
+ this.status.emit(StatusDocumentDetector.INITIALIZING);
135
135
  this.mbComponentEl.startCameraScan();
136
136
  }
137
137
  async startImageScan(file) {
@@ -255,7 +255,7 @@ export class DocumentDetector {
255
255
  }, onFeedback: (ev) => {
256
256
  this.feedbackEl.show(ev.detail);
257
257
  this.feedback.emit(ev.detail);
258
- }, onScanSuccess: (ev) => this.scanSuccess.emit(ev.detail), onReady: (ev) => this.ready.emit(ev.detail), onCameraScanStarted: (ev) => this.cameraScanStarted.emit(ev.detail), onImageScanStarted: (ev) => this.imageScanStarted.emit(ev.detail), onScanError: (ev) => this.scanError.emit(ev.detail), onScanAborted: (ev) => this.scanAborted.emit(ev.detail) })), h("mb-feedback", { dir: this.hostEl.getAttribute("dir"), visible: !this.hideFeedback, ref: (el) => (this.feedbackEl = el) }))));
258
+ }, onScanSuccess: (ev) => this.scanSuccess.emit(ev.detail), onReady: (ev) => this.ready.emit(ev.detail), onCameraScanStarted: (ev) => this.cameraScanStarted.emit(ev.detail), onImageScanStarted: (ev) => this.imageScanStarted.emit(ev.detail), onScanError: (ev) => this.scanError.emit(ev.detail), onScanAborted: (ev) => this.scanAborted.emit(ev.detail), onStatus: (ev) => this.status.emit(ev.detail) })), h("mb-feedback", { dir: this.hostEl.getAttribute("dir"), visible: !this.hideFeedback, ref: (el) => (this.feedbackEl = el) }))));
259
259
  }
260
260
  static get is() { return "document-detector"; }
261
261
  static get encapsulation() { return "shadow"; }
@@ -1,10 +1,11 @@
1
- import { Host, h, } from "@stencil/core";
2
- import { CameraExperienceState, Code, MultiSideImageType, FeedbackCode, ImageRecognitionType, RecognitionStatus, SDKError, } from "../../../utils/data-structures";
1
+ import { h, Host, } from "@stencil/core";
2
+ import { CameraExperienceState, Code, FeedbackCode, ImageRecognitionType, MultiSideImageType, RecognitionStatus, SDKError, } from "../../../utils/data-structures";
3
3
  import * as ErrorTypes from "../../../utils/error-structures";
4
- import { sdkErrors, ErrorCodes, LicenseErrorType, } from "@microblink/blinkid-in-browser-sdk";
4
+ import { ErrorCodes, LicenseErrorType, sdkErrors, } from "@microblink/blinkid-in-browser-sdk";
5
5
  import * as DeviceHelpers from "../../../utils/device.helpers";
6
6
  import * as GenericHelpers from "../../../utils/generic.helpers";
7
7
  import * as Utils from "./mb-component.utils";
8
+ import { StatusDocumentDetector } from "../../../utils/status.document-detector";
8
9
  export class MbComponent {
9
10
  constructor() {
10
11
  this.screens = {
@@ -396,9 +397,11 @@ export class MbComponent {
396
397
  break;
397
398
  case RecognitionStatus.DetectionStatusFail:
398
399
  this.cameraExperience.setState(CameraExperienceState.Default, this.isBackSide);
400
+ this.status.emit(StatusDocumentDetector.DOCUMENT_NOT_FOUND);
399
401
  break;
400
402
  case RecognitionStatus.DetectionStatusSuccess:
401
403
  this.detectionSuccessLock = true;
404
+ this.status.emit(StatusDocumentDetector.DOCUMENT_DETECTED);
402
405
  window.setTimeout(() => {
403
406
  if (this.detectionSuccessLock) {
404
407
  this.cameraExperience.setState(CameraExperienceState.Detection);
@@ -542,6 +545,8 @@ export class MbComponent {
542
545
  break;
543
546
  // handle flipping of other documents
544
547
  case RecognitionStatus.OnFirstSideResult:
548
+ this.status.emit(StatusDocumentDetector.CHANGE_SIDE);
549
+ this.status.emit(StatusDocumentDetector.BACK_SIDE_DETECTION);
545
550
  this.sdkService.videoRecognizer.pauseRecognition();
546
551
  window.setTimeout(async () => {
547
552
  if (this.areHelpScreensOpen) {
@@ -2150,6 +2155,26 @@ export class MbComponent {
2150
2155
  "resolved": "boolean",
2151
2156
  "references": {}
2152
2157
  }
2158
+ }, {
2159
+ "method": "status",
2160
+ "name": "status",
2161
+ "bubbles": true,
2162
+ "cancelable": true,
2163
+ "composed": true,
2164
+ "docs": {
2165
+ "tags": [],
2166
+ "text": ""
2167
+ },
2168
+ "complexType": {
2169
+ "original": "StatusDocumentDetector",
2170
+ "resolved": "StatusDocumentDetector.BACK_SIDE_DETECTION | StatusDocumentDetector.CHANGE_SIDE | StatusDocumentDetector.DETECTION_FAILED | StatusDocumentDetector.DOCUMENT_DETECTED | StatusDocumentDetector.DOCUMENT_NOT_FOUND | StatusDocumentDetector.ERROR | StatusDocumentDetector.FRONT_SIDE_DETECTION | StatusDocumentDetector.INITIALIZING | StatusDocumentDetector.RECORDING | StatusDocumentDetector.RESULTS_EMPTY | StatusDocumentDetector.RESULTS_SUCCESS | StatusDocumentDetector.RUNNING",
2171
+ "references": {
2172
+ "StatusDocumentDetector": {
2173
+ "location": "import",
2174
+ "path": "../../../utils/status.document-detector"
2175
+ }
2176
+ }
2177
+ }
2153
2178
  }];
2154
2179
  }
2155
2180
  static get methods() {
@@ -6120,7 +6120,7 @@ const DocumentDetector = class {
6120
6120
  };
6121
6121
  this.ready = {
6122
6122
  emit: (data) => {
6123
- this.status.emit(StatusDocumentDetector.INITIALIZING);
6123
+ this.status.emit(StatusDocumentDetector.RECORDING);
6124
6124
  return undefined;
6125
6125
  }
6126
6126
  };
@@ -6139,13 +6139,12 @@ const DocumentDetector = class {
6139
6139
  };
6140
6140
  this.feedback = {
6141
6141
  emit: (data) => {
6142
- console.log(data);
6143
6142
  return undefined;
6144
6143
  }
6145
6144
  };
6146
6145
  this.cameraScanStarted = {
6147
6146
  emit: () => {
6148
- this.status.emit(StatusDocumentDetector.RECORDING);
6147
+ this.status.emit(StatusDocumentDetector.FRONT_SIDE_DETECTION);
6149
6148
  return undefined;
6150
6149
  }
6151
6150
  };
@@ -6213,6 +6212,7 @@ const DocumentDetector = class {
6213
6212
  this.mbComponentEl.setUiState(state);
6214
6213
  }
6215
6214
  async startCameraScan() {
6215
+ this.status.emit(StatusDocumentDetector.INITIALIZING);
6216
6216
  this.mbComponentEl.startCameraScan();
6217
6217
  }
6218
6218
  async startImageScan(file) {
@@ -6336,7 +6336,7 @@ const DocumentDetector = class {
6336
6336
  }, onFeedback: (ev) => {
6337
6337
  this.feedbackEl.show(ev.detail);
6338
6338
  this.feedback.emit(ev.detail);
6339
- }, onScanSuccess: (ev) => this.scanSuccess.emit(ev.detail), onReady: (ev) => this.ready.emit(ev.detail), onCameraScanStarted: (ev) => this.cameraScanStarted.emit(ev.detail), onImageScanStarted: (ev) => this.imageScanStarted.emit(ev.detail), onScanError: (ev) => this.scanError.emit(ev.detail), onScanAborted: (ev) => this.scanAborted.emit(ev.detail) })), h("mb-feedback", { dir: this.hostEl.getAttribute("dir"), visible: !this.hideFeedback, ref: (el) => (this.feedbackEl = el) }))));
6339
+ }, onScanSuccess: (ev) => this.scanSuccess.emit(ev.detail), onReady: (ev) => this.ready.emit(ev.detail), onCameraScanStarted: (ev) => this.cameraScanStarted.emit(ev.detail), onImageScanStarted: (ev) => this.imageScanStarted.emit(ev.detail), onScanError: (ev) => this.scanError.emit(ev.detail), onScanAborted: (ev) => this.scanAborted.emit(ev.detail), onStatus: (ev) => this.status.emit(ev.detail) })), h("mb-feedback", { dir: this.hostEl.getAttribute("dir"), visible: !this.hideFeedback, ref: (el) => (this.feedbackEl = el) }))));
6340
6340
  }
6341
6341
  get hostEl() { return getElement(this); }
6342
6342
  static get watchers() { return {
@@ -6984,6 +6984,7 @@ const MbComponent = class {
6984
6984
  this.imageScanStarted = createEvent(this, "imageScanStarted", 7);
6985
6985
  this.scanAborted = createEvent(this, "scanAborted", 7);
6986
6986
  this.setIsCameraActive = createEvent(this, "setIsCameraActive", 7);
6987
+ this.status = createEvent(this, "status", 7);
6987
6988
  this.screens = {
6988
6989
  action: null,
6989
6990
  error: null,
@@ -7373,9 +7374,11 @@ const MbComponent = class {
7373
7374
  break;
7374
7375
  case RecognitionStatus.DetectionStatusFail:
7375
7376
  this.cameraExperience.setState(CameraExperienceState.Default, this.isBackSide);
7377
+ this.status.emit(StatusDocumentDetector.DOCUMENT_NOT_FOUND);
7376
7378
  break;
7377
7379
  case RecognitionStatus.DetectionStatusSuccess:
7378
7380
  this.detectionSuccessLock = true;
7381
+ this.status.emit(StatusDocumentDetector.DOCUMENT_DETECTED);
7379
7382
  window.setTimeout(() => {
7380
7383
  if (this.detectionSuccessLock) {
7381
7384
  this.cameraExperience.setState(CameraExperienceState.Detection);
@@ -7519,6 +7522,8 @@ const MbComponent = class {
7519
7522
  break;
7520
7523
  // handle flipping of other documents
7521
7524
  case RecognitionStatus.OnFirstSideResult:
7525
+ this.status.emit(StatusDocumentDetector.CHANGE_SIDE);
7526
+ this.status.emit(StatusDocumentDetector.BACK_SIDE_DETECTION);
7522
7527
  this.sdkService.videoRecognizer.pauseRecognition();
7523
7528
  window.setTimeout(async () => {
7524
7529
  if (this.areHelpScreensOpen) {