@smileid/web-components 10.0.5 → 11.0.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 (31) hide show
  1. package/README.md +15 -15
  2. package/dist/esm/{DocumentCaptureScreens-BIJUlWLB.js → DocumentCaptureScreens-RECPb0wH.js} +3 -3
  3. package/dist/esm/{DocumentCaptureScreens-BIJUlWLB.js.map → DocumentCaptureScreens-RECPb0wH.js.map} +1 -1
  4. package/dist/esm/EndUserConsent-D4fd1ovG.js.map +1 -1
  5. package/dist/esm/Navigation-CTjK6tLU.js.map +1 -1
  6. package/dist/esm/PoweredBySmileId-CxbaihMu.js.map +1 -1
  7. package/dist/esm/SelfieCaptureScreens-CqBVGEJk.js +7901 -0
  8. package/dist/esm/SelfieCaptureScreens-CqBVGEJk.js.map +1 -0
  9. package/dist/esm/SignaturePad-C7MtmT8m.js.map +1 -1
  10. package/dist/esm/TotpConsent-CQU5jQi4.js.map +1 -1
  11. package/dist/esm/combobox.js.map +1 -1
  12. package/dist/esm/document.js +1 -1
  13. package/dist/esm/main.js +2 -2
  14. package/dist/esm/{package-PZvRbm5J.js → package-BDJnoIAU.js} +2 -2
  15. package/dist/esm/{package-PZvRbm5J.js.map → package-BDJnoIAU.js.map} +1 -1
  16. package/dist/esm/selfie.js +1 -1
  17. package/dist/esm/smart-camera-web.js +3 -3
  18. package/dist/esm/smart-camera-web.js.map +1 -1
  19. package/dist/smart-camera-web.js +72 -98
  20. package/dist/smart-camera-web.js.map +1 -1
  21. package/lib/components/document/src/DocumentCaptureScreens.js +1 -0
  22. package/lib/components/selfie/src/SelfieCaptureScreens.js +7 -18
  23. package/lib/components/selfie/src/selfie-capture/SelfieCapture.js +15 -0
  24. package/lib/components/selfie/src/selfie-capture-wrapper/SelfieCaptureWrapper.tsx +19 -2
  25. package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.tsx +2 -20
  26. package/lib/components/selfie/src/smartselfie-capture/components/CaptureControls.tsx +2 -0
  27. package/lib/components/selfie/src/smartselfie-capture/hooks/useFaceCapture.ts +5 -4
  28. package/lib/components/signature-pad/package.json +1 -1
  29. package/package.json +2 -2
  30. package/dist/esm/SelfieCaptureScreens-CnMaKUmP.js +0 -11361
  31. package/dist/esm/SelfieCaptureScreens-CnMaKUmP.js.map +0 -1
