@idmission/websdk-ui 0.2.0-rc.1 → 0.2.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.
Files changed (128) hide show
  1. package/README.md +147 -56
  2. package/dist/DocumentCaptureView.d.ts +37 -0
  3. package/dist/DocumentCaptureView.d.ts.map +1 -1
  4. package/dist/DocumentCaptureView.js +489 -6
  5. package/dist/FaceLivenessView.d.ts +1 -1
  6. package/dist/FaceLivenessView.d.ts.map +1 -1
  7. package/dist/FaceLivenessView.js +37 -29
  8. package/dist/IdCaptureView.d.ts +6 -5
  9. package/dist/IdCaptureView.d.ts.map +1 -1
  10. package/dist/IdCaptureView.js +52 -12
  11. package/dist/SelfieCaptureView.d.ts +1 -1
  12. package/dist/SelfieCaptureView.d.ts.map +1 -1
  13. package/dist/SelfieCaptureView.js +6 -3
  14. package/dist/SignatureCaptureView.d.ts +9 -1
  15. package/dist/SignatureCaptureView.d.ts.map +1 -1
  16. package/dist/SignatureCaptureView.js +51 -10
  17. package/dist/VideoIdCaptureView.d.ts +1 -1
  18. package/dist/VideoIdCaptureView.d.ts.map +1 -1
  19. package/dist/VideoIdCaptureView.js +24 -4
  20. package/dist/components/CameraFeed.d.ts +11 -3
  21. package/dist/components/CameraFeed.d.ts.map +1 -1
  22. package/dist/components/CameraFeed.js +24 -4
  23. package/dist/components/barcode/BarcodeGuideOverlay.d.ts +7 -1
  24. package/dist/components/barcode/BarcodeGuideOverlay.d.ts.map +1 -1
  25. package/dist/components/barcode/BarcodeGuideOverlay.js +2 -2
  26. package/dist/components/debug/debug.d.ts +4 -4
  27. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.d.ts +29 -0
  28. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.d.ts.map +1 -0
  29. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.js +274 -0
  30. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.d.ts +56 -0
  31. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.d.ts.map +1 -0
  32. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.js +101 -0
  33. package/dist/components/document/DocumentCaptureGuideOverlay.d.ts +31 -1
  34. package/dist/components/document/DocumentCaptureGuideOverlay.d.ts.map +1 -1
  35. package/dist/components/document/DocumentCaptureGuideOverlay.js +121 -2
  36. package/dist/components/document/DocumentCaptureReviewScreen.d.ts +44 -0
  37. package/dist/components/document/DocumentCaptureReviewScreen.d.ts.map +1 -0
  38. package/dist/components/document/DocumentCaptureReviewScreen.js +40 -0
  39. package/dist/components/document/types.d.ts +25 -0
  40. package/dist/components/document/types.d.ts.map +1 -1
  41. package/dist/components/document/types.js +18 -1
  42. package/dist/components/guides/IdCaptureGuides.d.ts.map +1 -1
  43. package/dist/components/guides/IdCaptureGuides.js +3 -4
  44. package/dist/components/review/ReviewScreen.d.ts.map +1 -1
  45. package/dist/components/review/ReviewScreen.js +1 -1
  46. package/dist/components/review/SignatureCaptureDiagnostics.d.ts +50 -0
  47. package/dist/components/review/SignatureCaptureDiagnostics.d.ts.map +1 -0
  48. package/dist/components/review/SignatureCaptureDiagnostics.js +142 -0
  49. package/dist/components/selfie/SelfieCaptureSurface.d.ts +11 -2
  50. package/dist/components/selfie/SelfieCaptureSurface.d.ts.map +1 -1
  51. package/dist/components/selfie/SelfieCaptureSurface.js +5 -2
  52. package/dist/components/videoId/VideoIdCaptureGuides.d.ts +4 -1
  53. package/dist/components/videoId/VideoIdCaptureGuides.d.ts.map +1 -1
  54. package/dist/components/videoId/VideoIdCaptureGuides.js +2 -2
  55. package/dist/flows/CompositeWizard.d.ts +5 -0
  56. package/dist/flows/CompositeWizard.d.ts.map +1 -1
  57. package/dist/flows/CompositeWizard.js +2 -1
  58. package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts +13 -0
  59. package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts.map +1 -1
  60. package/dist/flows/CustomerBiometricsEnrollmentFlow.js +8 -3
  61. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts +25 -0
  62. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts.map +1 -1
  63. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.js +12 -5
  64. package/dist/flows/DocumentCaptureFlow.d.ts +7 -1
  65. package/dist/flows/DocumentCaptureFlow.d.ts.map +1 -1
  66. package/dist/flows/DocumentCaptureFlow.js +10 -7
  67. package/dist/flows/FaceValidationFlow.d.ts +7 -0
  68. package/dist/flows/FaceValidationFlow.d.ts.map +1 -1
  69. package/dist/flows/FaceValidationFlow.js +6 -2
  70. package/dist/flows/IdAndFaceValidationFlow.d.ts +19 -0
  71. package/dist/flows/IdAndFaceValidationFlow.d.ts.map +1 -1
  72. package/dist/flows/IdAndFaceValidationFlow.js +10 -4
  73. package/dist/flows/IdValidationFlow.d.ts +12 -0
  74. package/dist/flows/IdValidationFlow.d.ts.map +1 -1
  75. package/dist/flows/IdValidationFlow.js +6 -2
  76. package/dist/flows/SignatureKYCFlow.d.ts +13 -0
  77. package/dist/flows/SignatureKYCFlow.d.ts.map +1 -1
  78. package/dist/flows/SignatureKYCFlow.js +8 -3
  79. package/dist/flows/SubmissionProvider.d.ts.map +1 -1
  80. package/dist/flows/SubmissionProvider.js +2 -4
  81. package/dist/flows/VideoIdValidationFlow.d.ts +25 -1
  82. package/dist/flows/VideoIdValidationFlow.d.ts.map +1 -1
  83. package/dist/flows/VideoIdValidationFlow.js +12 -5
  84. package/dist/flows/approval.d.ts +15 -0
  85. package/dist/flows/approval.d.ts.map +1 -0
  86. package/dist/flows/approval.js +19 -0
  87. package/dist/flows/autoCaptureMountGuard.d.ts +22 -0
  88. package/dist/flows/autoCaptureMountGuard.d.ts.map +1 -0
  89. package/dist/flows/autoCaptureMountGuard.js +61 -0
  90. package/dist/flows/customerMatch/CustomerMatchFlow.d.ts +7 -0
  91. package/dist/flows/customerMatch/CustomerMatchFlow.d.ts.map +1 -1
  92. package/dist/flows/customerMatch/CustomerMatchFlow.js +4 -1
  93. package/dist/flows/latestCallbacks.d.ts +31 -0
  94. package/dist/flows/latestCallbacks.d.ts.map +1 -0
  95. package/dist/flows/latestCallbacks.js +56 -0
  96. package/dist/flows/ringScreens.d.ts +0 -3
  97. package/dist/flows/ringScreens.d.ts.map +1 -1
  98. package/dist/flows/ringScreens.js +2 -3
  99. package/dist/guidance/selfieStrings.d.ts +9 -1
  100. package/dist/guidance/selfieStrings.d.ts.map +1 -1
  101. package/dist/guidance/selfieStrings.js +59 -20
  102. package/dist/i18n/index.d.ts +28 -1177
  103. package/dist/i18n/index.d.ts.map +1 -1
  104. package/dist/i18n/index.js +58 -22
  105. package/dist/i18n/locales/threeOh.d.ts +4 -0
  106. package/dist/i18n/locales/threeOh.d.ts.map +1 -0
  107. package/dist/i18n/locales/threeOh.js +105 -0
  108. package/dist/index.d.ts +3 -0
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +1 -0
  111. package/dist/testing/autoCaptureFrames.d.ts +23 -0
  112. package/dist/testing/autoCaptureFrames.d.ts.map +1 -0
  113. package/dist/testing/autoCaptureFrames.js +187 -0
  114. package/dist/testing/fakeDocumentController.d.ts +7 -1
  115. package/dist/testing/fakeDocumentController.d.ts.map +1 -1
  116. package/dist/testing/fakeDocumentController.js +10 -2
  117. package/dist/testing/index.d.ts +1 -0
  118. package/dist/testing/index.d.ts.map +1 -1
  119. package/dist/testing/index.js +1 -0
  120. package/dist/useIdmissionClient.d.ts +29 -0
  121. package/dist/useIdmissionClient.d.ts.map +1 -0
  122. package/dist/useIdmissionClient.js +44 -0
  123. package/dist/utils/canvas.d.ts.map +1 -1
  124. package/dist/utils/canvas.js +41 -0
  125. package/dist/version.d.ts +1 -1
  126. package/dist/version.d.ts.map +1 -1
  127. package/dist/version.js +1 -1
  128. package/package.json +3 -2
