tempest-react-sdk 0.34.0 → 0.36.0
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 +72 -68
- package/dist/audio/audio-output.cjs +2 -0
- package/dist/audio/audio-output.cjs.map +1 -0
- package/dist/audio/audio-output.js +17 -0
- package/dist/audio/audio-output.js.map +1 -0
- package/dist/audio/audio-player.cjs +1 -1
- package/dist/audio/audio-player.cjs.map +1 -1
- package/dist/audio/audio-player.js +21 -20
- package/dist/audio/audio-player.js.map +1 -1
- package/dist/audio/audio-recorder.cjs +2 -0
- package/dist/audio/audio-recorder.cjs.map +1 -0
- package/dist/audio/audio-recorder.js +30 -0
- package/dist/audio/audio-recorder.js.map +1 -0
- package/dist/audio/duration.cjs +2 -0
- package/dist/audio/duration.cjs.map +1 -0
- package/dist/audio/duration.js +10 -0
- package/dist/audio/duration.js.map +1 -0
- package/dist/audio/level-meter.cjs +2 -0
- package/dist/audio/level-meter.cjs.map +1 -0
- package/dist/audio/level-meter.js +34 -0
- package/dist/audio/level-meter.js.map +1 -0
- package/dist/audio/media-access.cjs +2 -0
- package/dist/audio/media-access.cjs.map +1 -0
- package/dist/audio/media-access.js +51 -0
- package/dist/audio/media-access.js.map +1 -0
- package/dist/audio/use-audio-recorder.cjs +2 -0
- package/dist/audio/use-audio-recorder.cjs.map +1 -0
- package/dist/audio/use-audio-recorder.js +94 -0
- package/dist/audio/use-audio-recorder.js.map +1 -0
- package/dist/audio/use-audio.cjs.map +1 -1
- package/dist/audio/use-audio.js.map +1 -1
- package/dist/audio/use-microphone.cjs +2 -0
- package/dist/audio/use-microphone.cjs.map +1 -0
- package/dist/audio/use-microphone.js +54 -0
- package/dist/audio/use-microphone.js.map +1 -0
- package/dist/audio/wav.cjs +2 -0
- package/dist/audio/wav.cjs.map +1 -0
- package/dist/audio/wav.js +49 -0
- package/dist/audio/wav.js.map +1 -0
- package/dist/auth/passkey.cjs +2 -0
- package/dist/auth/passkey.cjs.map +1 -0
- package/dist/auth/passkey.js +171 -0
- package/dist/auth/passkey.js.map +1 -0
- package/dist/auth/use-passkey.cjs +2 -0
- package/dist/auth/use-passkey.cjs.map +1 -0
- package/dist/auth/use-passkey.js +120 -0
- package/dist/auth/use-passkey.js.map +1 -0
- package/dist/br/PixQRCode.cjs +2 -0
- package/dist/br/PixQRCode.cjs.map +1 -0
- package/dist/br/PixQRCode.js +70 -0
- package/dist/br/PixQRCode.js.map +1 -0
- package/dist/br/PixQRCode.module.cjs +2 -0
- package/dist/br/PixQRCode.module.cjs.map +1 -0
- package/dist/br/PixQRCode.module.js +15 -0
- package/dist/br/PixQRCode.module.js.map +1 -0
- package/dist/br/boleto.cjs +2 -0
- package/dist/br/boleto.cjs.map +1 -0
- package/dist/br/boleto.js +225 -0
- package/dist/br/boleto.js.map +1 -0
- package/dist/br/holidays.cjs +2 -0
- package/dist/br/holidays.cjs.map +1 -0
- package/dist/br/holidays.js +148 -0
- package/dist/br/holidays.js.map +1 -0
- package/dist/br/nfe.cjs +2 -0
- package/dist/br/nfe.cjs.map +1 -0
- package/dist/br/nfe.js +104 -0
- package/dist/br/nfe.js.map +1 -0
- package/dist/br/pix.cjs +2 -0
- package/dist/br/pix.cjs.map +1 -0
- package/dist/br/pix.js +148 -0
- package/dist/br/pix.js.map +1 -0
- package/dist/br.cjs +1 -1
- package/dist/br.cjs.map +1 -1
- package/dist/br.d.ts +878 -0
- package/dist/br.js +7 -2
- package/dist/br.js.map +1 -1
- package/dist/capture/barcode.cjs +2 -0
- package/dist/capture/barcode.cjs.map +1 -0
- package/dist/capture/barcode.js +59 -0
- package/dist/capture/barcode.js.map +1 -0
- package/dist/capture/media-recorder.cjs +2 -0
- package/dist/capture/media-recorder.cjs.map +1 -0
- package/dist/capture/media-recorder.js +64 -0
- package/dist/capture/media-recorder.js.map +1 -0
- package/dist/capture/use-barcode-scanner.cjs +2 -0
- package/dist/capture/use-barcode-scanner.cjs.map +1 -0
- package/dist/capture/use-barcode-scanner.js +86 -0
- package/dist/capture/use-barcode-scanner.js.map +1 -0
- package/dist/capture/use-screen-capture.cjs +2 -0
- package/dist/capture/use-screen-capture.cjs.map +1 -0
- package/dist/capture/use-screen-capture.js +79 -0
- package/dist/capture/use-screen-capture.js.map +1 -0
- package/dist/capture/use-speech-recognition.cjs +2 -0
- package/dist/capture/use-speech-recognition.cjs.map +1 -0
- package/dist/capture/use-speech-recognition.js +118 -0
- package/dist/capture/use-speech-recognition.js.map +1 -0
- package/dist/capture/use-torch.cjs +2 -0
- package/dist/capture/use-torch.cjs.map +1 -0
- package/dist/capture/use-torch.js +33 -0
- package/dist/capture/use-torch.js.map +1 -0
- package/dist/capture/use-video-recorder.cjs +2 -0
- package/dist/capture/use-video-recorder.cjs.map +1 -0
- package/dist/capture/use-video-recorder.js +90 -0
- package/dist/capture/use-video-recorder.js.map +1 -0
- package/dist/capture/video-recorder.cjs +2 -0
- package/dist/capture/video-recorder.cjs.map +1 -0
- package/dist/capture/video-recorder.js +31 -0
- package/dist/capture/video-recorder.js.map +1 -0
- package/dist/components/AIChat/AIChat.cjs +1 -1
- package/dist/components/AIChat/AIChat.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.js +93 -97
- package/dist/components/AIChat/AIChat.js.map +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs.map +1 -1
- package/dist/components/AIChat/AIChatComposer.js +2 -1
- package/dist/components/AIChat/AIChatComposer.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs +2 -2
- package/dist/components/AIChat/AIChatTurn.js +6 -6
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/Alert/Alert.module.cjs.map +1 -1
- package/dist/components/Alert/Alert.module.js.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.cjs +2 -0
- package/dist/components/AudioPlayer/AudioPlayer.cjs.map +1 -0
- package/dist/components/AudioPlayer/AudioPlayer.js +123 -0
- package/dist/components/AudioPlayer/AudioPlayer.js.map +1 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.cjs +2 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.cjs.map +1 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.js +12 -0
- package/dist/components/AudioPlayer/AudioPlayer.module.js.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.cjs +2 -0
- package/dist/components/AudioRecorder/AudioRecorder.cjs.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.js +179 -0
- package/dist/components/AudioRecorder/AudioRecorder.js.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.cjs +2 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.cjs.map +1 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.js +19 -0
- package/dist/components/AudioRecorder/AudioRecorder.module.js.map +1 -0
- package/dist/components/Badge/Badge.module.cjs.map +1 -1
- package/dist/components/Badge/Badge.module.js.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs +2 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs.map +1 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.js +123 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.js.map +1 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.cjs +2 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.cjs.map +1 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.js +22 -0
- package/dist/components/BarcodeScanner/BarcodeScanner.module.js.map +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.module.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.module.js.map +1 -1
- package/dist/components/Button/Button.module.cjs.map +1 -1
- package/dist/components/Button/Button.module.js.map +1 -1
- package/dist/components/Combobox/Combobox.module.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.module.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +203 -66
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/DataTable.module.cjs +1 -1
- package/dist/components/DataTable/DataTable.module.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.module.js +9 -3
- package/dist/components/DataTable/DataTable.module.js.map +1 -1
- package/dist/components/DataTable/EditableCell.cjs +2 -0
- package/dist/components/DataTable/EditableCell.cjs.map +1 -0
- package/dist/components/DataTable/EditableCell.js +77 -0
- package/dist/components/DataTable/EditableCell.js.map +1 -0
- package/dist/components/DataTable/edit-labels.cjs +2 -0
- package/dist/components/DataTable/edit-labels.cjs.map +1 -0
- package/dist/components/DataTable/edit-labels.js +11 -0
- package/dist/components/DataTable/edit-labels.js.map +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.module.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.module.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.module.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.module.js.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.cjs.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.js.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.cjs +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.cjs.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.js +33 -32
- package/dist/components/SyncStatusBadge/SyncStatusBadge.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js +1 -2
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/hooks/use-announce.cjs +2 -0
- package/dist/hooks/use-announce.cjs.map +1 -0
- package/dist/hooks/use-announce.js +50 -0
- package/dist/hooks/use-announce.js.map +1 -0
- package/dist/hooks/use-media-devices.cjs +2 -0
- package/dist/hooks/use-media-devices.cjs.map +1 -0
- package/dist/hooks/use-media-devices.js +46 -0
- package/dist/hooks/use-media-devices.js.map +1 -0
- package/dist/hooks/use-media-permission.cjs +2 -0
- package/dist/hooks/use-media-permission.cjs.map +1 -0
- package/dist/hooks/use-media-permission.js +33 -0
- package/dist/hooks/use-media-permission.js.map +1 -0
- package/dist/http/resumable-upload.cjs +2 -0
- package/dist/http/resumable-upload.cjs.map +1 -0
- package/dist/http/resumable-upload.js +249 -0
- package/dist/http/resumable-upload.js.map +1 -0
- package/dist/perf/cache-size.cjs +2 -0
- package/dist/perf/cache-size.cjs.map +1 -0
- package/dist/perf/cache-size.js +16 -0
- package/dist/perf/cache-size.js.map +1 -0
- package/dist/perf/device.cjs +2 -0
- package/dist/perf/device.cjs.map +1 -0
- package/dist/perf/device.js +22 -0
- package/dist/perf/device.js.map +1 -0
- package/dist/perf/format.cjs +2 -0
- package/dist/perf/format.cjs.map +1 -0
- package/dist/perf/format.js +8 -0
- package/dist/perf/format.js.map +1 -0
- package/dist/perf/profiler.cjs +2 -0
- package/dist/perf/profiler.cjs.map +1 -0
- package/dist/perf/profiler.js +46 -0
- package/dist/perf/profiler.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +2705 -38
- package/dist/tempest-react-sdk.js +268 -240
- package/dist/vision/core/timing.cjs +2 -0
- package/dist/vision/core/timing.cjs.map +1 -0
- package/dist/vision/core/timing.js +24 -0
- package/dist/vision/core/timing.js.map +1 -0
- package/dist/vision/index.cjs +1 -1
- package/dist/vision/index.cjs.map +1 -1
- package/dist/vision/index.js +16 -15
- package/dist/vision/index.js.map +1 -1
- package/dist/vision/postprocess/detection.cjs +1 -1
- package/dist/vision/postprocess/detection.cjs.map +1 -1
- package/dist/vision/postprocess/detection.js +2 -2
- package/dist/vision/postprocess/detection.js.map +1 -1
- package/dist/vision/postprocess/segmentation.cjs +1 -1
- package/dist/vision/postprocess/segmentation.cjs.map +1 -1
- package/dist/vision/postprocess/segmentation.js +1 -1
- package/dist/vision/postprocess/segmentation.js.map +1 -1
- package/dist/vision/results.cjs +1 -1
- package/dist/vision/results.cjs.map +1 -1
- package/dist/vision/results.js +18 -13
- package/dist/vision/results.js.map +1 -1
- package/dist/vision/tasks/classifier.cjs +1 -1
- package/dist/vision/tasks/classifier.cjs.map +1 -1
- package/dist/vision/tasks/classifier.js +46 -39
- package/dist/vision/tasks/classifier.js.map +1 -1
- package/dist/vision/tasks/detector.cjs +1 -1
- package/dist/vision/tasks/detector.cjs.map +1 -1
- package/dist/vision/tasks/detector.js +40 -33
- package/dist/vision/tasks/detector.js.map +1 -1
- package/dist/vision/tasks/segmenter.cjs +1 -1
- package/dist/vision/tasks/segmenter.cjs.map +1 -1
- package/dist/vision/tasks/segmenter.js +35 -28
- package/dist/vision/tasks/segmenter.js.map +1 -1
- package/dist/vision/use-camera-stream.cjs +1 -1
- package/dist/vision/use-camera-stream.cjs.map +1 -1
- package/dist/vision/use-camera-stream.js +40 -57
- package/dist/vision/use-camera-stream.js.map +1 -1
- package/dist/vision.cjs +1 -1
- package/dist/vision.d.ts +93 -13
- package/dist/vision.js +21 -20
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { classifyMediaError as e, missingCaptureApiError as t } from "../audio/media-access.js";
|
|
2
|
+
import { useEffect as n, useRef as r, useState as i } from "react";
|
|
2
3
|
//#region src/vision/use-camera-stream.ts
|
|
3
|
-
var
|
|
4
|
+
var a = {
|
|
4
5
|
video: {
|
|
5
6
|
facingMode: { ideal: "environment" },
|
|
6
7
|
width: { ideal: 1920 },
|
|
@@ -8,77 +9,59 @@ var r = {
|
|
|
8
9
|
},
|
|
9
10
|
audio: !1
|
|
10
11
|
};
|
|
11
|
-
function
|
|
12
|
-
if (typeof window > "u") return {
|
|
13
|
-
kind: "unsupported",
|
|
14
|
-
message: "Camera is unavailable in this environment."
|
|
15
|
-
};
|
|
16
|
-
if (!window.isSecureContext) return {
|
|
17
|
-
kind: "insecure",
|
|
18
|
-
message: "Camera access requires a secure (HTTPS) connection."
|
|
19
|
-
};
|
|
20
|
-
if (e instanceof DOMException) switch (e.name) {
|
|
21
|
-
case "NotAllowedError":
|
|
22
|
-
case "SecurityError": return {
|
|
23
|
-
kind: "permission-denied",
|
|
24
|
-
message: "Camera permission denied. Enable access in your browser settings."
|
|
25
|
-
};
|
|
26
|
-
case "NotFoundError":
|
|
27
|
-
case "OverconstrainedError": return {
|
|
28
|
-
kind: "no-camera",
|
|
29
|
-
message: "No camera available on this device."
|
|
30
|
-
};
|
|
31
|
-
case "NotReadableError":
|
|
32
|
-
case "AbortError": return {
|
|
33
|
-
kind: "in-use",
|
|
34
|
-
message: "The camera is in use by another app. Close it and try again."
|
|
35
|
-
};
|
|
36
|
-
}
|
|
12
|
+
function o({ kind: e, message: t }) {
|
|
37
13
|
return {
|
|
38
|
-
kind: "
|
|
39
|
-
message:
|
|
14
|
+
kind: e === "not-found" ? "no-camera" : e,
|
|
15
|
+
message: t
|
|
40
16
|
};
|
|
41
17
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
18
|
+
function s(t) {
|
|
19
|
+
return o(e(t, "camera"));
|
|
20
|
+
}
|
|
21
|
+
function c(e = {}) {
|
|
22
|
+
let [c, l] = i("loading"), [u, d] = i(null), [f, p] = i(null), [m, h] = i(0), g = r(null), _ = r(e.constraints ?? a);
|
|
23
|
+
n(() => {
|
|
24
|
+
_.current = e.constraints ?? a;
|
|
25
|
+
}, [e.constraints]);
|
|
26
|
+
let v = e.enabled ?? !0;
|
|
27
|
+
return n(() => {
|
|
28
|
+
let e = !1, n = null, r = null;
|
|
29
|
+
async function i() {
|
|
30
|
+
if (!v) {
|
|
31
|
+
l("idle"), d(null);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (l("loading"), d(null), typeof navigator > "u" || !navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
|
|
35
|
+
e || (d(o(t("camera"))), l("error"));
|
|
54
36
|
return;
|
|
55
37
|
}
|
|
56
38
|
try {
|
|
57
|
-
if (
|
|
58
|
-
|
|
39
|
+
if (n = await navigator.mediaDevices.getUserMedia(_.current), e) {
|
|
40
|
+
n.getTracks().forEach((e) => e.stop());
|
|
59
41
|
return;
|
|
60
42
|
}
|
|
61
|
-
let
|
|
62
|
-
if (!
|
|
63
|
-
|
|
43
|
+
let t = g.current;
|
|
44
|
+
if (!t) {
|
|
45
|
+
n.getTracks().forEach((e) => e.stop());
|
|
64
46
|
return;
|
|
65
47
|
}
|
|
66
|
-
|
|
48
|
+
r = t, t.srcObject = n, p(n), await t.play().catch(() => void 0), e || l("ready");
|
|
67
49
|
} catch (t) {
|
|
68
|
-
e || (
|
|
50
|
+
e || (d(s(t)), l("error"));
|
|
69
51
|
}
|
|
70
52
|
}
|
|
71
|
-
return
|
|
72
|
-
e = !0,
|
|
53
|
+
return i(), () => {
|
|
54
|
+
e = !0, n && n.getTracks().forEach((e) => e.stop()), r && (r.srcObject = null), p(null);
|
|
73
55
|
};
|
|
74
|
-
}, [
|
|
75
|
-
status:
|
|
76
|
-
error:
|
|
77
|
-
videoRef:
|
|
78
|
-
|
|
56
|
+
}, [m, v]), {
|
|
57
|
+
status: c,
|
|
58
|
+
error: u,
|
|
59
|
+
videoRef: g,
|
|
60
|
+
stream: f,
|
|
61
|
+
retry: () => h((e) => e + 1)
|
|
79
62
|
};
|
|
80
63
|
}
|
|
81
64
|
//#endregion
|
|
82
|
-
export {
|
|
65
|
+
export { c as useCameraStream };
|
|
83
66
|
|
|
84
67
|
//# sourceMappingURL=use-camera-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-camera-stream.js","names":[],"sources":["../../src/vision/use-camera-stream.ts"],"sourcesContent":["import { useEffect, useRef, useState, type RefObject } from \"react\";\n\n/** Lifecycle status of the camera stream. */\nexport type CameraStreamStatus = \"idle\" | \"loading\" | \"ready\" | \"error\";\n\n/** Classified reason a camera stream could not be acquired. */\nexport type CameraStreamErrorKind =\n \"unsupported\" | \"permission-denied\" | \"no-camera\" | \"in-use\" | \"insecure\" | \"unknown\";\n\n/** A classified camera error with a human-readable, English message. */\nexport interface CameraStreamError {\n kind: CameraStreamErrorKind;\n message: string;\n}\n\n/** Options for {@link useCameraStream}. */\nexport interface UseCameraStreamOptions {\n /**\n * Constraints passed to `getUserMedia`. Defaults to the rear\n * (\"environment\") camera at Full-HD ideal resolution with audio off.\n * Read when the stream (re)starts — change it and call `retry()` to apply.\n */\n constraints?: MediaStreamConstraints;\n}\n\n/** Value returned by {@link useCameraStream}. */\nexport interface UseCameraStreamApi {\n /** Current lifecycle status. */\n status: CameraStreamStatus;\n /** The classified error, or `null` while not in the `error` status. */\n error: CameraStreamError | null;\n /** Attach to a `<video ref={…} />`. The stream is wired to it once ready. */\n videoRef: RefObject<HTMLVideoElement | null>;\n /** Manually re-attempt after an error (e.g. the user changed permissions). */\n retry: () => void;\n}\n\n/** Rear-camera Full-HD defaults used when no `constraints` are supplied. */\nconst DEFAULT_CONSTRAINTS: MediaStreamConstraints = {\n video: {\n facingMode: { ideal: \"environment\" },\n width: { ideal: 1920 },\n height: { ideal: 1080 },\n },\n audio: false,\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"use-camera-stream.js","names":[],"sources":["../../src/vision/use-camera-stream.ts"],"sourcesContent":["import { useEffect, useRef, useState, type RefObject } from \"react\";\n\nimport {\n classifyMediaError,\n missingCaptureApiError,\n type MediaAccessError,\n} from \"@/audio/media-access\";\n\n/** Lifecycle status of the camera stream. */\nexport type CameraStreamStatus = \"idle\" | \"loading\" | \"ready\" | \"error\";\n\n/** Classified reason a camera stream could not be acquired. */\nexport type CameraStreamErrorKind =\n \"unsupported\" | \"permission-denied\" | \"no-camera\" | \"in-use\" | \"insecure\" | \"unknown\";\n\n/** A classified camera error with a human-readable, English message. */\nexport interface CameraStreamError {\n kind: CameraStreamErrorKind;\n message: string;\n}\n\n/** Options for {@link useCameraStream}. */\nexport interface UseCameraStreamOptions {\n /**\n * Constraints passed to `getUserMedia`. Defaults to the rear\n * (\"environment\") camera at Full-HD ideal resolution with audio off.\n * Read when the stream (re)starts — change it and call `retry()` to apply.\n */\n constraints?: MediaStreamConstraints;\n /**\n * Hold off acquiring the camera until this is `true`. Default `true`.\n *\n * The point is to be able to *not* prompt. A permission prompt costs the user a\n * decision and, if they refuse, costs the app the feature permanently — so a\n * surface that already knows it cannot do its job (a barcode scanner in a browser\n * with no decoder) must not open the camera to then say so. Flipping this to `false`\n * also releases a stream that is already live.\n */\n enabled?: boolean;\n}\n\n/** Value returned by {@link useCameraStream}. */\nexport interface UseCameraStreamApi {\n /** Current lifecycle status. */\n status: CameraStreamStatus;\n /** The classified error, or `null` while not in the `error` status. */\n error: CameraStreamError | null;\n /** Attach to a `<video ref={…} />`. The stream is wired to it once ready. */\n videoRef: RefObject<HTMLVideoElement | null>;\n /**\n * The live stream, or `null`.\n *\n * Exposed for the things that need the **track** rather than the picture — the LED\n * torch (`useTorch`), the real frame size from `getSettings()`, recording it with\n * `useVideoRecorder`. Do not stop it yourself: the hook owns its lifetime and\n * releases it on unmount and on `retry()`.\n */\n stream: MediaStream | null;\n /** Manually re-attempt after an error (e.g. the user changed permissions). */\n retry: () => void;\n}\n\n/** Rear-camera Full-HD defaults used when no `constraints` are supplied. */\nconst DEFAULT_CONSTRAINTS: MediaStreamConstraints = {\n video: {\n facingMode: { ideal: \"environment\" },\n width: { ideal: 1920 },\n height: { ideal: 1080 },\n },\n audio: false,\n};\n\n/**\n * Re-label a {@link MediaAccessError} as a {@link CameraStreamError}.\n *\n * The classification itself lives in one place for the whole SDK\n * (`classifyMediaError`), so a microphone and a camera failure are never explained\n * two different ways. Only the name of one kind differs: this surface shipped\n * `\"no-camera\"` where the shared taxonomy says `\"not-found\"`, and renaming a\n * published union member would break every consumer switching on it.\n *\n * @param error - The shared classification.\n * @returns The same error under this module's kind names.\n */\nfunction toCameraError({ kind, message }: MediaAccessError): CameraStreamError {\n return { kind: kind === \"not-found\" ? \"no-camera\" : kind, message };\n}\n\n/**\n * Map an unknown `getUserMedia` failure into a {@link CameraStreamError}. Secure-context\n * and environment checks run first (they are the reason `getUserMedia` is missing or\n * rejects), then the `DOMException.name` is mapped to a stable `kind`.\n */\nfunction classifyError(err: unknown): CameraStreamError {\n return toCameraError(classifyMediaError(err, \"camera\"));\n}\n\n/**\n * Acquire a `MediaStream` via `getUserMedia`, attach it to a `<video>` element,\n * and expose status/error so the page can render permission and error states.\n * The stream is automatically released on unmount or retry.\n *\n * Defaults to the rear (\"environment\") camera; desktops fall back to whatever\n * single camera they expose. Pass `options.constraints` to override, or\n * `options.enabled: false` to render the surface without prompting for the camera\n * at all.\n *\n * Implementation notes:\n * - Cleanup detaches the stream from a *snapshotted* video node, so it releases\n * the same element it attached to even if the page remounts the `<video>`.\n * - When `getUserMedia` is missing, an insecure context is the usual cause, so\n * the hook prefers that (actionable) error; otherwise it reports `unsupported`.\n * - `video.play()` rejections are swallowed: autoplay may be blocked, but the\n * user gesture that opened the camera usually counts and playback resumes on\n * the next interaction.\n *\n * @param options - optional configuration (see {@link UseCameraStreamOptions}).\n * @returns The stream status, classified error, a `videoRef` to attach, the live\n * `stream` for whatever needs the track itself, and a `retry()` to re-attempt\n * acquisition.\n */\nexport function useCameraStream(options: UseCameraStreamOptions = {}): UseCameraStreamApi {\n const [status, setStatus] = useState<CameraStreamStatus>(\"loading\");\n const [error, setError] = useState<CameraStreamError | null>(null);\n const [live, setLive] = useState<MediaStream | null>(null);\n const [retryToken, setRetryToken] = useState(0);\n const videoRef = useRef<HTMLVideoElement | null>(null);\n const constraintsRef = useRef<MediaStreamConstraints>(\n options.constraints ?? DEFAULT_CONSTRAINTS,\n );\n useEffect(() => {\n constraintsRef.current = options.constraints ?? DEFAULT_CONSTRAINTS;\n }, [options.constraints]);\n\n const enabled = options.enabled ?? true;\n\n useEffect(() => {\n let cancelled = false;\n let stream: MediaStream | null = null;\n let attachedVideo: HTMLVideoElement | null = null;\n\n async function start(): Promise<void> {\n if (!enabled) {\n setStatus(\"idle\");\n setError(null);\n return;\n }\n setStatus(\"loading\");\n setError(null);\n\n if (\n typeof navigator === \"undefined\" ||\n !navigator.mediaDevices ||\n typeof navigator.mediaDevices.getUserMedia !== \"function\"\n ) {\n if (!cancelled) {\n setError(toCameraError(missingCaptureApiError(\"camera\")));\n setStatus(\"error\");\n }\n return;\n }\n\n try {\n stream = await navigator.mediaDevices.getUserMedia(constraintsRef.current);\n if (cancelled) {\n stream.getTracks().forEach((track) => track.stop());\n return;\n }\n const video = videoRef.current;\n if (!video) {\n stream.getTracks().forEach((track) => track.stop());\n return;\n }\n attachedVideo = video;\n video.srcObject = stream;\n setLive(stream);\n await video.play().catch(() => undefined);\n if (!cancelled) setStatus(\"ready\");\n } catch (err) {\n if (!cancelled) {\n setError(classifyError(err));\n setStatus(\"error\");\n }\n }\n }\n\n void start();\n\n return () => {\n cancelled = true;\n if (stream) {\n stream.getTracks().forEach((track) => track.stop());\n }\n if (attachedVideo) {\n attachedVideo.srcObject = null;\n }\n setLive(null);\n };\n }, [retryToken, enabled]);\n\n return {\n status,\n error,\n videoRef,\n stream: live,\n retry: () => setRetryToken((n) => n + 1),\n };\n}\n"],"mappings":";;;AA+DA,IAAM,IAA8C;CAChD,OAAO;EACH,YAAY,EAAE,OAAO,cAAc;EACnC,OAAO,EAAE,OAAO,KAAK;EACrB,QAAQ,EAAE,OAAO,KAAK;CAC1B;CACA,OAAO;AACX;AAcA,SAAS,EAAc,EAAE,SAAM,cAAgD;CAC3E,OAAO;EAAE,MAAM,MAAS,cAAc,cAAc;EAAM;CAAQ;AACtE;AAOA,SAAS,EAAc,GAAiC;CACpD,OAAO,EAAc,EAAmB,GAAK,QAAQ,CAAC;AAC1D;AA0BA,SAAgB,EAAgB,IAAkC,CAAC,GAAuB;CACtF,IAAM,CAAC,GAAQ,KAAa,EAA6B,SAAS,GAC5D,CAAC,GAAO,KAAY,EAAmC,IAAI,GAC3D,CAAC,GAAM,KAAW,EAA6B,IAAI,GACnD,CAAC,GAAY,KAAiB,EAAS,CAAC,GACxC,IAAW,EAAgC,IAAI,GAC/C,IAAiB,EACnB,EAAQ,eAAe,CAC3B;CACA,QAAgB;EACZ,EAAe,UAAU,EAAQ,eAAe;CACpD,GAAG,CAAC,EAAQ,WAAW,CAAC;CAExB,IAAM,IAAU,EAAQ,WAAW;CAkEnC,OAhEA,QAAgB;EACZ,IAAI,IAAY,IACZ,IAA6B,MAC7B,IAAyC;EAE7C,eAAe,IAAuB;GAClC,IAAI,CAAC,GAAS;IAEV,AADA,EAAU,MAAM,GAChB,EAAS,IAAI;IACb;GACJ;GAIA,IAHA,EAAU,SAAS,GACnB,EAAS,IAAI,GAGT,OAAO,YAAc,OACrB,CAAC,UAAU,gBACX,OAAO,UAAU,aAAa,gBAAiB,YACjD;IACE,AAAK,MACD,EAAS,EAAc,EAAuB,QAAQ,CAAC,CAAC,GACxD,EAAU,OAAO;IAErB;GACJ;GAEA,IAAI;IAEA,IADA,IAAS,MAAM,UAAU,aAAa,aAAa,EAAe,OAAO,GACrE,GAAW;KACX,EAAO,UAAU,CAAC,CAAC,SAAS,MAAU,EAAM,KAAK,CAAC;KAClD;IACJ;IACA,IAAM,IAAQ,EAAS;IACvB,IAAI,CAAC,GAAO;KACR,EAAO,UAAU,CAAC,CAAC,SAAS,MAAU,EAAM,KAAK,CAAC;KAClD;IACJ;IAKA,AAJA,IAAgB,GAChB,EAAM,YAAY,GAClB,EAAQ,CAAM,GACd,MAAM,EAAM,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS,GACnC,KAAW,EAAU,OAAO;GACrC,SAAS,GAAK;IACV,AAAK,MACD,EAAS,EAAc,CAAG,CAAC,GAC3B,EAAU,OAAO;GAEzB;EACJ;EAIA,OAFA,EAAW,SAEE;GAQT,AAPA,IAAY,IACR,KACA,EAAO,UAAU,CAAC,CAAC,SAAS,MAAU,EAAM,KAAK,CAAC,GAElD,MACA,EAAc,YAAY,OAE9B,EAAQ,IAAI;EAChB;CACJ,GAAG,CAAC,GAAY,CAAO,CAAC,GAEjB;EACH;EACA;EACA;EACA,QAAQ;EACR,aAAa,GAAe,MAAM,IAAI,CAAC;CAC3C;AACJ"}
|
package/dist/vision.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vision/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vision/use-camera-stream.cjs"),t=require("./vision/core/exceptions.cjs"),n=require("./vision/types.cjs"),r=require("./vision/core/timing.cjs"),i=require("./vision/results.cjs"),a=require("./vision/labels.cjs"),o=require("./vision/core/providers.cjs"),s=require("./vision/core/session.cjs"),c=require("./vision/io/image.cjs"),l=require("./vision/preprocess/image.cjs"),u=require("./vision/postprocess/classification.cjs"),d=require("./vision/postprocess/detection.cjs"),f=require("./vision/postprocess/segmentation.cjs"),p=require("./vision/tasks/base.cjs"),m=require("./vision/tasks/classifier.cjs"),h=require("./vision/tasks/detector.cjs"),g=require("./vision/tasks/segmenter.cjs"),_=require("./vision/index.cjs"),v=require("./vision/luminance.cjs"),y=require("./vision/use-live-luminance.cjs");exports.BoundingBox=n.BoundingBox,exports.Boxes=i.Boxes,exports.COCO_CLASSES=a.COCO_CLASSES,exports.ClassificationResults=i.ClassificationResults,exports.Classifier=m.Classifier,exports.DEFAULT_PROVIDERS=o.DEFAULT_PROVIDERS,exports.DetectionResults=i.DetectionResults,exports.Detector=h.Detector,exports.ImageLoadError=t.ImageLoadError,exports.InferenceError=t.InferenceError,exports.LUMINANCE_SAMPLE_MAX_EDGE=v.LUMINANCE_SAMPLE_MAX_EDGE,exports.LabelMapError=t.LabelMapError,exports.LowLuminanceError=v.LowLuminanceError,exports.Mask=n.Mask,exports.Masks=i.Masks,exports.ModelLoadError=t.ModelLoadError,exports.OrtSession=s.OrtSession,exports.OrtVisionError=t.OrtVisionError,exports.Probs=i.Probs,exports.ProviderNotAvailableError=t.ProviderNotAvailableError,exports.RGBImage=n.RGBImage,exports.SegmentationResults=i.SegmentationResults,exports.Segmenter=g.Segmenter,exports.SpeedTimer=r.SpeedTimer,exports.VERSION=_.VERSION,exports.VisionTask=p.VisionTask,exports.batchedNms=d.batchedNms,exports.computeImageLuminance=v.computeImageLuminance,exports.decodeYolo=d.decodeYolo,exports.decodeYoloAnchors=d.decodeYoloAnchors,exports.decodeYoloSeg=f.decodeYoloSeg,exports.decodeYoloV8=d.decodeYoloV8,exports.decodeYoloV8Anchors=d.decodeYoloV8Anchors,exports.decodeYoloV8Seg=f.decodeYoloV8Seg,exports.fromCv2=l.fromCv2,exports.isLuminanceAcceptable=v.isLuminanceAcceptable,exports.letterbox=l.letterbox,exports.loadImage=c.loadImage,exports.nms=d.nms,exports.normalize=l.normalize,exports.resize=l.resize,exports.resolveLabels=a.resolveLabels,exports.resolveProviders=o.resolveProviders,exports.softmax=u.softmax,exports.toCHW=l.toCHW,exports.toCv2=l.toCv2,exports.toFloat32=l.toFloat32,exports.toFloat32Tensor=l.toFloat32Tensor,exports.toTensor=l.toTensor,exports.topK=u.topK,exports.useCameraStream=e.useCameraStream,exports.useLiveLuminance=y.useLiveLuminance;
|
package/dist/vision.d.ts
CHANGED
|
@@ -149,8 +149,8 @@ export declare class ClassificationResults {
|
|
|
149
149
|
readonly origImg: RGBImage;
|
|
150
150
|
readonly origShape: readonly [number, number];
|
|
151
151
|
readonly path: string | null;
|
|
152
|
-
readonly speed: Readonly<
|
|
153
|
-
constructor(probs: Probs, result: ClassificationResult, names: Readonly<Record<number, string>>, origImg: RGBImage, origShape: readonly [number, number], path?: string | null, speed?: Readonly<
|
|
152
|
+
readonly speed: Readonly<Speed>;
|
|
153
|
+
constructor(probs: Probs, result: ClassificationResult, names: Readonly<Record<number, string>>, origImg: RGBImage, origShape: readonly [number, number], path?: string | null, speed?: Readonly<Speed>);
|
|
154
154
|
/** Top-1 class index (Ultralytics-style alias). */
|
|
155
155
|
get cls(): number;
|
|
156
156
|
/** Top-1 confidence (Ultralytics-style alias). */
|
|
@@ -385,12 +385,12 @@ export declare interface DecodeYoloSegOptions {
|
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
387
|
* @deprecated since 0.2.0 — use {@link decodeYolo}. Same behavior; the
|
|
388
|
-
* decoder covers v8/v9/v10/v11/v12 detect heads. Will be removed in 0.
|
|
388
|
+
* decoder covers v8/v9/v10/v11/v12 detect heads. Will be removed in 0.4.0.
|
|
389
389
|
*/
|
|
390
390
|
export declare function decodeYoloV8(output: Float32Array, outputDims: readonly number[], options: DecodeYoloOptions): DecodedDetection[];
|
|
391
391
|
|
|
392
392
|
/**
|
|
393
|
-
* @deprecated since 0.2.0 — use {@link decodeYoloAnchors}. Will be removed in 0.
|
|
393
|
+
* @deprecated since 0.2.0 — use {@link decodeYoloAnchors}. Will be removed in 0.4.0.
|
|
394
394
|
*/
|
|
395
395
|
export declare function decodeYoloV8Anchors(data: Float32Array, dims: readonly number[], options: DecodeYoloAnchorsOptions): DecodedAnchors;
|
|
396
396
|
|
|
@@ -400,7 +400,7 @@ export declare type DecodeYoloV8AnchorsOptions = DecodeYoloAnchorsOptions;
|
|
|
400
400
|
/** @deprecated since 0.2.0 — use {@link DecodeYoloOptions}. */
|
|
401
401
|
export declare type DecodeYoloV8Options = DecodeYoloOptions;
|
|
402
402
|
|
|
403
|
-
/** @deprecated since 0.2.0 — use {@link decodeYoloSeg}. Will be removed in 0.
|
|
403
|
+
/** @deprecated since 0.2.0 — use {@link decodeYoloSeg}. Will be removed in 0.4.0. */
|
|
404
404
|
export declare function decodeYoloV8Seg(perAnchorData: Float32Array, perAnchorDims: readonly number[], prototypeData: Float32Array, prototypeDims: readonly number[], options: DecodeYoloSegOptions): DecodedSegmentation[];
|
|
405
405
|
|
|
406
406
|
/** @deprecated since 0.2.0 — use {@link DecodeYoloSegOptions}. */
|
|
@@ -459,8 +459,8 @@ export declare class DetectionResults implements Iterable<DetectionResult> {
|
|
|
459
459
|
readonly origImg: RGBImage;
|
|
460
460
|
readonly origShape: readonly [number, number];
|
|
461
461
|
readonly path: string | null;
|
|
462
|
-
readonly speed: Readonly<
|
|
463
|
-
constructor(boxes: Boxes, detections: readonly DetectionResult[], names: Readonly<Record<number, string>>, origImg: RGBImage, origShape: readonly [number, number], path?: string | null, speed?: Readonly<
|
|
462
|
+
readonly speed: Readonly<Speed>;
|
|
463
|
+
constructor(boxes: Boxes, detections: readonly DetectionResult[], names: Readonly<Record<number, string>>, origImg: RGBImage, origShape: readonly [number, number], path?: string | null, speed?: Readonly<Speed>);
|
|
464
464
|
/** Number of surviving detections. */
|
|
465
465
|
get length(): number;
|
|
466
466
|
/** Index into the per-instance detections. */
|
|
@@ -514,7 +514,12 @@ export declare class Detector extends VisionTask {
|
|
|
514
514
|
* {@link DetectorPredictOptions} (including `classes`) is supported.
|
|
515
515
|
*/
|
|
516
516
|
call(image: ImageInput, options?: DetectorPredictOptions): Promise<DetectionResults[]>;
|
|
517
|
-
/**
|
|
517
|
+
/**
|
|
518
|
+
* Run detection on a single image.
|
|
519
|
+
*
|
|
520
|
+
* The returned envelope carries a {@link Speed} breakdown in `speed`,
|
|
521
|
+
* mirroring Ultralytics' `results[0].speed`.
|
|
522
|
+
*/
|
|
518
523
|
predict(image: ImageInput, options?: DetectorPredictOptions): Promise<DetectionResults[]>;
|
|
519
524
|
private _preprocess;
|
|
520
525
|
private _buildResult;
|
|
@@ -934,8 +939,8 @@ export declare interface LetterboxResult {
|
|
|
934
939
|
readonly origImg: RGBImage;
|
|
935
940
|
readonly origShape: readonly [number, number];
|
|
936
941
|
readonly path: string | null;
|
|
937
|
-
readonly speed: Readonly<
|
|
938
|
-
constructor(boxes: Boxes, masks: Masks, detections: readonly SegmentationResult[], names: Readonly<Record<number, string>>, origImg: RGBImage, origShape: readonly [number, number], path?: string | null, speed?: Readonly<
|
|
942
|
+
readonly speed: Readonly<Speed>;
|
|
943
|
+
constructor(boxes: Boxes, masks: Masks, detections: readonly SegmentationResult[], names: Readonly<Record<number, string>>, origImg: RGBImage, origShape: readonly [number, number], path?: string | null, speed?: Readonly<Speed>);
|
|
939
944
|
/** Number of surviving instances. */
|
|
940
945
|
get length(): number;
|
|
941
946
|
/** Index into the per-instance results. */
|
|
@@ -1049,6 +1054,59 @@ export declare interface LetterboxResult {
|
|
|
1049
1054
|
/** Apply numerically-stable softmax to a 1-D vector of logits. */
|
|
1050
1055
|
export declare function softmax(logits: Float32Array | readonly number[]): Float32Array;
|
|
1051
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* Per-stage timing for a single `predict()` call.
|
|
1059
|
+
*
|
|
1060
|
+
* Populates the `speed` field every `Results` envelope carries, mirroring
|
|
1061
|
+
* Ultralytics' `results[0].speed`. All values are milliseconds measured with
|
|
1062
|
+
* `performance.now()`.
|
|
1063
|
+
*/
|
|
1064
|
+
/**
|
|
1065
|
+
* Stage durations of one inference, in milliseconds.
|
|
1066
|
+
*
|
|
1067
|
+
* `preprocess`, `inference` and `postprocess` are the three keys Ultralytics
|
|
1068
|
+
* reports, measured over the same boundaries. `load` is specific to this SDK:
|
|
1069
|
+
* `predict()` accepts a URL, `Blob` or DOM element and decodes it internally,
|
|
1070
|
+
* so the fetch/decode cost would otherwise be invisible — and on a cold cache
|
|
1071
|
+
* it dominates everything else.
|
|
1072
|
+
*/
|
|
1073
|
+
export declare interface Speed {
|
|
1074
|
+
/** Fetching and decoding the input into an `RGBImage`. */
|
|
1075
|
+
load: number;
|
|
1076
|
+
/** Letterbox/resize, normalization and tensor packing. */
|
|
1077
|
+
preprocess: number;
|
|
1078
|
+
/** The ONNX Runtime forward pass. */
|
|
1079
|
+
inference: number;
|
|
1080
|
+
/** Decoding raw outputs into results (NMS, mask assembly, top-k). */
|
|
1081
|
+
postprocess: number;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Accumulate stage durations while a `predict()` call runs.
|
|
1086
|
+
*
|
|
1087
|
+
* Each `stage()` call closes the previous stage: the elapsed time since the
|
|
1088
|
+
* last boundary is attributed to the name given. This keeps the call sites
|
|
1089
|
+
* free of paired start/stop bookkeeping and guarantees the four stages tile
|
|
1090
|
+
* the whole call without gaps.
|
|
1091
|
+
*/
|
|
1092
|
+
export declare class SpeedTimer {
|
|
1093
|
+
private _last;
|
|
1094
|
+
private readonly _speed;
|
|
1095
|
+
constructor();
|
|
1096
|
+
/**
|
|
1097
|
+
* Attribute the time elapsed since the previous boundary to `stage`.
|
|
1098
|
+
*
|
|
1099
|
+
* @param stage Which stage just finished.
|
|
1100
|
+
*/
|
|
1101
|
+
stage(stage: keyof Speed): void;
|
|
1102
|
+
/**
|
|
1103
|
+
* The accumulated durations.
|
|
1104
|
+
*
|
|
1105
|
+
* @returns The `speed` object to hand to the `Results` envelope.
|
|
1106
|
+
*/
|
|
1107
|
+
speed(): Speed;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1052
1110
|
/**
|
|
1053
1111
|
* Transpose interleaved HWC data to planar CHW layout.
|
|
1054
1112
|
*
|
|
@@ -1098,7 +1156,9 @@ export declare interface LetterboxResult {
|
|
|
1098
1156
|
* The stream is automatically released on unmount or retry.
|
|
1099
1157
|
*
|
|
1100
1158
|
* Defaults to the rear ("environment") camera; desktops fall back to whatever
|
|
1101
|
-
* single camera they expose. Pass `options.constraints` to override
|
|
1159
|
+
* single camera they expose. Pass `options.constraints` to override, or
|
|
1160
|
+
* `options.enabled: false` to render the surface without prompting for the camera
|
|
1161
|
+
* at all.
|
|
1102
1162
|
*
|
|
1103
1163
|
* Implementation notes:
|
|
1104
1164
|
* - Cleanup detaches the stream from a *snapshotted* video node, so it releases
|
|
@@ -1110,8 +1170,9 @@ export declare interface LetterboxResult {
|
|
|
1110
1170
|
* the next interaction.
|
|
1111
1171
|
*
|
|
1112
1172
|
* @param options - optional configuration (see {@link UseCameraStreamOptions}).
|
|
1113
|
-
* @returns The stream status, classified error, a `videoRef` to attach,
|
|
1114
|
-
* `retry()` to re-attempt
|
|
1173
|
+
* @returns The stream status, classified error, a `videoRef` to attach, the live
|
|
1174
|
+
* `stream` for whatever needs the track itself, and a `retry()` to re-attempt
|
|
1175
|
+
* acquisition.
|
|
1115
1176
|
*/
|
|
1116
1177
|
export declare function useCameraStream(options?: UseCameraStreamOptions): UseCameraStreamApi;
|
|
1117
1178
|
|
|
@@ -1123,6 +1184,15 @@ export declare interface LetterboxResult {
|
|
|
1123
1184
|
error: CameraStreamError | null;
|
|
1124
1185
|
/** Attach to a `<video ref={…} />`. The stream is wired to it once ready. */
|
|
1125
1186
|
videoRef: RefObject<HTMLVideoElement | null>;
|
|
1187
|
+
/**
|
|
1188
|
+
* The live stream, or `null`.
|
|
1189
|
+
*
|
|
1190
|
+
* Exposed for the things that need the **track** rather than the picture — the LED
|
|
1191
|
+
* torch (`useTorch`), the real frame size from `getSettings()`, recording it with
|
|
1192
|
+
* `useVideoRecorder`. Do not stop it yourself: the hook owns its lifetime and
|
|
1193
|
+
* releases it on unmount and on `retry()`.
|
|
1194
|
+
*/
|
|
1195
|
+
stream: MediaStream | null;
|
|
1126
1196
|
/** Manually re-attempt after an error (e.g. the user changed permissions). */
|
|
1127
1197
|
retry: () => void;
|
|
1128
1198
|
}
|
|
@@ -1135,6 +1205,16 @@ export declare interface LetterboxResult {
|
|
|
1135
1205
|
* Read when the stream (re)starts — change it and call `retry()` to apply.
|
|
1136
1206
|
*/
|
|
1137
1207
|
constraints?: MediaStreamConstraints;
|
|
1208
|
+
/**
|
|
1209
|
+
* Hold off acquiring the camera until this is `true`. Default `true`.
|
|
1210
|
+
*
|
|
1211
|
+
* The point is to be able to *not* prompt. A permission prompt costs the user a
|
|
1212
|
+
* decision and, if they refuse, costs the app the feature permanently — so a
|
|
1213
|
+
* surface that already knows it cannot do its job (a barcode scanner in a browser
|
|
1214
|
+
* with no decoder) must not open the camera to then say so. Flipping this to `false`
|
|
1215
|
+
* also releases a stream that is already live.
|
|
1216
|
+
*/
|
|
1217
|
+
enabled?: boolean;
|
|
1138
1218
|
}
|
|
1139
1219
|
|
|
1140
1220
|
/**
|
package/dist/vision.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
1
|
+
import { useCameraStream as e } from "./vision/use-camera-stream.js";
|
|
2
|
+
import { ImageLoadError as t, InferenceError as n, LabelMapError as r, ModelLoadError as i, OrtVisionError as a, ProviderNotAvailableError as o } from "./vision/core/exceptions.js";
|
|
3
|
+
import { BoundingBox as s, Mask as c, RGBImage as l } from "./vision/types.js";
|
|
4
|
+
import { SpeedTimer as u } from "./vision/core/timing.js";
|
|
5
|
+
import { Boxes as d, ClassificationResults as f, DetectionResults as p, Masks as m, Probs as h, SegmentationResults as g } from "./vision/results.js";
|
|
6
|
+
import { COCO_CLASSES as _, resolveLabels as v } from "./vision/labels.js";
|
|
7
|
+
import { DEFAULT_PROVIDERS as y, resolveProviders as b } from "./vision/core/providers.js";
|
|
8
|
+
import { OrtSession as x } from "./vision/core/session.js";
|
|
9
|
+
import { loadImage as S } from "./vision/io/image.js";
|
|
10
|
+
import { fromCv2 as C, letterbox as w, normalize as T, resize as E, toCHW as D, toCv2 as O, toFloat32 as k, toFloat32Tensor as A, toTensor as j } from "./vision/preprocess/image.js";
|
|
11
|
+
import { softmax as M, topK as N } from "./vision/postprocess/classification.js";
|
|
12
|
+
import { batchedNms as P, decodeYolo as F, decodeYoloAnchors as I, decodeYoloV8 as L, decodeYoloV8Anchors as R, nms as z } from "./vision/postprocess/detection.js";
|
|
13
|
+
import { decodeYoloSeg as B, decodeYoloV8Seg as V } from "./vision/postprocess/segmentation.js";
|
|
14
|
+
import { VisionTask as H } from "./vision/tasks/base.js";
|
|
15
|
+
import { Classifier as U } from "./vision/tasks/classifier.js";
|
|
16
|
+
import { Detector as W } from "./vision/tasks/detector.js";
|
|
17
|
+
import { Segmenter as G } from "./vision/tasks/segmenter.js";
|
|
18
|
+
import { VERSION as K } from "./vision/index.js";
|
|
19
|
+
import { LUMINANCE_SAMPLE_MAX_EDGE as q, LowLuminanceError as J, computeImageLuminance as Y, isLuminanceAcceptable as X } from "./vision/luminance.js";
|
|
20
|
+
import { useLiveLuminance as Z } from "./vision/use-live-luminance.js";
|
|
21
|
+
export { s as BoundingBox, d as Boxes, _ as COCO_CLASSES, f as ClassificationResults, U as Classifier, y as DEFAULT_PROVIDERS, p as DetectionResults, W as Detector, t as ImageLoadError, n as InferenceError, q as LUMINANCE_SAMPLE_MAX_EDGE, r as LabelMapError, J as LowLuminanceError, c as Mask, m as Masks, i as ModelLoadError, x as OrtSession, a as OrtVisionError, h as Probs, o as ProviderNotAvailableError, l as RGBImage, g as SegmentationResults, G as Segmenter, u as SpeedTimer, K as VERSION, H as VisionTask, P as batchedNms, Y as computeImageLuminance, F as decodeYolo, I as decodeYoloAnchors, B as decodeYoloSeg, L as decodeYoloV8, R as decodeYoloV8Anchors, V as decodeYoloV8Seg, C as fromCv2, X as isLuminanceAcceptable, w as letterbox, S as loadImage, z as nms, T as normalize, E as resize, v as resolveLabels, b as resolveProviders, M as softmax, D as toCHW, O as toCv2, k as toFloat32, A as toFloat32Tensor, j as toTensor, N as topK, e as useCameraStream, Z as useLiveLuminance };
|