@@ -104,6 +104,7 @@ class DocumentCaptureScreens extends HTMLElement {
104
104
 
105
105
  disconnectedCallback() {
106
106
  SmartCamera.stopMedia();
107
+ smartCameraWeb?.dispatchEvent(new CustomEvent('metadata.cleanup'));
107
108
  if (this.activeScreen) {
108
109
  this.activeScreen.removeAttribute('hidden');
109
110
  }
@@ -120,6 +120,7 @@ class SelfieCaptureScreens extends HTMLElement {
120
120
 
121
121
  disconnectedCallback() {
122
122
  SmartCamera.stopMedia();
123
+ smartCameraWeb?.dispatchEvent(new CustomEvent('metadata.cleanup'));
123
124
 
124
125
  if (this._selfieWrapperListeners) {
125
126
  this._selfieWrapperListeners.forEach(({ event, handler }) => {
@@ -140,24 +141,6 @@ class SelfieCaptureScreens extends HTMLElement {
140
141
  'selfie-capture-instructions.capture',
141
142
  async () => {
142
143
  this.setActiveScreen(this.selfieCapture);
143
-
144
- const selfieCapture =
145
- this.selfieCapture.querySelector('selfie-capture');
146
- if (selfieCapture) {
147
- smartCameraWeb?.dispatchEvent(
148
- new CustomEvent('metadata.selfie-capture-start'),
149
- );
150
- smartCameraWeb?.dispatchEvent(
151
- new CustomEvent('metadata.selfie-origin', {
152
- detail: {
153
- imageOrigin: {
154
- environment: 'back_camera',
155
- user: 'front_camera',
156
- }[this.getAgentMode()],
157
- },
158
- }),
159
- );
160
- }
161
144
  },
162
145
  );
163
146
  this.selfieInstruction.addEventListener(
@@ -405,6 +388,9 @@ class SelfieCaptureScreens extends HTMLElement {
405
388
  'show-navigation',
406
389
  'hide-back-to-host',
407
390
  'initial-screen',
391
+ 'allow-agent-mode',
392
+ 'show-agent-mode-for-tests',
393
+ 'disable-image-tests',
408
394
  ];
409
395
  }
410
396
 
@@ -413,6 +399,9 @@ class SelfieCaptureScreens extends HTMLElement {
413
399
  case 'title':
414
400
  case 'hidden':
415
401
  case 'initial-screen':
402
+ case 'allow-agent-mode':
403
+ case 'show-agent-mode-for-tests':
404
+ case 'disable-image-tests':
416
405
  this.connectedCallback();
417
406
  break;
418
407
  default:
@@ -643,6 +643,21 @@ class SelfieCaptureScreen extends HTMLElement {
643
643
  this.switchCamera.disabled = true;
644
644
  }
645
645
 
646
+ const smartCameraWeb = document.querySelector('smart-camera-web');
647
+ smartCameraWeb?.dispatchEvent(
648
+ new CustomEvent('metadata.selfie-capture-start'),
649
+ );
650
+ smartCameraWeb?.dispatchEvent(
651
+ new CustomEvent('metadata.selfie-origin', {
652
+ detail: {
653
+ imageOrigin: {
654
+ environment: 'back_camera',
655
+ user: 'front_camera',
656
+ }[this.inAgentMode ? 'environment' : 'user'],
657
+ },
658
+ }),
659
+ );
660
+
646
661
  /**
647
662
  * this was culled from https://jakearchibald.com/2013/animated-line-drawing-svg/
648
663
  */
@@ -29,16 +29,33 @@ const SelfieCaptureWrapper: FunctionComponent<Props> = ({
29
29
  hidden: hiddenProp = false,
30
30
  ...props
31
31
  }) => {
32
+ const isParentCypress = (() => {
33
+ try {
34
+ return (
35
+ !!(window.parent as any).Cypress ||
36
+ (window.parent.navigator.userAgent.includes('Electron') &&
37
+ (window.parent as any).__Cypress)
38
+ );
39
+ } catch {
40
+ return false;
41
+ }
42
+ })();
43
+ const isCypress =
44
+ isParentCypress ||
45
+ !!(window as any).Cypress ||
46
+ (window.navigator.userAgent.includes('Electron') &&
47
+ (window as any).__Cypress);
48
+
32
49
  const hidden = getBoolProp(hiddenProp);
33
50
  const startCountdown = getBoolProp(startCountdownProp);
34
51
  const [mediapipeReady, setMediapipeReady] = useState(false);
35
- const [loadingProgress, setLoadingProgress] = useState(0);
52
+ const [loadingProgress, setLoadingProgress] = useState(isCypress ? 100 : 0);
36
53
  const [initialSessionCompleted, setInitialSessionCompleted] = useState(false);
37
54
  const [mediapipeLoading, setMediapipeLoading] = useState(false);
38
55
  const [usingSelfieCapture, setUsingSelfieCapture] = useState(false);
39
56
 
40
57
  useEffect(() => {
41
- if (mediapipeReady || mediapipeLoading) return;
58
+ if (mediapipeReady || mediapipeLoading || isCypress) return;
42
59
 
43
60
  const loadMediapipe = async () => {
44
61
  setMediapipeLoading(true);
@@ -2,7 +2,7 @@ import { useRef, useEffect } from 'preact/hooks';
2
2
  import { useSignal } from '@preact/signals';
3
3
  import register from 'preact-custom-element';
4
4
  import type { FunctionComponent } from 'preact';
5
- import { throttle } from 'lodash';
5
+ import throttle from 'lodash/throttle';
6
6
 
7
7
  import { getBoolProp } from '../../../../utils/props';
8
8
  import { useFaceCapture, useCamera } from './hooks';
@@ -149,24 +149,6 @@ const SmartSelfieCapture: FunctionComponent<Props> = ({
149
149
  }
150
150
  }, [faceCapture.hasFinishedCapture.value]);
151
151
 
152
- const handleStartCapture = () => {
153
- faceCapture.startCapture();
154
- const smartCameraWeb = document.querySelector('smart-camera-web');
155
- smartCameraWeb?.dispatchEvent(
156
- new CustomEvent('metadata.selfie-capture-start'),
157
- );
158
- smartCameraWeb?.dispatchEvent(
159
- new CustomEvent('metadata.selfie-origin', {
160
- detail: {
161
- imageOrigin: {
162
- environment: 'back_camera',
163
- user: 'front_camera',
164
- }[camera.facingMode],
165
- },
166
- }),
167
- );
168
- };
169
-
170
152
  return (
171
153
  <div className="smartselfie-capture">
172
154
  {showNavigation && (
@@ -201,7 +183,7 @@ const SmartSelfieCapture: FunctionComponent<Props> = ({
201
183
  showAgentModeForTests={showAgentModeForTests}
202
184
  facingMode={camera.facingMode}
203
185
  themeColor={themeColor}
204
- onStartCapture={handleStartCapture}
186
+ onStartCapture={faceCapture.startCapture}
205
187
  onSwitchCamera={camera.switchCamera}
206
188
  />
207
189
  )}
@@ -28,6 +28,7 @@ export const CaptureControls: FunctionComponent<CaptureControlsProps> = ({
28
28
  <>
29
29
  <div className="controls">
30
30
  <button
31
+ id="start-image-capture"
31
32
  class="btn-primary"
32
33
  onClick={onStartCapture}
33
34
  disabled={isCapturing || hasFinishedCapture || !isReadyToCapture}
@@ -37,6 +38,7 @@ export const CaptureControls: FunctionComponent<CaptureControlsProps> = ({
37
38
 
38
39
  {allowAgentMode && (agentSupported || showAgentModeForTests) && (
39
40
  <button
41
+ id="switch-camera"
40
42
  onClick={onSwitchCamera}
41
43
  className="agent-mode-btn"
42
44
  disabled={isCapturing || hasFinishedCapture}
@@ -1,7 +1,8 @@
1
1
  import { useRef } from 'preact/hooks';
2
2
  import { useSignal, useComputed } from '@preact/signals';
3
+ import type { RefObject } from 'preact';
3
4
  import { FaceLandmarker } from '@mediapipe/tasks-vision';
4
- import { throttle } from 'lodash';
5
+ import throttle from 'lodash/throttle';
5
6
  import {
6
7
  calculateFaceSize,
7
8
  isFaceInBounds,
@@ -21,8 +22,8 @@ import packageJson from '../../../../../../package.json';
21
22
  const COMPONENTS_VERSION = packageJson.version;
22
23
 
23
24
  interface UseFaceCaptureProps {
24
- videoRef: React.RefObject<HTMLVideoElement>;
25
- canvasRef: React.RefObject<HTMLCanvasElement>;
25
+ videoRef: RefObject<HTMLVideoElement>;
26
+ canvasRef: RefObject<HTMLCanvasElement>;
26
27
  interval: number;
27
28
  duration: number;
28
29
  smileThreshold: number;
@@ -96,7 +97,7 @@ export const useFaceCapture = ({
96
97
  const updateAlert = useRef(
97
98
  throttle((messageKey: MessageKey | null) => {
98
99
  updateAlertImmediate(messageKey);
99
- }, 300),
100
+ }, 600),
100
101
  ).current;
101
102
 
102
103
  const initializeFaceLandmarker = async () => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smileid/signature-pad",
3
- "version": "10.0.5",
3
+ "version": "11.0.0",
4
4
  "private": "true",
5
5
  "exports": {
6
6
  ".": "./index.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smileid/web-components",
3
- "version": "10.0.5",
3
+ "version": "11.0.0",
4
4
  "private": false,
5
5
  "main": "dist/esm/main.js",
6
6
  "module": "dist/esm/main.js",
@@ -105,7 +105,7 @@
105
105
  "prettier": "^3.6.2",
106
106
  "rollup-plugin-visualizer": "^6.0.3",
107
107
  "typescript": "^5.8.3",
108
- "vite": "^7.0.1",
108
+ "vite": "^7.1.5",
109
109
  "vite-plugin-dts": "^4.5.4",
110
110
  "vite-plugin-tsconfig-paths": "^1.4.1"
111
111
  }