@@ -11,12 +11,15 @@ import { MicrophoneAccessDeniedOverlay, } from './flows/overlays';
11
11
  import { IdCaptureLoadingOverlay, } from './components/loading/IdCaptureLoadingOverlay';
12
12
  import { defaultIdCaptureGuideImages, } from './components/guide_images';
13
13
  import { VideoIdCaptureGuides } from './components/videoId/VideoIdCaptureGuides';
14
- import { useLanguage, useTranslations, useVerbiage, } from './i18n';
14
+ import { SdkLanguageProvider, useLanguage, useTranslations, useVerbiage, } from './i18n';
15
15
  import { VIDEO_ID_FALLBACKS } from './guidance/videoIdStrings';
16
16
  import { DebugBoundingBoxOverlay, DebugStatsPane, IdCaptureDetectedObjectDebugBox, useDebugScalingDetails, } from './components/debug/debug';
17
17
  import useResizeObserver from './layout/useResizeObserver';
18
18
  import { useSessionReady } from './flows/AuthStateContext';
19
- export function VideoIdCaptureView({ controller, sessionReady: sessionReadyProp, autoStart = true, loadingOverlayMode = 'default', autoContinueAfterLoading = false, showIntroScreen = false, transitionFromFaceCapture = false, lang = 'auto', onExit, onCompleted, readTextPrompt, onReadingFinished, onMicrophoneAccessDenied, verbiage, classNames = {}, guideImages = defaultIdCaptureGuideImages, loadingOverlayAssets, videoRef: providedVideoRef, debugMode = false, }) {
19
+ export function VideoIdCaptureView(props) {
20
+ return (_jsx(SdkLanguageProvider, { lang: props.lang ?? 'auto', children: _jsx(VideoIdCaptureViewContent, { ...props }) }));
21
+ }
22
+ function VideoIdCaptureViewContent({ controller, sessionReady: sessionReadyProp, autoStart = true, loadingOverlayMode = 'default', autoContinueAfterLoading = false, showIntroScreen = false, transitionFromFaceCapture = false, lang = 'auto', onExit, onCompleted, readTextPrompt, onReadingFinished, onMicrophoneAccessDenied, verbiage, classNames = {}, guideImages = defaultIdCaptureGuideImages, loadingOverlayAssets, videoRef: providedVideoRef, debugMode = false, }) {
20
23
  // Omitted means "follow the session": mounted inside a flow this view now
21
24
  // renders during session validation, so its own loading overlay is the one
22
25
  // loading surface (2.x behaviour — see useSessionReady). An explicit prop
@@ -107,6 +110,23 @@ export function VideoIdCaptureView({ controller, sessionReady: sessionReadyProp,
107
110
  ? 'SHOW_PASSPORT'
108
111
  : 'FLIP_ID';
109
112
  const capturing = state.phase === 'capturing';
113
+ // `CameraLayer` hides the feed with `display: none`, which pauses the
114
+ // element. The controller attaches ONCE and holds that exact node, and only
115
+ // a camera acquisition writes a stream into it — so the review screen's
116
+ // Retry, which restarts the attempt WITHOUT re-attaching (its detach/attach
117
+ // branch is for the error path only), un-hides an element nothing has asked
118
+ // to play again. Same reasoning, and same fix, as IdCaptureView's resume.
119
+ const feedVisible = capturing || state.phase === 'ready';
120
+ useEffect(() => {
121
+ if (!feedVisible)
122
+ return;
123
+ const el = videoRef.current;
124
+ // Nothing to resume on an element with no stream (pre-attach, or a
125
+ // deferred acquisition that has not happened yet) — see IdCaptureView.
126
+ if (!el?.srcObject)
127
+ return;
128
+ void Promise.resolve(el.play()).catch(() => { });
129
+ }, [feedVisible, videoRef]);
110
130
  const showLoadingOverlay = !overlayDismissed &&
111
131
  (state.phase === 'idle' ||
112
132
  state.phase === 'loading' ||
@@ -132,7 +152,7 @@ export function VideoIdCaptureView({ controller, sessionReady: sessionReadyProp,
132
152
  const backImageAlt = typeof text.backImageAlt === 'string'
133
153
  ? text.backImageAlt
134
154
  : VIDEO_ID_FALLBACKS.backImageAlt;
135
- return (_jsxs(Root, { ref: rootRef, className: classNames.container, children: [onExit && capturing ? (_jsx(ExitCaptureButton, { onClick: onExit, className: classNames.exitBtn })) : null, _jsx(CameraLayer, { "$visible": capturing || state.phase === 'ready', children: _jsx(CameraVideoTag, { ref: videoRef, isRearFacing: state.camera.isRearFacing, className: classNames.cameraFeed }) }), capturing ? (_jsx(VideoIdCaptureGuides, { classNames: {
155
+ return (_jsxs(Root, { ref: rootRef, className: classNames.container, children: [onExit && capturing ? (_jsx(ExitCaptureButton, { onClick: onExit, className: classNames.exitBtn })) : null, _jsx(CameraLayer, { "$visible": feedVisible, children: _jsx(CameraVideoTag, { ref: videoRef, isRearFacing: state.camera.isRearFacing, className: classNames.cameraFeed }) }), capturing ? (_jsx(VideoIdCaptureGuides, { classNames: {
136
156
  container: classNames.guides,
137
157
  instructions: classNames.guidance,
138
158
  instructionsContainer: classNames.guidanceContainer,
@@ -143,7 +163,7 @@ export function VideoIdCaptureView({ controller, sessionReady: sessionReadyProp,
143
163
  idCardGuideImageContainer: classNames.idCardGuideImageContainer,
144
164
  idCardGuideImage: classNames.idCardGuideImage,
145
165
  flipIdPrompt: classNames.flipIdPrompt,
146
- }, images: guideImages, requestedAction: guideAction, idDocumentType: state.documentType, instruction: instruction, isMirrored: !state.camera.isRearFacing, satisfied: state.guidance === VideoIdCaptureGuidanceCode.HOLD_STEADY, idCardGuideStatus: state.countdownRemaining === null ? 'ready' : 'capturing', idCardCaptureProgress: state.countdownRemaining === null ? 0 : 1 })) : null, state.countdownRemaining !== null ? (_jsx(Countdown, { "aria-live": "assertive", className: classNames.countdown, children: state.countdownRemaining })) : null, state.reading.active ? (_jsxs(ReadTextPrompt, { role: "status", "aria-live": "polite", className: classNames.readTextPrompt, children: [_jsx(ReadTextHeading, { className: classNames.readTextHeading, children: readTextHeading }), _jsx(ReadTextSentence, { className: classNames.readTextSentence, children: readTextPromptText }), _jsx(LoaderButton, { variant: "positive", finished: true, disabled: !state.reading.canFinish, className: classNames.readTextDoneBtn, onClick: () => {
166
+ }, images: guideImages, requestedAction: guideAction, idDocumentType: state.documentType, instruction: instruction, guidanceCode: state.guidance, isMirrored: !state.camera.isRearFacing, satisfied: state.guidance === VideoIdCaptureGuidanceCode.HOLD_STEADY, idCardGuideStatus: state.countdownRemaining === null ? 'ready' : 'capturing', idCardCaptureProgress: state.countdownRemaining === null ? 0 : 1 })) : null, state.countdownRemaining !== null ? (_jsx(Countdown, { "aria-live": "assertive", className: classNames.countdown, children: state.countdownRemaining })) : null, state.reading.active ? (_jsxs(ReadTextPrompt, { role: "status", "aria-live": "polite", className: classNames.readTextPrompt, children: [_jsx(ReadTextHeading, { className: classNames.readTextHeading, children: readTextHeading }), _jsx(ReadTextSentence, { className: classNames.readTextSentence, children: readTextPromptText }), _jsx(LoaderButton, { variant: "positive", finished: true, disabled: !state.reading.canFinish, className: classNames.readTextDoneBtn, onClick: () => {
147
167
  onReadingFinished?.();
148
168
  void controller.actions.finishReading();
149
169
  }, children: doneReadingText })] })) : null, debugMode && capturing ? (_jsx(VideoIdCaptureDebugLayer, { state: state, pageWidth: rootWidth, pageHeight: rootHeight })) : null, showLoadingOverlay ? (_jsx(IdCaptureLoadingOverlay, { state: state, mode: loadingOverlayMode, sessionReady: sessionReady, autoContinueAfterLoading: autoContinueAfterLoading, showIntroScreen: showIntroScreen, transitionFromPreviousStage: transitionFromFaceCapture, assets: loadingOverlayAssets, classNames: classNames.loadingOverlay, verbiage: loadingOverlayVerbiage, onDismissed: () => setOverlayDismissed(true), onUserCancel: onExit, onRequestCamera: () => controller.actions.requestCamera() })) : null, state.phase === 'reviewing' || state.phase === 'completed' ? (_jsxs(Review, { className: classNames.review, children: [_jsx("h1", { className: classNames.reviewHeading, children: text.headingText }), previewUrl ? (_jsx("video", { src: previewUrl, className: classNames.video, controls: true, playsInline: true, preload: "metadata" })) : null, _jsxs(CapturedFrames, { children: [state.artifact ? (_jsx("img", { src: state.artifact.frontImage, alt: frontImageAlt, className: classNames.frontImage })) : null, state.artifact?.backImage ? (_jsx("img", { src: state.artifact.backImage, alt: backImageAlt, className: classNames.backImage })) : null] }), state.phase === 'reviewing' ? (_jsxs(ButtonsRow, { className: classNames.buttonsRow, children: [_jsx(LoaderButton, { finished: true, variant: "warning", className: classNames.retryBtn, onClick: () => void controller.actions.retry(), children: text.retryBtnText }), _jsx(LoaderButton, { finished: true, variant: "positive", className: classNames.doneBtn, onClick: controller.actions.done, children: text.doneBtnText })] })) : null] })) : null, micDenied ? (_jsx(MicrophoneAccessDeniedOverlay, { onRetry: () => void controller.actions.retry(), classNames: classNames.microphoneAccessDenied, verbiage: verbiage?.microphoneAccessDenied })) : null, state.phase === 'error' && !micDenied ? (_jsxs(ErrorPanel, { role: "alert", className: classNames.error, children: [_jsx("h1", { children: text.errorHeadingText }), _jsx("p", { children: state.error?.message }), state.error?.recoverable ? (_jsx(LoaderButton, { finished: true, onClick: () => void controller.actions.retry(), children: text.retryBtnText })) : null] })) : null] }));
@@ -7,21 +7,29 @@ export declare const CameraVideoTag: import("react").ForwardRefExoticComponent<O
7
7
  isRearFacing?: boolean;
8
8
  } & import("react").RefAttributes<HTMLVideoElement>>;
9
9
  export type CameraFeedMode = 'snapToGuides' | 'fullscreen';
10
- export declare const CameraFeedWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$mode" | "$x" | "$y" | "$w" | "$h" | "$radius"> & {
10
+ export declare const CameraFeedWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$mode" | "$x" | "$y" | "$w" | "$h" | "$radius" | "$hidden"> & {
11
11
  $mode: CameraFeedMode;
12
12
  $x: number;
13
13
  $y: number;
14
14
  $w: number;
15
15
  $h: number;
16
16
  $radius?: number;
17
- }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$mode" | "$x" | "$y" | "$w" | "$h" | "$radius"> & {
17
+ $hidden?: boolean;
18
+ }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$mode" | "$x" | "$y" | "$w" | "$h" | "$radius" | "$hidden"> & {
18
19
  $mode: CameraFeedMode;
19
20
  $x: number;
20
21
  $y: number;
21
22
  $w: number;
22
23
  $h: number;
23
24
  $radius?: number;
25
+ $hidden?: boolean;
24
26
  }, never>>> & string;
27
+ /**
28
+ * Whether the feed is hidden in this phase. Hiding pauses the element, so the
29
+ * owner of the <video> — the one holding the ref it attached with — has to ask
30
+ * it to play again on the way back; `IdCaptureView` does, keyed on this.
31
+ */
32
+ export declare function isCameraFeedHidden(phase: CapturePhase): boolean;
25
33
  export type ScalingCameraFeedProps = {
26
34
  videoRef: Ref<HTMLVideoElement>;
27
35
  phase: CapturePhase;
@@ -32,5 +40,5 @@ export type ScalingCameraFeedProps = {
32
40
  /** 2.x parity: sdk2's `classNames.cameraFeed` on the ID/selfie wizards. */
33
41
  className?: string;
34
42
  };
35
- export declare function ScalingCameraFeed({ videoRef, phase, isRearFacing, cameraFeedMode, className, }: ScalingCameraFeedProps): ReactElement | null;
43
+ export declare function ScalingCameraFeed({ videoRef, phase, isRearFacing, cameraFeedMode, className, }: ScalingCameraFeedProps): ReactElement;
36
44
  //# sourceMappingURL=CameraFeed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CameraFeed.d.ts","sourceRoot":"","sources":["../../src/components/CameraFeed.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAc,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAGpE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,GAAG;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc;mBAHV,OAAO;oDAgBvB,CAAA;AAgBD,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,YAAY,CAAA;AAE1D,eAAO,MAAM,iBAAiB;WACrB,cAAc;QACjB,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;cACA,MAAM;;WALT,cAAc;QACjB,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;cACA,MAAM;oBAyBjB,CAAA;AAaD,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC/B,KAAK,EAAE,YAAY,CAAA;IACnB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;0EACsE;IACtE,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,cAA+B,EAC/B,SAAS,GACV,EAAE,sBAAsB,GAAG,YAAY,GAAG,IAAI,CAqB9C"}
1
+ {"version":3,"file":"CameraFeed.d.ts","sourceRoot":"","sources":["../../src/components/CameraFeed.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAc,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAGpE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,GAAG;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc;mBAHV,OAAO;oDAgBvB,CAAA;AAgBD,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,YAAY,CAAA;AAE1D,eAAO,MAAM,iBAAiB;WACrB,cAAc;QACjB,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;cACA,MAAM;cACN,OAAO;;WANV,cAAc;QACjB,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;cACA,MAAM;cACN,OAAO;oBA4BlB,CAAA;AAuBD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAE/D;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC/B,KAAK,EAAE,YAAY,CAAA;IACnB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;0EACsE;IACtE,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,cAA+B,EAC/B,SAAS,GACV,EAAE,sBAAsB,GAAG,YAAY,CAoBvC"}
@@ -12,7 +12,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
12
12
  // divergence 4 — those fields never crossed the core port); captureState
13
13
  // becomes a `phase: CapturePhase` prop, and the sdk2 `captureState ===
14
14
  // 'complete'` null-check becomes phase-in-{'reviewing','uploading',
15
- // 'complete'} (the CapturePhase values that mean capture is over).
15
+ // 'complete'} (the CapturePhase values that mean capture is over) — as a
16
+ // `display: none`, not an unmount; see PHASES_WITH_NO_CAMERA_FEED below.
16
17
  import { forwardRef } from 'react';
17
18
  import { styled } from 'styled-components';
18
19
  import { useGuideLayout } from '../layout/GuideLayoutContext';
@@ -55,20 +56,39 @@ export const CameraFeedWrapper = styled.div `
55
56
  width: 100%;
56
57
  height: 100%;
57
58
  overflow: hidden;`}
59
+
60
+ /* Last, so it wins over both branches' display. */
61
+ ${(props) => (props.$hidden ? 'display: none;' : '')}
58
62
  `;
59
63
  // sdk2's ScalingCameraFeed hides itself once captureState === 'complete'.
60
64
  // The core port's CapturePhase spreads that one boolean across three
61
65
  // phases — 'reviewing' (post-capture, pre-submit), 'uploading' (submitting),
62
66
  // and 'complete' (submitted) — all of which mean "camera feed no longer
63
67
  // needed".
68
+ //
69
+ // HIDDEN, never unmounted. sdk2 could drop the <video>: its camera store held
70
+ // the stream and re-assigned `srcObject` to whatever element mounted next. In
71
+ // 3.0 the element IS the attachment — `controller.attach(el)` keeps that exact
72
+ // node (controller.ts, `const el = videoEl`) and only a camera acquisition
73
+ // wires a stream into it — so unmounting here orphaned the stream on a
74
+ // detached node. The view attaches once per controller, so nothing re-wired
75
+ // the fresh element React mounted on the way back to capturing: a retake
76
+ // returned to the capture screen with guides, border and a live pipeline over
77
+ // a blank feed. The element outlives every phase; only its visibility changes.
64
78
  const PHASES_WITH_NO_CAMERA_FEED = new Set([
65
79
  'reviewing',
66
80
  'uploading',
67
81
  'complete',
68
82
  ]);
83
+ /**
84
+ * Whether the feed is hidden in this phase. Hiding pauses the element, so the
85
+ * owner of the <video> — the one holding the ref it attached with — has to ask
86
+ * it to play again on the way back; `IdCaptureView` does, keyed on this.
87
+ */
88
+ export function isCameraFeedHidden(phase) {
89
+ return PHASES_WITH_NO_CAMERA_FEED.has(phase);
90
+ }
69
91
  export function ScalingCameraFeed({ videoRef, phase, isRearFacing, cameraFeedMode = 'snapToGuides', className, }) {
70
92
  const { guideRect } = useGuideLayout();
71
- if (PHASES_WITH_NO_CAMERA_FEED.has(phase))
72
- return null;
73
- return (_jsx(CameraFeedWrapper, { "$x": guideRect?.x ?? 0, "$y": guideRect?.y ?? 0, "$w": guideRect?.width ?? 0, "$h": guideRect?.height ?? 0, "$radius": guideRect?.radius, "$mode": cameraFeedMode, children: _jsx(CameraVideoTag, { ref: videoRef, isRearFacing: isRearFacing, className: className }) }));
93
+ return (_jsx(CameraFeedWrapper, { "$x": guideRect?.x ?? 0, "$y": guideRect?.y ?? 0, "$w": guideRect?.width ?? 0, "$h": guideRect?.height ?? 0, "$radius": guideRect?.radius, "$mode": cameraFeedMode, "$hidden": isCameraFeedHidden(phase), children: _jsx(CameraVideoTag, { ref: videoRef, isRearFacing: isRearFacing, className: className }) }));
74
94
  }
@@ -15,9 +15,15 @@ export type BarcodeGuideOverlayProps = {
15
15
  borderRadius?: number;
16
16
  headerText?: string | ReactElement;
17
17
  instructionText?: string | ReactElement;
18
+ /**
19
+ * Stable identifier for `instructionText`, emitted as `data-guidance-code` so
20
+ * a stylesheet can target this specific message. Optional because the
21
+ * component keeps a standalone default for its own text.
22
+ */
23
+ instructionCode?: string;
18
24
  isSuccess?: boolean;
19
25
  successColor?: string;
20
26
  classNames?: BarcodeGuideOverlayClassNames;
21
27
  };
22
- export declare function BarcodeGuideOverlay({ aspectRatio, maskColor, cornerColor, cornerLength, cornerWidth, padding, borderRadius, headerText, instructionText, isSuccess, successColor, classNames, }: BarcodeGuideOverlayProps): import("react/jsx-runtime").JSX.Element;
28
+ export declare function BarcodeGuideOverlay({ aspectRatio, maskColor, cornerColor, cornerLength, cornerWidth, padding, borderRadius, headerText, instructionText, instructionCode, isSuccess, successColor, classNames, }: BarcodeGuideOverlayProps): import("react/jsx-runtime").JSX.Element;
23
29
  //# sourceMappingURL=BarcodeGuideOverlay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BarcodeGuideOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/barcode/BarcodeGuideOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAA;AAQvD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;IACvC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,6BAA6B,CAAA;CAC3C,CAAA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,WAAiC,EACjC,SAAS,EACT,WAAqB,EACrB,YAAiB,EACjB,WAAe,EACf,OAAO,EACP,YAAgB,EAChB,UAA+B,EAC/B,eAAoF,EACpF,SAAiB,EACjB,YAAwB,EACxB,UAAe,GAChB,EAAE,wBAAwB,2CAyJ1B"}
1
+ {"version":3,"file":"BarcodeGuideOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/barcode/BarcodeGuideOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAA;AAQvD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;IACvC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,6BAA6B,CAAA;CAC3C,CAAA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,WAAiC,EACjC,SAAS,EACT,WAAqB,EACrB,YAAiB,EACjB,WAAe,EACf,OAAO,EACP,YAAgB,EAChB,UAA+B,EAC/B,eAAoF,EACpF,eAAe,EACf,SAAiB,EACjB,YAAwB,EACxB,UAAe,GAChB,EAAE,wBAAwB,2CA4J1B"}
@@ -5,7 +5,7 @@ import { resetCanvasDimensions, setCanvasDimensions } from '../../utils/canvas';
5
5
  import { isMobile } from '../../utils/isMobile';
6
6
  import useResizeObserver from '../../layout/useResizeObserver';
7
7
  const PDF417_ASPECT_RATIO = 3 / 1;
8
- export function BarcodeGuideOverlay({ aspectRatio = PDF417_ASPECT_RATIO, maskColor, cornerColor = 'white', cornerLength = 40, cornerWidth = 4, padding, borderRadius = 8, headerText = 'SCAN THE BARCODE', instructionText = 'Bring camera closer until the barcode fills the rectangular box.', isSuccess = false, successColor = '#22c55e', classNames = {}, }) {
8
+ export function BarcodeGuideOverlay({ aspectRatio = PDF417_ASPECT_RATIO, maskColor, cornerColor = 'white', cornerLength = 40, cornerWidth = 4, padding, borderRadius = 8, headerText = 'SCAN THE BARCODE', instructionText = 'Bring camera closer until the barcode fills the rectangular box.', instructionCode, isSuccess = false, successColor = '#22c55e', classNames = {}, }) {
9
9
  const canvasRef = useRef(null);
10
10
  const { ref: wrapperRef, width: wrapperWidth = 1, height: wrapperHeight = 1, } = useResizeObserver();
11
11
  const theme = useTheme();
@@ -102,7 +102,7 @@ export function BarcodeGuideOverlay({ aspectRatio = PDF417_ASPECT_RATIO, maskCol
102
102
  wrapperHeight,
103
103
  wrapperWidth,
104
104
  ]);
105
- return (_jsxs(Wrapper, { ref: wrapperRef, className: classNames.wrapper, children: [_jsx(Canvas, { ref: canvasRef, className: classNames.canvas }), _jsxs(TextOverlay, { children: [_jsx(HeaderText, { className: classNames.header, children: headerText }), _jsx(InstructionText, { className: classNames.instruction, children: instructionText })] })] }));
105
+ return (_jsxs(Wrapper, { ref: wrapperRef, className: classNames.wrapper, children: [_jsx(Canvas, { ref: canvasRef, className: classNames.canvas }), _jsxs(TextOverlay, { children: [_jsx(HeaderText, { className: classNames.header, children: headerText }), _jsx(InstructionText, { className: classNames.instruction, "data-guidance-code": instructionCode, children: instructionText })] })] }));
106
106
  }
107
107
  const Wrapper = styled.div `
108
108
  position: absolute;
@@ -9,10 +9,10 @@ export declare const ObjectDetectionDebugOverlayDiv: import("styled-components/d
9
9
  }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$flipX"> & {
10
10
  $flipX?: boolean;
11
11
  }, never>>> & string;
12
- export declare const ObjectDetectionDebugBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$color" | "$flipX"> & {
12
+ export declare const ObjectDetectionDebugBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$flipX" | "$color"> & {
13
13
  $color?: string;
14
14
  $flipX?: boolean;
15
- }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$color" | "$flipX"> & {
15
+ }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$flipX" | "$color"> & {
16
16
  $color?: string;
17
17
  $flipX?: boolean;
18
18
  }, never>>> & string;
@@ -21,10 +21,10 @@ export declare const ObjectDetectionDebugLabel: import("styled-components/dist/t
21
21
  }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "$color"> & {
22
22
  $color?: string;
23
23
  }, never>>> & string;
24
- export declare const FaceDetectionKeypointMarker: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$color" | "$flipX"> & {
24
+ export declare const FaceDetectionKeypointMarker: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$flipX" | "$color"> & {
25
25
  $color?: string;
26
26
  $flipX?: boolean;
27
- }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$color" | "$flipX"> & {
27
+ }, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$flipX" | "$color"> & {
28
28
  $color?: string;
29
29
  $flipX?: boolean;
30
30
  }, never>>> & string;
@@ -0,0 +1,29 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { AutoCaptureDiagnostics, DocumentCaptureControllerState } from '@idmission/websdk-core/documentCapture';
3
+ export type DocumentCaptureAutoCaptureDebugLayerProps = {
4
+ state: DocumentCaptureControllerState;
5
+ /**
6
+ * Reads the controller's ring buffer. Passed in rather than read off
7
+ * `controller` directly so the replay story — which drives a fake controller
8
+ * from a recorded log — can hand back that same log.
9
+ */
10
+ getLog: () => AutoCaptureDiagnostics[];
11
+ /**
12
+ * Collapse to the controls alone, dropping the stats and the boxes.
13
+ *
14
+ * Set while the review card is up. Two reasons, and the second is the one
15
+ * that matters: the shared pane sits at `z-index: 10002`, so it paints
16
+ * straight over the captured image — the operator cannot see the thing they
17
+ * just captured. And the numbers behind it are STALE anyway, because an
18
+ * accepted capture tears the engine down, so there is no live frame to
19
+ * report.
20
+ *
21
+ * NOT hidden outright. SAVE LOG and COPY are the deliverable of a tuning
22
+ * session (#341), and the moment a capture lands is exactly when an operator
23
+ * reaches for them — the same reasoning that made `stopAutoCapture` drain the
24
+ * ring buffer before dropping the engine.
25
+ */
26
+ compact?: boolean;
27
+ };
28
+ export declare function DocumentCaptureAutoCaptureDebugLayer({ state, getLog, compact, }: DocumentCaptureAutoCaptureDebugLayerProps): ReactElement;
29
+ //# sourceMappingURL=DocumentCaptureAutoCaptureDebugLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentCaptureAutoCaptureDebugLayer.d.ts","sourceRoot":"","sources":["../../../src/components/document/DocumentCaptureAutoCaptureDebugLayer.tsx"],"names":[],"mappings":"AAqCA,OAAO,EAAyB,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AAGhF,OAAO,KAAK,EACV,sBAAsB,EACtB,8BAA8B,EAG/B,MAAM,wCAAwC,CAAA;AAmF/C,MAAM,MAAM,yCAAyC,GAAG;IACtD,KAAK,EAAE,8BAA8B,CAAA;IACrC;;;;OAIG;IACH,MAAM,EAAE,MAAM,sBAAsB,EAAE,CAAA;IACtC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,wBAAgB,oCAAoC,CAAC,EACnD,KAAK,EACL,MAAM,EACN,OAAe,GAChB,EAAE,yCAAyC,GAAG,YAAY,CA8S1D"}
@@ -0,0 +1,274 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The POA auto-capture tuning overlay (#341, built by #353).
3
+ //
4
+ // This is a SHIPPED debug layer, not prototype scaffolding. The paper and the
5
+ // applicants are in Mexico, so the instrument #343 and #344 are measured with
6
+ // has to reach a published 2.4.x build — which is why it lives here rather
7
+ // than on a branch, and why its enablement is the existing 2.x `debugMode`
8
+ // rather than a new prop.
9
+ //
10
+ // Governing rule, from #341: EVERY GATE SHOWS VALUE, THRESHOLD, AND VERDICT.
11
+ // A verdict alone cannot distinguish "the threshold is wrong" from "the signal
12
+ // is wrong", and that distinction is the entire point of the exercise. Two
13
+ // consequences visible below:
14
+ //
15
+ // - Fill prints the WINDOWED MEAN the verdict is taken on, this frame's
16
+ // instantaneous value, and the window's peak-to-peak spread. #343 gated on
17
+ // the aggregate precisely because the instant dithers across the box
18
+ // encodings' grid; showing only one of the two would make "the threshold is
19
+ // wrong" and "the signal is jittering" indistinguishable, which is the
20
+ // confusion this pane exists to prevent. The spread is also the reading
21
+ // #380 answers the hysteresis question from.
22
+ // - Fill prints both components as well as the max. `computePoaFraming`
23
+ // reports the max because that is what the gate compares, but the max
24
+ // hides which axis is binding.
25
+ // - Margins print to four decimals and gate NOTHING. #343 deleted the margin
26
+ // gate; they survive as the reading that says which way to move, and at
27
+ // four places because that is how every number already on the map is
28
+ // recorded.
29
+ //
30
+ // Everything above is packed into the SAME FOUR LINES the pre-#343 pane used,
31
+ // which is a constraint rather than tidiness: #353's device pass found the
32
+ // pane hitting its 45% cap and covering the top edge of the sheet — the very
33
+ // edge the operator is there to frame. A row added here costs a row of paper.
34
+ //
35
+ // The on-glass text is a LIVENESS CHECK, not the deliverable. The ~300-frame
36
+ // ring buffer behind COPY is what gets replayed into Storybook and pinned as
37
+ // fixtures; nobody tunes a 1.3%-wide band by reading numbers off a phone in
38
+ // their hand.
39
+ import { useCallback, useState } from 'react';
40
+ import { warn } from '../../utils/logger';
41
+ import { styled } from 'styled-components';
42
+ import { DebugBoundingBoxOverlay, DebugStatsPane, DebugStatsPaneDiv, IdCaptureDetectedObjectDebugBox, useDebugScalingDetails, } from '../debug/debug';
43
+ import { useGuideLayout } from '../../layout/GuideLayoutContext';
44
+ /** Human wording for each gate, in the order the engine reports them. */
45
+ /** Short enough that the triple fits one line on a phone. */
46
+ const GUIDANCE_LABELS = {
47
+ none: '—',
48
+ noDocument: 'no doc',
49
+ tooClose: 'close',
50
+ tooFar: 'far',
51
+ notStable: 'move',
52
+ outOfFocus: 'blur',
53
+ holdStill: 'OK',
54
+ };
55
+ const GATE_LABELS = {
56
+ noDocument: 'no document',
57
+ tooClose: 'too close',
58
+ tooFar: 'too far',
59
+ outOfFocus: 'out of focus',
60
+ notStable: 'not stable',
61
+ };
62
+ /**
63
+ * Fixed-width so a value changing from 0.9990 to 0.0130 does not reflow the
64
+ * pane. `toFixed` on a negative margin keeps its sign, which is the point —
65
+ * negative means the box runs off that edge.
66
+ */
67
+ function n(value, places = 3) {
68
+ if (value === null || value === undefined || !Number.isFinite(value)) {
69
+ return '—';
70
+ }
71
+ return value.toFixed(places);
72
+ }
73
+ /** Margins get four places: see the header on the 1.3%-wide band. */
74
+ function margin(value) {
75
+ return n(value, 4);
76
+ }
77
+ /** Labels shown on glass. The rest are counted, not listed. */
78
+ const PEAK_SCORES_SHOWN = 4;
79
+ /**
80
+ * The highest-scoring labels, with the remainder reduced to a count so the
81
+ * pane cannot grow over the sheet it is measuring. `scores` is keyed by the
82
+ * label the model emitted (#341), so an unmapped class shows up here as
83
+ * `class_NN` rather than silently vanishing — which is the reason this row
84
+ * exists at all, and why the count matters when the list is truncated.
85
+ */
86
+ function formatPeakScores(scores) {
87
+ const ranked = Object.entries(scores).sort((a, b) => b[1] - a[1]);
88
+ if (ranked.length === 0)
89
+ return 'no detections';
90
+ const shown = ranked
91
+ .slice(0, PEAK_SCORES_SHOWN)
92
+ .map(([label, score]) => `${label} ${n(score, 2)}`)
93
+ .join(' ');
94
+ const hidden = ranked.length - PEAK_SCORES_SHOWN;
95
+ return hidden > 0 ? `${shown} +${hidden} more` : shown;
96
+ }
97
+ function Gate({ pass, children, }) {
98
+ return (_jsxs(_Fragment, { children: [pass ? '✅' : '❌', " ", children, _jsx("br", {})] }));
99
+ }
100
+ export function DocumentCaptureAutoCaptureDebugLayer({ state, getLog, compact = false, }) {
101
+ const { guideRect } = useGuideLayout();
102
+ // Tapping the pane hides the boxes: #341 asked for this because rectangles
103
+ // drawn over the sheet visibly bias how the operator frames it, and the
104
+ // framing IS the measurement.
105
+ const [showBoxes, setShowBoxes] = useState(true);
106
+ // Freeze latches the last live reading. At 30fps the numbers that matter are
107
+ // unreadable in motion, and the interesting frame is always the one that just
108
+ // went past.
109
+ const [frozen, setFrozen] = useState(null);
110
+ const [copied, setCopied] = useState(null);
111
+ const [saved, setSaved] = useState(null);
112
+ const live = state.autoCapture;
113
+ const shown = frozen ?? live;
114
+ /**
115
+ * Writes the ring buffer to a file.
116
+ *
117
+ * #353's device pass produced 300 real frames and did not keep them, which
118
+ * is why #343 had to answer the dither question from a synthetic proxy — so
119
+ * #380 made saving the buffer the deliverable rather than a nicety. COPY
120
+ * survives beside this because the payload is ~600KB and iOS pasteboard
121
+ * handling of that is its own adventure; a download lands in Files, which
122
+ * AirDrops.
123
+ */
124
+ const saveLog = useCallback(() => {
125
+ const log = getLog();
126
+ const blob = new Blob([JSON.stringify(log)], { type: 'application/json' });
127
+ const url = URL.createObjectURL(blob);
128
+ const anchor = document.createElement('a');
129
+ anchor.href = url;
130
+ // Frame count in the name: a truncated download announces itself, and a
131
+ // session produces several files that are otherwise indistinguishable.
132
+ anchor.download = `poa-autocapture-${log.length}f-${Date.now()}.json`;
133
+ document.body.appendChild(anchor);
134
+ anchor.click();
135
+ anchor.remove();
136
+ // Revoked on a timeout, not immediately: iOS Safari has not necessarily
137
+ // read the blob by the time click() returns.
138
+ setTimeout(() => URL.revokeObjectURL(url), 60_000);
139
+ setSaved(`${log.length}f saved`);
140
+ }, [getLog]);
141
+ const copyLog = useCallback(() => {
142
+ const log = getLog();
143
+ const text = JSON.stringify(log);
144
+ // Clipboard access needs a secure context and, on iOS, a user gesture —
145
+ // this IS one, but a tunnelled http:// Storybook is not secure, which is
146
+ // exactly how these sessions get run. The console fallback keeps the log
147
+ // recoverable there instead of the button silently doing nothing.
148
+ const fallback = () => {
149
+ // `warn`, not `debug` or `log`: those two sit above the default level and
150
+ // would be swallowed, and this is the one path where the operator has no
151
+ // other way to reach the buffer. It IS a degradation notice — the
152
+ // clipboard was unavailable — so the level is honest as well as audible.
153
+ //
154
+ // Deliberately the UI package's own logger, per AGENTS.md. `debugMode`
155
+ // raises CORE's level, not this one, so routing through `debug()` here
156
+ // would silence the fallback in exactly the session that needs it.
157
+ warn('[autoCapture] diagnostics log', text);
158
+ setCopied(`${log.length}f → console`);
159
+ };
160
+ if (!navigator.clipboard?.writeText) {
161
+ fallback();
162
+ return;
163
+ }
164
+ navigator.clipboard.writeText(text).then(() => setCopied(`${log.length}f copied`), fallback);
165
+ }, [getLog]);
166
+ const scaling = useDebugScalingDetails({
167
+ enabled: true,
168
+ pageWidth: guideRect?.width || 1,
169
+ pageHeight: guideRect?.height || 1,
170
+ videoWidth: state.videoWidth,
171
+ videoHeight: state.videoHeight,
172
+ });
173
+ const framing = shown?.framing ?? null;
174
+ const fillWindow = shown?.fillWindow ?? null;
175
+ const focus = shown?.focus ?? null;
176
+ const stability = shown?.stability ?? null;
177
+ return (_jsxs(_Fragment, { children: [showBoxes && !compact && (_jsx(DebugBoundingBoxOverlay
178
+ // Document capture prefers the rear camera and a rear feed is not
179
+ // mirrored, so the boxes must not be either — same rule as the feed.
180
+ , { "$flipX": !state.camera.isRearFacing, scaling: scaling, guideRect: guideRect, children: (shown?.detectedObjects ?? []).map((obj, i) => (_jsx(IdCaptureDetectedObjectDebugBox, { obj: obj, scaling: scaling, flipX: !state.camera.isRearFacing,
181
+ // The box geometry is being measured on is called out, because
182
+ // several labels fire on one sheet and only one drives the gates.
183
+ color: obj.label === shown?.target?.label ? 'green' : 'orange' }, i))) })), _jsx(PaneAnchor, { children: _jsx(DebugStatsPane, { children: _jsxs(InteractivePane, { "data-testid": "autocapture-debug-pane", onClick: () => setShowBoxes((visible) => !visible), children: [compact ? null : (_jsx(Gate, { pass: state.camera.ready, children: state.camera.ready
184
+ ? `Camera ${state.videoWidth}x${state.videoHeight}`
185
+ : 'Camera not ready' })), compact ? null : (_jsxs(Gate, { pass: state.models.state === 'ready', children: ["Models: ", state.models.state, state.models.state === 'downloading'
186
+ ? ` ${Math.round(state.models.downloadProgress)}%`
187
+ : '', state.models.error ? ` — ${state.models.error.message}` : ''] })), compact ? null : !shown ? ('Waiting for the first frame…') : (_jsxs(_Fragment, { children: [_jsxs(Gate, { pass: shown.frameRate > 10, children: [n(shown.frameRate, 1), " fps (", n(shown.detectionTimeMs, 0), "ms detect)"] }), _jsxs(Gate, { pass: !!shown.target, children: ["Target:", ' ', shown.target
188
+ ? `${shown.target.label} ${n(shown.target.score)}`
189
+ : 'none', ' ', "\u2265 ", n(shown.targetMinScore)] }), framing ? (_jsxs(_Fragment, { children: [_jsxs(Row, { children: ["L ", margin(framing.leftMargin), " R", ' ', margin(framing.rightMargin), " min", ' ', margin(framing.minMargin), _jsx("br", {}), "T ", margin(framing.topMargin), " B", ' ', margin(framing.bottomMargin)] }), _jsxs(Row, { children: ["Rect ", Math.round(shown.guideRect.width), "\u00D7", Math.round(shown.guideRect.height), " of", ' ', shown.frameWidth, "\u00D7", shown.frameHeight, shown.guideRect.width < shown.frameWidth ||
190
+ shown.guideRect.height < shown.frameHeight
191
+ ? ' (guide)'
192
+ : ' (full frame)'] })] })) : (_jsx(Row, { children: "No box \u2014 framing unmeasurable" })), fillWindow && (_jsxs(_Fragment, { children: [_jsxs(Gate, { pass: !fillWindow.tooClose && !fillWindow.tooFar, children: ["Fill ", n(fillWindow.mean), " in [", n(fillWindow.fillMin), ",", ' ', n(fillWindow.fillMax), "]"] }), _jsxs(Row, { children: ["now ", n(fillWindow.instant), " \u00B1", n(fillWindow.spread, 4), ' ', fillWindow.framesTracked, "/", fillWindow.framesNeeded, "f", framing
193
+ ? ` (w ${n(framing.fillWidth)} h ${n(framing.fillHeight)})`
194
+ : ''] })] })), focus ? (_jsxs(Gate, { pass: focus.thresholdMet, children: ["Focus ", n(focus.score), " \u2265 ", n(focus.threshold), " (", focus.branch, ")"] })) : (_jsxs(Row, { children: ["Focus:", ' ', shown.target ? 'model unavailable' : 'no box to measure'] })), stability && (_jsxs(Gate, { pass: stability.isStable, children: ["IoU ", n(stability.worstIou), " \u2265 ", n(stability.threshold), " (", stability.framesTracked, "/", stability.framesNeeded, "f)"] })), _jsxs(Row, { children: ["Failing:", ' ', shown.failingGates.length === 0
195
+ ? 'none'
196
+ : shown.failingGates
197
+ .map((gate) => GATE_LABELS[gate])
198
+ .join(' › ')] }), _jsxs(Row, { children: ["Msg: ", GUIDANCE_LABELS[shown.guidance.raw], " \u2192", ' ', GUIDANCE_LABELS[shown.guidance.pendingCandidate], " \u2192", ' ', GUIDANCE_LABELS[shown.guidance.displayed], " (", Math.round(shown.guidance.displayedForMs), "ms)"] }), _jsx(Row, { children: formatPeakScores(shown.scores) })] })), _jsxs(Controls, { children: [_jsx(Chip, { type: "button", "data-testid": "autocapture-debug-freeze", "$active": frozen !== null, onClick: (event) => {
199
+ event.stopPropagation();
200
+ setFrozen(frozen ? null : (live ?? null));
201
+ }, children: frozen ? 'FROZEN' : 'LIVE' }), _jsx(Chip, { type: "button", "data-testid": "autocapture-debug-save", onClick: (event) => {
202
+ event.stopPropagation();
203
+ saveLog();
204
+ }, children: saved ?? 'SAVE LOG' }), _jsx(Chip, { type: "button", "data-testid": "autocapture-debug-copy", onClick: (event) => {
205
+ event.stopPropagation();
206
+ copyLog();
207
+ }, children: copied ?? 'COPY' })] })] }) }) })] }));
208
+ }
209
+ /**
210
+ * Re-anchors the shared stats pane to the TOP of the capture surface.
211
+ *
212
+ * `DebugStatsPaneDiv` sits at `bottom: 20px`, which is right where
213
+ * `DocumentCaptureView` puts its instructions and the Capture button —
214
+ * `IdCaptureView` has nothing there, so the shared default has never had to
215
+ * dodge anything. A pane covering the shutter is worse than no pane: the
216
+ * operator has to be able to frame the sheet AND take the picture while
217
+ * reading the numbers. Anchoring at the top also leaves the lower two-thirds
218
+ * of the guide box clear, which is where the sheet actually sits.
219
+ *
220
+ * `pointer-events: none` on the anchor is what keeps a full-surface div from
221
+ * swallowing every tap; `InteractivePane` re-enables them for itself alone.
222
+ */
223
+ const PaneAnchor = styled.div `
224
+ position: absolute;
225
+ inset: 0;
226
+ pointer-events: none;
227
+
228
+ ${DebugStatsPaneDiv} {
229
+ top: 0;
230
+ bottom: auto;
231
+ left: 0;
232
+ right: 0;
233
+ margin: 0;
234
+ font-size: 11px;
235
+ line-height: 1.4;
236
+ /* Capped so a long detection list cannot grow over the whole sheet; the
237
+ ring buffer is the record, this is only the liveness check. */
238
+ max-height: 45%;
239
+ overflow-y: auto;
240
+ /* The shared pane's rgba(0,0,0,0.5) was chosen against IdCaptureView,
241
+ where it sits over a held ID at the BOTTOM of the frame. Here it sits
242
+ over the top of a sheet of white paper, in the daylight someone reads a
243
+ utility bill in, and 11px limegreen at half opacity stops being legible
244
+ exactly when the sheet is well framed — the frames that matter most.
245
+ Scoped to this anchor so IdCaptureView's pane is untouched. */
246
+ background: rgba(0, 0, 0, 0.78);
247
+ }
248
+ `;
249
+ // `DebugStatsPaneDiv` sets `pointer-events: none` so the shared pane can never
250
+ // swallow a capture tap. This one has to be tappable, so it re-enables them on
251
+ // its own subtree only.
252
+ const InteractivePane = styled.span `
253
+ pointer-events: auto;
254
+ display: block;
255
+ cursor: pointer;
256
+ user-select: none;
257
+ `;
258
+ const Row = styled.span `
259
+ display: block;
260
+ `;
261
+ const Controls = styled.span `
262
+ display: flex;
263
+ gap: 6px;
264
+ margin-top: 6px;
265
+ `;
266
+ const Chip = styled.button `
267
+ font: bold 11px monospace;
268
+ padding: 4px 8px;
269
+ border: 1px solid limegreen;
270
+ border-radius: 3px;
271
+ background: ${({ $active }) => ($active ? 'limegreen' : 'transparent')};
272
+ color: ${({ $active }) => ($active ? 'black' : 'limegreen')};
273
+ cursor: pointer;
274
+ `;
@@ -0,0 +1,56 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { PoaGuidanceCode } from '@idmission/websdk-core/documentCapture';
3
+ /**
4
+ * Which verbiage member renders each code.
5
+ *
6
+ * `notStable` and `outOfFocus` map to DIFFERENT members that happen to carry
7
+ * the same default string. Keeping the members distinct is what lets an
8
+ * integrator separate them later without a breaking change, while the shared
9
+ * default reflects #383's finding that on paper a focus failure IS a motion
10
+ * failure — so "hold still" is right for both, and a second sentence saying it
11
+ * differently is a distinction the applicant cannot act on.
12
+ */
13
+ export declare const AUTO_CAPTURE_GUIDANCE_VERBIAGE_KEYS: {
14
+ readonly noDocument: "autoCaptureNoDocumentText";
15
+ readonly tooClose: "autoCaptureTooCloseText";
16
+ readonly tooFar: "autoCaptureTooFarText";
17
+ readonly notStable: "autoCaptureNotStableText";
18
+ readonly outOfFocus: "autoCaptureOutOfFocusText";
19
+ readonly holdStill: "autoCaptureHoldStillText";
20
+ };
21
+ export type AutoCaptureGuidanceVerbiageKey = (typeof AUTO_CAPTURE_GUIDANCE_VERBIAGE_KEYS)[keyof typeof AUTO_CAPTURE_GUIDANCE_VERBIAGE_KEYS];
22
+ /**
23
+ * A resolved verbiage bag.
24
+ *
25
+ * Optional because `useTranslations` types its result from a verbiage type
26
+ * whose members are optional, even though every fallback key is always filled
27
+ * at runtime. Widening here beats asserting at the call site.
28
+ */
29
+ export type ResolvedGuidanceMessages = Partial<Record<AutoCaptureGuidanceVerbiageKey, string | ReactElement>>;
30
+ export type DocumentCaptureAutoCaptureGuidanceProps = {
31
+ /** The stabilized code. `'none'` renders nothing — the pre-first-frame state. */
32
+ code: PoaGuidanceCode;
33
+ /** Resolved strings, keyed as above. */
34
+ messages: ResolvedGuidanceMessages;
35
+ className?: string;
36
+ };
37
+ export declare function DocumentCaptureAutoCaptureGuidance({ code, messages, className, }: DocumentCaptureAutoCaptureGuidanceProps): ReactElement | null;
38
+ /**
39
+ * Why a Capture button just appeared (#345).
40
+ *
41
+ * This replaced a bottom sheet that asked "Having trouble? Would you like to
42
+ * take the photo yourself?" over two buttons. The sheet had to go: it covered
43
+ * the guidance pill, which is the only thing on screen that answers its own
44
+ * question, and it made the applicant confirm a permission they already had.
45
+ *
46
+ * So the button simply appears and this says why. It is a CAPTION, not a
47
+ * dialog: no scrim, no actions, nothing to dismiss, and the loop keeps running
48
+ * behind it. Rendered in the same stack as the pill so the live guidance still
49
+ * reads as the more urgent of the two.
50
+ */
51
+ export type DocumentCaptureManualCaptureHintProps = {
52
+ message: string | ReactElement | undefined;
53
+ className?: string;
54
+ };
55
+ export declare function DocumentCaptureManualCaptureHint({ message, className, }: DocumentCaptureManualCaptureHintProps): ReactElement | null;
56
+ //# sourceMappingURL=DocumentCaptureAutoCaptureGuidance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentCaptureAutoCaptureGuidance.d.ts","sourceRoot":"","sources":["../../../src/components/document/DocumentCaptureAutoCaptureGuidance.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE7E;;;;;;;;;GASG;AACH,eAAO,MAAM,mCAAmC;;;;;;;CAOqB,CAAA;AAErE,MAAM,MAAM,8BAA8B,GACxC,CAAC,OAAO,mCAAmC,CAAC,CAAC,MAAM,OAAO,mCAAmC,CAAC,CAAA;AAEhG;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,MAAM,CAAC,8BAA8B,EAAE,MAAM,GAAG,YAAY,CAAC,CAC9D,CAAA;AAED,MAAM,MAAM,uCAAuC,GAAG;IACpD,iFAAiF;IACjF,IAAI,EAAE,eAAe,CAAA;IACrB,wCAAwC;IACxC,QAAQ,EAAE,wBAAwB,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,kCAAkC,CAAC,EACjD,IAAI,EACJ,QAAQ,EACR,SAAS,GACV,EAAE,uCAAuC,GAAG,YAAY,GAAG,IAAI,CAsB/D;AA+CD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,gCAAgC,CAAC,EAC/C,OAAO,EACP,SAAS,GACV,EAAE,qCAAqC,GAAG,YAAY,GAAG,IAAI,CAe7D"}