@smileid/web-components 11.4.2 → 11.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/{DocumentCaptureScreens-zEVFc_Kr.js → DocumentCaptureScreens-D1oMAv4n.js} +4 -4
- package/dist/esm/{DocumentCaptureScreens-zEVFc_Kr.js.map → DocumentCaptureScreens-D1oMAv4n.js.map} +1 -1
- package/dist/esm/{EndUserConsent-BXvS7t8z.js → EndUserConsent-D26UoVk5.js} +3 -3
- package/dist/esm/{EndUserConsent-BXvS7t8z.js.map → EndUserConsent-D26UoVk5.js.map} +1 -1
- package/dist/esm/{Navigation-BRFmg7s1.js → Navigation-nvehze1F.js} +2 -2
- package/dist/esm/{Navigation-BRFmg7s1.js.map → Navigation-nvehze1F.js.map} +1 -1
- package/dist/esm/{SelfieCaptureScreens-DsFp21uW.js → SelfieCaptureScreens-CC-y0CpT.js} +1140 -1110
- package/dist/esm/SelfieCaptureScreens-CC-y0CpT.js.map +1 -0
- package/dist/esm/{TotpConsent-Cn2DkVza.js → TotpConsent-owUOdKzP.js} +2 -2
- package/dist/esm/{TotpConsent-Cn2DkVza.js.map → TotpConsent-owUOdKzP.js.map} +1 -1
- package/dist/esm/combobox.js +1 -1
- package/dist/esm/document.js +1 -1
- package/dist/esm/end-user-consent.js +1 -1
- package/dist/esm/{index-DBUdxnp9.js → index-5Nn2kzHI.js} +4 -4
- package/dist/esm/{index-DBUdxnp9.js.map → index-5Nn2kzHI.js.map} +1 -1
- package/dist/esm/localisation.js +1 -1
- package/dist/esm/main.js +6 -6
- package/dist/esm/navigation.js +1 -1
- package/dist/esm/{package-Do9oHVnx.js → package-BxstV9r_.js} +3 -3
- package/dist/esm/{package-Do9oHVnx.js.map → package-BxstV9r_.js.map} +1 -1
- package/dist/esm/selfie.js +1 -1
- package/dist/esm/smart-camera-web.js +5 -5
- package/dist/esm/totp-consent.js +1 -1
- package/dist/smart-camera-web.js +43 -34
- package/dist/smart-camera-web.js.map +1 -1
- package/dist/types/main.d.ts +4 -4
- package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.tsx +72 -39
- package/lib/components/selfie/src/smartselfie-capture/hooks/useCamera.ts +12 -0
- package/lib/components/signature-pad/package.json +1 -1
- package/package.json +10 -1
- package/dist/esm/SelfieCaptureScreens-DsFp21uW.js.map +0 -1
package/dist/types/main.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ declare class ComboboxRoot extends HTMLElement {
|
|
|
38
38
|
declare class ComboboxTrigger extends HTMLElement {
|
|
39
39
|
handleKeyUp(event: any): void;
|
|
40
40
|
handleKeyDown(event: any): void;
|
|
41
|
+
handleInput(event: any): void;
|
|
42
|
+
handleChange(event: any): void;
|
|
41
43
|
handleSelection(event: any): void;
|
|
42
44
|
toggleExpansionState(): void;
|
|
43
45
|
get type(): string;
|
|
@@ -87,14 +89,13 @@ export declare class DocumentCaptureScreens extends HTMLElement {
|
|
|
87
89
|
setUpEventListeners(): void;
|
|
88
90
|
_publishSelectedImages(): void;
|
|
89
91
|
get hideInstructions(): boolean;
|
|
90
|
-
get autoCapture(): boolean;
|
|
91
|
-
get autoCaptureMode(): string;
|
|
92
92
|
get hideBackOfId(): boolean;
|
|
93
93
|
get showNavigation(): "" | "show-navigation";
|
|
94
94
|
get title(): string;
|
|
95
95
|
get documentCaptureModes(): string;
|
|
96
96
|
get documentType(): string;
|
|
97
97
|
get hideAttribution(): "" | "hide-attribution";
|
|
98
|
+
get newInstructions(): boolean;
|
|
98
99
|
get themeColor(): string;
|
|
99
100
|
handleBackEvents(): void;
|
|
100
101
|
handleCloseEvents(): void;
|
|
@@ -330,14 +331,13 @@ export declare class SmartCameraWeb extends HTMLElement {
|
|
|
330
331
|
get isPortraitCaptureView(): boolean;
|
|
331
332
|
get hideInstructions(): "" | "hide-instructions";
|
|
332
333
|
get hideBackOfId(): "" | "hide-back-of-id";
|
|
334
|
+
get newInstructions(): "" | "new-instructions";
|
|
333
335
|
get showNavigation(): "" | "show-navigation";
|
|
334
336
|
get hideBackToHost(): "" | "hide-back";
|
|
335
337
|
get allowAgentMode(): string;
|
|
336
338
|
get allowAgentModeTests(): "" | "show-agent-mode-for-tests";
|
|
337
339
|
get title(): string;
|
|
338
340
|
get documentCaptureModes(): string;
|
|
339
|
-
get autoCapture(): string;
|
|
340
|
-
get autoCaptureMode(): string;
|
|
341
341
|
get disableImageTests(): "" | "disable-image-tests";
|
|
342
342
|
get allowLegacySelfieFallback(): string;
|
|
343
343
|
get hideAttribution(): "" | "hide-attribution";
|
|
@@ -3,6 +3,7 @@ import register from 'preact-custom-element';
|
|
|
3
3
|
import type { FunctionComponent } from 'preact';
|
|
4
4
|
|
|
5
5
|
import { getBoolProp } from '../../../../utils/props';
|
|
6
|
+
import { translate } from '../../../../domain/localisation';
|
|
6
7
|
import { useFaceCapture, useCamera } from './hooks';
|
|
7
8
|
import { CameraPreview } from './components/CameraPreview';
|
|
8
9
|
import { AlertDisplay } from './components/AlertDisplay';
|
|
@@ -61,8 +62,8 @@ const SmartSelfieCapture: FunctionComponent<Props> = ({
|
|
|
61
62
|
getFacingMode: () => camera.facingMode,
|
|
62
63
|
});
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const initializeCamera = async () => {
|
|
66
|
+
try {
|
|
66
67
|
await camera.startCamera(initialFacingMode, (cameraName) => {
|
|
67
68
|
const smartCameraWeb = document.querySelector('smart-camera-web');
|
|
68
69
|
smartCameraWeb?.dispatchEvent(
|
|
@@ -71,15 +72,20 @@ const SmartSelfieCapture: FunctionComponent<Props> = ({
|
|
|
71
72
|
}),
|
|
72
73
|
);
|
|
73
74
|
});
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
} catch {
|
|
76
|
+
// startCamera already set cameraError; surface UI and skip downstream init
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
await camera.checkAgentSupport();
|
|
80
|
+
await faceCapture.initializeFaceLandmarker();
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
faceCapture.setupCanvas();
|
|
84
|
+
faceCapture.startDetectionLoop();
|
|
85
|
+
}, 500);
|
|
86
|
+
};
|
|
82
87
|
|
|
88
|
+
useEffect(() => {
|
|
83
89
|
camera.registerCameraSwitchCallback(() => {
|
|
84
90
|
try {
|
|
85
91
|
faceCapture.resetFaceDetectionState();
|
|
@@ -142,39 +148,57 @@ const SmartSelfieCapture: FunctionComponent<Props> = ({
|
|
|
142
148
|
<smileid-navigation ref={navigationRef} theme-color={themeColor} />
|
|
143
149
|
)}
|
|
144
150
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
isCapturing={faceCapture.isCapturing.value}
|
|
164
|
-
hasFinishedCapture={faceCapture.hasFinishedCapture.value}
|
|
165
|
-
isReadyToCapture={faceCapture.isReadyToCapture.value}
|
|
166
|
-
captureButtonFallbackEnabled={
|
|
167
|
-
faceCapture.captureButtonFallbackEnabled.value
|
|
168
|
-
}
|
|
169
|
-
allowAgentMode={allowAgentMode}
|
|
170
|
-
agentSupported={camera.agentSupported}
|
|
171
|
-
showAgentModeForTests={showAgentModeForTests}
|
|
151
|
+
{camera.cameraError ? (
|
|
152
|
+
<div className="camera-error" role="alert">
|
|
153
|
+
<p>{camera.cameraError}</p>
|
|
154
|
+
<button
|
|
155
|
+
type="button"
|
|
156
|
+
className="btn-primary"
|
|
157
|
+
onClick={() => {
|
|
158
|
+
initializeCamera();
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
{translate('camera.error.retry')}
|
|
162
|
+
</button>
|
|
163
|
+
</div>
|
|
164
|
+
) : (
|
|
165
|
+
<>
|
|
166
|
+
<CameraPreview
|
|
167
|
+
videoRef={camera.videoRef}
|
|
168
|
+
canvasRef={canvasRef}
|
|
172
169
|
facingMode={camera.facingMode}
|
|
170
|
+
progress={
|
|
171
|
+
faceCapture.capturesTaken.value > 0
|
|
172
|
+
? faceCapture.capturesTaken.value /
|
|
173
|
+
faceCapture.totalCaptures.value
|
|
174
|
+
: 0
|
|
175
|
+
}
|
|
176
|
+
interval={interval}
|
|
173
177
|
themeColor={themeColor}
|
|
174
|
-
onStartCapture={faceCapture.startCapture}
|
|
175
|
-
onSwitchCamera={camera.switchCamera}
|
|
176
178
|
/>
|
|
177
|
-
|
|
179
|
+
|
|
180
|
+
<AlertDisplay alertTitle={faceCapture.alertTitle.value} />
|
|
181
|
+
|
|
182
|
+
{!faceCapture.isCapturing.value &&
|
|
183
|
+
!faceCapture.hasFinishedCapture.value && (
|
|
184
|
+
<CaptureControls
|
|
185
|
+
isCapturing={faceCapture.isCapturing.value}
|
|
186
|
+
hasFinishedCapture={faceCapture.hasFinishedCapture.value}
|
|
187
|
+
isReadyToCapture={faceCapture.isReadyToCapture.value}
|
|
188
|
+
captureButtonFallbackEnabled={
|
|
189
|
+
faceCapture.captureButtonFallbackEnabled.value
|
|
190
|
+
}
|
|
191
|
+
allowAgentMode={allowAgentMode}
|
|
192
|
+
agentSupported={camera.agentSupported}
|
|
193
|
+
showAgentModeForTests={showAgentModeForTests}
|
|
194
|
+
facingMode={camera.facingMode}
|
|
195
|
+
themeColor={themeColor}
|
|
196
|
+
onStartCapture={faceCapture.startCapture}
|
|
197
|
+
onSwitchCamera={camera.switchCamera}
|
|
198
|
+
/>
|
|
199
|
+
)}
|
|
200
|
+
</>
|
|
201
|
+
)}
|
|
178
202
|
|
|
179
203
|
{/* @ts-expect-error -- preact-custom-element doesn't have proper types for refs */}
|
|
180
204
|
{!hideAttribution && <powered-by-smile-id />}
|
|
@@ -227,6 +251,15 @@ const SmartSelfieCapture: FunctionComponent<Props> = ({
|
|
|
227
251
|
padding: 1rem;
|
|
228
252
|
font-family: sans-serif;
|
|
229
253
|
}
|
|
254
|
+
|
|
255
|
+
.camera-error {
|
|
256
|
+
margin-top: 1.5rem;
|
|
257
|
+
padding: 1rem 1.5rem;
|
|
258
|
+
color: #b00020;
|
|
259
|
+
text-align: center;
|
|
260
|
+
font-size: 1rem;
|
|
261
|
+
font-weight: 500;
|
|
262
|
+
}
|
|
230
263
|
`}</style>
|
|
231
264
|
</div>
|
|
232
265
|
);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { useRef, useState, useEffect } from 'preact/hooks';
|
|
2
|
+
import SmartCamera from '../../../../../domain/camera/src/SmartCamera';
|
|
2
3
|
|
|
3
4
|
export const useCamera = (initialFacingMode: CameraFacingMode = 'user') => {
|
|
4
5
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
5
6
|
const streamRef = useRef<MediaStream | null>(null);
|
|
6
7
|
const [facingMode, setFacingMode] = useState(initialFacingMode);
|
|
7
8
|
const [agentSupported, setAgentSupported] = useState(false);
|
|
9
|
+
const [cameraError, setCameraError] = useState<string | null>(null);
|
|
8
10
|
const onCameraSwitchCallbackRef = useRef<(() => void) | null>(null);
|
|
9
11
|
const isSwitchingCameraRef = useRef(false);
|
|
10
12
|
const timeoutIdsRef = useRef<Set<NodeJS.Timeout>>(new Set());
|
|
@@ -63,6 +65,7 @@ export const useCamera = (initialFacingMode: CameraFacingMode = 'user') => {
|
|
|
63
65
|
video: { facingMode: targetFacingMode || facingMode },
|
|
64
66
|
});
|
|
65
67
|
streamRef.current = stream;
|
|
68
|
+
setCameraError(null);
|
|
66
69
|
|
|
67
70
|
const track = stream.getVideoTracks()[0];
|
|
68
71
|
const settings = track.getSettings();
|
|
@@ -94,9 +97,15 @@ export const useCamera = (initialFacingMode: CameraFacingMode = 'user') => {
|
|
|
94
97
|
}
|
|
95
98
|
} catch (error) {
|
|
96
99
|
console.error('Failed to start camera:', error);
|
|
100
|
+
setCameraError(SmartCamera.handleCameraError(error as Error));
|
|
101
|
+
throw error;
|
|
97
102
|
}
|
|
98
103
|
};
|
|
99
104
|
|
|
105
|
+
const retryCamera = async () => {
|
|
106
|
+
await startCamera(facingMode);
|
|
107
|
+
};
|
|
108
|
+
|
|
100
109
|
const switchCamera = async () => {
|
|
101
110
|
const newFacingMode = facingMode === 'user' ? 'environment' : 'user';
|
|
102
111
|
isSwitchingCameraRef.current = true;
|
|
@@ -118,6 +127,7 @@ export const useCamera = (initialFacingMode: CameraFacingMode = 'user') => {
|
|
|
118
127
|
await startCamera(previousFacingMode);
|
|
119
128
|
} catch (restoreError) {
|
|
120
129
|
console.error('Failed to restore previous camera:', restoreError);
|
|
130
|
+
setCameraError(SmartCamera.handleCameraError(restoreError as Error));
|
|
121
131
|
}
|
|
122
132
|
}
|
|
123
133
|
};
|
|
@@ -229,7 +239,9 @@ export const useCamera = (initialFacingMode: CameraFacingMode = 'user') => {
|
|
|
229
239
|
streamRef,
|
|
230
240
|
facingMode,
|
|
231
241
|
agentSupported,
|
|
242
|
+
cameraError,
|
|
232
243
|
startCamera,
|
|
244
|
+
retryCamera,
|
|
233
245
|
switchCamera,
|
|
234
246
|
checkAgentSupport,
|
|
235
247
|
stopCamera,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smileid/web-components",
|
|
3
|
-
"version": "11.4.
|
|
3
|
+
"version": "11.4.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/esm/main.js",
|
|
6
6
|
"module": "dist/esm/main.js",
|
|
@@ -76,6 +76,15 @@
|
|
|
76
76
|
],
|
|
77
77
|
"type": "module",
|
|
78
78
|
"author": "SmileID <support@usesmileid.com> (https://usesmileid.com)",
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "git+https://github.com/smileidentity/web-client.git",
|
|
82
|
+
"directory": "packages/web-components"
|
|
83
|
+
},
|
|
84
|
+
"bugs": {
|
|
85
|
+
"url": "https://github.com/smileidentity/web-client/issues"
|
|
86
|
+
},
|
|
87
|
+
"homepage": "https://github.com/smileidentity/web-client#readme",
|
|
79
88
|
"dependencies": {
|
|
80
89
|
"@lottiefiles/dotlottie-web": "^0.71.0",
|
|
81
90
|
"@mediapipe/tasks-vision": "^0.10.22-rc.20250304",
|