@jaak.ai/stamps 2.0.0-dev.27 → 2.0.0-dev.28
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/dist/cjs/jaak-stamps.cjs.entry.js +102 -9
- package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -1
- package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -1
- package/dist/collection/components/my-component/my-component.js +102 -9
- package/dist/collection/components/my-component/my-component.js.map +1 -1
- package/dist/components/jaak-stamps.js +102 -9
- package/dist/components/jaak-stamps.js.map +1 -1
- package/dist/esm/jaak-stamps.entry.js +102 -9
- package/dist/esm/jaak-stamps.entry.js.map +1 -1
- 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-67b8e4cf.entry.js +2 -0
- package/dist/jaak-stamps-webcomponent/p-67b8e4cf.entry.js.map +1 -0
- package/dist/types/components/my-component/my-component.d.ts +1 -0
- package/package.json +1 -1
- package/dist/jaak-stamps-webcomponent/p-eb318f43.entry.js +0 -2
- package/dist/jaak-stamps-webcomponent/p-eb318f43.entry.js.map +0 -1
|
@@ -589,9 +589,36 @@ const JaakStamps = class {
|
|
|
589
589
|
this.debugLog('🤖 Preloading detection model:', modelPath);
|
|
590
590
|
// Configure ONNX Runtime with device-specific optimizations
|
|
591
591
|
const sessionOptions = this.getSessionOptions();
|
|
592
|
-
|
|
592
|
+
const deviceInfo = this.getDeviceMemoryInfo();
|
|
593
|
+
try {
|
|
594
|
+
this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
|
|
595
|
+
}
|
|
596
|
+
catch (error) {
|
|
597
|
+
if (error.message.includes('failed to allocate a buffer')) {
|
|
598
|
+
this.debugLog('❌ Buffer allocation failed during preload, trying with minimal settings');
|
|
599
|
+
const fallbackOptions = {
|
|
600
|
+
executionProviders: ['wasm'],
|
|
601
|
+
graphOptimizationLevel: 'disabled',
|
|
602
|
+
logSeverityLevel: 4,
|
|
603
|
+
enableCpuMemArena: false,
|
|
604
|
+
enableMemPattern: false,
|
|
605
|
+
executionMode: 'sequential',
|
|
606
|
+
interOpNumThreads: 1,
|
|
607
|
+
intraOpNumThreads: 1,
|
|
608
|
+
};
|
|
609
|
+
this.session = await window.ort.InferenceSession.create(modelPath, fallbackOptions);
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
593
615
|
// Preload MobileNet model and classes only if classification is enabled
|
|
616
|
+
// For low memory devices, load sequentially to avoid memory pressure
|
|
594
617
|
if (this.useDocumentClassification) {
|
|
618
|
+
if (deviceInfo.isLowMemory) {
|
|
619
|
+
this.debugLog('🔄 Sequential model loading for low memory device');
|
|
620
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
621
|
+
}
|
|
595
622
|
await this.loadMobileNetModel();
|
|
596
623
|
}
|
|
597
624
|
this.isModelPreloaded = true;
|
|
@@ -656,7 +683,28 @@ const JaakStamps = class {
|
|
|
656
683
|
this.debugLog('📋 MobileNet classes loaded:', this.mobileNetClassMap);
|
|
657
684
|
// Load model
|
|
658
685
|
const sessionOptions = this.getSessionOptions();
|
|
659
|
-
|
|
686
|
+
try {
|
|
687
|
+
this.mobileNetSession = await window.ort.InferenceSession.create(this.MOBILENET_MODEL_PATH, sessionOptions);
|
|
688
|
+
}
|
|
689
|
+
catch (error) {
|
|
690
|
+
if (error.message.includes('failed to allocate a buffer')) {
|
|
691
|
+
this.debugLog('❌ MobileNet buffer allocation failed, trying with minimal settings');
|
|
692
|
+
const fallbackOptions = {
|
|
693
|
+
executionProviders: ['wasm'],
|
|
694
|
+
graphOptimizationLevel: 'disabled',
|
|
695
|
+
logSeverityLevel: 4,
|
|
696
|
+
enableCpuMemArena: false,
|
|
697
|
+
enableMemPattern: false,
|
|
698
|
+
executionMode: 'sequential',
|
|
699
|
+
interOpNumThreads: 1,
|
|
700
|
+
intraOpNumThreads: 1,
|
|
701
|
+
};
|
|
702
|
+
this.mobileNetSession = await window.ort.InferenceSession.create(this.MOBILENET_MODEL_PATH, fallbackOptions);
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
throw error;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
660
708
|
this.debugLog('✅ MobileNet model loaded successfully');
|
|
661
709
|
}
|
|
662
710
|
catch (error) {
|
|
@@ -891,15 +939,39 @@ const JaakStamps = class {
|
|
|
891
939
|
const transposedData = new Float32Array(R.concat(G, B));
|
|
892
940
|
return new window.ort.Tensor("float32", transposedData, [1, 3, this.INPUT_SIZE, this.INPUT_SIZE]);
|
|
893
941
|
}
|
|
942
|
+
getDeviceMemoryInfo() {
|
|
943
|
+
const nav = navigator;
|
|
944
|
+
const memory = nav.deviceMemory || nav.hardwareConcurrency || 4;
|
|
945
|
+
const connection = nav.connection || nav.mozConnection || nav.webkitConnection;
|
|
946
|
+
const isSlowConnection = connection && (connection.effectiveType === 'slow-2g' || connection.effectiveType === '2g');
|
|
947
|
+
return {
|
|
948
|
+
estimatedRAM: memory,
|
|
949
|
+
isLowMemory: memory <= 4,
|
|
950
|
+
isSlowConnection: isSlowConnection
|
|
951
|
+
};
|
|
952
|
+
}
|
|
894
953
|
getSessionOptions() {
|
|
954
|
+
const deviceInfo = this.getDeviceMemoryInfo();
|
|
955
|
+
if (deviceInfo.isLowMemory) {
|
|
956
|
+
return {
|
|
957
|
+
executionProviders: ['wasm'],
|
|
958
|
+
graphOptimizationLevel: 'basic',
|
|
959
|
+
logSeverityLevel: 4,
|
|
960
|
+
logVerbosityLevel: 0,
|
|
961
|
+
enableCpuMemArena: false,
|
|
962
|
+
enableMemPattern: false,
|
|
963
|
+
executionMode: 'sequential',
|
|
964
|
+
interOpNumThreads: 1,
|
|
965
|
+
intraOpNumThreads: 1,
|
|
966
|
+
};
|
|
967
|
+
}
|
|
895
968
|
return {
|
|
896
969
|
executionProviders: [
|
|
897
|
-
// Try WebGL first for GPU acceleration, fallback to WASM
|
|
898
970
|
'webgl',
|
|
899
971
|
'wasm'
|
|
900
972
|
],
|
|
901
|
-
graphOptimizationLevel: 'all',
|
|
902
|
-
logSeverityLevel: this.debug ? 2 : 4,
|
|
973
|
+
graphOptimizationLevel: 'all',
|
|
974
|
+
logSeverityLevel: this.debug ? 2 : 4,
|
|
903
975
|
logVerbosityLevel: 0,
|
|
904
976
|
enableCpuMemArena: true,
|
|
905
977
|
enableMemPattern: true,
|
|
@@ -924,7 +996,28 @@ const JaakStamps = class {
|
|
|
924
996
|
const modelPath = this.MODEL_PATH;
|
|
925
997
|
this.debugLog('🤖 Loading detection model:', modelPath);
|
|
926
998
|
const sessionOptions = this.getSessionOptions();
|
|
927
|
-
|
|
999
|
+
try {
|
|
1000
|
+
this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
|
|
1001
|
+
}
|
|
1002
|
+
catch (error) {
|
|
1003
|
+
if (error.message.includes('failed to allocate a buffer')) {
|
|
1004
|
+
this.debugLog('❌ Buffer allocation failed, trying with minimal settings');
|
|
1005
|
+
const fallbackOptions = {
|
|
1006
|
+
executionProviders: ['wasm'],
|
|
1007
|
+
graphOptimizationLevel: 'disabled',
|
|
1008
|
+
logSeverityLevel: 4,
|
|
1009
|
+
enableCpuMemArena: false,
|
|
1010
|
+
enableMemPattern: false,
|
|
1011
|
+
executionMode: 'sequential',
|
|
1012
|
+
interOpNumThreads: 1,
|
|
1013
|
+
intraOpNumThreads: 1,
|
|
1014
|
+
};
|
|
1015
|
+
this.session = await window.ort.InferenceSession.create(modelPath, fallbackOptions);
|
|
1016
|
+
}
|
|
1017
|
+
else {
|
|
1018
|
+
throw error;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
928
1021
|
// Load MobileNet model if classification is enabled and not already loaded
|
|
929
1022
|
if (this.useDocumentClassification && !this.mobileNetSession) {
|
|
930
1023
|
if (this.debug) {
|
|
@@ -1444,7 +1537,7 @@ const JaakStamps = class {
|
|
|
1444
1537
|
this.cleanup();
|
|
1445
1538
|
}
|
|
1446
1539
|
render() {
|
|
1447
|
-
return (index.h("div", { key: '
|
|
1540
|
+
return (index.h("div", { key: 'bacf8b2ded1c5015d01dd4240dda6a93fbfb629e', class: "detector-container" }, index.h("div", { key: '235aefbd8916d6b53ab191c654ed00f303ca73b7', class: "video-container" }, index.h("video", { key: '9b641c7092c5ecfa601b1f80d6bf8c310539c436', 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: '2c3c384436b7dd91084dbdd27a34ac9192fa3f22', ref: el => this.canvasRef = el, class: this.shouldMirrorVideo ? 'mirror' : '' }), this.isMaskReady && (index.h("div", { key: '9e2ca398482ebae4da984854483af3159d908d2b', class: "overlay-mask" }, index.h("div", { key: 'ee14fd65d752351644a281fc4cbd7d8cf8765eec', class: "card-outline" }, index.h("div", { key: 'c5a924145ac54e7f545b0b6571f1d7d259fc1145', class: "side side-top" }), index.h("div", { key: 'a88e9ab5f1a4f7041edb44008697b619bf52a85b', class: "side side-right" }), index.h("div", { key: '08fbf94000951ea31d029469d8158b8bd3349bf8', class: "side side-bottom" }), index.h("div", { key: '3b9ead8e1d2c0f7fea2878a248241681c07bd0f6', class: "side side-left" }), index.h("div", { key: 'f96b9a5a0f00f016b11486a63ca984b368d18c8b', class: "corner corner-tl" }), index.h("div", { key: '30210f2ec60913466665dea50a1e8bc6cba34b41', class: "corner corner-tr" }), index.h("div", { key: 'cc4644c99957a9ddf68901ddd368037e01c56899', class: "corner corner-bl" }), index.h("div", { key: '95b08e9b36f880dda1d614f929ceb71259f5ec38', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (index.h("div", { key: '9bb545a793764b258381b0e3d665472c67d65b5b', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (index.h("button", { key: '3b78e394067ea610021fd915215fca30ed0d654b', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso")), this.isVideoActive && (index.h("div", { key: '85fbcf97d151fbf1f37a2f6f90bbd93ef77afdba', class: "camera-controls" }, this.isMultipleCamerasAvailable && (index.h("button", { key: '56bab78e6ea660e42057b5e6bc322f6990116119', class: "flip-camera-button", onClick: () => this.flipCamera(), type: "button", title: "Cambiar c\u00E1mara" }, "Girar c\u00E1mara")), index.h("button", { key: 'c149303ed671d326efada743393e52b5a3710710', class: "camera-selector-button", onClick: () => this.toggleCameraSelector(), type: "button", title: "Seleccionar c\u00E1mara" }, "C\u00E1maras"), this.debug && (index.h("div", { key: 'ce7c0c1dbc2ba267dbd0181dd7268e2d9f7209c0', style: {
|
|
1448
1541
|
position: 'absolute',
|
|
1449
1542
|
top: '50px',
|
|
1450
1543
|
right: '0',
|
|
@@ -1454,10 +1547,10 @@ const JaakStamps = class {
|
|
|
1454
1547
|
fontSize: '10px',
|
|
1455
1548
|
borderRadius: '4px',
|
|
1456
1549
|
whiteSpace: 'nowrap'
|
|
1457
|
-
} }, "C\u00E1maras: ", this.availableCameras.length, index.h("br", { key: '
|
|
1550
|
+
} }, "C\u00E1maras: ", this.availableCameras.length, index.h("br", { key: 'd62a6ddde7160f41075b3b1d00340515019a48ca' }), "M\u00FAltiples: ", this.isMultipleCamerasAvailable ? 'Sí' : 'No', index.h("br", { key: 'fe8c322421809a58f49150ef877ae0502d34d002' }), "Selector: ", this.showCameraSelector ? 'Visible' : 'Oculto', index.h("br", { key: '084d8c5c6c0193edcaf3bd7d64d0bce8e0bb6964' }), "Video: ", this.isVideoActive ? 'Activo' : 'Inactivo')))), this.showCameraSelector && this.availableCameras.length > 0 && (index.h("div", { key: '03b1a66188e65f1843c50aec096db840d60bb703', class: "camera-selector-dropdown" }, index.h("div", { key: 'fe7e08d25dd394d893a7f6269c80a2aaa4732134', class: "camera-selector-header" }, index.h("span", { key: '1b8f4892c3eef6dac8c682e152abb35e2331496c' }, "Seleccionar C\u00E1mara"), index.h("button", { key: '396c78a3753c707619e27ef7e5f3a412ba8480c6', class: "close-selector", onClick: () => this.toggleCameraSelector(), type: "button" }, "\u00D7")), index.h("div", { key: '6d56d67efe54719f21978cc6cc44cf2f421469bb', class: "camera-list" }, this.availableCameras.map((camera) => (index.h("button", { key: camera.deviceId, class: `camera-option ${this.selectedCameraId === camera.deviceId ? 'selected' : ''}`, onClick: () => {
|
|
1458
1551
|
this.switchCamera(camera.deviceId);
|
|
1459
1552
|
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: '
|
|
1553
|
+
}, 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: '7f5dda6214695d50c08d2ba4ccec236f3bd158cf', class: "device-info" }, index.h("small", { key: '50d2768f82b9b7f0a9c1729a5167493f731fb4f6' }, "Dispositivo: ", this.deviceType)))))), this.isCapturing && (index.h("div", { key: '7ed246b862639b2c6df54dbd32ebb883776bfbd7', class: "capture-animation" })), this.showFlipAnimation && (index.h("div", { key: 'f2d3a97dfcb9fd757b2f39ec184bce3f5dcb3595', class: "flip-animation" }, index.h("div", { key: '89a98223c60317d2b9449029ba393c75bec154b3', class: "id-card-icon" }), index.h("div", { key: '507f6f1b7f38082772bbac2fc28046618161c69b', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (index.h("div", { key: '9010d5be6684759b5d99c58ee65b0a7ebe82b9cb', class: "success-animation" }, index.h("div", { key: '454c39a5c0d457418b8abdc6e63b1c8a249a118f', class: "check-icon" }), index.h("div", { key: '502e55f1496f7d8cde9178c416bd9db4cf0491eb', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (index.h("div", { key: 'e4d6b7c5ebc8da42689150195dd837e77e152ea3', class: "loading-overlay" }, index.h("div", { key: '7cc39dbbe94e0730c47829291b83717476517f7f', class: "loading-spinner" }), index.h("div", { key: '4c1afe04fc7a627c9a57c2f7b851ce62f9305676', class: "loading-text" }, this.statusMessage))), this.debug && (index.h("div", { key: '8745c4603b35003bff859657c86c713b7f58e204', class: "status-bar" }, index.h("div", { key: 'e098f2402d58d1808052e3d213f851e66db69ee4', class: "status-message", style: { 'color': this.statusColor } }, this.statusMessage))), index.h("div", { key: 'af4e07b405af5b1786009b0e9ecf72551753de28', class: "watermark" }, index.h("img", { key: '25f4b80f13528617007aad160c855c4fff0c8af5', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
|
|
1461
1554
|
}
|
|
1462
1555
|
};
|
|
1463
1556
|
JaakStamps.style = myComponentCss;
|