@jaak.ai/stamps 2.0.0-dev.25 → 2.0.0-dev.27
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 +3 -0
- package/dist/cjs/{index-DGM9-FNg.js → index-BfhtOB0D.js} +5 -2
- package/dist/cjs/index-BfhtOB0D.js.map +1 -0
- package/dist/cjs/jaak-stamps-webcomponent.cjs.js +2 -2
- package/dist/cjs/jaak-stamps.cjs.entry.js +431 -23
- package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -1
- package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/my-component/my-component.css +252 -0
- package/dist/collection/components/my-component/my-component.js +493 -22
- package/dist/collection/components/my-component/my-component.js.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/jaak-stamps.js +438 -23
- package/dist/components/jaak-stamps.js.map +1 -1
- package/dist/esm/{index-DqoVMnc7.js → index-BP1Q4KOg.js} +5 -2
- package/dist/esm/index-BP1Q4KOg.js.map +1 -0
- package/dist/esm/jaak-stamps-webcomponent.js +3 -3
- package/dist/esm/jaak-stamps.entry.js +431 -23
- package/dist/esm/jaak-stamps.entry.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +1 -1
- package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -1
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js +3 -0
- package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js.map +1 -0
- package/dist/jaak-stamps-webcomponent/p-eb318f43.entry.js +2 -0
- package/dist/jaak-stamps-webcomponent/p-eb318f43.entry.js.map +1 -0
- package/dist/types/components/my-component/my-component.d.ts +36 -0
- package/dist/types/components.d.ts +10 -0
- package/package.json +1 -1
- package/dist/cjs/index-DGM9-FNg.js.map +0 -1
- package/dist/esm/index-DqoVMnc7.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js +0 -3
- package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js.map +0 -1
- package/dist/jaak-stamps-webcomponent/p-f1172b06.entry.js +0 -2
- package/dist/jaak-stamps-webcomponent/p-f1172b06.entry.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-BfhtOB0D.js');
|
|
4
4
|
|
|
5
|
-
const myComponentCss = ":host{display:block;width:100%;height:100%;font-family:system-ui, -apple-system, sans-serif;color:#1a1a1a}.detector-container{display:flex;flex-direction:column;align-items:center;width:100%;height:100%}h1{font-size:24px;font-weight:500;color:#333;margin:0 0 24px 0}.video-container{position:relative;width:100%;height:100%;background:#333;border:1px solid #e0e0e0;border-radius:8px;overflow:hidden}video,canvas{position:absolute;width:100%;height:100%;border-radius:8px}video.mirror,canvas.mirror{transform:rotateY(180deg)}canvas{z-index:1}video{z-index:0}.status{margin-top:16px;font-size:12px;color:#666}.overlay-mask{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10;display:block;pointer-events:none}.card-outline{position:absolute;top:var(--mask-center-y, 50%);left:var(--mask-center-x, 50%);transform:translate(-50%, -50%);width:var(--mask-width, 88%);height:var(--mask-height, 55%);border:none;border-radius:4px;background:transparent;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7);opacity:0.8}.card-outline.perfect-match{box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7)}.side{position:absolute;background:#999;transition:background-color 0.3s ease}.side.aligned{background:#28a745}.side-top{top:0;left:0;width:100%;height:3px}.side-right{top:0;right:0;width:3px;height:100%}.side-bottom{bottom:0;left:0;width:100%;height:3px}.side-left{top:0;left:0;width:3px;height:100%}.corner{position:absolute;width:20px;height:20px;border:2px solid #999;z-index:12}.corner-tl{top:-10px;left:-10px;border-right:none;border-bottom:none}.corner-tr{top:-10px;right:-10px;border-left:none;border-bottom:none}.corner-bl{bottom:-10px;left:-10px;border-right:none;border-top:none}.corner-br{bottom:-10px;right:-10px;border-left:none;border-top:none}.corner.perfect-match{border-color:#28a745}.guide-text{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);color:#fff;font-size:14px;font-weight:600;text-align:center;white-space:normal;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px;z-index:20}.capture-animation{position:absolute;top:0;left:0;width:100%;height:100%;background:#fff;opacity:0;z-index:30;pointer-events:none;animation:captureFlash 0.6s ease-out}@keyframes captureFlash{0%{opacity:0}15%{opacity:0.8}30%{opacity:0}45%{opacity:0.4}60%{opacity:0}100%{opacity:0}}.card-outline.capturing{animation:pulseGreen 0.6s ease-out}@keyframes pulseGreen{0%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(40, 167, 69, 0)}50%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 8px rgba(40, 167, 69, 0.6)}100%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(40, 167, 69, 0)}}.flip-animation{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:35;pointer-events:none;opacity:0;animation:showFlipInstruction 3s ease-in-out;display:flex;flex-direction:column;align-items:center;justify-content:center}.id-card-icon{width:80px;height:50px;background:linear-gradient(135deg, #6c757d 0%, #495057 100%);border-radius:8px;position:relative;animation:flipCard 2s ease-in-out infinite;box-shadow:0 4px 12px rgba(0, 0, 0, 0.3)}.id-card-icon::before{content:'';position:absolute;top:8px;left:8px;width:16px;height:12px;background:rgba(255, 255, 255, 0.9);border-radius:2px}.id-card-icon::after{content:'';position:absolute;top:25px;left:8px;width:64px;height:3px;background:rgba(255, 255, 255, 0.7);border-radius:1px;box-shadow:0 6px 0 rgba(255, 255, 255, 0.7), 0 12px 0 rgba(255, 255, 255, 0.7)}.flip-text{margin-top:12px;color:#fff;font-size:14px;font-weight:600;text-align:center;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px}@keyframes showFlipInstruction{0%{opacity:0;transform:translate(-50%, -50%) scale(0.8)}15%{opacity:1;transform:translate(-50%, -50%) scale(1)}85%{opacity:1;transform:translate(-50%, -50%) scale(1)}100%{opacity:0;transform:translate(-50%, -50%) scale(0.8)}}@keyframes flipCard{0%{transform:rotateY(0deg)}50%{transform:rotateY(180deg)}100%{transform:rotateY(360deg)}}.success-animation{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:35;pointer-events:none;opacity:0;animation:showSuccessMessage 3s ease-in-out;display:flex;flex-direction:column;align-items:center;justify-content:center}.check-icon{width:80px;height:80px;background:linear-gradient(135deg, #6c757d 0%, #495057 100%);border-radius:50%;position:relative;animation:bounceSuccess 0.6s ease-out;box-shadow:0 4px 16px rgba(108, 117, 125, 0.4);display:flex;align-items:center;justify-content:center}.check-icon::before{content:'';position:absolute;width:20px;height:35px;border:4px solid #fff;border-top:none;border-left:none;transform:rotate(45deg);animation:drawCheck 0.4s ease-out 0.2s both}.success-text{margin-top:16px;color:#fff;font-size:14px;font-weight:600;text-align:center;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px;animation:fadeInUp 0.5s ease-out 0.4s both}@keyframes showSuccessMessage{0%{opacity:0;transform:translate(-50%, -50%) scale(0.5)}15%{opacity:1;transform:translate(-50%, -50%) scale(1)}85%{opacity:1;transform:translate(-50%, -50%) scale(1)}100%{opacity:0;transform:translate(-50%, -50%) scale(0.9)}}@keyframes bounceSuccess{0%{transform:scale(0)}50%{transform:scale(1.1)}100%{transform:scale(1)}}@keyframes drawCheck{0%{width:0;height:0}50%{width:20px;height:0}100%{width:20px;height:35px}}@keyframes fadeInUp{0%{opacity:0;transform:translateY(20px)}100%{opacity:1;transform:translateY(0)}}.skip-button{position:absolute;bottom:20px;left:50%;transform:translateX(-50%);z-index:25;pointer-events:auto;background:#fff;color:#333;border:none;border-radius:25px;padding:12px 24px;font-size:14px;font-weight:600;cursor:pointer;transition:all 0.3s ease}.skip-button:hover{background:#f8f9fa}.skip-button:active{background:#e9ecef;transform:translateX(-50%) translateY(0)}.watermark{position:absolute;bottom:12px;right:12px;z-index:15;pointer-events:none;opacity:0.7}.watermark img{height:24px;width:auto;filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3))}.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.8);display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:30;border-radius:20px}.loading-spinner{width:60px;height:60px;border:4px solid rgba(255, 255, 255, 0.2);border-top:4px solid #007bff;border-radius:50%;animation:spin 1s linear infinite;margin-bottom:20px}.loading-text{color:white;font-size:16px;font-weight:500;text-align:center;opacity:0.9}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
|
|
5
|
+
const myComponentCss = ":host{display:block;width:100%;height:100%;font-family:system-ui, -apple-system, sans-serif;color:#1a1a1a}.detector-container{display:flex;flex-direction:column;align-items:center;width:100%;height:100%}h1{font-size:24px;font-weight:500;color:#333;margin:0 0 24px 0}.video-container{position:relative;width:100%;height:100%;background:#333;border:1px solid #e0e0e0;border-radius:8px;overflow:hidden}video,canvas{position:absolute;width:100%;height:100%;border-radius:8px}video.mirror,canvas.mirror{transform:rotateY(180deg)}canvas{z-index:1}video{z-index:0}.status{margin-top:16px;font-size:12px;color:#666}.overlay-mask{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10;display:block;pointer-events:none}.card-outline{position:absolute;top:var(--mask-center-y, 50%);left:var(--mask-center-x, 50%);transform:translate(-50%, -50%);width:var(--mask-width, 88%);height:var(--mask-height, 55%);border:none;border-radius:4px;background:transparent;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7);opacity:0.8}.card-outline.perfect-match{box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7)}.side{position:absolute;background:#999;transition:background-color 0.3s ease}.side.aligned{background:#28a745}.side-top{top:0;left:0;width:100%;height:3px}.side-right{top:0;right:0;width:3px;height:100%}.side-bottom{bottom:0;left:0;width:100%;height:3px}.side-left{top:0;left:0;width:3px;height:100%}.corner{position:absolute;width:20px;height:20px;border:2px solid #999;z-index:12}.corner-tl{top:-10px;left:-10px;border-right:none;border-bottom:none}.corner-tr{top:-10px;right:-10px;border-left:none;border-bottom:none}.corner-bl{bottom:-10px;left:-10px;border-right:none;border-top:none}.corner-br{bottom:-10px;right:-10px;border-left:none;border-top:none}.corner.perfect-match{border-color:#28a745}.guide-text{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);color:#fff;font-size:14px;font-weight:600;text-align:center;white-space:normal;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px;z-index:20}.capture-animation{position:absolute;top:0;left:0;width:100%;height:100%;background:#fff;opacity:0;z-index:30;pointer-events:none;animation:captureFlash 0.6s ease-out}@keyframes captureFlash{0%{opacity:0}15%{opacity:0.8}30%{opacity:0}45%{opacity:0.4}60%{opacity:0}100%{opacity:0}}.card-outline.capturing{animation:pulseGreen 0.6s ease-out}@keyframes pulseGreen{0%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(40, 167, 69, 0)}50%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 8px rgba(40, 167, 69, 0.6)}100%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(40, 167, 69, 0)}}.flip-animation{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:35;pointer-events:none;opacity:0;animation:showFlipInstruction 3s ease-in-out;display:flex;flex-direction:column;align-items:center;justify-content:center}.id-card-icon{width:80px;height:50px;background:linear-gradient(135deg, #6c757d 0%, #495057 100%);border-radius:8px;position:relative;animation:flipCard 2s ease-in-out infinite;box-shadow:0 4px 12px rgba(0, 0, 0, 0.3)}.id-card-icon::before{content:'';position:absolute;top:8px;left:8px;width:16px;height:12px;background:rgba(255, 255, 255, 0.9);border-radius:2px}.id-card-icon::after{content:'';position:absolute;top:25px;left:8px;width:64px;height:3px;background:rgba(255, 255, 255, 0.7);border-radius:1px;box-shadow:0 6px 0 rgba(255, 255, 255, 0.7), 0 12px 0 rgba(255, 255, 255, 0.7)}.flip-text{margin-top:12px;color:#fff;font-size:14px;font-weight:600;text-align:center;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px}@keyframes showFlipInstruction{0%{opacity:0;transform:translate(-50%, -50%) scale(0.8)}15%{opacity:1;transform:translate(-50%, -50%) scale(1)}85%{opacity:1;transform:translate(-50%, -50%) scale(1)}100%{opacity:0;transform:translate(-50%, -50%) scale(0.8)}}@keyframes flipCard{0%{transform:rotateY(0deg)}50%{transform:rotateY(180deg)}100%{transform:rotateY(360deg)}}.success-animation{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:35;pointer-events:none;opacity:0;animation:showSuccessMessage 3s ease-in-out;display:flex;flex-direction:column;align-items:center;justify-content:center}.check-icon{width:80px;height:80px;background:linear-gradient(135deg, #6c757d 0%, #495057 100%);border-radius:50%;position:relative;animation:bounceSuccess 0.6s ease-out;box-shadow:0 4px 16px rgba(108, 117, 125, 0.4);display:flex;align-items:center;justify-content:center}.check-icon::before{content:'';position:absolute;width:20px;height:35px;border:4px solid #fff;border-top:none;border-left:none;transform:rotate(45deg);animation:drawCheck 0.4s ease-out 0.2s both}.success-text{margin-top:16px;color:#fff;font-size:14px;font-weight:600;text-align:center;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px;animation:fadeInUp 0.5s ease-out 0.4s both}@keyframes showSuccessMessage{0%{opacity:0;transform:translate(-50%, -50%) scale(0.5)}15%{opacity:1;transform:translate(-50%, -50%) scale(1)}85%{opacity:1;transform:translate(-50%, -50%) scale(1)}100%{opacity:0;transform:translate(-50%, -50%) scale(0.9)}}@keyframes bounceSuccess{0%{transform:scale(0)}50%{transform:scale(1.1)}100%{transform:scale(1)}}@keyframes drawCheck{0%{width:0;height:0}50%{width:20px;height:0}100%{width:20px;height:35px}}@keyframes fadeInUp{0%{opacity:0;transform:translateY(20px)}100%{opacity:1;transform:translateY(0)}}.skip-button{position:absolute;bottom:20px;left:50%;transform:translateX(-50%);z-index:25;pointer-events:auto;background:#fff;color:#333;border:none;border-radius:25px;padding:12px 24px;font-size:14px;font-weight:600;cursor:pointer;transition:all 0.3s ease}.skip-button:hover{background:#f8f9fa}.skip-button:active{background:#e9ecef;transform:translateX(-50%) translateY(0)}.camera-controls{position:absolute;top:16px;right:16px;z-index:25;display:flex;gap:8px;pointer-events:auto}.flip-camera-button{height:40px;padding:0 16px;border:none;border-radius:8px;background:rgba(0, 0, 0, 0.6);backdrop-filter:blur(12px);color:#ffffff;font-size:12px;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;justify-content:center;border:1px solid rgba(255, 255, 255, 0.1);white-space:nowrap;min-width:fit-content}.camera-selector-button{height:40px;padding:0 16px;border:none;border-radius:8px;background:rgba(0, 0, 0, 0.6);backdrop-filter:blur(12px);color:#ffffff;font-size:12px;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;justify-content:center;border:1px solid rgba(255, 255, 255, 0.1);white-space:nowrap;min-width:fit-content}.flip-camera-button:hover,.camera-selector-button:hover{background:rgba(0, 0, 0, 0.8);border-color:rgba(255, 255, 255, 0.2);transform:translateY(-1px)}.flip-camera-button:active,.camera-selector-button:active{transform:translateY(0);background:rgba(0, 0, 0, 0.9)}.camera-selector-dropdown{position:absolute;top:56px;right:16px;z-index:30;background:rgba(0, 0, 0, 0.85);backdrop-filter:blur(20px);border-radius:12px;min-width:260px;max-width:300px;border:1px solid rgba(255, 255, 255, 0.1);overflow:hidden;pointer-events:auto;animation:slideInFromTop 0.3s ease-out}@keyframes slideInFromTop{0%{opacity:0;transform:translateY(-8px) scale(0.95)}100%{opacity:1;transform:translateY(0) scale(1)}}.camera-selector-header{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid rgba(255, 255, 255, 0.1)}.camera-selector-header span{font-weight:500;color:#ffffff;font-size:13px;opacity:0.9}.close-selector{width:20px;height:20px;border:none;background:none;color:rgba(255, 255, 255, 0.7);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:all 0.2s ease}.close-selector:hover{background:rgba(255, 255, 255, 0.1);color:#ffffff}.camera-list{padding:4px 0;max-height:240px;overflow-y:auto}.camera-option{width:100%;padding:10px 16px;border:none;background:none;text-align:left;cursor:pointer;transition:all 0.2s ease;display:flex;justify-content:space-between;align-items:center;color:rgba(255, 255, 255, 0.9)}.camera-option:hover{background:rgba(255, 255, 255, 0.08)}.camera-option.selected{background:rgba(255, 255, 255, 0.12);color:#ffffff}.camera-label{font-size:13px;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-right:8px;font-weight:400}.selected-indicator{font-size:14px;color:#ffffff;opacity:0.9}.device-info{padding:8px 16px;border-top:1px solid rgba(255, 255, 255, 0.1);background:rgba(255, 255, 255, 0.05)}.device-info small{color:rgba(255, 255, 255, 0.6);font-size:11px;text-transform:capitalize;font-weight:400}@media (max-width: 480px){.camera-controls{top:12px;right:12px;gap:6px}.flip-camera-button{height:36px;padding:0 12px;font-size:11px;border-radius:6px}.camera-selector-button{height:36px;padding:0 12px;font-size:11px;border-radius:6px}.camera-selector-dropdown{right:12px;top:48px;min-width:240px;max-width:calc(100vw - 24px)}.camera-selector-header{padding:10px 14px}.camera-option{padding:8px 14px}.device-info{padding:6px 14px}}.watermark{position:absolute;bottom:12px;right:12px;z-index:15;pointer-events:none;opacity:0.7}.watermark img{height:24px;width:auto;filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3))}.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.8);display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:30;border-radius:20px}.loading-spinner{width:60px;height:60px;border:4px solid rgba(255, 255, 255, 0.2);border-top:4px solid #007bff;border-radius:50%;animation:spin 1s linear infinite;margin-bottom:20px}.loading-text{color:white;font-size:16px;font-weight:500;text-align:center;opacity:0.9}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.status-bar{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);background:rgba(0, 0, 0, 0.7);border-radius:15px;padding:8px 16px;z-index:40;backdrop-filter:blur(5px);border:1px solid rgba(255, 255, 255, 0.1)}.status-message{font-size:12px;font-weight:500;text-align:center;color:#fff;white-space:nowrap;max-width:280px;overflow:hidden;text-overflow:ellipsis}";
|
|
6
6
|
|
|
7
7
|
const JaakStamps = class {
|
|
8
8
|
constructor(hostRef) {
|
|
@@ -16,6 +16,7 @@ const JaakStamps = class {
|
|
|
16
16
|
maskSize = 90; // Porcentaje del video que ocupará la máscara (default 90%)
|
|
17
17
|
cropMargin = 0; // Margen en píxeles para el recorte del documento (default 0)
|
|
18
18
|
useDocumentClassification = false; // Habilita la clasificación automática de documentos para determinar si solicitar reverso
|
|
19
|
+
preferredCamera = 'auto'; // Define qué cámara usar: 'auto' (automático según dispositivo), 'front' (frontal), 'back' (trasera)
|
|
19
20
|
captureCompleted;
|
|
20
21
|
isReady;
|
|
21
22
|
isVideoActive = false;
|
|
@@ -41,6 +42,10 @@ const JaakStamps = class {
|
|
|
41
42
|
isLoading = false;
|
|
42
43
|
isModelPreloaded = false;
|
|
43
44
|
isMaskReady = false;
|
|
45
|
+
availableCameras = [];
|
|
46
|
+
selectedCameraId = null;
|
|
47
|
+
showCameraSelector = false;
|
|
48
|
+
isMultipleCamerasAvailable = false;
|
|
44
49
|
videoRef;
|
|
45
50
|
canvasRef;
|
|
46
51
|
session;
|
|
@@ -51,6 +56,9 @@ const JaakStamps = class {
|
|
|
51
56
|
lastDetectedBox;
|
|
52
57
|
mobileNetSession;
|
|
53
58
|
mobileNetClassMap;
|
|
59
|
+
// Camera management properties
|
|
60
|
+
deviceType = 'desktop';
|
|
61
|
+
preferredCameraFacing = null;
|
|
54
62
|
// Performance optimization properties
|
|
55
63
|
frameSkipCounter = 0;
|
|
56
64
|
FRAME_SKIP = 2; // Process every 3rd frame (reduces CPU by ~66%)
|
|
@@ -87,6 +95,13 @@ const JaakStamps = class {
|
|
|
87
95
|
this.cropMargin = 0;
|
|
88
96
|
}
|
|
89
97
|
}
|
|
98
|
+
validatePreferredCamera() {
|
|
99
|
+
const validOptions = ['auto', 'front', 'back'];
|
|
100
|
+
if (!validOptions.includes(this.preferredCamera)) {
|
|
101
|
+
console.warn(`preferredCamera debe ser uno de: ${validOptions.join(', ')}. Valor actual: ${this.preferredCamera}. Usando valor por defecto: 'auto'`);
|
|
102
|
+
this.preferredCamera = 'auto';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
90
105
|
emitReadyEvent() {
|
|
91
106
|
const isDocumentReady = !!window.ort && this.isModelPreloaded;
|
|
92
107
|
this.isReady.emit(isDocumentReady);
|
|
@@ -99,21 +114,318 @@ const JaakStamps = class {
|
|
|
99
114
|
const settings = videoTrack.getSettings();
|
|
100
115
|
return settings.facingMode === 'environment';
|
|
101
116
|
}
|
|
117
|
+
async detectDeviceTypeAndCameras() {
|
|
118
|
+
// Detect device type
|
|
119
|
+
const userAgent = navigator.userAgent;
|
|
120
|
+
const isMobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
|
|
121
|
+
const isTablet = /iPad|Android/i.test(userAgent) && window.innerWidth >= 768;
|
|
122
|
+
if (isTablet) {
|
|
123
|
+
this.deviceType = 'tablet';
|
|
124
|
+
}
|
|
125
|
+
else if (isMobile) {
|
|
126
|
+
this.deviceType = 'mobile';
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.deviceType = 'desktop';
|
|
130
|
+
}
|
|
131
|
+
this.debugLog('📱 Device type detected:', this.deviceType);
|
|
132
|
+
// Enumerate available cameras
|
|
133
|
+
await this.enumerateAndDetectCameras();
|
|
134
|
+
// Load user preference
|
|
135
|
+
this.loadCameraPreference();
|
|
136
|
+
}
|
|
137
|
+
async enumerateAndDetectCameras() {
|
|
138
|
+
try {
|
|
139
|
+
// First, check if we have permission to enumerate devices
|
|
140
|
+
const permissionStatus = await this.checkCameraPermission();
|
|
141
|
+
if (permissionStatus === 'denied') {
|
|
142
|
+
this.debugLog('❌ Camera permission denied');
|
|
143
|
+
this.statusMessage = "Permiso de cámara denegado";
|
|
144
|
+
this.statusColor = "#ff6b6b";
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Request minimal permission to get device labels
|
|
148
|
+
if (permissionStatus === 'prompt') {
|
|
149
|
+
const tempStream = await navigator.mediaDevices.getUserMedia({ video: true });
|
|
150
|
+
tempStream.getTracks().forEach(track => track.stop());
|
|
151
|
+
}
|
|
152
|
+
// Now enumerate devices with labels
|
|
153
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
154
|
+
this.availableCameras = devices.filter(device => device.kind === 'videoinput');
|
|
155
|
+
this.isMultipleCamerasAvailable = this.availableCameras.length > 1;
|
|
156
|
+
this.debugLog('📹 Available cameras:', {
|
|
157
|
+
count: this.availableCameras.length,
|
|
158
|
+
isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
|
|
159
|
+
cameras: this.availableCameras.map(cam => ({
|
|
160
|
+
id: cam.deviceId,
|
|
161
|
+
label: cam.label || 'Unknown Camera'
|
|
162
|
+
}))
|
|
163
|
+
});
|
|
164
|
+
// Set initial camera preference based on device type
|
|
165
|
+
this.setInitialCameraPreference();
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
this.debugLog('❌ Error enumerating cameras:', error);
|
|
169
|
+
this.handleCameraPermissionError(error);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async checkCameraPermission() {
|
|
173
|
+
try {
|
|
174
|
+
if (!navigator.permissions) {
|
|
175
|
+
return 'prompt'; // Assume we need to prompt on older browsers
|
|
176
|
+
}
|
|
177
|
+
const permission = await navigator.permissions.query({ name: 'camera' });
|
|
178
|
+
return permission.state;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
this.debugLog('⚠️ Could not check camera permission:', error);
|
|
182
|
+
return 'prompt';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
handleCameraPermissionError(error) {
|
|
186
|
+
if (error.name === 'NotAllowedError') {
|
|
187
|
+
this.statusMessage = "Permiso de cámara denegado. Active el permiso en configuración.";
|
|
188
|
+
this.statusColor = "#ff6b6b";
|
|
189
|
+
this.availableCameras = [];
|
|
190
|
+
this.isMultipleCamerasAvailable = false;
|
|
191
|
+
}
|
|
192
|
+
else if (error.name === 'NotFoundError') {
|
|
193
|
+
this.statusMessage = "No se encontraron cámaras disponibles.";
|
|
194
|
+
this.statusColor = "#ff6b6b";
|
|
195
|
+
this.availableCameras = [];
|
|
196
|
+
this.isMultipleCamerasAvailable = false;
|
|
197
|
+
}
|
|
198
|
+
else if (error.name === 'NotReadableError') {
|
|
199
|
+
this.statusMessage = "Cámara en uso por otra aplicación.";
|
|
200
|
+
this.statusColor = "#ff6b6b";
|
|
201
|
+
this.availableCameras = [];
|
|
202
|
+
this.isMultipleCamerasAvailable = false;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
this.statusMessage = "Error al acceder a las cámaras.";
|
|
206
|
+
this.statusColor = "#ff6b6b";
|
|
207
|
+
this.availableCameras = [];
|
|
208
|
+
this.isMultipleCamerasAvailable = false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
setInitialCameraPreference() {
|
|
212
|
+
if (this.availableCameras.length === 0)
|
|
213
|
+
return;
|
|
214
|
+
// Apply user preference for camera selection
|
|
215
|
+
if (this.preferredCamera === 'front') {
|
|
216
|
+
// User explicitly wants front camera
|
|
217
|
+
this.preferredCameraFacing = 'user';
|
|
218
|
+
const frontCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('front') ||
|
|
219
|
+
camera.label.toLowerCase().includes('user') ||
|
|
220
|
+
camera.label.toLowerCase().includes('selfie') ||
|
|
221
|
+
!camera.label.toLowerCase().includes('back') && !camera.label.toLowerCase().includes('rear'));
|
|
222
|
+
if (frontCamera) {
|
|
223
|
+
this.selectedCameraId = frontCamera.deviceId;
|
|
224
|
+
this.debugLog('👤 User selected front camera:', frontCamera.label);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
228
|
+
this.debugLog('⚠️ Front camera not found, using first available:', this.availableCameras[0].label);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (this.preferredCamera === 'back') {
|
|
232
|
+
// User explicitly wants back camera
|
|
233
|
+
this.preferredCameraFacing = 'environment';
|
|
234
|
+
const backCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('back') ||
|
|
235
|
+
camera.label.toLowerCase().includes('rear') ||
|
|
236
|
+
camera.label.toLowerCase().includes('environment'));
|
|
237
|
+
if (backCamera) {
|
|
238
|
+
this.selectedCameraId = backCamera.deviceId;
|
|
239
|
+
this.debugLog('📷 User selected back camera:', backCamera.label);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
243
|
+
this.debugLog('⚠️ Back camera not found, using first available:', this.availableCameras[0].label);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// Auto mode - use device type to determine best camera
|
|
248
|
+
if (this.deviceType === 'mobile' || this.deviceType === 'tablet') {
|
|
249
|
+
// For mobile/tablet, prefer rear camera for document scanning
|
|
250
|
+
this.preferredCameraFacing = 'environment';
|
|
251
|
+
const rearCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('back') ||
|
|
252
|
+
camera.label.toLowerCase().includes('rear') ||
|
|
253
|
+
camera.label.toLowerCase().includes('environment'));
|
|
254
|
+
if (rearCamera) {
|
|
255
|
+
this.selectedCameraId = rearCamera.deviceId;
|
|
256
|
+
this.debugLog('📱 Auto-selected rear camera for mobile:', rearCamera.label);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
260
|
+
this.debugLog('📱 Rear camera not found, using first available:', this.availableCameras[0].label);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
// For desktop, use first available camera (usually the only one)
|
|
265
|
+
this.selectedCameraId = this.availableCameras[0].deviceId;
|
|
266
|
+
this.debugLog('💻 Auto-selected desktop camera:', this.availableCameras[0].label);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
loadCameraPreference() {
|
|
271
|
+
try {
|
|
272
|
+
const saved = localStorage.getItem('jaak-stamps-camera-preference');
|
|
273
|
+
if (saved) {
|
|
274
|
+
const preference = JSON.parse(saved);
|
|
275
|
+
// Validate that the saved camera is still available
|
|
276
|
+
const isStillAvailable = this.availableCameras.some(camera => camera.deviceId === preference.cameraId);
|
|
277
|
+
if (isStillAvailable) {
|
|
278
|
+
this.selectedCameraId = preference.cameraId;
|
|
279
|
+
this.preferredCameraFacing = preference.facing;
|
|
280
|
+
this.debugLog('💾 Loaded camera preference:', preference);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
this.debugLog('⚠️ Error loading camera preference:', error);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
saveCameraPreference() {
|
|
289
|
+
try {
|
|
290
|
+
const preference = {
|
|
291
|
+
cameraId: this.selectedCameraId,
|
|
292
|
+
facing: this.preferredCameraFacing,
|
|
293
|
+
timestamp: Date.now()
|
|
294
|
+
};
|
|
295
|
+
localStorage.setItem('jaak-stamps-camera-preference', JSON.stringify(preference));
|
|
296
|
+
this.debugLog('💾 Saved camera preference:', preference);
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
this.debugLog('⚠️ Error saving camera preference:', error);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async switchCamera(cameraId) {
|
|
303
|
+
if (!this.isVideoActive || this.selectedCameraId === cameraId)
|
|
304
|
+
return;
|
|
305
|
+
try {
|
|
306
|
+
// Check if the selected camera is still available
|
|
307
|
+
const selectedCamera = this.availableCameras.find(cam => cam.deviceId === cameraId);
|
|
308
|
+
if (!selectedCamera) {
|
|
309
|
+
this.debugLog('❌ Selected camera not found, re-enumerating...');
|
|
310
|
+
await this.enumerateAndDetectCameras();
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
// Show loading state
|
|
314
|
+
if (this.debug) {
|
|
315
|
+
this.statusMessage = "Cambiando cámara...";
|
|
316
|
+
this.statusColor = "#007bff";
|
|
317
|
+
}
|
|
318
|
+
// Stop current stream
|
|
319
|
+
if (this.videoStream) {
|
|
320
|
+
this.videoStream.getTracks().forEach(track => track.stop());
|
|
321
|
+
}
|
|
322
|
+
// Update selected camera
|
|
323
|
+
this.selectedCameraId = cameraId;
|
|
324
|
+
// Update facing mode preference
|
|
325
|
+
const isRearCamera = selectedCamera.label.toLowerCase().includes('back') ||
|
|
326
|
+
selectedCamera.label.toLowerCase().includes('rear') ||
|
|
327
|
+
selectedCamera.label.toLowerCase().includes('environment');
|
|
328
|
+
this.preferredCameraFacing = isRearCamera ? 'environment' : 'user';
|
|
329
|
+
// Save preference
|
|
330
|
+
this.saveCameraPreference();
|
|
331
|
+
// Setup new camera with error handling
|
|
332
|
+
await this.setupCameraWithRetry();
|
|
333
|
+
this.debugLog('🔄 Switched to camera:', selectedCamera.label);
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
this.debugLog('❌ Error switching camera:', error);
|
|
337
|
+
this.handleCameraPermissionError(error);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
async setupCameraWithRetry(maxRetries = 3) {
|
|
341
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
342
|
+
try {
|
|
343
|
+
await this.setupCamera();
|
|
344
|
+
if (this.debug) {
|
|
345
|
+
this.statusMessage = "Cámara configurada correctamente";
|
|
346
|
+
this.statusColor = "#28a745";
|
|
347
|
+
}
|
|
348
|
+
return; // Success
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
this.debugLog(`❌ Camera setup attempt ${attempt} failed:`, error);
|
|
352
|
+
if (attempt === maxRetries) {
|
|
353
|
+
// Last attempt failed, handle the error
|
|
354
|
+
this.statusMessage = "Error al configurar la cámara";
|
|
355
|
+
this.statusColor = "#ff6b6b";
|
|
356
|
+
this.handleCameraPermissionError(error);
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
// Update status for retry attempt
|
|
360
|
+
if (this.debug) {
|
|
361
|
+
this.statusMessage = `Reintentando configuración de cámara... (${attempt}/${maxRetries})`;
|
|
362
|
+
this.statusColor = "#ffb366";
|
|
363
|
+
}
|
|
364
|
+
// Wait before retrying
|
|
365
|
+
await new Promise(resolve => setTimeout(resolve, 500 * attempt));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
toggleCameraSelector() {
|
|
370
|
+
this.showCameraSelector = !this.showCameraSelector;
|
|
371
|
+
this.debugLog('📹 Camera selector toggled:', {
|
|
372
|
+
showCameraSelector: this.showCameraSelector,
|
|
373
|
+
isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
|
|
374
|
+
availableCameras: this.availableCameras.length,
|
|
375
|
+
isVideoActive: this.isVideoActive
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
async flipCamera() {
|
|
379
|
+
if (!this.isMultipleCamerasAvailable)
|
|
380
|
+
return;
|
|
381
|
+
const currentIndex = this.availableCameras.findIndex(camera => camera.deviceId === this.selectedCameraId);
|
|
382
|
+
const nextIndex = (currentIndex + 1) % this.availableCameras.length;
|
|
383
|
+
const nextCamera = this.availableCameras[nextIndex];
|
|
384
|
+
await this.switchCamera(nextCamera.deviceId);
|
|
385
|
+
}
|
|
102
386
|
async componentDidLoad() {
|
|
387
|
+
if (this.debug) {
|
|
388
|
+
// Show detailed initialization loading state only in debug mode
|
|
389
|
+
this.isLoading = true;
|
|
390
|
+
this.statusMessage = 'Inicializando componente...';
|
|
391
|
+
this.statusColor = '#007bff';
|
|
392
|
+
// Small delay to ensure initialization message is visible
|
|
393
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
394
|
+
}
|
|
103
395
|
this.validateMaskSize();
|
|
104
396
|
this.validateCropMargin();
|
|
397
|
+
this.validatePreferredCamera();
|
|
398
|
+
if (this.debug) {
|
|
399
|
+
// Update status for camera detection
|
|
400
|
+
this.statusMessage = 'Detectando cámaras disponibles...';
|
|
401
|
+
}
|
|
402
|
+
await this.detectDeviceTypeAndCameras();
|
|
105
403
|
if (!window.ort) {
|
|
404
|
+
if (this.debug) {
|
|
405
|
+
// Update status for ONNX runtime loading
|
|
406
|
+
this.statusMessage = 'Cargando librerías de IA...';
|
|
407
|
+
}
|
|
106
408
|
const script = document.createElement('script');
|
|
107
409
|
script.src = 'https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js';
|
|
108
410
|
document.head.appendChild(script);
|
|
109
411
|
// Wait for ONNX runtime to load before emitting ready event
|
|
110
412
|
script.onload = () => {
|
|
111
|
-
|
|
413
|
+
setTimeout(() => {
|
|
414
|
+
this.statusMessage = 'Presione el botón para activar la cámara';
|
|
415
|
+
this.statusColor = '#aaa';
|
|
416
|
+
this.isLoading = false;
|
|
417
|
+
this.emitReadyEvent();
|
|
418
|
+
}, 300);
|
|
112
419
|
};
|
|
113
420
|
}
|
|
114
421
|
else {
|
|
115
422
|
// ONNX runtime already loaded
|
|
116
|
-
|
|
423
|
+
setTimeout(() => {
|
|
424
|
+
this.statusMessage = 'Presione el botón para activar la cámara';
|
|
425
|
+
this.statusColor = '#aaa';
|
|
426
|
+
this.isLoading = false;
|
|
427
|
+
this.emitReadyEvent();
|
|
428
|
+
}, 300);
|
|
117
429
|
}
|
|
118
430
|
// Initialize canvas pool for better performance
|
|
119
431
|
this.initializeCanvasPool();
|
|
@@ -303,6 +615,35 @@ const JaakStamps = class {
|
|
|
303
615
|
this.completeProcess(true);
|
|
304
616
|
}
|
|
305
617
|
}
|
|
618
|
+
async getCameraInfo() {
|
|
619
|
+
return {
|
|
620
|
+
availableCameras: this.availableCameras.map(camera => ({
|
|
621
|
+
id: camera.deviceId,
|
|
622
|
+
label: camera.label || 'Unknown Camera',
|
|
623
|
+
selected: camera.deviceId === this.selectedCameraId
|
|
624
|
+
})),
|
|
625
|
+
selectedCameraId: this.selectedCameraId,
|
|
626
|
+
deviceType: this.deviceType,
|
|
627
|
+
isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
|
|
628
|
+
preferredFacing: this.preferredCameraFacing,
|
|
629
|
+
userPreferredCamera: this.preferredCamera
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
async setPreferredCamera(camera) {
|
|
633
|
+
this.preferredCamera = camera;
|
|
634
|
+
this.debugLog('🎯 Camera preference changed to:', camera);
|
|
635
|
+
// Re-detect and apply new camera preference
|
|
636
|
+
await this.enumerateAndDetectCameras();
|
|
637
|
+
// If video is active, switch to the new preferred camera
|
|
638
|
+
if (this.isVideoActive && this.selectedCameraId) {
|
|
639
|
+
await this.switchCamera(this.selectedCameraId);
|
|
640
|
+
}
|
|
641
|
+
return {
|
|
642
|
+
success: true,
|
|
643
|
+
selectedCamera: this.selectedCameraId,
|
|
644
|
+
availableCameras: this.availableCameras.length
|
|
645
|
+
};
|
|
646
|
+
}
|
|
306
647
|
async loadMobileNetModel() {
|
|
307
648
|
try {
|
|
308
649
|
this.debugLog('🤖 Loading MobileNet model...');
|
|
@@ -419,18 +760,37 @@ const JaakStamps = class {
|
|
|
419
760
|
}
|
|
420
761
|
async getMaxResolution() {
|
|
421
762
|
try {
|
|
422
|
-
//
|
|
763
|
+
// Build constraints with selected camera if available
|
|
764
|
+
const videoConstraints = {};
|
|
765
|
+
if (this.selectedCameraId) {
|
|
766
|
+
videoConstraints.deviceId = { exact: this.selectedCameraId };
|
|
767
|
+
}
|
|
768
|
+
else if (this.preferredCameraFacing) {
|
|
769
|
+
videoConstraints.facingMode = this.preferredCameraFacing;
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
videoConstraints.facingMode = "environment";
|
|
773
|
+
}
|
|
774
|
+
// Get temporary stream to access capabilities
|
|
423
775
|
const tempStream = await navigator.mediaDevices.getUserMedia({
|
|
424
|
-
video:
|
|
776
|
+
video: videoConstraints
|
|
425
777
|
});
|
|
426
778
|
const videoTrack = tempStream.getVideoTracks()[0];
|
|
427
779
|
const capabilities = videoTrack.getCapabilities();
|
|
428
780
|
// Detener el stream temporal
|
|
429
781
|
tempStream.getTracks().forEach(track => track.stop());
|
|
430
|
-
//
|
|
431
|
-
const constraints = {
|
|
432
|
-
|
|
433
|
-
|
|
782
|
+
// Build constraints with resolution optimized for tablets
|
|
783
|
+
const constraints = {};
|
|
784
|
+
// Set camera selection constraints
|
|
785
|
+
if (this.selectedCameraId) {
|
|
786
|
+
constraints.deviceId = { exact: this.selectedCameraId };
|
|
787
|
+
}
|
|
788
|
+
else if (this.preferredCameraFacing) {
|
|
789
|
+
constraints.facingMode = this.preferredCameraFacing;
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
constraints.facingMode = "environment";
|
|
793
|
+
}
|
|
434
794
|
if (capabilities.width && capabilities.height) {
|
|
435
795
|
// Limitar resolución máxima para tablets para evitar problemas de rendimiento
|
|
436
796
|
const maxWidth = Math.min(capabilities.width.max, 1920);
|
|
@@ -457,13 +817,23 @@ const JaakStamps = class {
|
|
|
457
817
|
}
|
|
458
818
|
catch (err) {
|
|
459
819
|
this.debugLog('⚠️ Could not get capabilities, using fallback');
|
|
460
|
-
//
|
|
820
|
+
// Optimized fallback for tablets
|
|
461
821
|
const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
|
|
462
|
-
|
|
463
|
-
facingMode: "environment",
|
|
822
|
+
const fallbackConstraints = {
|
|
464
823
|
width: { ideal: isTablet ? 1280 : 1920 },
|
|
465
824
|
height: { ideal: isTablet ? 720 : 1080 }
|
|
466
825
|
};
|
|
826
|
+
// Add camera selection to fallback
|
|
827
|
+
if (this.selectedCameraId) {
|
|
828
|
+
fallbackConstraints.deviceId = { exact: this.selectedCameraId };
|
|
829
|
+
}
|
|
830
|
+
else if (this.preferredCameraFacing) {
|
|
831
|
+
fallbackConstraints.facingMode = this.preferredCameraFacing;
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
fallbackConstraints.facingMode = "environment";
|
|
835
|
+
}
|
|
836
|
+
return fallbackConstraints;
|
|
467
837
|
}
|
|
468
838
|
}
|
|
469
839
|
async setupCamera() {
|
|
@@ -498,8 +868,7 @@ const JaakStamps = class {
|
|
|
498
868
|
}
|
|
499
869
|
catch (err) {
|
|
500
870
|
this.debugLog("❌ No se pudo acceder a la cámara:", err);
|
|
501
|
-
this.
|
|
502
|
-
this.statusColor = "#ff6b6b";
|
|
871
|
+
this.handleCameraPermissionError(err);
|
|
503
872
|
}
|
|
504
873
|
}
|
|
505
874
|
preprocess(video) {
|
|
@@ -544,28 +913,48 @@ const JaakStamps = class {
|
|
|
544
913
|
// Check if model is already preloaded
|
|
545
914
|
if (!this.session) {
|
|
546
915
|
this.isLoading = true;
|
|
547
|
-
this.
|
|
548
|
-
|
|
916
|
+
if (this.debug) {
|
|
917
|
+
this.statusMessage = "Cargando modelo de detección...";
|
|
918
|
+
this.statusColor = "#007bff";
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
this.statusMessage = "Cargando modelos...";
|
|
922
|
+
this.statusColor = "#007bff";
|
|
923
|
+
}
|
|
549
924
|
const modelPath = this.MODEL_PATH;
|
|
550
925
|
this.debugLog('🤖 Loading detection model:', modelPath);
|
|
551
926
|
const sessionOptions = this.getSessionOptions();
|
|
552
927
|
this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
|
|
553
928
|
// Load MobileNet model if classification is enabled and not already loaded
|
|
554
929
|
if (this.useDocumentClassification && !this.mobileNetSession) {
|
|
930
|
+
if (this.debug) {
|
|
931
|
+
this.statusMessage = "Cargando modelo de clasificación...";
|
|
932
|
+
}
|
|
555
933
|
await this.loadMobileNetModel();
|
|
556
934
|
}
|
|
557
935
|
this.isModelPreloaded = true;
|
|
936
|
+
if (this.debug) {
|
|
937
|
+
this.statusMessage = "Modelos cargados exitosamente";
|
|
938
|
+
}
|
|
558
939
|
this.emitReadyEvent();
|
|
559
940
|
}
|
|
560
941
|
else {
|
|
561
942
|
this.debugLog('🚀 Using preloaded models');
|
|
562
|
-
this.
|
|
563
|
-
|
|
943
|
+
if (this.debug) {
|
|
944
|
+
this.statusMessage = "Usando modelos precargados...";
|
|
945
|
+
this.statusColor = "#007bff";
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
if (this.debug) {
|
|
949
|
+
this.statusMessage = "Configurando cámara...";
|
|
564
950
|
}
|
|
565
|
-
this.statusMessage = "Configurando cámara...";
|
|
566
951
|
await this.setupCamera();
|
|
567
952
|
this.startTime = Date.now();
|
|
568
953
|
this.isLoading = false;
|
|
954
|
+
if (this.debug) {
|
|
955
|
+
this.statusMessage = "Detección activa - Busque su identificación";
|
|
956
|
+
this.statusColor = "#28a745";
|
|
957
|
+
}
|
|
569
958
|
this.detectFrame();
|
|
570
959
|
}
|
|
571
960
|
catch (err) {
|
|
@@ -1037,8 +1426,14 @@ const JaakStamps = class {
|
|
|
1037
1426
|
this.videoStream.getTracks().forEach(track => track.stop());
|
|
1038
1427
|
this.videoStream = undefined;
|
|
1039
1428
|
this.isVideoActive = false;
|
|
1040
|
-
this.
|
|
1041
|
-
|
|
1429
|
+
if (this.debug) {
|
|
1430
|
+
this.statusMessage = "Cámara desactivada - Listo para nueva sesión";
|
|
1431
|
+
this.statusColor = "#6c757d";
|
|
1432
|
+
}
|
|
1433
|
+
else {
|
|
1434
|
+
this.statusMessage = "Presione el botón para activar la cámara";
|
|
1435
|
+
this.statusColor = "#aaa";
|
|
1436
|
+
}
|
|
1042
1437
|
}
|
|
1043
1438
|
this.isLoading = false;
|
|
1044
1439
|
// Limpiar canvas al finalizar sesión
|
|
@@ -1049,7 +1444,20 @@ const JaakStamps = class {
|
|
|
1049
1444
|
this.cleanup();
|
|
1050
1445
|
}
|
|
1051
1446
|
render() {
|
|
1052
|
-
return (index.h("div", { key: '
|
|
1447
|
+
return (index.h("div", { key: '86ff6966e69804bea4faef5a9201480bd7ef5b9a', class: "detector-container" }, index.h("div", { key: 'aaed4a078d4eff98674f2163a56a1596782612bd', class: "video-container" }, index.h("video", { key: '6ae6a7c626c9b2b6e6915c826517d1365205b3a0', ref: el => this.videoRef = el, autoplay: true, muted: true, playsinline: true, class: this.shouldMirrorVideo ? 'mirror' : '', style: { display: this.isVideoActive ? 'block' : 'none' } }), index.h("canvas", { key: 'c8666e4b4814e633155be738e23ada098fb3be93', ref: el => this.canvasRef = el, class: this.shouldMirrorVideo ? 'mirror' : '' }), this.isMaskReady && (index.h("div", { key: '968bcd21315afcf054f881647723299e7e57c29b', class: "overlay-mask" }, index.h("div", { key: '77f8a331f3d9e19b35c11b6c23b06420cbab9fd5', class: "card-outline" }, index.h("div", { key: '9d0164e7b2dcf6392471151c236127cd57507512', class: "side side-top" }), index.h("div", { key: '05a003eb49d25c72644aea2511b6519c5241ffb4', class: "side side-right" }), index.h("div", { key: 'a561ae9a94eb78aacfc24bac717164b3e22f41e5', class: "side side-bottom" }), index.h("div", { key: '81d64e5b58032c14062fc8efdee417db7f8a9f12', class: "side side-left" }), index.h("div", { key: '03c02e2c4c73c525965e34c7c47bb74f769d577f', class: "corner corner-tl" }), index.h("div", { key: '84780aec021ec4e0c7d38f6a659be765c4604ed5', class: "corner corner-tr" }), index.h("div", { key: '1ea67789c5a38cbc790f911f8f06b55c866d3927', class: "corner corner-bl" }), index.h("div", { key: 'e0e1999b0c5c37451850203eed4dbc2ff5834261', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (index.h("div", { key: '4909eb28d62b1674436c148ef46cd05a35ff8ec8', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (index.h("button", { key: '5a971c2121cf9962719ad89fc45530b8acccb550', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso")), this.isVideoActive && (index.h("div", { key: '109e5885c49212f89d5678d9c9716ebd48614126', class: "camera-controls" }, this.isMultipleCamerasAvailable && (index.h("button", { key: '7c8ce2cd775c0646c80378cd0ad1f70243443ddf', class: "flip-camera-button", onClick: () => this.flipCamera(), type: "button", title: "Cambiar c\u00E1mara" }, "Girar c\u00E1mara")), index.h("button", { key: '5d3d066ba7e317fdc33878eeb9f2f7d28c6f65dc', class: "camera-selector-button", onClick: () => this.toggleCameraSelector(), type: "button", title: "Seleccionar c\u00E1mara" }, "C\u00E1maras"), this.debug && (index.h("div", { key: '4cbc284f2efbcb90ef91ea2e064bf0aa1e7980af', style: {
|
|
1448
|
+
position: 'absolute',
|
|
1449
|
+
top: '50px',
|
|
1450
|
+
right: '0',
|
|
1451
|
+
background: 'rgba(0,0,0,0.8)',
|
|
1452
|
+
color: 'white',
|
|
1453
|
+
padding: '8px',
|
|
1454
|
+
fontSize: '10px',
|
|
1455
|
+
borderRadius: '4px',
|
|
1456
|
+
whiteSpace: 'nowrap'
|
|
1457
|
+
} }, "C\u00E1maras: ", this.availableCameras.length, index.h("br", { key: 'df214515289add2cc73f989bfacb59069334a0e6' }), "M\u00FAltiples: ", this.isMultipleCamerasAvailable ? 'Sí' : 'No', index.h("br", { key: 'aa2b1784781b5b45d24139e2b6cc4865d9f3a00c' }), "Selector: ", this.showCameraSelector ? 'Visible' : 'Oculto', index.h("br", { key: 'fb95b2b58c9fb89f632d85a9271b7788d45a66c0' }), "Video: ", this.isVideoActive ? 'Activo' : 'Inactivo')))), this.showCameraSelector && this.availableCameras.length > 0 && (index.h("div", { key: 'ec1c90c5a6c84e3ef75724e7e600a60714545608', class: "camera-selector-dropdown" }, index.h("div", { key: 'ea118817b6563c78b7fbf5ee66af2e38a441a8b7', class: "camera-selector-header" }, index.h("span", { key: '52603259d50ffb7aa6ea5753762f0f0d018b39ff' }, "Seleccionar C\u00E1mara"), index.h("button", { key: '422ae0643f5d1451cf539b3a77becbf44904a484', class: "close-selector", onClick: () => this.toggleCameraSelector(), type: "button" }, "\u00D7")), index.h("div", { key: 'd5acef7ba0b1645c52fb3ea7b3c64e70fa187a5f', class: "camera-list" }, this.availableCameras.map((camera) => (index.h("button", { key: camera.deviceId, class: `camera-option ${this.selectedCameraId === camera.deviceId ? 'selected' : ''}`, onClick: () => {
|
|
1458
|
+
this.switchCamera(camera.deviceId);
|
|
1459
|
+
this.toggleCameraSelector();
|
|
1460
|
+
}, type: "button" }, index.h("span", { class: "camera-label" }, camera.label || `Cámara ${this.availableCameras.indexOf(camera) + 1}`), this.selectedCameraId === camera.deviceId && (index.h("span", { class: "selected-indicator" }, "\u2713")))))), index.h("div", { key: 'b670e7bf441559bf156874dbe3bbf83dbff2fa0d', class: "device-info" }, index.h("small", { key: '4d333925c1ff4197b6009414ed694b0a0eb06159' }, "Dispositivo: ", this.deviceType)))))), this.isCapturing && (index.h("div", { key: '21f7ea0e50575226daba8607ab4bccc5029aa179', class: "capture-animation" })), this.showFlipAnimation && (index.h("div", { key: 'c2350cc43d3a119391f62f2cf771ed5afcdb3558', class: "flip-animation" }, index.h("div", { key: 'a91de9e8662a4750555bce2a879b89f9216b8156', class: "id-card-icon" }), index.h("div", { key: 'def1c2534e1aae27e262deb6fd26a73ff0c8cb9b', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (index.h("div", { key: 'acbbfb6d07e4f6bf343ff18af2d55979e76db3d4', class: "success-animation" }, index.h("div", { key: 'f5acd84325226e6b1ede1180335d7495a6b2d95e', class: "check-icon" }), index.h("div", { key: '393fd8300ce48e59bd3ef94f0e895abc3a938c1f', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (index.h("div", { key: 'ce0d1baebab8bf0e18531a26b549f38e349a0d72', class: "loading-overlay" }, index.h("div", { key: '14c76fa00ddd814f37bd9c6dc57f761119886566', class: "loading-spinner" }), index.h("div", { key: '87ccb288f927e61ec126d83f44061699810c9e06', class: "loading-text" }, this.statusMessage))), this.debug && (index.h("div", { key: '943dff6e2772f2595a95116e8943866f97cada6e', class: "status-bar" }, index.h("div", { key: '00fe53b71ef94d51636259f106e4518df910848d', class: "status-message", style: { 'color': this.statusColor } }, this.statusMessage))), index.h("div", { key: '4c3bd150006473d9540fb1418f11f45fb96d1e56', class: "watermark" }, index.h("img", { key: 'c634701f52a4422c7be5b4007bf34ba4aeb4ebcc', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
|
|
1053
1461
|
}
|
|
1054
1462
|
};
|
|
1055
1463
|
JaakStamps.style = myComponentCss;
|