@jaak.ai/stamps 2.0.0-dev.18 → 2.0.0-dev.19
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 +30 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,12 @@ yarn add @jaak.ai/stamps
|
|
|
58
58
|
// event.detail contiene las imágenes capturadas
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
// Escuchar evento de componente listo
|
|
62
|
+
detector.addEventListener('isReady', (event) => {
|
|
63
|
+
console.log('Componente listo:', event.detail);
|
|
64
|
+
// event.detail indica si el componente está listo (true/false)
|
|
65
|
+
});
|
|
66
|
+
|
|
61
67
|
function startCapture() {
|
|
62
68
|
detector.startCapture();
|
|
63
69
|
}
|
|
@@ -134,7 +140,8 @@ import { Component, ElementRef, ViewChild, OnInit } from '@angular/core';
|
|
|
134
140
|
<jaak-stamps
|
|
135
141
|
#detector
|
|
136
142
|
[debug]="false"
|
|
137
|
-
(captureCompleted)="onCaptureCompleted($event)"
|
|
143
|
+
(captureCompleted)="onCaptureCompleted($event)"
|
|
144
|
+
(isReady)="onComponentReady($event)">
|
|
138
145
|
</jaak-stamps>
|
|
139
146
|
|
|
140
147
|
<div class="controls">
|
|
@@ -211,6 +218,11 @@ export class AppComponent implements OnInit {
|
|
|
211
218
|
this.capturedData = event.detail;
|
|
212
219
|
this.isCompleted = true;
|
|
213
220
|
}
|
|
221
|
+
|
|
222
|
+
onComponentReady(event: any) {
|
|
223
|
+
console.log('Componente listo en Angular:', event.detail);
|
|
224
|
+
// El componente está listo para iniciar detección
|
|
225
|
+
}
|
|
214
226
|
}
|
|
215
227
|
```
|
|
216
228
|
|
|
@@ -229,7 +241,7 @@ import React, { useRef, useEffect, useImperativeHandle, forwardRef } from 'react
|
|
|
229
241
|
// Importar el web component
|
|
230
242
|
import '@jaak.ai/stamps/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js';
|
|
231
243
|
|
|
232
|
-
const JaakStampsWrapper = forwardRef(({ debug = false, onCaptureCompleted }, ref) => {
|
|
244
|
+
const JaakStampsWrapper = forwardRef(({ debug = false, onCaptureCompleted, onIsReady }, ref) => {
|
|
233
245
|
const elementRef = useRef(null);
|
|
234
246
|
|
|
235
247
|
useImperativeHandle(ref, () => ({
|
|
@@ -252,14 +264,22 @@ const JaakStampsWrapper = forwardRef(({ debug = false, onCaptureCompleted }, ref
|
|
|
252
264
|
}
|
|
253
265
|
};
|
|
254
266
|
|
|
267
|
+
const handleIsReady = (event) => {
|
|
268
|
+
if (onIsReady) {
|
|
269
|
+
onIsReady(event.detail);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
255
273
|
if (element) {
|
|
256
274
|
element.addEventListener('captureCompleted', handleCaptureCompleted);
|
|
275
|
+
element.addEventListener('isReady', handleIsReady);
|
|
257
276
|
|
|
258
277
|
return () => {
|
|
259
278
|
element.removeEventListener('captureCompleted', handleCaptureCompleted);
|
|
279
|
+
element.removeEventListener('isReady', handleIsReady);
|
|
260
280
|
};
|
|
261
281
|
}
|
|
262
|
-
}, [onCaptureCompleted]);
|
|
282
|
+
}, [onCaptureCompleted, onIsReady]);
|
|
263
283
|
|
|
264
284
|
return (
|
|
265
285
|
<jaak-stamps
|
|
@@ -290,6 +310,11 @@ function App() {
|
|
|
290
310
|
setIsCompleted(true);
|
|
291
311
|
};
|
|
292
312
|
|
|
313
|
+
const handleIsReady = (isReady) => {
|
|
314
|
+
console.log('Componente listo:', isReady);
|
|
315
|
+
// El componente está listo para iniciar detección
|
|
316
|
+
};
|
|
317
|
+
|
|
293
318
|
const preloadModel = async () => {
|
|
294
319
|
try {
|
|
295
320
|
const result = await detectorRef.current?.preloadModel();
|
|
@@ -340,6 +365,7 @@ function App() {
|
|
|
340
365
|
ref={detectorRef}
|
|
341
366
|
debug={false}
|
|
342
367
|
onCaptureCompleted={handleCaptureCompleted}
|
|
368
|
+
onIsReady={handleIsReady}
|
|
343
369
|
/>
|
|
344
370
|
|
|
345
371
|
<div className="controls">
|
|
@@ -428,6 +454,7 @@ export default App;
|
|
|
428
454
|
| Evento | Payload | Descripción |
|
|
429
455
|
|--------|---------|-------------|
|
|
430
456
|
| `captureCompleted` | `CapturedImages` | Se emite cuando se completa el proceso de captura |
|
|
457
|
+
| `isReady` | `boolean` | Se emite cuando el componente está listo para comenzar la detección (modelo ONNX cargado) |
|
|
431
458
|
|
|
432
459
|
### Tipos de Datos
|
|
433
460
|
|