@simprints/simface-sdk 0.11.1 → 0.12.1
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/components/simface-capture.js +26 -24
- package/dist/components/simface-capture.js.map +1 -1
- package/dist/simface-sdk.js +146 -144
- package/dist/simface-sdk.umd.cjs +26 -24
- package/package.json +1 -1
package/dist/simface-sdk.umd.cjs
CHANGED
|
@@ -108,7 +108,8 @@
|
|
|
108
108
|
`}async beginCapture(){if(!this.active||this.captureState==="starting"||this.captureState==="live")return;this.stopSession(),this.resetState(),this.captureState="starting",this.feedbackMessage="Requesting camera access...",this.feedbackTone="neutral";const t=wc({capturePreference:this.capturePreference,allowMediaPickerFallback:this.allowMediaPickerFallback},this);t.label=this.label,t.idleFeedbackLabel=this.idleFeedbackLabel,t.confirmLabel=this.confirmLabel,t.captureLabel=this.captureLabel,t.retakeLabel=this.retakeLabel,t.retryLabel=this.retryLabel;const r=await Vu({capturePreference:t.capturePreference}),s=Gu(t,r),n=s.steps.find(a=>a==="auto-camera"||a==="manual-camera")??null,i=s.steps.includes("media-picker");if(!n){await this.startMediaPicker();return}try{this.stream=await zu()}catch(a){if(a instanceof Vn&&i){await this.startMediaPicker();return}this.handleCaptureError(a);return}if(await this.updateComplete,!this.active){this.stopSession();return}const o=this.embeddedVideoElement;if(!o||!this.stream){this.handleCaptureError(new Error("Inline camera preview could not be created."));return}o.srcObject=this.stream,this.currentCaptureStep=n,this.sessionController=new F2({videoElement:o,initialMode:n==="auto-camera"?"auto":"manual",copy:{autoReadyMessage:"Center your face in the oval. We will capture automatically when framing looks good.",manualReadyMessage:"When you are ready, press Take photo.",autoUnavailableMessage:"Automatic capture is unavailable. Press Take photo instead.",retakeReadyMessage:"When you are ready, press Take photo."},onStateChange:a=>this.applySessionState(a)});try{await this.sessionController.start()}catch(a){this.handleCaptureError(a)}}async startMediaPicker(){this.stopSession(),this.currentCaptureStep="media-picker",this.captureState="starting",this.feedbackMessage="Opening media picker...",this.feedbackTone="neutral";try{const t=await Ac();if(!t){this.handleCancel();return}await this.showPickedPreview(t)}catch(t){this.handleCaptureError(t)}}applySessionState(t){if(this.captureState=t.phase,this.feedbackMessage=t.feedbackMessage,this.feedbackTone=t.feedbackTone,this.syncProgress(t.countdownProgress),this.qualityResult=t.qualityResult,this.errorMessage=t.phase==="error"?t.errorMessage:"",this.canTakePhoto=t.canTakePhoto,this.captureMode=t.mode,t.phase==="preview"){this.capturedBlob=t.previewBlob,this.setPreviewBlob(t.previewBlob);return}this.capturedBlob=null,this.clearPreviewUrl()}async showPickedPreview(t){const r=await this.assessPickedBlob(t);this.capturedBlob=t,this.qualityResult=r,this.captureState="preview",this.feedbackMessage=(r==null?void 0:r.message)??"Review this capture before continuing.",this.feedbackTone=r?r.passesQualityChecks?"success":"error":"neutral",this.syncProgress(r?1:0),this.setPreviewBlob(t)}handleManualCapture(){var t;(t=this.sessionController)==null||t.takePhotoNow().catch(r=>{this.handleCaptureError(r)})}handleRetake(){var t;if(this.capturedBlob=null,this.qualityResult=null,this.clearPreviewUrl(),this.currentCaptureStep==="media-picker"){this.active&&this.beginCapture();return}(t=this.sessionController)==null||t.retake().catch(r=>{this.handleCaptureError(r)})}handleConfirm(){if(!this.capturedBlob)return;const t=this.capturedBlob;this.active=!1,this.stopSession(),this.resetState(),this.dispatchCaptured(t)}handleCancel(){this.active=!1,this.stopSession(),this.resetState(),this.dispatchCancelled()}handleCaptureError(t){this.stopSession(),this.errorMessage=t instanceof Error?t.message:"Capture failed",this.captureState="error",this.feedbackMessage=this.errorMessage,this.feedbackTone="error",this.dispatchError(this.errorMessage)}endCapture(){this.stopSession(),this.resetState()}stopSession(){var r;(r=this.sessionController)==null||r.stop(),this.sessionController=null,this.currentCaptureStep=null,this.stream&&(this.stream.getTracks().forEach(s=>s.stop()),this.stream=null);const t=this.embeddedVideoElement;t&&(t.srcObject=null),this.syncProgress(0)}resetState(){this.clearPreviewUrl(),this.captureState="idle",this.errorMessage="",this.feedbackMessage=this.idleFeedbackLabel,this.feedbackTone="neutral",this.syncProgress(0),this.qualityResult=null,this.capturedBlob=null,this.captureMode="auto"}syncProgress(t){this.style.setProperty("--capture-progress",String(t))}setPreviewBlob(t){this.clearPreviewUrl(),this.previewUrl=URL.createObjectURL(t)}clearPreviewUrl(){this.previewUrl&&(URL.revokeObjectURL(this.previewUrl),this.previewUrl="")}dispatchCaptured(t){this.dispatchEvent(new CustomEvent("simface-captured",{detail:{imageBlob:t},bubbles:!0,composed:!0}))}dispatchCancelled(){this.dispatchEvent(new CustomEvent("simface-cancelled",{bubbles:!0,composed:!0}))}dispatchError(t){this.dispatchEvent(new CustomEvent("simface-error",{detail:{error:t},bubbles:!0,composed:!0}))}feedbackClass(){return this.feedbackTone==="success"?"quality-good":this.feedbackTone==="error"?"quality-bad":this.feedbackTone==="manual"?"quality-manual":"quality-neutral"}async assessPickedBlob(t){try{const r=await Gn(t);return await Dn(r)}catch{return null}}},_.SimFaceCapture.styles=s2`
|
|
109
109
|
:host {
|
|
110
110
|
display: block;
|
|
111
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
111
|
+
font-family: 'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
112
|
+
color: #212529;
|
|
112
113
|
max-width: 400px;
|
|
113
114
|
margin: 0 auto;
|
|
114
115
|
text-align: center;
|
|
@@ -123,9 +124,9 @@
|
|
|
123
124
|
.container {
|
|
124
125
|
position: relative;
|
|
125
126
|
padding: 16px;
|
|
126
|
-
border: 1px solid #
|
|
127
|
+
border: 1px solid #E0E0E0;
|
|
127
128
|
border-radius: 16px;
|
|
128
|
-
background: #
|
|
129
|
+
background: #F6F6F6;
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
.close-btn {
|
|
@@ -142,7 +143,7 @@
|
|
|
142
143
|
border: none;
|
|
143
144
|
border-radius: 50%;
|
|
144
145
|
background: rgba(0, 0, 0, 0.06);
|
|
145
|
-
color: #
|
|
146
|
+
color: #5D5E5E;
|
|
146
147
|
cursor: pointer;
|
|
147
148
|
transition: background-color 0.15s;
|
|
148
149
|
}
|
|
@@ -165,7 +166,7 @@
|
|
|
165
166
|
|
|
166
167
|
.capture-copy {
|
|
167
168
|
margin: 0;
|
|
168
|
-
color: #
|
|
169
|
+
color: #5D5E5E;
|
|
169
170
|
text-align: center;
|
|
170
171
|
width: 100%;
|
|
171
172
|
}
|
|
@@ -177,8 +178,8 @@
|
|
|
177
178
|
aspect-ratio: 3 / 4;
|
|
178
179
|
border-radius: 22px;
|
|
179
180
|
background:
|
|
180
|
-
radial-gradient(circle at top, rgba(
|
|
181
|
-
linear-gradient(180deg, #
|
|
181
|
+
radial-gradient(circle at top, rgba(0, 179, 209, 0.16), transparent 30%),
|
|
182
|
+
linear-gradient(180deg, #1a1a1a, #0d0d0d);
|
|
182
183
|
box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
|
|
183
184
|
}
|
|
184
185
|
|
|
@@ -210,7 +211,7 @@
|
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
.guide-mask {
|
|
213
|
-
fill: rgba(
|
|
214
|
+
fill: rgba(42, 42, 42, 0.75);
|
|
214
215
|
fill-rule: evenodd;
|
|
215
216
|
}
|
|
216
217
|
|
|
@@ -224,7 +225,7 @@
|
|
|
224
225
|
|
|
225
226
|
.ring-progress {
|
|
226
227
|
fill: none;
|
|
227
|
-
stroke: #
|
|
228
|
+
stroke: #00B3D1;
|
|
228
229
|
stroke-width: 2.8;
|
|
229
230
|
stroke-linecap: round;
|
|
230
231
|
stroke-linejoin: round;
|
|
@@ -248,24 +249,25 @@
|
|
|
248
249
|
border: none;
|
|
249
250
|
border-radius: 100px;
|
|
250
251
|
font-size: 15px;
|
|
251
|
-
font-weight:
|
|
252
|
-
letter-spacing: 0.
|
|
252
|
+
font-weight: 700;
|
|
253
|
+
letter-spacing: 0.04em;
|
|
254
|
+
text-transform: var(--simface-button-text-transform, uppercase);
|
|
253
255
|
cursor: pointer;
|
|
254
256
|
transition: background-color 0.15s, box-shadow 0.15s;
|
|
255
257
|
}
|
|
256
258
|
|
|
257
259
|
.btn-primary {
|
|
258
|
-
background: #
|
|
260
|
+
background: #00B3D1;
|
|
259
261
|
color: white;
|
|
260
262
|
}
|
|
261
263
|
|
|
262
264
|
.btn-primary:hover {
|
|
263
|
-
background: #
|
|
264
|
-
box-shadow: 0 1px 3px rgba(
|
|
265
|
+
background: #009DB8;
|
|
266
|
+
box-shadow: 0 1px 3px rgba(0, 179, 209, 0.3);
|
|
265
267
|
}
|
|
266
268
|
|
|
267
269
|
.btn-primary:disabled {
|
|
268
|
-
background: #
|
|
270
|
+
background: #80D9E8;
|
|
269
271
|
cursor: not-allowed;
|
|
270
272
|
box-shadow: none;
|
|
271
273
|
}
|
|
@@ -291,12 +293,12 @@
|
|
|
291
293
|
}
|
|
292
294
|
|
|
293
295
|
.btn-secondary {
|
|
294
|
-
background: #
|
|
295
|
-
color: #
|
|
296
|
+
background: #E0E0E0;
|
|
297
|
+
color: #212529;
|
|
296
298
|
}
|
|
297
299
|
|
|
298
300
|
.btn-secondary:hover {
|
|
299
|
-
background: #
|
|
301
|
+
background: #D0D0D0;
|
|
300
302
|
}
|
|
301
303
|
|
|
302
304
|
.quality-msg {
|
|
@@ -323,21 +325,21 @@
|
|
|
323
325
|
}
|
|
324
326
|
|
|
325
327
|
.quality-neutral {
|
|
326
|
-
background: #
|
|
327
|
-
color: #
|
|
328
|
+
background: #E0E0E0;
|
|
329
|
+
color: #212529;
|
|
328
330
|
}
|
|
329
331
|
|
|
330
332
|
.quality-manual {
|
|
331
|
-
background: #
|
|
332
|
-
color: #
|
|
333
|
+
background: #E0F7FB;
|
|
334
|
+
color: #212529;
|
|
333
335
|
}
|
|
334
336
|
|
|
335
337
|
.spinner {
|
|
336
338
|
display: inline-block;
|
|
337
339
|
width: 24px;
|
|
338
340
|
height: 24px;
|
|
339
|
-
border: 3px solid #
|
|
340
|
-
border-top: 3px solid #
|
|
341
|
+
border: 3px solid #E0E0E0;
|
|
342
|
+
border-top: 3px solid #00B3D1;
|
|
341
343
|
border-radius: 50%;
|
|
342
344
|
animation: spin 0.8s linear infinite;
|
|
343
345
|
margin: 12px auto;
|