@ai-matrx/capture 0.5.4 → 0.5.6
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/CHANGELOG.md +9 -0
- package/README.md +5 -1
- package/dist/react.cjs +47 -10
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +30 -1
- package/dist/react.d.ts +30 -1
- package/dist/react.js +47 -10
- package/dist/react.js.map +1 -1
- package/package.json +2 -2
package/dist/react.d.cts
CHANGED
|
@@ -776,6 +776,35 @@ declare function nextCameraDevice<T extends {
|
|
|
776
776
|
deviceId: string;
|
|
777
777
|
}>(cameras: readonly T[], currentDeviceId: string | null | undefined): T | null;
|
|
778
778
|
|
|
779
|
+
/**
|
|
780
|
+
* The one terminal video contract shared by the package-owned MediaRecorder
|
|
781
|
+
* engine and host adapters. Emitted bytes are stronger MIME evidence than a
|
|
782
|
+
* requested/recorder format, and a delivered recording always carries a
|
|
783
|
+
* positive integer duration.
|
|
784
|
+
*/
|
|
785
|
+
interface FinalizeCapturedVideoOptions {
|
|
786
|
+
parts: readonly BlobPart[];
|
|
787
|
+
/** MIME observed on emitted/final Blob data — the strongest authority. */
|
|
788
|
+
emittedMime?: string | null | undefined;
|
|
789
|
+
/** MediaRecorder-reported MIME — fallback when emitted bytes have none. */
|
|
790
|
+
recorderMime?: string | null | undefined;
|
|
791
|
+
durationMs: number;
|
|
792
|
+
fileNamePrefix: string;
|
|
793
|
+
/** Injectable filename clock for deterministic tests. */
|
|
794
|
+
timestampMs?: number;
|
|
795
|
+
}
|
|
796
|
+
interface CapturedVideoResult {
|
|
797
|
+
file: File;
|
|
798
|
+
mime: string;
|
|
799
|
+
durationMs: number;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Finalize recording bytes without letting requested MIME, filename, and
|
|
803
|
+
* duration drift apart. Unknown/non-video formats fail loudly rather than
|
|
804
|
+
* producing a mislabeled upload.
|
|
805
|
+
*/
|
|
806
|
+
declare function finalizeCapturedVideo(options: FinalizeCapturedVideoOptions): CapturedVideoResult;
|
|
807
|
+
|
|
779
808
|
/**
|
|
780
809
|
* src/engine/permissions.ts — permission pre-checks + error classification
|
|
781
810
|
* for the default engine (and for hosts, so they stop re-implementing the
|
|
@@ -986,4 +1015,4 @@ interface CloudLibrarySheetProps {
|
|
|
986
1015
|
}
|
|
987
1016
|
declare function CloudLibrarySheet({ open, onClose, items, loading, busy, onOpenItem, onUpload, title, }: CloudLibrarySheetProps): React__default.JSX.Element | null;
|
|
988
1017
|
|
|
989
|
-
export { CameraCapture, type CameraCaptureProps, CameraCaptureV3, type CameraCaptureV3Props, CameraFeed, type CaptureAspect, type CaptureCameraEngine, type CaptureCameraMode, type CaptureCameraSlots, type CaptureCameraV3Slots, type CaptureCloudLibraryItem, type CaptureCloudPort, CaptureExpandingField, type CaptureExpandingFieldProps, CaptureFilmstrip, type CaptureFilmstripProps, type CaptureMediaItem, type CaptureMediaSession, type CaptureOptionTile, CaptureRail, type CaptureRailAction, type CaptureRailProps, CaptureSheet, type CaptureSheetAction, type CaptureSheetProps, type CaptureTimerSetting, CloudLibrarySheet, type CloudLibrarySheetProps, CountdownOverlay, type DefaultCaptureEngine, type DefaultEngineOptions, GridOverlay, HoldShutter, type HoldShutterProps, ImageEditSheet, type ImageEditSheetProps, type MediaPermissionState, MediaViewer, type MediaViewerProps, type MicInterruptionReason, type MicStreamState, ModeSelector, type ModeSelectorProps, OptionsGridPanel, type OptionsGridPanelProps, PHOTO_JPEG_QUALITY, type ResolvedMedia, ShutterButton, type ShutterButtonProps, type TrackControls, ZoomRow, type ZoomRowProps, acquireWarmMic, adoptWarmAudioStream, buildWarmMicConstraints, classifyCameraBlockReason, cropBlobToAspect, getMediaUrl, getWarmMicState, hardStopWarmMic, invalidateMedia, isMediaDenialError, nextCameraDevice, notifyMicPermissionRevoked, primeMedia, queryCameraPermission, queryMicPermission, releaseWarmMic, setPreferredMicDeviceId, shouldCombineMicPrompt, subscribeWarmMic, subscribeWarmMicInterruption, useDefaultCaptureEngine, useMediaUrl, useTrackControls, warmMicDebug };
|
|
1018
|
+
export { CameraCapture, type CameraCaptureProps, CameraCaptureV3, type CameraCaptureV3Props, CameraFeed, type CaptureAspect, type CaptureCameraEngine, type CaptureCameraMode, type CaptureCameraSlots, type CaptureCameraV3Slots, type CaptureCloudLibraryItem, type CaptureCloudPort, CaptureExpandingField, type CaptureExpandingFieldProps, CaptureFilmstrip, type CaptureFilmstripProps, type CaptureMediaItem, type CaptureMediaSession, type CaptureOptionTile, CaptureRail, type CaptureRailAction, type CaptureRailProps, CaptureSheet, type CaptureSheetAction, type CaptureSheetProps, type CaptureTimerSetting, type CapturedVideoResult, CloudLibrarySheet, type CloudLibrarySheetProps, CountdownOverlay, type DefaultCaptureEngine, type DefaultEngineOptions, type FinalizeCapturedVideoOptions, GridOverlay, HoldShutter, type HoldShutterProps, ImageEditSheet, type ImageEditSheetProps, type MediaPermissionState, MediaViewer, type MediaViewerProps, type MicInterruptionReason, type MicStreamState, ModeSelector, type ModeSelectorProps, OptionsGridPanel, type OptionsGridPanelProps, PHOTO_JPEG_QUALITY, type ResolvedMedia, ShutterButton, type ShutterButtonProps, type TrackControls, ZoomRow, type ZoomRowProps, acquireWarmMic, adoptWarmAudioStream, buildWarmMicConstraints, classifyCameraBlockReason, cropBlobToAspect, finalizeCapturedVideo, getMediaUrl, getWarmMicState, hardStopWarmMic, invalidateMedia, isMediaDenialError, nextCameraDevice, notifyMicPermissionRevoked, primeMedia, queryCameraPermission, queryMicPermission, releaseWarmMic, setPreferredMicDeviceId, shouldCombineMicPrompt, subscribeWarmMic, subscribeWarmMicInterruption, useDefaultCaptureEngine, useMediaUrl, useTrackControls, warmMicDebug };
|
package/dist/react.d.ts
CHANGED
|
@@ -776,6 +776,35 @@ declare function nextCameraDevice<T extends {
|
|
|
776
776
|
deviceId: string;
|
|
777
777
|
}>(cameras: readonly T[], currentDeviceId: string | null | undefined): T | null;
|
|
778
778
|
|
|
779
|
+
/**
|
|
780
|
+
* The one terminal video contract shared by the package-owned MediaRecorder
|
|
781
|
+
* engine and host adapters. Emitted bytes are stronger MIME evidence than a
|
|
782
|
+
* requested/recorder format, and a delivered recording always carries a
|
|
783
|
+
* positive integer duration.
|
|
784
|
+
*/
|
|
785
|
+
interface FinalizeCapturedVideoOptions {
|
|
786
|
+
parts: readonly BlobPart[];
|
|
787
|
+
/** MIME observed on emitted/final Blob data — the strongest authority. */
|
|
788
|
+
emittedMime?: string | null | undefined;
|
|
789
|
+
/** MediaRecorder-reported MIME — fallback when emitted bytes have none. */
|
|
790
|
+
recorderMime?: string | null | undefined;
|
|
791
|
+
durationMs: number;
|
|
792
|
+
fileNamePrefix: string;
|
|
793
|
+
/** Injectable filename clock for deterministic tests. */
|
|
794
|
+
timestampMs?: number;
|
|
795
|
+
}
|
|
796
|
+
interface CapturedVideoResult {
|
|
797
|
+
file: File;
|
|
798
|
+
mime: string;
|
|
799
|
+
durationMs: number;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Finalize recording bytes without letting requested MIME, filename, and
|
|
803
|
+
* duration drift apart. Unknown/non-video formats fail loudly rather than
|
|
804
|
+
* producing a mislabeled upload.
|
|
805
|
+
*/
|
|
806
|
+
declare function finalizeCapturedVideo(options: FinalizeCapturedVideoOptions): CapturedVideoResult;
|
|
807
|
+
|
|
779
808
|
/**
|
|
780
809
|
* src/engine/permissions.ts — permission pre-checks + error classification
|
|
781
810
|
* for the default engine (and for hosts, so they stop re-implementing the
|
|
@@ -986,4 +1015,4 @@ interface CloudLibrarySheetProps {
|
|
|
986
1015
|
}
|
|
987
1016
|
declare function CloudLibrarySheet({ open, onClose, items, loading, busy, onOpenItem, onUpload, title, }: CloudLibrarySheetProps): React__default.JSX.Element | null;
|
|
988
1017
|
|
|
989
|
-
export { CameraCapture, type CameraCaptureProps, CameraCaptureV3, type CameraCaptureV3Props, CameraFeed, type CaptureAspect, type CaptureCameraEngine, type CaptureCameraMode, type CaptureCameraSlots, type CaptureCameraV3Slots, type CaptureCloudLibraryItem, type CaptureCloudPort, CaptureExpandingField, type CaptureExpandingFieldProps, CaptureFilmstrip, type CaptureFilmstripProps, type CaptureMediaItem, type CaptureMediaSession, type CaptureOptionTile, CaptureRail, type CaptureRailAction, type CaptureRailProps, CaptureSheet, type CaptureSheetAction, type CaptureSheetProps, type CaptureTimerSetting, CloudLibrarySheet, type CloudLibrarySheetProps, CountdownOverlay, type DefaultCaptureEngine, type DefaultEngineOptions, GridOverlay, HoldShutter, type HoldShutterProps, ImageEditSheet, type ImageEditSheetProps, type MediaPermissionState, MediaViewer, type MediaViewerProps, type MicInterruptionReason, type MicStreamState, ModeSelector, type ModeSelectorProps, OptionsGridPanel, type OptionsGridPanelProps, PHOTO_JPEG_QUALITY, type ResolvedMedia, ShutterButton, type ShutterButtonProps, type TrackControls, ZoomRow, type ZoomRowProps, acquireWarmMic, adoptWarmAudioStream, buildWarmMicConstraints, classifyCameraBlockReason, cropBlobToAspect, getMediaUrl, getWarmMicState, hardStopWarmMic, invalidateMedia, isMediaDenialError, nextCameraDevice, notifyMicPermissionRevoked, primeMedia, queryCameraPermission, queryMicPermission, releaseWarmMic, setPreferredMicDeviceId, shouldCombineMicPrompt, subscribeWarmMic, subscribeWarmMicInterruption, useDefaultCaptureEngine, useMediaUrl, useTrackControls, warmMicDebug };
|
|
1018
|
+
export { CameraCapture, type CameraCaptureProps, CameraCaptureV3, type CameraCaptureV3Props, CameraFeed, type CaptureAspect, type CaptureCameraEngine, type CaptureCameraMode, type CaptureCameraSlots, type CaptureCameraV3Slots, type CaptureCloudLibraryItem, type CaptureCloudPort, CaptureExpandingField, type CaptureExpandingFieldProps, CaptureFilmstrip, type CaptureFilmstripProps, type CaptureMediaItem, type CaptureMediaSession, type CaptureOptionTile, CaptureRail, type CaptureRailAction, type CaptureRailProps, CaptureSheet, type CaptureSheetAction, type CaptureSheetProps, type CaptureTimerSetting, type CapturedVideoResult, CloudLibrarySheet, type CloudLibrarySheetProps, CountdownOverlay, type DefaultCaptureEngine, type DefaultEngineOptions, type FinalizeCapturedVideoOptions, GridOverlay, HoldShutter, type HoldShutterProps, ImageEditSheet, type ImageEditSheetProps, type MediaPermissionState, MediaViewer, type MediaViewerProps, type MicInterruptionReason, type MicStreamState, ModeSelector, type ModeSelectorProps, OptionsGridPanel, type OptionsGridPanelProps, PHOTO_JPEG_QUALITY, type ResolvedMedia, ShutterButton, type ShutterButtonProps, type TrackControls, ZoomRow, type ZoomRowProps, acquireWarmMic, adoptWarmAudioStream, buildWarmMicConstraints, classifyCameraBlockReason, cropBlobToAspect, finalizeCapturedVideo, getMediaUrl, getWarmMicState, hardStopWarmMic, invalidateMedia, isMediaDenialError, nextCameraDevice, notifyMicPermissionRevoked, primeMedia, queryCameraPermission, queryMicPermission, releaseWarmMic, setPreferredMicDeviceId, shouldCombineMicPrompt, subscribeWarmMic, subscribeWarmMicInterruption, useDefaultCaptureEngine, useMediaUrl, useTrackControls, warmMicDebug };
|
package/dist/react.js
CHANGED
|
@@ -3033,6 +3033,43 @@ function warmMicDebug() {
|
|
|
3033
3033
|
};
|
|
3034
3034
|
}
|
|
3035
3035
|
|
|
3036
|
+
// src/engine/video-result.ts
|
|
3037
|
+
var VIDEO_EXTENSIONS = {
|
|
3038
|
+
"video/mp4": "mp4",
|
|
3039
|
+
"video/webm": "webm",
|
|
3040
|
+
"video/ogg": "ogv",
|
|
3041
|
+
"video/quicktime": "mov"
|
|
3042
|
+
};
|
|
3043
|
+
function firstNonEmpty(...values) {
|
|
3044
|
+
for (const value of values) {
|
|
3045
|
+
const normalized = value?.trim();
|
|
3046
|
+
if (normalized) return normalized;
|
|
3047
|
+
}
|
|
3048
|
+
return "video/webm";
|
|
3049
|
+
}
|
|
3050
|
+
function finalizeCapturedVideo(options) {
|
|
3051
|
+
if (!Number.isFinite(options.durationMs)) {
|
|
3052
|
+
throw new Error("finalizeCapturedVideo requires a finite duration.");
|
|
3053
|
+
}
|
|
3054
|
+
const mime = firstNonEmpty(options.emittedMime, options.recorderMime);
|
|
3055
|
+
const container = mime.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
3056
|
+
const extension = VIDEO_EXTENSIONS[container];
|
|
3057
|
+
if (!extension) {
|
|
3058
|
+
throw new Error(
|
|
3059
|
+
`finalizeCapturedVideo requires a recognized video MIME; received "${mime}".`
|
|
3060
|
+
);
|
|
3061
|
+
}
|
|
3062
|
+
const durationMs = Math.max(1, Math.round(options.durationMs));
|
|
3063
|
+
const blob = new Blob([...options.parts], { type: mime });
|
|
3064
|
+
const timestampMs = options.timestampMs ?? Date.now();
|
|
3065
|
+
const file = new File(
|
|
3066
|
+
[blob],
|
|
3067
|
+
`${options.fileNamePrefix}-video-${timestampMs}.${extension}`,
|
|
3068
|
+
{ type: mime }
|
|
3069
|
+
);
|
|
3070
|
+
return { file, mime, durationMs };
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3036
3073
|
// src/engine/useDefaultEngine.ts
|
|
3037
3074
|
var RECORDING_MIME_LADDER = [
|
|
3038
3075
|
'video/mp4;codecs="avc1.42E01E,mp4a.40.2"',
|
|
@@ -3287,16 +3324,15 @@ function useDefaultCaptureEngine(options) {
|
|
|
3287
3324
|
if (entry.micHeld) releaseWarmMic();
|
|
3288
3325
|
recorderRef.current = null;
|
|
3289
3326
|
setRecording(false);
|
|
3290
|
-
const
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
);
|
|
3327
|
+
const captured = finalizeCapturedVideo({
|
|
3328
|
+
parts: entry.chunks,
|
|
3329
|
+
// Emitted chunk MIME is stronger evidence than recorder.mimeType.
|
|
3330
|
+
emittedMime: entry.chunks.find((chunk) => chunk.type)?.type,
|
|
3331
|
+
recorderMime: recorder.mimeType,
|
|
3332
|
+
durationMs: performance.now() - entry.startedAt,
|
|
3333
|
+
fileNamePrefix
|
|
3334
|
+
});
|
|
3335
|
+
callbacksRef.current.onVideo(captured.file, captured.durationMs);
|
|
3300
3336
|
};
|
|
3301
3337
|
recorder.start(1e3);
|
|
3302
3338
|
setRecordElapsedSeconds(0);
|
|
@@ -3499,6 +3535,7 @@ export {
|
|
|
3499
3535
|
buildWarmMicConstraints,
|
|
3500
3536
|
classifyCameraBlockReason,
|
|
3501
3537
|
cropBlobToAspect,
|
|
3538
|
+
finalizeCapturedVideo,
|
|
3502
3539
|
getMediaUrl,
|
|
3503
3540
|
getWarmMicState,
|
|
3504
3541
|
hardStopWarmMic,
|