@incodetech/core 2.2.0 → 2.3.0-rc.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.
- package/THIRD_PARTY_NOTICES.txt +281 -0
- package/dist/BaseWasmProvider-Dyi6dKp1.d.ts +65 -0
- package/dist/{BrowserDiagnosticsCryptoProvider-B8vorxN5.esm.js → BrowserDiagnosticsCryptoProvider-C_9o3L2L.esm.js} +1 -1
- package/dist/{BrowserVisibilityObserverProvider-BX1BiLDK.esm.js → BrowserVisibilityObserverProvider-BrJN1B8A.esm.js} +2 -0
- package/dist/FaceDetectionProvider-DTetAE8H.esm.js +476 -0
- package/dist/FaceDetectionProvider-LdZ47bWy.d.ts +36 -0
- package/dist/{IIdCaptureCapability-DHTT3FC2.d.ts → IIdCaptureCapability-RNiFhvXR.d.ts} +7 -33
- package/dist/IWasmUtilCapability-CXXDA5l1.d.ts +159 -0
- package/dist/{MotionSensorProvider-DGiV77J_.esm.js → MotionSensorProvider-BgTYwg9L.esm.js} +1 -1
- package/dist/{deepsightService-DLVQS_RH.d.ts → StreamCanvasCapture-B3YT2Bt6.d.ts} +54 -41
- package/dist/{StreamCanvasCapture-D2XcXCZ4.esm.js → StreamCanvasCapture-C9jtgBdT.esm.js} +2 -2
- package/dist/{addressSearch-D1XpBdUS.esm.js → addressSearch-BRSu_aGA.esm.js} +1 -1
- package/dist/advanceableErrors-CpF2cBy6.esm.js +21 -0
- package/dist/ae-signature.d.ts +4 -2
- package/dist/ae-signature.esm.js +1 -1
- package/dist/antifraud.esm.js +2 -2
- package/dist/{antifraudManager-CQFNgSPt.esm.js → antifraudManager-Bg9ynGum.esm.js} +2 -2
- package/dist/{antifraudStateMachine-Bf_JVNwn.esm.js → antifraudStateMachine-BHxehiJZ.esm.js} +1 -1
- package/dist/{apiError-BA1d_au0.esm.js → apiError-D0v5hFyN.esm.js} +14 -2
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.esm.js +2 -2
- package/dist/{authenticationManager-zh9TC62P.esm.js → authenticationManager-C4B4-29g.esm.js} +5 -5
- package/dist/{authenticationManager-BBMGTcwW.d.ts → authenticationManager-DXTIUcma.d.ts} +7 -1
- package/dist/{authenticationStateMachine-xzi-vnvE.esm.js → authenticationStateMachine-DJ0zUm-A.esm.js} +6 -62
- package/dist/avatar.d.ts +1 -2
- package/dist/avatar.esm.js +1 -1
- package/dist/{backCameraStream-CUeYm5eu.esm.js → backCameraStream-BOtyQowf.esm.js} +83 -22
- package/dist/{camera-_2sXMXiF.esm.js → camera-sIa9ceW2.esm.js} +19 -1
- package/dist/camera.esm.js +1 -1
- package/dist/{canvas-E1zGkel4.esm.js → canvas-BxFzWTt-.esm.js} +19 -0
- package/dist/certificate-issuance.d.ts +2 -302
- package/dist/certificate-issuance.esm.js +3 -66
- package/dist/certificateIssuanceManager-Bfvkq7Cy.esm.js +69 -0
- package/dist/certificateIssuanceManager-DCgEidHz.d.ts +312 -0
- package/dist/{certificateIssuanceStateMachine-D_R92TYu.esm.js → certificateIssuanceStateMachine-BBD5h8c4.esm.js} +1 -1
- package/dist/consent.d.ts +1 -1
- package/dist/consent.esm.js +2 -2
- package/dist/{consentManager-BxjpLZAG.esm.js → consentManager-B5Vqdez-.esm.js} +2 -2
- package/dist/{consentManager-3Pbtj-RV.d.ts → consentManager-uhDPdU6i.d.ts} +4 -4
- package/dist/{consentStateMachine-D9D4ON8Z.esm.js → consentStateMachine-DbUmqWgV.esm.js} +1 -1
- package/dist/createCameraCycleOwnership-DQ5-F2oW.esm.js +826 -0
- package/dist/{createFaceAvatar-DQKaRise.esm.js → createFaceAvatar-BNHdeFj8.esm.js} +2 -2
- package/dist/createFaceAvatar-BlcTYgJv.d.ts +497 -0
- package/dist/cross-document-data-match.esm.js +1 -1
- package/dist/{crossDocumentDataMatchManager-CGT0V6RV.esm.js → crossDocumentDataMatchManager-QMOGwHXR.esm.js} +2 -2
- package/dist/curp-validation.d.ts +1 -1
- package/dist/curp-validation.esm.js +2 -2
- package/dist/{curpValidationManager-6Nmkn5u1.esm.js → curpValidationManager-D1ppROcF.esm.js} +2 -2
- package/dist/{curpValidationManager-DVGr7Fq7.d.ts → curpValidationManager-SSKNrm5Z.d.ts} +1 -1
- package/dist/{curpValidationStateMachine-Ds7KMacK.esm.js → curpValidationStateMachine-DvUPC_8S.esm.js} +1 -1
- package/dist/custom-fields.d.ts +2 -114
- package/dist/custom-fields.esm.js +2 -232
- package/dist/custom-watchlist.d.ts +2 -51
- package/dist/custom-watchlist.esm.js +3 -70
- package/dist/customFieldsManager-2j_PBq4U.esm.js +264 -0
- package/dist/customFieldsManager-8-W2KY4n.d.ts +141 -0
- package/dist/customWatchlistManager-DUVrEdw9.esm.js +73 -0
- package/dist/customWatchlistManager-PBWHr_oM.d.ts +64 -0
- package/dist/{customWatchlistStateMachine-YWSgKLbF.esm.js → customWatchlistStateMachine-qZVgkKgP.esm.js} +1 -1
- package/dist/{deepsightLoader--wMKWECS.esm.js → deepsightLoader-Dm7ejW4v.esm.js} +27 -71
- package/dist/device.d.ts +25 -2
- package/dist/device.esm.js +69 -7
- package/dist/document-capture.d.ts +2 -2
- package/dist/document-capture.esm.js +2 -2
- package/dist/{documentCaptureManager-DsQQhWry.esm.js → documentCaptureManager-DR_Wv-3H.esm.js} +2 -2
- package/dist/{documentCaptureManager-B3t0ydtg.d.ts → documentCaptureManager-DensIj5F.d.ts} +83 -83
- package/dist/{documentCaptureStateMachine-BM4Ex_5x.esm.js → documentCaptureStateMachine-CWOATHfE.esm.js} +5 -5
- package/dist/dynamic-forms.d.ts +1 -1
- package/dist/dynamic-forms.esm.js +2 -2
- package/dist/{dynamicFormsManager-fhK0yINk.d.ts → dynamicFormsManager-D5R_uxLQ.d.ts} +25 -3
- package/dist/{dynamicFormsManager-fFVIRBNv.esm.js → dynamicFormsManager-Dt98SDfV.esm.js} +16 -5
- package/dist/{dynamicFormsStateMachine-D6D7oEYk.esm.js → dynamicFormsStateMachine-obKr4IIp.esm.js} +35 -3
- package/dist/ekyb.d.ts +1 -1
- package/dist/ekyb.esm.js +3 -3
- package/dist/{ekybManager-Y3MkoXpC.esm.js → ekybManager-DNZKrKF3.esm.js} +2 -2
- package/dist/{ekybStateMachine-3nlnqdlr.esm.js → ekybStateMachine-DjhHQXZ8.esm.js} +3 -3
- package/dist/ekyc.esm.js +2 -2
- package/dist/{ekycManager-DgT48ky6.esm.js → ekycManager-CmQBpeiI.esm.js} +2 -2
- package/dist/{ekycStateMachine-CQwqiR-R.esm.js → ekycStateMachine-CmdW2gVm.esm.js} +2 -2
- package/dist/electronic-signature.d.ts +3 -3
- package/dist/electronic-signature.esm.js +2 -2
- package/dist/electronicSignatureManager-Ds-KEVTq.d.ts +2786 -0
- package/dist/{electronicSignatureManager-DGbAJ00W.esm.js → electronicSignatureManager-DzulxM4_.esm.js} +357 -51
- package/dist/email.esm.js +2 -2
- package/dist/{emailManager-BY0jeYwR.esm.js → emailManager-B5ek_UfM.esm.js} +2 -2
- package/dist/{emailStateMachine-Crw8QVmc.esm.js → emailStateMachine-CyPFZ7dW.esm.js} +1 -1
- package/dist/{endpoints-CCzL3XD_.esm.js → endpoints-D3B9mUHh.esm.js} +24 -7
- package/dist/{events-DYiyoSlx.esm.js → events-ijlbX_Wx.esm.js} +2 -2
- package/dist/events.d.ts +1 -1
- package/dist/events.esm.js +1 -1
- package/dist/extensibility.d.ts +24 -64
- package/dist/extensibility.esm.js +35 -29
- package/dist/face-match.esm.js +2 -2
- package/dist/{faceCaptureManagerFactory-BxWPpxyd.d.ts → faceCaptureManagerFactory-CvtqcLxs.d.ts} +87 -54
- package/dist/{faceCaptureManagerFactory-CVnZ0fa5.esm.js → faceCaptureManagerFactory-pCmG4MeF.esm.js} +68 -7
- package/dist/faceCaptureSetup-BSextack.esm.js +2106 -0
- package/dist/{faceMatchManager-Ri4UbNz0.esm.js → faceMatchManager-Caal2zyV.esm.js} +2 -2
- package/dist/{faceMatchStateMachine-20DdZ3jg.esm.js → faceMatchStateMachine-BUc5FXYy.esm.js} +1 -1
- package/dist/{feature-management-CPQ4qv3F.esm.js → feature-management-B0sGlozZ.esm.js} +32 -7
- package/dist/feature-management.d.ts +1 -1
- package/dist/feature-management.esm.js +1 -1
- package/dist/field-comparison.esm.js +1 -1
- package/dist/{fieldComparisonManager-Cg6kPQQx.esm.js → fieldComparisonManager-BIs6HPJG.esm.js} +2 -2
- package/dist/fiscal-qr.d.ts +2 -56
- package/dist/fiscal-qr.esm.js +2 -308
- package/dist/fiscalQrManager-Bp_-3LJr.esm.js +34131 -0
- package/dist/fiscalQrManager-CHcBJwUM.d.ts +68 -0
- package/dist/flow-events.d.ts +1 -1
- package/dist/flow.d.ts +212 -185
- package/dist/flow.esm.js +119 -30
- package/dist/{flowCompletionService-tfeoGre9.esm.js → flowCompletionService-CLtbWhSK.esm.js} +2 -2
- package/dist/{flowServices-f5Ruz7R9.esm.js → flowServices-B5FwukTQ.esm.js} +91 -26
- package/dist/geolocation.esm.js +2 -2
- package/dist/{geolocationManager-CH6RfqFH.esm.js → geolocationManager-DIw-xq9a.esm.js} +2 -2
- package/dist/{geolocationStateMachine-DmbWFely.esm.js → geolocationStateMachine-DpG0TFOU.esm.js} +3 -3
- package/dist/getBrowser-CBiibsL-.esm.js +19 -0
- package/dist/{getBrowser-DNrQeL4T.esm.js → getBrowser-Cbe1C4Tn.esm.js} +2 -1
- package/dist/{getDeviceClass-9y-kbVDw.esm.js → getDeviceClass-5NYZg9s6.esm.js} +2 -2
- package/dist/getParsedUserAgent-B2iFDql1.esm.js +1278 -0
- package/dist/government-validation.d.ts +2 -85
- package/dist/government-validation.esm.js +3 -120
- package/dist/governmentValidationManager-D02vT4yY.d.ts +63 -0
- package/dist/governmentValidationManager-TjC9iVjH.esm.js +79 -0
- package/dist/governmentValidationStateMachine-D1ZnEqdd.esm.js +54 -0
- package/dist/home.d.ts +1 -1
- package/dist/home.esm.js +1 -1
- package/dist/id-ocr.d.ts +2 -2
- package/dist/id-ocr.esm.js +2 -2
- package/dist/id-selfie-flow.d.ts +3 -2
- package/dist/id-selfie-flow.esm.js +11 -10
- package/dist/id-verification.esm.js +2 -2
- package/dist/id.d.ts +29 -5
- package/dist/id.esm.js +48 -46
- package/dist/idCaptureDefaults-BcxjQDI3.esm.js +484 -0
- package/dist/{idCaptureManager-CqrqSjJV.d.ts → idCaptureManager-CvmHOWWd.d.ts} +227 -39
- package/dist/{idCaptureManager-BYwTZ2H8.esm.js → idCaptureManager-Vby8oYqh.esm.js} +259 -46
- package/dist/{idCaptureServices-44kwQItl.esm.js → idCaptureServices-CJIxD9ep.esm.js} +342 -31
- package/dist/idCaptureStateMachine-CmqihkUy.esm.js +5343 -0
- package/dist/{idOcrManager-DXc_xRN7.d.ts → idOcrManager-BF_cXZq8.d.ts} +1 -1
- package/dist/{idOcrManager-BIQYQXXj.esm.js → idOcrManager-DHU22hVn.esm.js} +2 -2
- package/dist/{idOcrStateMachine-cSxzHpHt.esm.js → idOcrStateMachine-33UvRAHE.esm.js} +1 -1
- package/dist/{idVerificationManager-JpV_SAsl.esm.js → idVerificationManager-CyaixD0D.esm.js} +2 -2
- package/dist/{idVerificationStateMachine-nPeUNyFq.esm.js → idVerificationStateMachine-BPGrQZEm.esm.js} +1 -1
- package/dist/identity-reuse.esm.js +2 -2
- package/dist/{identityReuseManager-kNCg9AbD.esm.js → identityReuseManager-CWaNHBO3.esm.js} +2 -2
- package/dist/{identityReuseStateMachine-DyulxDjP.esm.js → identityReuseStateMachine-CQgnATo5.esm.js} +1 -1
- package/dist/{index-CLMF0QLQ.d.ts → index-DLcJT5YP.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/{invokeOnCaptureCallback-GpvMuz9o.esm.js → invokeOnCaptureCallback-BjzPjJ_p.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +2 -2
- package/dist/mandatory-consent.esm.js +2 -2
- package/dist/{mandatoryConsentManager-DyPzUmsZ.d.ts → mandatoryConsentManager-CJSyhTpi.d.ts} +5 -5
- package/dist/{mandatoryConsentManager-B4Niyg_u.esm.js → mandatoryConsentManager-Du-m-tZ_.esm.js} +2 -2
- package/dist/{mandatoryConsentStateMachine-B4-1u-L8.esm.js → mandatoryConsentStateMachine-DSDAk7WZ.esm.js} +1 -1
- package/dist/multipartRecordingService-B3C_zlev.esm.js +594 -0
- package/dist/{permissionGuards-KINpmKtI.esm.js → permissionGuards-uYZYFu4J.esm.js} +1 -1
- package/dist/{permissionServices-UvUcOSRb.esm.js → permissionServices-Bj_fyWtv.esm.js} +5 -5
- package/dist/personhood.d.ts +6 -5
- package/dist/personhood.esm.js +10 -10
- package/dist/phone.esm.js +2 -2
- package/dist/{phoneManager-FsJ0W2Ei.esm.js → phoneManager-N1-sbrY4.esm.js} +2 -2
- package/dist/{phoneStateMachine-Ba0wKHyX.esm.js → phoneStateMachine-jl8LJKCo.esm.js} +1 -1
- package/dist/{platform-BJrm5nzZ.esm.js → platform-DkcRc9JV.esm.js} +29 -1
- package/dist/qe-signature.d.ts +5 -3
- package/dist/qe-signature.esm.js +2 -2
- package/dist/recordingsRepository-CCWy13M-.esm.js +72 -0
- package/dist/redirect-to-mobile.esm.js +2 -2
- package/dist/{redirectToMobileManager-y4VQB11M.esm.js → redirectToMobileManager-DsFzdTwA.esm.js} +2 -2
- package/dist/{redirectToMobileStateMachine-Cyv2x0PP.esm.js → redirectToMobileStateMachine-v3otpT-L.esm.js} +1 -1
- package/dist/{rolldown-runtime-FZ4Itg2g.esm.js → rolldown-runtime-FDOR9p9I.esm.js} +1 -19
- package/dist/{runChildModule-Dukuw23X.esm.js → runChildModule-TuyGE00X.esm.js} +3 -21
- package/dist/safeStorage-B-trhxg6.esm.js +423 -0
- package/dist/{sdkVersion-D1Bm59g6.esm.js → sdkVersion-CLxKvdyz.esm.js} +1 -1
- package/dist/selfie.d.ts +5 -5
- package/dist/selfie.esm.js +14 -76
- package/dist/{selfieErrorUtils-C2PYBVsp.esm.js → selfieErrorUtils-C77GXJH6.esm.js} +30 -4
- package/dist/{selfieManager-Bj6B2ZVy.esm.js → selfieManager-CihVnODO.esm.js} +5 -5
- package/dist/{selfieManager-DwlCppg0.d.ts → selfieManager-D1KRJ39M.d.ts} +8 -11
- package/dist/selfieStateMachine-fwMmNtOi.esm.js +69 -0
- package/dist/{session-BFdLgN4i.esm.js → session-BHIeAamR.esm.js} +4 -5
- package/dist/session.d.ts +21 -11
- package/dist/session.esm.js +5 -5
- package/dist/{sessionInitializer-dlfDehHk.esm.js → sessionInitializer-BLoK7SP9.esm.js} +187 -68
- package/dist/{setup-BgoWtvIS.d.ts → setup-Cv-JM9QC.d.ts} +63 -69
- package/dist/{setup-BIAtLa8k.esm.js → setup-msLybMbC.esm.js} +226 -100
- package/dist/signature.esm.js +2 -2
- package/dist/{signatureManager-Ca43yhwk.esm.js → signatureManager-ChsB-nMD.esm.js} +2 -2
- package/dist/{signatureStateMachine-K1LMRrxG.esm.js → signatureStateMachine-BHPwkJZS.esm.js} +1 -1
- package/dist/{src-0Jurt29N.esm.js → src-35ekGRzK.esm.js} +1 -1
- package/dist/{stats-B0nFKawG.esm.js → stats-DkK-f8JT.esm.js} +1 -1
- package/dist/stats.esm.js +1 -1
- package/dist/{trueSightService---iW2KKJ.esm.js → trueSightService-CKrrfV0Q.esm.js} +7 -7
- package/dist/trust-graph.esm.js +1 -1
- package/dist/{types-BX_XkMsQ2.d.ts → types-9_esGTPj.d.ts} +1 -1
- package/dist/types-BT_Oalip.d.ts +1 -0
- package/dist/{types-DelMqZLe.d.ts → types-BjSly8cp.d.ts} +1 -1
- package/dist/{types-Hmd7U0JA.d.ts → types-CM-jtjJ2.d.ts} +6 -81
- package/dist/{types-Bdf8_LYB2.d.ts → types-CjKBS37a2.d.ts} +303 -13
- package/dist/{types-DVmXIdzW.d.ts → types-D0gekt4U.d.ts} +38 -5
- package/dist/types-DgDvvzg0.d.ts +10 -0
- package/dist/{types-KPvmag_B.d.ts → types-Do5rEXij.d.ts} +7 -4
- package/dist/types-ZT1XFIJ8.d.ts +6 -0
- package/dist/video-selfie.d.ts +59 -35
- package/dist/video-selfie.esm.js +510 -601
- package/dist/{videoSelfieCameraWarmer-NEhFZvWx.esm.js → videoSelfieCameraWarmer-CB1IzZkt.esm.js} +14 -153
- package/dist/videoSelfieFlowModuleMachine-BUe2uACW.esm.js +32 -0
- package/dist/{videoSelfieStepDetector-D3oo2ofo.d.ts → videoSelfieStepDetector-5YHFe0Mq.d.ts} +21 -5
- package/dist/virtualCameraCheck-WOloJ-do.esm.js +48 -0
- package/dist/warmup-CUUnwYxe.esm.js +714 -0
- package/dist/warmup-Cis2p6O0.d.ts +128 -0
- package/dist/wasm.d.ts +30 -6
- package/dist/wasm.esm.js +36 -4
- package/dist/{wasmDsFlagSync-BqUCwLY8.esm.js → wasmDsFlagSync-B2e8p268.esm.js} +2 -2
- package/dist/{wasmWebClient-DM8lkb0z.esm.js → wasmWebClient-B7baE-Wf.esm.js} +358 -28
- package/dist/watchlist-for-business.d.ts +2 -78
- package/dist/watchlist-for-business.esm.js +3 -102
- package/dist/watchlist.esm.js +2 -2
- package/dist/watchlistForBusinessManager-CpuuB1J2.esm.js +107 -0
- package/dist/watchlistForBusinessManager-CsnJnG-C.d.ts +99 -0
- package/dist/{watchlistForBusinessStateMachine-CxFnlshm.esm.js → watchlistForBusinessStateMachine-DEzgjz7C.esm.js} +13 -6
- package/dist/{watchlistManager-LoNZH9qm.esm.js → watchlistManager-CI8BHFob.esm.js} +2 -2
- package/dist/{watchlistStateMachine-DIKQDoUT.esm.js → watchlistStateMachine-DvOby3a-.esm.js} +1 -1
- package/dist/workflow.d.ts +12 -8
- package/dist/workflow.esm.js +48 -39
- package/package.json +4 -10
- package/dist/BrowserStorageProvider-k-FDkC4W.esm.js +0 -67
- package/dist/FaceDetectionProvider-Mh6q3EbA.d.ts +0 -349
- package/dist/IFaceAvatarCapability-BrL19G0s.d.ts +0 -23
- package/dist/IStorageCapability-ORkQfK3F.d.ts +0 -242
- package/dist/OpenViduRecordingProvider-Du98qevC.esm.js +0 -85
- package/dist/createFaceAvatar-BEj18KXi.d.ts +0 -50
- package/dist/document-upload.d.ts +0 -325
- package/dist/document-upload.esm.js +0 -197
- package/dist/electronicSignatureManager-CcUXQZS7.d.ts +0 -1300
- package/dist/faceCaptureSetup-Cd-04W_X.esm.js +0 -863
- package/dist/getBrowser-Cb8Zgrgp.esm.js +0 -7
- package/dist/getParsedUserAgent-pJjATANs.esm.js +0 -1622
- package/dist/governmentValidationStateMachine-CK9DrZXX.esm.js +0 -226
- package/dist/idCaptureDefaults-WeHbQM7W.esm.js +0 -225
- package/dist/idCaptureStateMachine-kZ5OpdfM.esm.js +0 -3342
- package/dist/lib-DAyUtOTj.esm.js +0 -12420
- package/dist/manualReviewService-D4IkipnN.esm.js +0 -15
- package/dist/mediaRecorderOptions-dALSV8af.esm.js +0 -40
- package/dist/onDeviceFaceResults-CUHwyZT4.esm.js +0 -646
- package/dist/openviduLazy-CCDpFWg1.esm.js +0 -10
- package/dist/recordingService-3NSENVwp.esm.js +0 -329
- package/dist/safeStorage-Ep56I-f_.esm.js +0 -982
- package/dist/selfieStateMachine-CHV_WNst.esm.js +0 -55
- package/dist/trueSight-B_icM8r2.esm.js +0 -1
- package/dist/types-EELWyWpd.d.ts +0 -6
- package/dist/types-Vb4P9ovf.d.ts +0 -22
- package/dist/warmup-Dv2alr2-.d.ts +0 -82
- package/dist/wasmDefaults-DTUrftxR.esm.js +0 -125
- package/dist/{Face2DProvider-UUQt_vRC.esm.js → Face2DProvider-BF48sz5c.esm.js} +1 -1
- package/dist/{PrivacyLensProvider-D8PS7AJa.esm.js → PrivacyLensProvider-EwnC_C5n.esm.js} +1 -1
- /package/dist/{types-BfgmV7s72.d.ts → types-BfgmV7s7.d.ts} +0 -0
- /package/dist/{types-CJ7Yl9K-2.d.ts → types-CJ7Yl9K-.d.ts} +0 -0
|
@@ -1,982 +0,0 @@
|
|
|
1
|
-
import { c as loadWasmModule, l as SemaphoreProvider, n as createWebApiHostAdapter, s as wasmCallWrapper } from "./wasmWebClient-DM8lkb0z.esm.js";
|
|
2
|
-
var mlWasmJSApi_default = class MlWasmJSApi {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.versionsFile = null;
|
|
5
|
-
this.modelsBuffers = null;
|
|
6
|
-
this.inputImageBuffer = null;
|
|
7
|
-
this.wasmModule = null;
|
|
8
|
-
this.workflowApiUtilities = null;
|
|
9
|
-
this.utilityApi = null;
|
|
10
|
-
this.idCaptureWasmApi = null;
|
|
11
|
-
this.faceProcessingWasmApi = null;
|
|
12
|
-
this.webApi = null;
|
|
13
|
-
this.imageWidth_ = null;
|
|
14
|
-
this.imageHeight_ = null;
|
|
15
|
-
this.pipelines_ = null;
|
|
16
|
-
this.isInitialized_ = false;
|
|
17
|
-
this.inspectorOpened_ = false;
|
|
18
|
-
this.onDeviceMode_ = false;
|
|
19
|
-
this.dsEnabled_ = false;
|
|
20
|
-
this.wasmCallSemaphore = new SemaphoreProvider();
|
|
21
|
-
this.Module = null;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Initiallization method, use it when the application starts
|
|
25
|
-
* TODO: this method can return the list of promises to be awaited together with other initialization code
|
|
26
|
-
* @param {string} webLibPath - The path to the webassembly binary
|
|
27
|
-
* @param {string} webLibPathSimd - The path to the SIMD version webassembly binary
|
|
28
|
-
* @param {string} glueCodePath - The path to the non-SIMD glue (`webLib.js`)
|
|
29
|
-
* @param {string} glueCodeSimdPath - The path to the SIMD-paired glue (`webLibSimd.js`); pass `''` to derive from `webLibPathSimd`
|
|
30
|
-
* @param {boolean} useSimd - Indicates whether SIMD optimizations should be used
|
|
31
|
-
* @param {string} versionsFile - The path to the file containing versioning information
|
|
32
|
-
* @param {Map.<WasmPipelineType, Array<string>>} pipelines - pipelines for initialization and corresponding models paths
|
|
33
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether SIMD is enabled once the initialization is complete.
|
|
34
|
-
* @throws {Error} Throws an error if the initialization fails.
|
|
35
|
-
*/
|
|
36
|
-
async initialize(webLibPath, webLibPathSimd, glueCodePath, glueCodeSimdPath, useSimd, versionsFile, pipelines) {
|
|
37
|
-
await this.freeResources();
|
|
38
|
-
this.pipelines_ = pipelines;
|
|
39
|
-
this.versionsFile = versionsFile;
|
|
40
|
-
const { wasmModule, simdUsed } = await loadWasmModule({
|
|
41
|
-
glueCodePath,
|
|
42
|
-
glueCodeSimdPath: glueCodeSimdPath || void 0,
|
|
43
|
-
wasmPath: webLibPath,
|
|
44
|
-
wasmSimdPath: webLibPathSimd,
|
|
45
|
-
useSimd
|
|
46
|
-
});
|
|
47
|
-
this.wasmModule = wasmModule;
|
|
48
|
-
this.Module = window.Module;
|
|
49
|
-
this.workflowApiUtilities = new this.wasmModule.WorkflowApiUtilities();
|
|
50
|
-
this.utilityApi = new this.wasmModule.UtilityApi();
|
|
51
|
-
this.utilityApi.setOnDeviceMode(this.onDeviceMode_);
|
|
52
|
-
this.idCaptureWasmApi = new this.wasmModule.IdCaptureApi();
|
|
53
|
-
this.faceProcessingWasmApi = new this.wasmModule.FaceProcessingApi();
|
|
54
|
-
this.webApi = new this.wasmModule.WebApi(createWebApiHostAdapter());
|
|
55
|
-
this.isInitialized_ = true;
|
|
56
|
-
return simdUsed;
|
|
57
|
-
}
|
|
58
|
-
static getInstance() {
|
|
59
|
-
if (!MlWasmJSApi.instance) MlWasmJSApi.instance = new MlWasmJSApi();
|
|
60
|
-
return MlWasmJSApi.instance;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns initialization status
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
isInitialized() {
|
|
67
|
-
return this.workflowApiUtilities != null && this.utilityApi != null && this.idCaptureWasmApi != null && this.faceProcessingWasmApi != null && this.isInitialized_;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Allocate shared memory for image buffers (RGBA format)
|
|
71
|
-
* Use it every time when the frame dimentions changes
|
|
72
|
-
* @param {number} imageWidth - image width
|
|
73
|
-
* @param {number} imageHeight - image height
|
|
74
|
-
*/
|
|
75
|
-
async allocateImageBuffers(imageWidth, imageHeight) {
|
|
76
|
-
this.checkWasmInitialization("Unable to allocate image buffers, cpp API hasn't been initialized");
|
|
77
|
-
if (imageWidth && imageHeight && imageWidth == this.imageWidth_ && imageHeight == this.imageHeight_ && this.inputImageBuffer && imageWidth * imageHeight * 4 === this.inputImageBuffer.length) return;
|
|
78
|
-
this.imageWidth_ = imageWidth;
|
|
79
|
-
this.imageHeight_ = imageHeight;
|
|
80
|
-
this.inputImageBuffer = this.workflowApiUtilities.allocateInputImageBuffer(imageWidth, imageHeight, 4);
|
|
81
|
-
}
|
|
82
|
-
async handleDetectionCallAndUpdateState(type) {
|
|
83
|
-
this.checkWasmInitialization("Unable to update pipeline state, cpp API hasn't been initialized");
|
|
84
|
-
this.workflowApiUtilities.handleDetectionCallAndUpdateState(this.pipelineTypeToWasmEnum(type));
|
|
85
|
-
}
|
|
86
|
-
ens(image) {
|
|
87
|
-
this.checkWasmInitialization("Unable to encrypt the image, cpp API hasn't been initialized");
|
|
88
|
-
return this.utilityApi.ens(image);
|
|
89
|
-
}
|
|
90
|
-
isVirtualCamera(label) {
|
|
91
|
-
this.checkWasmInitialization("Unable to check if the camera is virtual, cpp API hasn't been initialized");
|
|
92
|
-
if (label) return this.utilityApi.isVirtualCamera(label);
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
estimatePerformance() {
|
|
96
|
-
this.checkWasmInitialization("Unable to estimate performance, cpp API hasn't been initialized");
|
|
97
|
-
return this.utilityApi.estimatePerformance();
|
|
98
|
-
}
|
|
99
|
-
async analyzeFrame(image) {
|
|
100
|
-
this.checkWasmInitialization("Unable to analyze the frame, cpp API hasn't been initialized");
|
|
101
|
-
await this.allocateImageBuffers(image.width, image.height);
|
|
102
|
-
this.inputImageBuffer.set(image.data);
|
|
103
|
-
this.utilityApi.analyzeFrame();
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Free allocated memory
|
|
107
|
-
*/
|
|
108
|
-
async freeResources() {
|
|
109
|
-
this.versionsFile = null;
|
|
110
|
-
this.modelsBuffers = null;
|
|
111
|
-
this.inputImageBuffer = null;
|
|
112
|
-
this.imageWidth_ = null;
|
|
113
|
-
this.imageHeight_ = null;
|
|
114
|
-
this.pipelines_ = null;
|
|
115
|
-
window.wasmArrayBuffer = null;
|
|
116
|
-
if (this.workflowApiUtilities && typeof this.workflowApiUtilities.delete === "function") {
|
|
117
|
-
this.workflowApiUtilities.delete();
|
|
118
|
-
this.workflowApiUtilities = null;
|
|
119
|
-
}
|
|
120
|
-
if (this.utilityApi && typeof this.utilityApi.delete === "function") {
|
|
121
|
-
this.utilityApi.delete();
|
|
122
|
-
this.utilityApi = null;
|
|
123
|
-
}
|
|
124
|
-
if (this.idCaptureWasmApi && typeof this.idCaptureWasmApi.delete === "function") {
|
|
125
|
-
this.idCaptureWasmApi.delete();
|
|
126
|
-
this.idCaptureWasmApi = null;
|
|
127
|
-
}
|
|
128
|
-
if (this.faceProcessingWasmApi && typeof this.faceProcessingWasmApi.delete === "function") {
|
|
129
|
-
this.faceProcessingWasmApi.delete();
|
|
130
|
-
this.faceProcessingWasmApi = null;
|
|
131
|
-
}
|
|
132
|
-
if (this.webApi && typeof this.webApi.delete === "function") this.webApi.delete();
|
|
133
|
-
this.webApi = null;
|
|
134
|
-
this.wasmModule = null;
|
|
135
|
-
this.isInitialized_ = false;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Clear pipeline state
|
|
139
|
-
*/
|
|
140
|
-
resetPipeline(type) {
|
|
141
|
-
this.checkWasmInitialization("Unable to reset pipeline, cpp API hasn't been initialized");
|
|
142
|
-
this.workflowApiUtilities.resetWorkflow(this.pipelineTypeToWasmEnum(type));
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Clear all pipelines states
|
|
146
|
-
*/
|
|
147
|
-
resetAllPipelines() {
|
|
148
|
-
this.checkWasmInitialization("Unable to reset pipelines, cpp API hasn't been initialized");
|
|
149
|
-
for (const [type, model] of this.pipelines_) this.resetPipeline(type);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Clear all states, not related to ml pipelines
|
|
153
|
-
*/
|
|
154
|
-
resetOther() {
|
|
155
|
-
this.checkWasmInitialization("Unable to reset other states, cpp API hasn't been initialized");
|
|
156
|
-
this.utilityApi.resetOther();
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Full reset
|
|
160
|
-
*/
|
|
161
|
-
reset() {
|
|
162
|
-
this.resetAllPipelines();
|
|
163
|
-
this.resetOther();
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Process one frame using one of the pipelines
|
|
167
|
-
* @param {ImageData} image - input image
|
|
168
|
-
* @param {WasmPipelineType} type - pipeline type
|
|
169
|
-
* @returns
|
|
170
|
-
*/
|
|
171
|
-
async process(image, type) {
|
|
172
|
-
this.checkWasmInitialization("Unable to process the image, cpp API hasn't been initialized");
|
|
173
|
-
if (this.inputImageBuffer === null) throw new Error("Unable to process the image, buffers haven't been allocated!");
|
|
174
|
-
this.inputImageBuffer.set(image.data);
|
|
175
|
-
switch (type) {
|
|
176
|
-
case 0:
|
|
177
|
-
case 1: return this.idCaptureWasmApi.runIdCaptureWorkflow(this.pipelineTypeToWasmEnum(type));
|
|
178
|
-
case 2: return this.idCaptureWasmApi.runIdVideoSelfieWorkflow();
|
|
179
|
-
case 3:
|
|
180
|
-
case 4:
|
|
181
|
-
case 5: return this.faceProcessingWasmApi.runSelfieWorkflow(this.pipelineTypeToWasmEnum(type));
|
|
182
|
-
default: throw new Error("Unknown pipeline type");
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
async runIdCapture(image) {
|
|
186
|
-
this.checkWasmInitialization("Unable to run Id Capture, cpp API hasn't been initialized");
|
|
187
|
-
if (this.inputImageBuffer === null) throw new Error("Unable to process the image, buffers haven't been allocated!");
|
|
188
|
-
this.inputImageBuffer.set(image.data);
|
|
189
|
-
return this.idCaptureWasmApi.runIdCapture();
|
|
190
|
-
}
|
|
191
|
-
async runSelfieCapture(image) {
|
|
192
|
-
this.checkWasmInitialization("Unable to run Selfie Capture, cpp API hasn't been initialized");
|
|
193
|
-
if (this.inputImageBuffer === null) throw new Error("Unable to process the image, buffers haven't been allocated!");
|
|
194
|
-
this.inputImageBuffer.set(image.data);
|
|
195
|
-
return this.faceProcessingWasmApi.runSelfieCapture();
|
|
196
|
-
}
|
|
197
|
-
async setFacePositionConstraints(type, minX, minY, maxX, maxY) {
|
|
198
|
-
this.checkWasmInitialization("Unable to set face position constraints, cpp API hasn't been initialized");
|
|
199
|
-
this.faceProcessingWasmApi.setFacePositionConstraints(this.pipelineTypeToWasmEnum(type), minX, minY, maxX, maxY);
|
|
200
|
-
}
|
|
201
|
-
async setFaceDetectionThresholds(type, brightnessThreshold, blurrinessThreshold, tiltRotationAngleThreshold, minMagicCropSize, autocaptureInterval, minFaceQualityScore, faceOcclusionThreshold, getReadyDelay, framesAggregationInterval, minFramesWithFace) {
|
|
202
|
-
this.checkWasmInitialization("Unable to set face detection thresholds, cpp API hasn't been initialized");
|
|
203
|
-
this.faceProcessingWasmApi.setFaceProcessingThresholds(this.pipelineTypeToWasmEnum(type), brightnessThreshold, blurrinessThreshold, tiltRotationAngleThreshold, minMagicCropSize, autocaptureInterval, minFaceQualityScore, faceOcclusionThreshold, getReadyDelay, framesAggregationInterval, minFramesWithFace);
|
|
204
|
-
}
|
|
205
|
-
async setFaceAttributesThresholds(type, headwearThreshold, lensesThreshold, closedEyesThreshold, maskThreshold) {
|
|
206
|
-
this.checkWasmInitialization("Unable to set face attributes thresholds, cpp API hasn't been initialized");
|
|
207
|
-
this.faceProcessingWasmApi.setFaceAttributesThresholds(this.pipelineTypeToWasmEnum(type), headwearThreshold, lensesThreshold, closedEyesThreshold, maskThreshold);
|
|
208
|
-
}
|
|
209
|
-
async setFaceChecksEnabled(type, isLensesCheckEnabled, isMaskCheckEnabled, isClosedEyesCheckEnabled, isHeadWearCheckEnabled, isOcclusionCheckEnabled) {
|
|
210
|
-
this.checkWasmInitialization("Unable to set face checks enabled flags, cpp API hasn't been initialized");
|
|
211
|
-
this.faceProcessingWasmApi.setFaceChecksEnabled(this.pipelineTypeToWasmEnum(type), isLensesCheckEnabled, isMaskCheckEnabled, isClosedEyesCheckEnabled, isHeadWearCheckEnabled, isOcclusionCheckEnabled);
|
|
212
|
-
}
|
|
213
|
-
async setFaceDetectionMode(type, isVideoSelfie) {
|
|
214
|
-
this.checkWasmInitialization("Unable to set face detection mode, cpp API hasn't been initialized");
|
|
215
|
-
this.faceProcessingWasmApi.setFaceProcessingMode(this.pipelineTypeToWasmEnum(type), isVideoSelfie);
|
|
216
|
-
}
|
|
217
|
-
async setFaceDetectionCallbacks(type, onFarAway, onTooClose, onTooManyFaces, onNoFace, onCapture, onGetReady, onGetReadyFinished, onCenterFace, onDark, onBlur, onFaceAngle, onLenses, onMask, onEyesClosed, onHeadWear, onSwitchToManualCapture, onFaceOccluded) {
|
|
218
|
-
this.checkWasmInitialization("Unable to set face detection callbacks, cpp API hasn't been initialized");
|
|
219
|
-
this.faceProcessingWasmApi.setFaceProcessingCallbacks(this.pipelineTypeToWasmEnum(type), onFarAway, onTooClose, onTooManyFaces, onNoFace, onCapture, onGetReady, onGetReadyFinished, onCenterFace, onDark, onBlur, onFaceAngle, onLenses, onMask, onEyesClosed, onHeadWear, onSwitchToManualCapture, onFaceOccluded);
|
|
220
|
-
}
|
|
221
|
-
async setIdCaptureThresholds(type, blurThreshold, blurChangeThreshold, glareThreshold, clsThreshold, sideThreshold, iouThreshold, idDetectedTimeout, autocaptureTimeout, framesAggregationInterval) {
|
|
222
|
-
this.checkWasmInitialization("Unable to set thresholds, cpp API hasn't been initialized");
|
|
223
|
-
this.idCaptureWasmApi.setIdCaptureThresholds(this.pipelineTypeToWasmEnum(type), blurThreshold, blurChangeThreshold, glareThreshold, clsThreshold, sideThreshold, iouThreshold, idDetectedTimeout, autocaptureTimeout, framesAggregationInterval);
|
|
224
|
-
}
|
|
225
|
-
async setIdCaptureCallbacks(type, onFarAway, onDetectionStarted, onMaskChange, onBlur, onGlare, onCapturing, onCapture, onBestFrame, onIDNotDetected, onSwitchToManualCapture, onIDTypeChange, onIDSideChange, onCapturingCounterValueChange) {
|
|
226
|
-
this.checkWasmInitialization("Unable to set callbacks, cpp API hasn't been initialized");
|
|
227
|
-
this.idCaptureWasmApi.setIdCaptureCallbacks(this.pipelineTypeToWasmEnum(type), onFarAway, onDetectionStarted, onMaskChange, onBlur, onGlare, onCapturing, onCapture, onBestFrame, onIDNotDetected, onSwitchToManualCapture, onIDTypeChange, onIDSideChange, onCapturingCounterValueChange);
|
|
228
|
-
}
|
|
229
|
-
async setIdCaptureGeometryParams(type, areaDown, areaUp, areaIOSPassportUp, areaIOSPassportDown, widthIOSUp, widthIOSDown, widthDown, widthUp, windowOuterWidth, windowOuterHeight, windowInnerWidth, windowInnerHeight) {
|
|
230
|
-
this.checkWasmInitialization("Unable to set geometry params, cpp API hasn't been initialized");
|
|
231
|
-
this.idCaptureWasmApi.setIdCaptureGeometryParams(this.pipelineTypeToWasmEnum(type), areaDown, areaUp, areaIOSPassportUp, areaIOSPassportDown, widthIOSUp, widthIOSDown, widthDown, widthUp, windowOuterWidth, windowOuterHeight, windowInnerWidth, windowInnerHeight);
|
|
232
|
-
}
|
|
233
|
-
async setIdCaptureConfigParams(type, isFixedMask, isIPhone14OrHigher, idType, isBlurCheckEnabled, isGlareCheckEnabled, _isIdFaceQualityCheckEnabled, isIouCheckEnabled, isFPSLimitEnabled) {
|
|
234
|
-
this.checkWasmInitialization("Unable to set config params, cpp API hasn't been initialized");
|
|
235
|
-
this.idCaptureWasmApi.setIdCaptureConfigParams(this.pipelineTypeToWasmEnum(type), isFixedMask, isIPhone14OrHigher, idType, isBlurCheckEnabled, isGlareCheckEnabled, isIouCheckEnabled, isFPSLimitEnabled);
|
|
236
|
-
}
|
|
237
|
-
setIdCaptureModelType(pipelineType, modelType) {
|
|
238
|
-
this.checkWasmInitialization("Unable to set model type, cpp API hasn't been initialized");
|
|
239
|
-
this.idCaptureWasmApi.setIdCaptureModelType(this.pipelineTypeToWasmEnum(pipelineType), this.IdCaptureModelTypeToWasmEnum(modelType));
|
|
240
|
-
}
|
|
241
|
-
setIdBarcodeCaptureEnabled(pipelineType, enabled) {
|
|
242
|
-
this.checkWasmInitialization("Unable to set barcode capture enabled, cpp API hasn't been initialized");
|
|
243
|
-
this.idCaptureWasmApi.setIdBarcodeCaptureEnabled(this.pipelineTypeToWasmEnum(pipelineType), enabled);
|
|
244
|
-
}
|
|
245
|
-
setIdBarcodeAutoCaptureOnDecode(pipelineType, enabled) {
|
|
246
|
-
this.checkWasmInitialization("Unable to set barcode auto-capture-on-decode, cpp API hasn't been initialized");
|
|
247
|
-
this.idCaptureWasmApi.setIdBarcodeAutoCaptureOnDecode(this.pipelineTypeToWasmEnum(pipelineType), enabled);
|
|
248
|
-
}
|
|
249
|
-
setIdBarcodeDecodedCallback(pipelineType, onBarcodeDecoded) {
|
|
250
|
-
this.checkWasmInitialization("Unable to set barcode decoded callback, cpp API hasn't been initialized");
|
|
251
|
-
this.idCaptureWasmApi.setIdBarcodeDecodedCallback(this.pipelineTypeToWasmEnum(pipelineType), onBarcodeDecoded);
|
|
252
|
-
}
|
|
253
|
-
async setIdBarcodeEnhancementModel(pipelineType, modelPath) {
|
|
254
|
-
this.checkWasmInitialization("Unable to set barcode enhancement model, cpp API hasn't been initialized");
|
|
255
|
-
const buffer = await fetch(modelPath).then((response) => response.arrayBuffer()).then((buf) => new Uint8Array(buf));
|
|
256
|
-
return this.idCaptureWasmApi.setBarcodeEnhancementModel(this.pipelineTypeToWasmEnum(pipelineType), buffer);
|
|
257
|
-
}
|
|
258
|
-
IdPerspectiveTransform(image, frameRect) {
|
|
259
|
-
this.checkWasmInitialization("Unable to perform perspective transform, cpp API hasn't been initialized");
|
|
260
|
-
return this.idCaptureWasmApi.IdPerspectiveTransform(image, frameRect);
|
|
261
|
-
}
|
|
262
|
-
async getVersions() {
|
|
263
|
-
const text = await (await fetch(this.versionsFile)).text();
|
|
264
|
-
return JSON.parse(text);
|
|
265
|
-
}
|
|
266
|
-
async loadModels() {
|
|
267
|
-
this.checkWasmInitialization("Unable load the models, cpp API hasn't been initialized");
|
|
268
|
-
const buffSizes = new this.wasmModule.WorkflowTypeToIntMap();
|
|
269
|
-
const modelData = /* @__PURE__ */ new Map();
|
|
270
|
-
const loadedModels = /* @__PURE__ */ new Map();
|
|
271
|
-
for (const [type, modelsPaths] of this.pipelines_) {
|
|
272
|
-
const wasmType = this.pipelineTypeToWasmEnum(type);
|
|
273
|
-
const pipelineBuffers = [];
|
|
274
|
-
const sizes = new this.wasmModule.VectorInt();
|
|
275
|
-
for (const path of modelsPaths) {
|
|
276
|
-
if (!loadedModels.has(path)) {
|
|
277
|
-
const model = await fetch(path).then((response) => response.arrayBuffer()).then((buffer) => new Uint8Array(buffer));
|
|
278
|
-
loadedModels.set(path, model);
|
|
279
|
-
}
|
|
280
|
-
const model = loadedModels.get(path);
|
|
281
|
-
sizes.push_back(model.byteLength);
|
|
282
|
-
pipelineBuffers.push(model);
|
|
283
|
-
}
|
|
284
|
-
buffSizes.set(wasmType, sizes);
|
|
285
|
-
modelData.set(wasmType, pipelineBuffers);
|
|
286
|
-
}
|
|
287
|
-
this.modelsBuffers = this.workflowApiUtilities.allocateModelsBuffers(buffSizes);
|
|
288
|
-
for (const [type, data] of modelData) {
|
|
289
|
-
const buffers = this.modelsBuffers?.get(type);
|
|
290
|
-
for (let k = 0; k < buffers.size(); k++) {
|
|
291
|
-
const buffer = buffers?.get(k);
|
|
292
|
-
if (buffer) buffer.set(data[k]);
|
|
293
|
-
else throw new Error("Unable to get model buffer from shared memory!");
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
async initializePipelines() {
|
|
298
|
-
this.checkWasmInitialization("Unable to initialize pipelines, cpp API hasn't been initialized");
|
|
299
|
-
if (!this.modelsBuffers) await this.loadModels();
|
|
300
|
-
this.workflowApiUtilities.initializeWorkflows();
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Sets the native (C++) utility API's production mode. When `true`, the WASM
|
|
304
|
-
* module suppresses its verbose debug logging; when `false`, it emits it.
|
|
305
|
-
*
|
|
306
|
-
* @param productionMode - `true` to silence WASM logs, `false` to emit them.
|
|
307
|
-
* @throws If the WASM C++ API has not been initialized yet.
|
|
308
|
-
*/
|
|
309
|
-
async setProductionMode(productionMode) {
|
|
310
|
-
this.checkWasmInitialization("Unable to set production mode, cpp API hasn't been initialized");
|
|
311
|
-
this.utilityApi.setProductionMode(productionMode);
|
|
312
|
-
}
|
|
313
|
-
getPipelineState() {
|
|
314
|
-
this.checkWasmInitialization("Unable to get pipeline state, cpp API hasn't been initialized");
|
|
315
|
-
return this.workflowApiUtilities.getWorkflowState();
|
|
316
|
-
}
|
|
317
|
-
getCurrentPipeline() {
|
|
318
|
-
this.checkWasmInitialization("Unable to get current pipeline, cpp API hasn't been initialized");
|
|
319
|
-
return this.pipelineTypeFromWasmEnum(this.workflowApiUtilities.getCurrentWorkflow());
|
|
320
|
-
}
|
|
321
|
-
setSdkVersion(sdkVersion) {
|
|
322
|
-
this.checkWasmInitialization("Unable to set sdk version, cpp API hasn't been initialized");
|
|
323
|
-
this.utilityApi.setSdkVersion(sdkVersion);
|
|
324
|
-
}
|
|
325
|
-
setSdkPlatform(sdkPlatform) {
|
|
326
|
-
this.checkWasmInitialization("Unable to set device type, cpp API hasn't been initialized");
|
|
327
|
-
this.utilityApi.setSdkPlatform(sdkPlatform);
|
|
328
|
-
}
|
|
329
|
-
setDeviceInfo(deviceInfo, overrideExisting = true) {
|
|
330
|
-
this.checkWasmInitialization("Unable to set device info, cpp API hasn't been initialized");
|
|
331
|
-
this.utilityApi.setDeviceInfo(deviceInfo, overrideExisting);
|
|
332
|
-
}
|
|
333
|
-
setBrowserInfo(browserInfo, overrideExisting = true) {
|
|
334
|
-
this.checkWasmInitialization("Unable to set browser info, cpp API hasn't been initialized");
|
|
335
|
-
this.utilityApi.setBrowserInfo(browserInfo, overrideExisting);
|
|
336
|
-
}
|
|
337
|
-
setCameraInfo(cameraInfo, overrideExisting = true) {
|
|
338
|
-
this.checkWasmInitialization("Unable to set camera info, cpp API hasn't been initialized");
|
|
339
|
-
this.utilityApi.setCameraInfo(cameraInfo, overrideExisting);
|
|
340
|
-
}
|
|
341
|
-
setZc(zc) {
|
|
342
|
-
this.checkWasmInitialization("Unable to set zc, cpp API hasn't been initialized");
|
|
343
|
-
this.utilityApi.setZc(zc);
|
|
344
|
-
}
|
|
345
|
-
setMotionStatus(motionStatus) {
|
|
346
|
-
this.checkWasmInitialization("Unable to set motion status, cpp API hasn't been initialized");
|
|
347
|
-
this.utilityApi.setMotionStatus(motionStatus);
|
|
348
|
-
}
|
|
349
|
-
setMetadataField(key, value) {
|
|
350
|
-
this.checkWasmInitialization("Unable to set metadata field, cpp API hasn't been initialized");
|
|
351
|
-
this.utilityApi.setMetadataField(key, value);
|
|
352
|
-
}
|
|
353
|
-
setInspectorOpened(inspectorOpened) {
|
|
354
|
-
this.inspectorOpened_ = inspectorOpened;
|
|
355
|
-
}
|
|
356
|
-
getInspectorOpened() {
|
|
357
|
-
return this.inspectorOpened_;
|
|
358
|
-
}
|
|
359
|
-
setBackgroundMode(backgroundMode) {
|
|
360
|
-
this.checkWasmInitialization("Unable to set background mode, cpp API hasn't been initialized");
|
|
361
|
-
this.utilityApi.setBackgroundMode(backgroundMode);
|
|
362
|
-
}
|
|
363
|
-
setOnDeviceMode(enabled) {
|
|
364
|
-
this.onDeviceMode_ = enabled;
|
|
365
|
-
if (this.utilityApi != null) this.utilityApi.setOnDeviceMode(enabled);
|
|
366
|
-
}
|
|
367
|
-
setDsEnabled(enabled) {
|
|
368
|
-
this.dsEnabled_ = enabled;
|
|
369
|
-
}
|
|
370
|
-
getCheck() {
|
|
371
|
-
this.checkWasmInitialization("Unable to get check, cpp API hasn't been initialized");
|
|
372
|
-
return this.utilityApi.getCheck();
|
|
373
|
-
}
|
|
374
|
-
getMetadata() {
|
|
375
|
-
this.checkWasmInitialization("Unable to get metadata, cpp API hasn't been initialized");
|
|
376
|
-
this.utilityApi.setInspectorOpened(this.inspectorOpened_);
|
|
377
|
-
return this.utilityApi.getMetadata();
|
|
378
|
-
}
|
|
379
|
-
async prc() {
|
|
380
|
-
this.checkWasmInitialization("Unable to prc, cpp API hasn't been initialized");
|
|
381
|
-
await wasmCallWrapper(this.wasmCallSemaphore, () => this.utilityApi.prc(this.dsEnabled_, false), true);
|
|
382
|
-
}
|
|
383
|
-
async poc(output) {
|
|
384
|
-
this.checkWasmInitialization("Unable to poc, cpp API hasn't been initialized");
|
|
385
|
-
await wasmCallWrapper(this.wasmCallSemaphore, () => this.utilityApi.poc(this.dsEnabled_, output), true);
|
|
386
|
-
}
|
|
387
|
-
async rsp() {
|
|
388
|
-
this.checkWasmInitialization("Unable to rsp, cpp API hasn't been initialized");
|
|
389
|
-
await wasmCallWrapper(this.wasmCallSemaphore, () => this.utilityApi.rsp(this.dsEnabled_), true);
|
|
390
|
-
}
|
|
391
|
-
ssl() {
|
|
392
|
-
this.checkWasmInitialization("Unable to ssl, cpp API hasn't been initialized");
|
|
393
|
-
this.utilityApi.ssl(this.dsEnabled_);
|
|
394
|
-
}
|
|
395
|
-
stl() {
|
|
396
|
-
this.checkWasmInitialization("Unable to stl, cpp API hasn't been initialized");
|
|
397
|
-
this.utilityApi.stl();
|
|
398
|
-
}
|
|
399
|
-
osv() {
|
|
400
|
-
this.checkWasmInitialization("Unable to set sensor beginning timestamp, cpp API hasn't been initialized");
|
|
401
|
-
this.utilityApi.osv();
|
|
402
|
-
}
|
|
403
|
-
oev() {
|
|
404
|
-
this.checkWasmInitialization("Unable to set sensor ending timestamp, cpp API hasn't been initialized");
|
|
405
|
-
this.utilityApi.oev();
|
|
406
|
-
}
|
|
407
|
-
ckvcks(data) {
|
|
408
|
-
this.checkWasmInitialization("Unable to ckvcks, cpp API hasn't been initialized");
|
|
409
|
-
this.utilityApi.ckvcks(data);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Synchronous manual-capture entry point for the OnDevice selfie workflow.
|
|
413
|
-
* Runs face detection + the full on-device quality / liveness / age pipeline
|
|
414
|
-
* on a single canvas image and stages the results inside the WASM `WebApi`
|
|
415
|
-
* for the next {@link postFaceResults} call. No polling, no semaphore wrap.
|
|
416
|
-
*
|
|
417
|
-
* Mirrors `ml-wasm-kit/WasmApi.processPhoto`.
|
|
418
|
-
*/
|
|
419
|
-
processPhoto(canvas) {
|
|
420
|
-
this.checkWasmInitialization("Unable to process photo, cpp API hasn't been initialized");
|
|
421
|
-
this.faceProcessingWasmApi.processPhoto(canvas);
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* POSTs the staged on-device face-results JSON to `/omni/add/face-results`
|
|
425
|
-
* via the C++ `WebApi`. The C++ side encrypts the body with
|
|
426
|
-
* `SessionEncryptor` and routes through the WASM `WebClient` with inline
|
|
427
|
-
* encryption (`ie=true`) — this does NOT depend on the WebClient E2EE
|
|
428
|
-
* session setup, so it works whether `setupWasmConnection` was called with
|
|
429
|
-
* `encryptionEnabled` true or false.
|
|
430
|
-
*
|
|
431
|
-
* Reads from the `WebApi` instance constructed in {@link initialize}. The
|
|
432
|
-
* C++ `OnDeviceSelfieWorkflow` has already staged the aggregated best-shot
|
|
433
|
-
* results into that instance via `WebApi::setFaceResults(...)` during
|
|
434
|
-
* per-frame processing (auto-capture) or via {@link processPhoto}
|
|
435
|
-
* (manual-capture).
|
|
436
|
-
*/
|
|
437
|
-
postFaceResults(config) {
|
|
438
|
-
this.checkWasmInitialization("Unable to post face results, cpp API hasn't been initialized");
|
|
439
|
-
return this.webApi.postFaceResults(config ?? {});
|
|
440
|
-
}
|
|
441
|
-
pipelineTypeToWasmEnum(type) {
|
|
442
|
-
switch (type) {
|
|
443
|
-
case 0: return this.wasmModule.WorkflowType.IdBlurGlareWorkflow;
|
|
444
|
-
case 1: return this.wasmModule.WorkflowType.IdBarcodeAndTextQualityWorkflow;
|
|
445
|
-
case 2: return this.wasmModule.WorkflowType.IdVideoSelfieWorkflow;
|
|
446
|
-
case 3: return this.wasmModule.WorkflowType.SelfieWithAggregationMetrics;
|
|
447
|
-
case 4: return this.wasmModule.WorkflowType.SelfieWithQualityMetrics;
|
|
448
|
-
case 5: return this.wasmModule.WorkflowType.OnDeviceSelfieWorkflow;
|
|
449
|
-
default: throw new Error("Unknown pipeline type");
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
pipelineTypeFromWasmEnum(type) {
|
|
453
|
-
switch (type) {
|
|
454
|
-
case this.wasmModule.WorkflowType.IdBlurGlareWorkflow: return 0;
|
|
455
|
-
case this.wasmModule.WorkflowType.IdBarcodeAndTextQualityWorkflow: return 1;
|
|
456
|
-
case this.wasmModule.WorkflowType.IdVideoSelfieWorkflow: return 2;
|
|
457
|
-
case this.wasmModule.WorkflowType.SelfieWithAggregationMetrics: return 3;
|
|
458
|
-
case this.wasmModule.WorkflowType.SelfieWithQualityMetrics: return 4;
|
|
459
|
-
case this.wasmModule.WorkflowType.OnDeviceSelfieWorkflow: return 5;
|
|
460
|
-
default: throw new Error("Unknown pipeline type");
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
IdCaptureModelTypeToWasmEnum(type) {
|
|
464
|
-
switch (type) {
|
|
465
|
-
case 0: return this.wasmModule.IdCaptureModelType.IdCaptureV1x;
|
|
466
|
-
case 1: return this.wasmModule.IdCaptureModelType.IdCaptureV2x;
|
|
467
|
-
case 2: return this.wasmModule.IdCaptureModelType.IdCaptureV3x;
|
|
468
|
-
default: throw new Error("Unknown Id Capture model type");
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
IdCaptureModelTypeFromWasmEnum(type) {
|
|
472
|
-
switch (type) {
|
|
473
|
-
case this.wasmModule.IdCaptureModelType.IdCaptureV1x: return 0;
|
|
474
|
-
case this.wasmModule.IdCaptureModelType.IdCaptureV2x: return 1;
|
|
475
|
-
case this.wasmModule.IdCaptureModelType.IdCaptureV3x: return 2;
|
|
476
|
-
default: throw new Error("Unknown Id Capture model type");
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
checkWasmInitialization(message) {
|
|
480
|
-
if (!this.isInitialized()) throw new Error(message);
|
|
481
|
-
}
|
|
482
|
-
}.getInstance();
|
|
483
|
-
//#endregion
|
|
484
|
-
//#region ../infra/src/wasm/warmup.ts
|
|
485
|
-
/**
|
|
486
|
-
* Pipelines preloaded when no explicit `pipelines` array is passed to
|
|
487
|
-
* {@link warmupWasm}. The on-device selfie bundle is opt-in (loaded only when
|
|
488
|
-
* a SELFIE/AUTH module has `onDeviceFaceResultsSubmissionEnabled: true`), so
|
|
489
|
-
* it is intentionally excluded here to keep the default warmup small.
|
|
490
|
-
*/
|
|
491
|
-
const WASM_PIPELINES = ["selfie", "idCapture"];
|
|
492
|
-
/**
|
|
493
|
-
* Default model files for each pipeline.
|
|
494
|
-
* These are the ONNX model files required by each ML pipeline.
|
|
495
|
-
*/
|
|
496
|
-
const DEFAULT_PIPELINE_MODELS = {
|
|
497
|
-
selfie: [
|
|
498
|
-
"selfie_bf_angles_192x192_opset9_fp16.ortmodelv2",
|
|
499
|
-
"face_attributes_v1_3_fp16.ortmodelv2",
|
|
500
|
-
"mls_regressor_4773007c657b4f05a460321456740d0f_fp16.ortmodelv2",
|
|
501
|
-
"face_occlusion_v0_2_fp16.ortmodelv2"
|
|
502
|
-
],
|
|
503
|
-
onDeviceSelfie: [
|
|
504
|
-
"selfie_bf_angles_192x192_opset9_fp16.ortmodelv2",
|
|
505
|
-
"face_attributes_v1_3_fp16.ortmodelv2",
|
|
506
|
-
"mls_regressor_4773007c657b4f05a460321456740d0f_fp16.ortmodelv2",
|
|
507
|
-
"face_occlusion_v0_2_fp16.ortmodelv2",
|
|
508
|
-
"ondevice_physical_liveness_v2_1_fp16.ortmodelv2",
|
|
509
|
-
"age_estimation_v2_2_2_fp16.ortmodelv2"
|
|
510
|
-
],
|
|
511
|
-
idCapture: ["id_capture_2_01_fp16.ortmodelv2", "id_fiqa_19a81a0b9bf6492eb03b4667f6db4c85_fp16.ortmodelv2"],
|
|
512
|
-
videoSelfie: [
|
|
513
|
-
"selfie_bf_angles_192x192_opset9_fp16.ortmodelv2",
|
|
514
|
-
"face_attributes_v1_3_fp16.ortmodelv2",
|
|
515
|
-
"mls_regressor_4773007c657b4f05a460321456740d0f_fp16.ortmodelv2",
|
|
516
|
-
"face_occlusion_v0_2_fp16.ortmodelv2"
|
|
517
|
-
],
|
|
518
|
-
videoSelfieId: ["id_capture_2_01_fp16.ortmodelv2"]
|
|
519
|
-
};
|
|
520
|
-
let state = "idle";
|
|
521
|
-
let loadingPromise = null;
|
|
522
|
-
let wasmError = null;
|
|
523
|
-
let loadedPipelines = [];
|
|
524
|
-
let lastConfig = null;
|
|
525
|
-
let pipelinesInFlight = [];
|
|
526
|
-
function mapPipelineToWasmType(pipeline) {
|
|
527
|
-
switch (pipeline) {
|
|
528
|
-
case "selfie": return 4;
|
|
529
|
-
case "onDeviceSelfie": return 5;
|
|
530
|
-
case "idCapture": return 0;
|
|
531
|
-
case "videoSelfie": return 3;
|
|
532
|
-
case "videoSelfieId": return 2;
|
|
533
|
-
default: throw new Error(`Unknown pipeline: ${pipeline}`);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Derives the models base path from the WASM path.
|
|
538
|
-
* Assumes models are in a 'models' subdirectory relative to the WASM binary location.
|
|
539
|
-
* e.g., '/wasm/v2/binary.wasm' -> '/wasm/v2/models'
|
|
540
|
-
*/
|
|
541
|
-
function deriveModelsBasePath(wasmPath) {
|
|
542
|
-
const lastSlashIndex = wasmPath.lastIndexOf("/");
|
|
543
|
-
if (lastSlashIndex === -1) return "models";
|
|
544
|
-
return `${wasmPath.substring(0, lastSlashIndex)}/models`;
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* The models base path resolved from the last successful warmup, mirroring the
|
|
548
|
-
* load-time resolution (explicit `modelsBasePath`, else derived from
|
|
549
|
-
* `wasmPath`). `undefined` before any warmup. Used to locate lazily-loaded
|
|
550
|
-
* models such as the PDF417 barcode enhancement model at the correct base so
|
|
551
|
-
* self-hosted / air-gapped deployments resolve it too.
|
|
552
|
-
*/
|
|
553
|
-
function getResolvedModelsBasePath() {
|
|
554
|
-
if (!lastConfig) return;
|
|
555
|
-
return lastConfig.modelsBasePath ?? deriveModelsBasePath(lastConfig.wasmPath);
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Builds the pipelines map with model paths for WASM initialization.
|
|
559
|
-
* @param pipelines - Array of pipeline types to initialize
|
|
560
|
-
* @param modelsBasePath - Base path where model files are located
|
|
561
|
-
* @param customModels - Optional custom model files per pipeline
|
|
562
|
-
*/
|
|
563
|
-
function buildPipelinesMap(pipelines, modelsBasePath, customModels) {
|
|
564
|
-
const pipelinesMap = /* @__PURE__ */ new Map();
|
|
565
|
-
for (const pipeline of pipelines) {
|
|
566
|
-
const wasmType = mapPipelineToWasmType(pipeline);
|
|
567
|
-
if (!pipelinesMap.has(wasmType)) {
|
|
568
|
-
const modelPaths = (customModels?.[pipeline] ?? DEFAULT_PIPELINE_MODELS[pipeline]).map((modelFile) => `${modelsBasePath}/${modelFile}`);
|
|
569
|
-
pipelinesMap.set(wasmType, modelPaths);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
return pipelinesMap;
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Preloads WASM binary and ML models at app startup.
|
|
576
|
-
* Runs asynchronously - app can continue while WASM loads in background.
|
|
577
|
-
*
|
|
578
|
-
* Model files are automatically loaded based on the pipeline type.
|
|
579
|
-
* By default, models are expected in a 'models' subdirectory relative to the WASM binary.
|
|
580
|
-
*
|
|
581
|
-
* @param config - Configuration for WASM warmup
|
|
582
|
-
* @returns Promise that resolves when WASM is ready
|
|
583
|
-
*
|
|
584
|
-
* @example
|
|
585
|
-
* ```ts
|
|
586
|
-
* // Basic usage - models loaded from /wasm/v2/models/
|
|
587
|
-
* warmupWasm({
|
|
588
|
-
* wasmPath: '/wasm/v2/ml-wasm.wasm',
|
|
589
|
-
* glueCodePath: '/wasm/v2/ml-wasm.js',
|
|
590
|
-
* pipelines: ['selfie', 'idCapture'],
|
|
591
|
-
* });
|
|
592
|
-
*
|
|
593
|
-
* // With explicit models path
|
|
594
|
-
* warmupWasm({
|
|
595
|
-
* wasmPath: '/wasm/v2/ml-wasm.wasm',
|
|
596
|
-
* glueCodePath: '/wasm/v2/ml-wasm.js',
|
|
597
|
-
* modelsBasePath: 'https://cdn.example.com/wasm/v2/models',
|
|
598
|
-
* pipelines: ['selfie'],
|
|
599
|
-
* });
|
|
600
|
-
* ```
|
|
601
|
-
*/
|
|
602
|
-
async function warmupWasm(config) {
|
|
603
|
-
const pipelines = config.pipelines ?? [...WASM_PIPELINES];
|
|
604
|
-
const modelsBasePath = config.modelsBasePath ?? deriveModelsBasePath(config.wasmPath);
|
|
605
|
-
if (state === "loading" && loadingPromise) {
|
|
606
|
-
const inFlight = loadingPromise;
|
|
607
|
-
if (pipelines.filter((p) => !pipelinesInFlight.includes(p)).length === 0) return inFlight;
|
|
608
|
-
return inFlight.then(() => warmupWasm(config));
|
|
609
|
-
}
|
|
610
|
-
if (state === "ready") {
|
|
611
|
-
if (pipelines.filter((p) => !loadedPipelines.includes(p)).length === 0) return;
|
|
612
|
-
if (!lastConfig) throw new Error("Cannot add pipelines: original warmup config not available");
|
|
613
|
-
if (lastConfig.wasmPath !== config.wasmPath || lastConfig.glueCodePath !== config.glueCodePath || (lastConfig.wasmSimdPath ?? lastConfig.wasmPath) !== (config.wasmSimdPath ?? config.wasmPath) || (lastConfig.glueCodeSimdPath ?? "") !== (config.glueCodeSimdPath ?? "") || (lastConfig.useSimd ?? true) !== (config.useSimd ?? true)) throw new Error("Cannot add pipelines: WASM config mismatch. Use same wasmPath, glueCodePath, and useSimd settings.");
|
|
614
|
-
const combinedPipelines = [.../* @__PURE__ */ new Set([...loadedPipelines, ...pipelines])];
|
|
615
|
-
state = "loading";
|
|
616
|
-
pipelinesInFlight = combinedPipelines;
|
|
617
|
-
wasmError = null;
|
|
618
|
-
loadingPromise = (async () => {
|
|
619
|
-
try {
|
|
620
|
-
const pipelinesMap = buildPipelinesMap(combinedPipelines, lastConfig.modelsBasePath ?? deriveModelsBasePath(lastConfig.wasmPath), lastConfig.pipelineModels);
|
|
621
|
-
await mlWasmJSApi_default.initialize(lastConfig.wasmPath, lastConfig.wasmSimdPath ?? lastConfig.wasmPath, lastConfig.glueCodePath, lastConfig.glueCodeSimdPath ?? "", lastConfig.useSimd ?? true, "", pipelinesMap);
|
|
622
|
-
await mlWasmJSApi_default.loadModels();
|
|
623
|
-
await mlWasmJSApi_default.initializePipelines();
|
|
624
|
-
state = "ready";
|
|
625
|
-
loadedPipelines = combinedPipelines;
|
|
626
|
-
lastConfig = {
|
|
627
|
-
...lastConfig,
|
|
628
|
-
pipelines: combinedPipelines
|
|
629
|
-
};
|
|
630
|
-
loadingPromise = null;
|
|
631
|
-
} catch (error) {
|
|
632
|
-
state = "error";
|
|
633
|
-
wasmError = error instanceof Error ? error : new Error(String(error));
|
|
634
|
-
loadingPromise = null;
|
|
635
|
-
pipelinesInFlight = [];
|
|
636
|
-
throw wasmError;
|
|
637
|
-
}
|
|
638
|
-
})();
|
|
639
|
-
return loadingPromise;
|
|
640
|
-
}
|
|
641
|
-
state = "loading";
|
|
642
|
-
pipelinesInFlight = [...pipelines];
|
|
643
|
-
wasmError = null;
|
|
644
|
-
loadingPromise = (async () => {
|
|
645
|
-
try {
|
|
646
|
-
const pipelinesMap = buildPipelinesMap(pipelines, modelsBasePath, config.pipelineModels);
|
|
647
|
-
if (config.onDeviceMode !== void 0) mlWasmJSApi_default.setOnDeviceMode(config.onDeviceMode);
|
|
648
|
-
await mlWasmJSApi_default.initialize(config.wasmPath, config.wasmSimdPath ?? config.wasmPath, config.glueCodePath, config.glueCodeSimdPath ?? "", config.useSimd ?? true, "", pipelinesMap);
|
|
649
|
-
await mlWasmJSApi_default.loadModels();
|
|
650
|
-
await mlWasmJSApi_default.initializePipelines();
|
|
651
|
-
state = "ready";
|
|
652
|
-
loadedPipelines = [...pipelines];
|
|
653
|
-
lastConfig = {
|
|
654
|
-
...config,
|
|
655
|
-
pipelines
|
|
656
|
-
};
|
|
657
|
-
loadingPromise = null;
|
|
658
|
-
} catch (error) {
|
|
659
|
-
state = "error";
|
|
660
|
-
wasmError = error instanceof Error ? error : new Error(String(error));
|
|
661
|
-
loadingPromise = null;
|
|
662
|
-
pipelinesInFlight = [];
|
|
663
|
-
throw wasmError;
|
|
664
|
-
}
|
|
665
|
-
})();
|
|
666
|
-
return loadingPromise;
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Returns the current warmup status.
|
|
670
|
-
* Useful for showing loading indicators.
|
|
671
|
-
*
|
|
672
|
-
* @returns Current warmup status
|
|
673
|
-
*/
|
|
674
|
-
function getWasmStatus() {
|
|
675
|
-
return {
|
|
676
|
-
isReady: state === "ready",
|
|
677
|
-
isLoading: state === "loading",
|
|
678
|
-
error: wasmError ?? void 0,
|
|
679
|
-
loadedPipelines: [...loadedPipelines]
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Returns true if WASM is fully initialized and ready.
|
|
684
|
-
*
|
|
685
|
-
* @returns True if WASM is ready
|
|
686
|
-
*/
|
|
687
|
-
function isWasmReady() {
|
|
688
|
-
return state === "ready";
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Returns a promise that resolves when WASM is ready.
|
|
692
|
-
* - If ready: resolves immediately
|
|
693
|
-
* - If loading: waits for completion, then resolves
|
|
694
|
-
* - If not started: rejects with error
|
|
695
|
-
*
|
|
696
|
-
* @returns Promise that resolves when WASM is ready
|
|
697
|
-
* @throws Error if WASM is in error state or was never started
|
|
698
|
-
*/
|
|
699
|
-
function waitForWasm() {
|
|
700
|
-
if (state === "ready") return Promise.resolve();
|
|
701
|
-
if (state === "loading" && loadingPromise) return loadingPromise;
|
|
702
|
-
if (state === "error") return Promise.reject(wasmError ?? /* @__PURE__ */ new Error("WASM initialization failed"));
|
|
703
|
-
return Promise.reject(/* @__PURE__ */ new Error("WASM warmup was not started. Call warmupWasm() first."));
|
|
704
|
-
}
|
|
705
|
-
/**
|
|
706
|
-
* Sets WASM on-device mode on the shared WASM singleton. Applied on the next
|
|
707
|
-
* `initialize()` (via warmupWasm), or live if WASM is already initialized.
|
|
708
|
-
* Used by setup() to derive on-device mode from the `fingerprint` option so
|
|
709
|
-
* the intent is honored even by lazy warmups whose config does not carry it.
|
|
710
|
-
*/
|
|
711
|
-
function setWasmOnDeviceMode(enabled) {
|
|
712
|
-
mlWasmJSApi_default.setOnDeviceMode(enabled);
|
|
713
|
-
}
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region ../infra/src/providers/wasm/BaseWasmProvider.ts
|
|
716
|
-
/**
|
|
717
|
-
* Base provider class that abstracts common WASM functionality.
|
|
718
|
-
* This serves as a foundation for specific ML capability providers
|
|
719
|
-
* like FaceDetectionProvider and IdCaptureProvider.
|
|
720
|
-
*/
|
|
721
|
-
var BaseWasmProvider = class {
|
|
722
|
-
/**
|
|
723
|
-
* Creates a new BaseWasmProvider
|
|
724
|
-
* @param pipelineType - The WASM pipeline type this provider uses
|
|
725
|
-
*/
|
|
726
|
-
constructor(pipelineType) {
|
|
727
|
-
this._isInitialized = false;
|
|
728
|
-
this.pipelineType = pipelineType;
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Returns whether this provider has been initialized.
|
|
732
|
-
*/
|
|
733
|
-
get initialized() {
|
|
734
|
-
return this._isInitialized;
|
|
735
|
-
}
|
|
736
|
-
getPipelineType() {
|
|
737
|
-
if (this.pipelineType === void 0) throw new Error(`${this.constructor.name} has no pipeline type configured.`);
|
|
738
|
-
return this.pipelineType;
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Initializes the provider by ensuring WASM is loaded
|
|
742
|
-
* @param config - Provider configuration
|
|
743
|
-
* @param pipeline - The pipeline type to warm up ('selfie', 'idCapture', etc.)
|
|
744
|
-
*/
|
|
745
|
-
async initializeBase(config, pipeline) {
|
|
746
|
-
if (this._isInitialized) return;
|
|
747
|
-
const status = getWasmStatus();
|
|
748
|
-
if (status.isLoading || isWasmReady() || status.error) await waitForWasm();
|
|
749
|
-
else {
|
|
750
|
-
if (!config.wasmPath || !config.glueCodePath) throw new Error("WASM path and glue code path are required. Call warmupWasm() first.");
|
|
751
|
-
await warmupWasm({
|
|
752
|
-
wasmPath: config.wasmPath,
|
|
753
|
-
wasmSimdPath: config.wasmSimdPath,
|
|
754
|
-
glueCodePath: config.glueCodePath,
|
|
755
|
-
glueCodeSimdPath: config.glueCodeSimdPath,
|
|
756
|
-
useSimd: config.useSimd,
|
|
757
|
-
modelsBasePath: config.modelsBasePath,
|
|
758
|
-
pipelines: [pipeline]
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
this._isInitialized = true;
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Ensures the provider is initialized before performing operations.
|
|
765
|
-
* @throws Error if not initialized
|
|
766
|
-
*/
|
|
767
|
-
ensureInitialized() {
|
|
768
|
-
if (!this._isInitialized) throw new Error(`${this.constructor.name} not initialized. Call initialize() first.`);
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Processes a frame through the WASM pipeline
|
|
772
|
-
* @param image - Image data to process
|
|
773
|
-
* @returns The pipeline result (type depends on pipeline - WASM returns any)
|
|
774
|
-
*/
|
|
775
|
-
async processFrameWasm(image) {
|
|
776
|
-
this.ensureInitialized();
|
|
777
|
-
const pipelineType = this.getPipelineType();
|
|
778
|
-
await mlWasmJSApi_default.allocateImageBuffers(image.width, image.height);
|
|
779
|
-
await mlWasmJSApi_default.handleDetectionCallAndUpdateState(pipelineType);
|
|
780
|
-
return await mlWasmJSApi_default.process(image, pipelineType);
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Resets the pipeline to its initial state.
|
|
784
|
-
* Safe to call even if not initialized (no-op in that case).
|
|
785
|
-
*/
|
|
786
|
-
reset() {
|
|
787
|
-
if (this._isInitialized && this.pipelineType !== void 0) mlWasmJSApi_default.resetPipeline(this.pipelineType);
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* Disposes of resources and resets initialization state.
|
|
791
|
-
* Safe to call even if not initialized.
|
|
792
|
-
*/
|
|
793
|
-
async dispose() {
|
|
794
|
-
this.reset();
|
|
795
|
-
this._isInitialized = false;
|
|
796
|
-
}
|
|
797
|
-
};
|
|
798
|
-
//#endregion
|
|
799
|
-
//#region ../infra/src/providers/wasm/WasmUtilProvider.ts
|
|
800
|
-
var WasmUtilProvider = class WasmUtilProvider extends BaseWasmProvider {
|
|
801
|
-
static async getInstance() {
|
|
802
|
-
if (WasmUtilProvider.instance) return WasmUtilProvider.instance;
|
|
803
|
-
if (WasmUtilProvider.initPromise) return WasmUtilProvider.initPromise;
|
|
804
|
-
WasmUtilProvider.initPromise = (async () => {
|
|
805
|
-
const instance = new WasmUtilProvider();
|
|
806
|
-
await instance.initializeBase({}, "selfie");
|
|
807
|
-
WasmUtilProvider.instance = instance;
|
|
808
|
-
return instance;
|
|
809
|
-
})();
|
|
810
|
-
return WasmUtilProvider.initPromise;
|
|
811
|
-
}
|
|
812
|
-
static resetInstance() {
|
|
813
|
-
WasmUtilProvider.instance = void 0;
|
|
814
|
-
WasmUtilProvider.initPromise = void 0;
|
|
815
|
-
}
|
|
816
|
-
constructor() {
|
|
817
|
-
super(void 0);
|
|
818
|
-
}
|
|
819
|
-
async initialize(config) {
|
|
820
|
-
if (this.initialized) return;
|
|
821
|
-
const pipeline = config.pipelines?.[0] ?? "selfie";
|
|
822
|
-
await this.initializeBase(config, pipeline);
|
|
823
|
-
}
|
|
824
|
-
async processFrame(_image) {
|
|
825
|
-
throw new Error("WasmUtilProvider does not support frame processing. Use encryptImage() instead.");
|
|
826
|
-
}
|
|
827
|
-
encryptImage(image) {
|
|
828
|
-
this.ensureInitialized();
|
|
829
|
-
return mlWasmJSApi_default.ens(image);
|
|
830
|
-
}
|
|
831
|
-
setSdkVersion(version) {
|
|
832
|
-
this.ensureInitialized();
|
|
833
|
-
mlWasmJSApi_default.setSdkVersion(version);
|
|
834
|
-
}
|
|
835
|
-
setSdkPlatform(platform) {
|
|
836
|
-
this.ensureInitialized();
|
|
837
|
-
mlWasmJSApi_default.setSdkPlatform(platform);
|
|
838
|
-
}
|
|
839
|
-
setDeviceInfo(deviceInfo, overrideExisting = true) {
|
|
840
|
-
this.ensureInitialized();
|
|
841
|
-
mlWasmJSApi_default.setDeviceInfo(deviceInfo, overrideExisting);
|
|
842
|
-
}
|
|
843
|
-
setBrowserInfo(browserInfo, overrideExisting = true) {
|
|
844
|
-
this.ensureInitialized();
|
|
845
|
-
mlWasmJSApi_default.setBrowserInfo(browserInfo, overrideExisting);
|
|
846
|
-
}
|
|
847
|
-
setCameraInfo(cameraInfo, overrideExisting = true) {
|
|
848
|
-
this.ensureInitialized();
|
|
849
|
-
mlWasmJSApi_default.setCameraInfo(cameraInfo, overrideExisting);
|
|
850
|
-
}
|
|
851
|
-
setMotionStatus(status) {
|
|
852
|
-
this.ensureInitialized();
|
|
853
|
-
mlWasmJSApi_default.setMotionStatus(status);
|
|
854
|
-
}
|
|
855
|
-
setBackgroundMode(backgroundMode) {
|
|
856
|
-
this.ensureInitialized();
|
|
857
|
-
mlWasmJSApi_default.setBackgroundMode(backgroundMode);
|
|
858
|
-
}
|
|
859
|
-
setOnDeviceMode(enabled) {
|
|
860
|
-
this.ensureInitialized();
|
|
861
|
-
mlWasmJSApi_default.setOnDeviceMode(enabled);
|
|
862
|
-
}
|
|
863
|
-
setZc(zc) {
|
|
864
|
-
this.ensureInitialized();
|
|
865
|
-
mlWasmJSApi_default.setZc(zc);
|
|
866
|
-
}
|
|
867
|
-
setInspectorOpened(opened) {
|
|
868
|
-
this.ensureInitialized();
|
|
869
|
-
mlWasmJSApi_default.setInspectorOpened(opened);
|
|
870
|
-
}
|
|
871
|
-
getInspectorOpened() {
|
|
872
|
-
return mlWasmJSApi_default.getInspectorOpened();
|
|
873
|
-
}
|
|
874
|
-
/**
|
|
875
|
-
* Toggles the WASM module's production mode. When `true`, the native module
|
|
876
|
-
* suppresses its verbose debug logging/console output; when `false`, those
|
|
877
|
-
* logs are emitted. The SDK forces this to `true` by default and only flips
|
|
878
|
-
* it off when the caller opts in via `setup({ wasm: { showLogs: true } })`.
|
|
879
|
-
*
|
|
880
|
-
* @param productionMode - `true` to silence WASM logs, `false` to emit them.
|
|
881
|
-
*/
|
|
882
|
-
async setProductionMode(productionMode) {
|
|
883
|
-
this.ensureInitialized();
|
|
884
|
-
await mlWasmJSApi_default.setProductionMode(productionMode);
|
|
885
|
-
}
|
|
886
|
-
getMetadata() {
|
|
887
|
-
this.ensureInitialized();
|
|
888
|
-
return mlWasmJSApi_default.getMetadata();
|
|
889
|
-
}
|
|
890
|
-
async analyzeFrame(image) {
|
|
891
|
-
this.ensureInitialized();
|
|
892
|
-
await mlWasmJSApi_default.analyzeFrame(image);
|
|
893
|
-
}
|
|
894
|
-
getCheck() {
|
|
895
|
-
this.ensureInitialized();
|
|
896
|
-
return mlWasmJSApi_default.getCheck();
|
|
897
|
-
}
|
|
898
|
-
getPipelineState() {
|
|
899
|
-
this.ensureInitialized();
|
|
900
|
-
return mlWasmJSApi_default.getPipelineState();
|
|
901
|
-
}
|
|
902
|
-
estimatePerformance() {
|
|
903
|
-
this.ensureInitialized();
|
|
904
|
-
return mlWasmJSApi_default.estimatePerformance();
|
|
905
|
-
}
|
|
906
|
-
isVirtualCamera(label) {
|
|
907
|
-
this.ensureInitialized();
|
|
908
|
-
return mlWasmJSApi_default.isVirtualCamera(label);
|
|
909
|
-
}
|
|
910
|
-
async prc() {
|
|
911
|
-
this.ensureInitialized();
|
|
912
|
-
await mlWasmJSApi_default.prc();
|
|
913
|
-
}
|
|
914
|
-
async poc(output) {
|
|
915
|
-
this.ensureInitialized();
|
|
916
|
-
await mlWasmJSApi_default.poc(output);
|
|
917
|
-
}
|
|
918
|
-
async rsp() {
|
|
919
|
-
this.ensureInitialized();
|
|
920
|
-
await mlWasmJSApi_default.rsp();
|
|
921
|
-
}
|
|
922
|
-
ssl() {
|
|
923
|
-
this.ensureInitialized();
|
|
924
|
-
mlWasmJSApi_default.ssl();
|
|
925
|
-
}
|
|
926
|
-
stl() {
|
|
927
|
-
this.ensureInitialized();
|
|
928
|
-
mlWasmJSApi_default.stl();
|
|
929
|
-
}
|
|
930
|
-
osv() {
|
|
931
|
-
this.ensureInitialized();
|
|
932
|
-
mlWasmJSApi_default.osv();
|
|
933
|
-
}
|
|
934
|
-
oev() {
|
|
935
|
-
this.ensureInitialized();
|
|
936
|
-
mlWasmJSApi_default.oev();
|
|
937
|
-
}
|
|
938
|
-
ckvcks(data) {
|
|
939
|
-
this.ensureInitialized();
|
|
940
|
-
mlWasmJSApi_default.ckvcks(data);
|
|
941
|
-
}
|
|
942
|
-
async getVersions() {
|
|
943
|
-
this.ensureInitialized();
|
|
944
|
-
return mlWasmJSApi_default.getVersions();
|
|
945
|
-
}
|
|
946
|
-
};
|
|
947
|
-
//#endregion
|
|
948
|
-
//#region ../infra/src/storage/safeStorage.ts
|
|
949
|
-
/**
|
|
950
|
-
* Storage resolvers that tolerate hosts which make Web Storage unreachable.
|
|
951
|
-
*
|
|
952
|
-
* Two hostile shapes occur in the field, and they fail differently:
|
|
953
|
-
*
|
|
954
|
-
* 1. **Deleted bare global** — a page mitigates self-XSS with
|
|
955
|
-
* `delete window.localStorage` and keeps a module-private reference. Since
|
|
956
|
-
* `window` *is* the global object, the identifier stops resolving: a bare
|
|
957
|
-
* read throws `ReferenceError`. `typeof` is the only safe probe, because it
|
|
958
|
-
* is the one operator that tolerates an unresolvable identifier.
|
|
959
|
-
* 2. **Blocked storage** — a webview or a cross-origin/partitioned context
|
|
960
|
-
* makes the accessor itself throw (`SecurityError`). Here `typeof` is *not*
|
|
961
|
-
* enough: it invokes the getter, so the throw escapes the guard.
|
|
962
|
-
*
|
|
963
|
-
* Handling only one shape leaves the other live, so always go through these
|
|
964
|
-
* resolvers instead of touching the globals directly. A `null` return means
|
|
965
|
-
* "no storage in this host" — callers degrade, they do not throw.
|
|
966
|
-
*/
|
|
967
|
-
function resolveLocalStorage() {
|
|
968
|
-
try {
|
|
969
|
-
return typeof localStorage === "undefined" ? null : localStorage;
|
|
970
|
-
} catch {
|
|
971
|
-
return null;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
function resolveSessionStorage() {
|
|
975
|
-
try {
|
|
976
|
-
return typeof sessionStorage === "undefined" ? null : sessionStorage;
|
|
977
|
-
} catch {
|
|
978
|
-
return null;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
//#endregion
|
|
982
|
-
export { getResolvedModelsBasePath as a, mlWasmJSApi_default as c, BaseWasmProvider as i, resolveSessionStorage as n, setWasmOnDeviceMode as o, WasmUtilProvider as r, warmupWasm as s, resolveLocalStorage as t };
|