@incodetech/core 0.0.0-dev-20260911-aec162f0 → 0.0.0-dev-20260914-8aef7789
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/{FaceDetectionProvider-Cn1wS-sA.d.ts → BaseWasmProvider-CO0GfaHM.d.ts} +7 -37
- package/dist/{BrowserDiagnosticsCryptoProvider-8sT0QLgq.esm.js → BrowserDiagnosticsCryptoProvider-BoYzmYY5.esm.js} +1 -1
- package/dist/{onDeviceFaceResults-hle2Ci9l.esm.js → FaceDetectionProvider-0bWjPgW5.esm.js} +219 -340
- package/dist/FaceDetectionProvider-CyLxkzRP.d.ts +36 -0
- package/dist/{IIdCaptureCapability-DDWlQzhi.d.ts → IIdCaptureCapability-nfpic2z2.d.ts} +7 -3
- package/dist/{IWasmUtilCapability-SNPhmIwB.d.ts → IWasmUtilCapability-DaP6pfHq.d.ts} +10 -4
- package/dist/{MotionSensorProvider-Vlyhbcty.esm.js → MotionSensorProvider-BnZ8_1Sk.esm.js} +1 -1
- package/dist/{StreamCanvasCapture-D2XcXCZ4.esm.js → StreamCanvasCapture-C9jtgBdT.esm.js} +2 -2
- package/dist/{deepsightService-MZOpj7Vp.d.ts → StreamCanvasCapture-D9Dz8kqB.d.ts} +54 -41
- package/dist/ae-signature.esm.js +1 -1
- package/dist/{apiError-XdhqSAmg.esm.js → apiError-CixFeCyt.esm.js} +1 -1
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.esm.js +2 -2
- package/dist/{authenticationManager-DqBOkMzk.esm.js → authenticationManager-CN26fkJa.esm.js} +4 -4
- package/dist/{authenticationManager-BCkV6CSG.d.ts → authenticationManager-D7UUqgnN.d.ts} +1 -1
- package/dist/{authenticationStateMachine-Cto_G5bN.esm.js → authenticationStateMachine-CUXpIxAD.esm.js} +6 -62
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.esm.js +1 -1
- package/dist/{backCameraStream-DE_5qY04.esm.js → backCameraStream-BOtyQowf.esm.js} +75 -18
- 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/createCameraCycleOwnership-DQ5-F2oW.esm.js +826 -0
- package/dist/{createFaceAvatar-DQKaRise.esm.js → createFaceAvatar-BNHdeFj8.esm.js} +2 -2
- package/dist/{createFaceAvatar-pUEkdk4X.d.ts → createFaceAvatar-CTM9aj9Q.d.ts} +12 -6
- package/dist/curp-validation.d.ts +1 -1
- package/dist/{curpValidationManager-cSd2MrOQ.d.ts → curpValidationManager-CTJB2RsD.d.ts} +1 -1
- package/dist/{deepsightLoader-Dwr1zKFa.esm.js → deepsightLoader-Dhz9T_KJ.esm.js} +19 -53
- package/dist/document-capture.esm.js +2 -2
- package/dist/{documentCaptureManager-BTpHZMgW.esm.js → documentCaptureManager-BwcbMwo5.esm.js} +1 -1
- package/dist/{documentCaptureStateMachine-CPizkpcg.esm.js → documentCaptureStateMachine-F8SCOtL_.esm.js} +4 -4
- package/dist/dynamic-forms.esm.js +2 -2
- package/dist/{dynamicFormsManager-Cmh84Nz4.esm.js → dynamicFormsManager-CNBrBOR3.esm.js} +1 -1
- package/dist/{dynamicFormsStateMachine-DZr7Ugvy.esm.js → dynamicFormsStateMachine-Bo2qrjHB.esm.js} +1 -1
- package/dist/ekyb.d.ts +1 -1
- package/dist/ekyb.esm.js +3 -3
- package/dist/{ekybManager-Dc2tT9fu.esm.js → ekybManager-D8DdfRAD.esm.js} +1 -1
- package/dist/{ekybStateMachine-GSEMOiHn.esm.js → ekybStateMachine-oPCbEFob.esm.js} +1 -1
- package/dist/electronic-signature.esm.js +1 -1
- package/dist/{electronicSignatureManager-CpLuqw7T.esm.js → electronicSignatureManager-DkKQ07vx.esm.js} +1 -1
- package/dist/extensibility.d.ts +11 -58
- package/dist/extensibility.esm.js +13 -13
- package/dist/{faceCaptureManagerFactory-kDmbL0I7.esm.js → faceCaptureManagerFactory-D_EjQnnE.esm.js} +19 -4
- package/dist/{faceCaptureManagerFactory-CzUr_ZPq.d.ts → faceCaptureManagerFactory-DqrYpjA5.d.ts} +24 -12
- package/dist/{faceCaptureSetup-CAGBnLVx.esm.js → faceCaptureSetup-WeO8-TfR.esm.js} +999 -382
- package/dist/{feature-management-B6CtmH1O.esm.js → feature-management-BEqf3Sr3.esm.js} +1 -1
- package/dist/feature-management.esm.js +1 -1
- package/dist/fiscal-qr.esm.js +1 -1
- package/dist/{fiscalQrManager-DI6uOffY.esm.js → fiscalQrManager-Bp_-3LJr.esm.js} +3 -3
- package/dist/flow-events.d.ts +1 -1
- package/dist/flow.d.ts +6 -6
- package/dist/flow.esm.js +3 -3
- package/dist/{flowCompletionService-BpoZDpAn.esm.js → flowCompletionService-DELbVeL5.esm.js} +1 -1
- package/dist/{flowServices-BVnSStkh.esm.js → flowServices-Brr2fh_c.esm.js} +5 -5
- package/dist/geolocation.esm.js +2 -2
- package/dist/{geolocationManager-CLm86P8G.esm.js → geolocationManager-CtVZDjng.esm.js} +1 -1
- package/dist/{geolocationStateMachine-Bi3vy7Wl.esm.js → geolocationStateMachine-tjsYcMhr.esm.js} +1 -1
- package/dist/home.d.ts +1 -1
- package/dist/id-selfie-flow.d.ts +3 -3
- package/dist/id-selfie-flow.esm.js +10 -10
- package/dist/id.d.ts +4 -4
- package/dist/id.esm.js +35 -44
- package/dist/{idCaptureDefaults-BLsd7shz.esm.js → idCaptureDefaults-C66YvkgN.esm.js} +19 -14
- package/dist/{idCaptureManager-DW1GeEUk.d.ts → idCaptureManager-DE_jyr5X.d.ts} +98 -37
- package/dist/{idCaptureManager-BUTdcmaD.esm.js → idCaptureManager-zjul9YdZ.esm.js} +27 -17
- package/dist/{idCaptureServices-fzIhBqAK.esm.js → idCaptureServices-UXYCBZPK.esm.js} +80 -20
- package/dist/{idCaptureStateMachine-Cp2_revF.esm.js → idCaptureStateMachine-D3pqfK2Z.esm.js} +1954 -1082
- package/dist/{index-1PoJuUJ-.d.ts → index-BGxFwnld.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/mandatory-consent.d.ts +2 -2
- package/dist/{mandatoryConsentManager-BJnylLZO.d.ts → mandatoryConsentManager-CZwhsUlO.d.ts} +1 -1
- package/dist/{permissionGuards-DxbvOoZJ.esm.js → permissionGuards-o1JLtewE.esm.js} +1 -1
- package/dist/{permissionServices-f7nBnW5P.esm.js → permissionServices-7lzEiOsO.esm.js} +3 -3
- package/dist/personhood.d.ts +5 -5
- package/dist/personhood.esm.js +8 -8
- package/dist/qe-signature.esm.js +1 -1
- package/dist/{runChildModule-BPlX2IDO.esm.js → runChildModule-BDlvNMrA.esm.js} +1 -1
- package/dist/{safeStorage-Dp9m6aOh.esm.js → safeStorage-1O9k0ulP.esm.js} +8 -8
- package/dist/{sdkVersion-Dr9_E3d9.esm.js → sdkVersion-CS_0s_Lc.esm.js} +1 -1
- package/dist/selfie.d.ts +4 -4
- package/dist/selfie.esm.js +12 -74
- package/dist/{selfieManager-BdP-RgH4.esm.js → selfieManager-BouB9yUQ.esm.js} +4 -4
- package/dist/{selfieManager-Bg_Xwe4p.d.ts → selfieManager-DZ3u_WN9.d.ts} +1 -1
- package/dist/{selfieStateMachine-B8vFeT39.esm.js → selfieStateMachine-TGfI9hNp.esm.js} +22 -31
- package/dist/{session-C2THUsQZ.esm.js → session-m9j27bHm.esm.js} +3 -3
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +4 -4
- package/dist/{sessionInitializer-CEycxhm4.esm.js → sessionInitializer-CUpgbHzs.esm.js} +4 -4
- package/dist/{setup-D6yz9se2.d.ts → setup-CEX95gJ1.d.ts} +11 -6
- package/dist/{setup-BHJ3-fhX.esm.js → setup-CfNAVG-d.esm.js} +12 -11
- package/dist/{trueSightService-DLzYznkh.esm.js → trueSightService-TqmmYye3.esm.js} +4 -4
- package/dist/types-BhHF-CuL.d.ts +6 -0
- package/dist/{types-DJ2OM9rw.d.ts → types-BzuUebkB.d.ts} +1 -1
- package/dist/{types-DzmqFoCH.d.ts → types-CBctcPeF.d.ts} +1 -1
- package/dist/{types-BBI4-s9u2.d.ts → types-CoOlCUp82.d.ts} +5 -5
- package/dist/{types-hSqUyXyw.d.ts → types-DL0CXuWv.d.ts} +3 -3
- package/dist/types-Ds928RiU.d.ts +1 -0
- package/dist/{types-_pWNFY1F.d.ts → types-eLtVBhon.d.ts} +1 -1
- package/dist/video-selfie.d.ts +3 -3
- package/dist/video-selfie.esm.js +5 -5
- package/dist/{videoSelfieCameraWarmer-D5E12WjL.esm.js → videoSelfieCameraWarmer-C-cESczy.esm.js} +9 -9
- package/dist/{videoSelfieStepDetector-B8TvFDNK.d.ts → videoSelfieStepDetector-CdXIFh9s.d.ts} +4 -4
- package/dist/virtualCameraCheck-WOloJ-do.esm.js +48 -0
- package/dist/{warmup-BOM-sD-6.esm.js → warmup-CUUnwYxe.esm.js} +282 -90
- package/dist/{warmup-CXHBgvFC.d.ts → warmup-Cis2p6O0.d.ts} +13 -2
- package/dist/wasm.d.ts +9 -3
- package/dist/wasm.esm.js +10 -4
- package/dist/{wasmDsFlagSync-C3k_VK9o.esm.js → wasmDsFlagSync-BJtLh2XK.esm.js} +1 -1
- package/dist/{wasmWebClient-BJCaFeBL.esm.js → wasmWebClient-B7baE-Wf.esm.js} +223 -2
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.esm.js +15 -15
- package/package.json +1 -1
- package/dist/imageFile-CLaua6xO.esm.js +0 -69
- package/dist/types-m4t_cT5J.d.ts +0 -6
- 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/{selfieErrorUtils-C6gC06J7.esm.js → selfieErrorUtils-C77GXJH6.esm.js} +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as WASM_PIPELINE_OPTIONAL_MODEL_NAMES, b as resolveWasmSource, d as SemaphoreProvider, h as WASM_PIPELINE_MODELS, l as loadWasmModule, n as createWebApiHostAdapter, p as WASM_MODEL_FILES, u as acquireWasmStorageFallback, v as buildModelVariantSources, y as missingWasmModelError } from "./wasmWebClient-B7baE-Wf.esm.js";
|
|
2
2
|
//#region ../infra/src/wasm/wasmEnumMaps.ts
|
|
3
3
|
function pipelineTypeToWasmEnum(wasmModule, type) {
|
|
4
4
|
switch (type) {
|
|
@@ -8,6 +8,9 @@ function pipelineTypeToWasmEnum(wasmModule, type) {
|
|
|
8
8
|
case 3: return wasmModule.WorkflowType.SelfieWithAggregationMetrics;
|
|
9
9
|
case 4: return wasmModule.WorkflowType.SelfieWithQualityMetrics;
|
|
10
10
|
case 5: return wasmModule.WorkflowType.OnDeviceSelfieWorkflow;
|
|
11
|
+
case 6: return wasmModule.WorkflowType.IdBlurGlareCoreWorkflow;
|
|
12
|
+
case 7: return wasmModule.WorkflowType.IdBarcodeAndTextQualityCoreWorkflow;
|
|
13
|
+
case 8: return wasmModule.WorkflowType.IdFaceQualityCoreWorkflow;
|
|
11
14
|
default: throw new Error("Unknown pipeline type");
|
|
12
15
|
}
|
|
13
16
|
}
|
|
@@ -19,6 +22,9 @@ function pipelineTypeFromWasmEnum(wasmModule, type) {
|
|
|
19
22
|
case wasmModule.WorkflowType.SelfieWithAggregationMetrics: return 3;
|
|
20
23
|
case wasmModule.WorkflowType.SelfieWithQualityMetrics: return 4;
|
|
21
24
|
case wasmModule.WorkflowType.OnDeviceSelfieWorkflow: return 5;
|
|
25
|
+
case wasmModule.WorkflowType.IdBlurGlareCoreWorkflow: return 6;
|
|
26
|
+
case wasmModule.WorkflowType.IdBarcodeAndTextQualityCoreWorkflow: return 7;
|
|
27
|
+
case wasmModule.WorkflowType.IdFaceQualityCoreWorkflow: return 8;
|
|
22
28
|
default: throw new Error("Unknown pipeline type");
|
|
23
29
|
}
|
|
24
30
|
}
|
|
@@ -39,10 +45,85 @@ function idCaptureModelTypeFromWasmEnum(wasmModule, type) {
|
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
//#endregion
|
|
48
|
+
//#region ../infra/src/wasm/CameraCycleOwnershipDomain.ts
|
|
49
|
+
const CAMERA_CYCLE_OWNERSHIP_DOMAIN = Symbol("cameraCycleOwnershipDomain");
|
|
50
|
+
var CameraCycleOwnershipDomain = class {
|
|
51
|
+
constructor() {
|
|
52
|
+
this.generation = 0;
|
|
53
|
+
}
|
|
54
|
+
snapshot() {
|
|
55
|
+
return {
|
|
56
|
+
generation: this.generation,
|
|
57
|
+
activeOwner: this.activeOwner
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
transfer(owner) {
|
|
61
|
+
this.generation += 1;
|
|
62
|
+
this.activeOwner = owner;
|
|
63
|
+
}
|
|
64
|
+
releaseController(creationGeneration, createdWithoutOwner) {
|
|
65
|
+
if (!createdWithoutOwner || this.generation !== creationGeneration || this.activeOwner !== void 0) return false;
|
|
66
|
+
this.generation += 1;
|
|
67
|
+
this.activeOwner = void 0;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
releaseAttempt(owner) {
|
|
71
|
+
if (this.activeOwner !== owner) return false;
|
|
72
|
+
this.generation += 1;
|
|
73
|
+
this.activeOwner = void 0;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function getCameraCycleOwnershipDomain(owner) {
|
|
78
|
+
const domainOwner = owner;
|
|
79
|
+
const existing = domainOwner[CAMERA_CYCLE_OWNERSHIP_DOMAIN];
|
|
80
|
+
if (existing) return existing;
|
|
81
|
+
const domain = new CameraCycleOwnershipDomain();
|
|
82
|
+
Object.defineProperty(domainOwner, CAMERA_CYCLE_OWNERSHIP_DOMAIN, {
|
|
83
|
+
configurable: false,
|
|
84
|
+
enumerable: false,
|
|
85
|
+
value: domain,
|
|
86
|
+
writable: false
|
|
87
|
+
});
|
|
88
|
+
return domain;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
42
91
|
//#region ../infra/src/wasm/WasmRuntime.ts
|
|
92
|
+
function attemptCleanup(firstFailure, cleanup) {
|
|
93
|
+
try {
|
|
94
|
+
cleanup();
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return firstFailure ?? { error };
|
|
97
|
+
}
|
|
98
|
+
return firstFailure;
|
|
99
|
+
}
|
|
100
|
+
function stopStreamTracks(stream) {
|
|
101
|
+
let firstFailure = null;
|
|
102
|
+
let tracks = [];
|
|
103
|
+
try {
|
|
104
|
+
tracks = stream?.getTracks() ?? [];
|
|
105
|
+
} catch (error) {
|
|
106
|
+
firstFailure = { error };
|
|
107
|
+
}
|
|
108
|
+
for (const track of tracks) try {
|
|
109
|
+
track.stop();
|
|
110
|
+
} catch (error) {
|
|
111
|
+
firstFailure ??= { error };
|
|
112
|
+
}
|
|
113
|
+
return firstFailure;
|
|
114
|
+
}
|
|
115
|
+
function deleteWasmHandle(firstFailure, handle) {
|
|
116
|
+
const deleteHandle = handle?.delete;
|
|
117
|
+
if (!deleteHandle) return firstFailure;
|
|
118
|
+
return attemptCleanup(firstFailure, () => deleteHandle.call(handle));
|
|
119
|
+
}
|
|
120
|
+
function releaseCameraCycleResources(stream, cameraCycleApi) {
|
|
121
|
+
return attemptCleanup(stopStreamTracks(stream), () => cameraCycleApi?.rcc());
|
|
122
|
+
}
|
|
43
123
|
var WasmRuntime = class WasmRuntime {
|
|
44
124
|
constructor(loadModule = loadWasmModule) {
|
|
45
125
|
this.loadModule = loadModule;
|
|
126
|
+
this[CAMERA_CYCLE_OWNERSHIP_DOMAIN] = new CameraCycleOwnershipDomain();
|
|
46
127
|
this.loadedModels = /* @__PURE__ */ new Map();
|
|
47
128
|
this.modelsBuffers = null;
|
|
48
129
|
this.inputImageBuffer = null;
|
|
@@ -51,27 +132,39 @@ var WasmRuntime = class WasmRuntime {
|
|
|
51
132
|
this.utilityApi = null;
|
|
52
133
|
this.idCaptureWasmApi = null;
|
|
53
134
|
this.faceProcessingWasmApi = null;
|
|
135
|
+
this.cameraCycleApi = null;
|
|
54
136
|
this.webApi = null;
|
|
137
|
+
this.storageFallbackLease = null;
|
|
138
|
+
this.unprotectedStream = null;
|
|
55
139
|
this.imageWidth_ = null;
|
|
56
140
|
this.imageHeight_ = null;
|
|
57
141
|
this.pipelines_ = null;
|
|
58
142
|
this.isInitialized_ = false;
|
|
59
|
-
this.
|
|
143
|
+
this.usedSimd_ = true;
|
|
60
144
|
this.mlCallSemaphore = new SemaphoreProvider();
|
|
61
145
|
}
|
|
62
146
|
async initialize({ module, pipelines }) {
|
|
63
147
|
await this.freeResources();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
148
|
+
try {
|
|
149
|
+
this.pipelines_ = pipelines;
|
|
150
|
+
this.storageFallbackLease = acquireWasmStorageFallback();
|
|
151
|
+
const { wasmModule, simdUsed } = await this.loadModule(module);
|
|
152
|
+
this.wasmModule = wasmModule;
|
|
153
|
+
this.usedSimd_ = simdUsed;
|
|
154
|
+
this.workflowApiUtilities = new this.wasmModule.WorkflowApiUtilities();
|
|
155
|
+
this.utilityApi = new this.wasmModule.UtilityApi();
|
|
156
|
+
this.idCaptureWasmApi = new this.wasmModule.IdCaptureApi();
|
|
157
|
+
this.faceProcessingWasmApi = new this.wasmModule.FaceProcessingApi();
|
|
158
|
+
this.cameraCycleApi = new this.wasmModule.CameraCycleApi();
|
|
159
|
+
this.webApi = new this.wasmModule.WebApi(createWebApiHostAdapter());
|
|
160
|
+
this.isInitialized_ = true;
|
|
161
|
+
return simdUsed;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
try {
|
|
164
|
+
await this.freeResources();
|
|
165
|
+
} catch {}
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
75
168
|
}
|
|
76
169
|
/**
|
|
77
170
|
* Returns initialization status
|
|
@@ -88,7 +181,7 @@ var WasmRuntime = class WasmRuntime {
|
|
|
88
181
|
*/
|
|
89
182
|
async allocateImageBuffers(imageWidth, imageHeight) {
|
|
90
183
|
const workflowApiUtilities = this.requireWorkflowApiUtilities("Unable to allocate image buffers, cpp API hasn't been initialized");
|
|
91
|
-
if (imageWidth && imageHeight && imageWidth == this.imageWidth_ && imageHeight == this.imageHeight_ && this.inputImageBuffer && imageWidth * imageHeight * 4 === this.inputImageBuffer.length) return;
|
|
184
|
+
if (imageWidth && imageHeight && imageWidth == this.imageWidth_ && imageHeight == this.imageHeight_ && this.inputImageBuffer && this.inputImageBuffer.byteLength !== 0 && imageWidth * imageHeight * 4 === this.inputImageBuffer.length) return;
|
|
92
185
|
this.imageWidth_ = imageWidth;
|
|
93
186
|
this.imageHeight_ = imageHeight;
|
|
94
187
|
this.inputImageBuffer = workflowApiUtilities.allocateInputImageBuffer(imageWidth, imageHeight, 4);
|
|
@@ -109,7 +202,7 @@ var WasmRuntime = class WasmRuntime {
|
|
|
109
202
|
*/
|
|
110
203
|
writeFrame(image) {
|
|
111
204
|
if (this.inputImageBuffer === null) throw new Error("Unable to process the image, buffers haven't been allocated!");
|
|
112
|
-
this.inputImageBuffer.set(image.data);
|
|
205
|
+
if (image) this.inputImageBuffer.set(image.data);
|
|
113
206
|
}
|
|
114
207
|
async handleDetectionCallAndUpdateState(type) {
|
|
115
208
|
this.requireWorkflowApiUtilities("Unable to update pipeline state, cpp API hasn't been initialized").handleDetectionCallAndUpdateState(this.pipelineTypeToWasmEnum(type));
|
|
@@ -119,32 +212,41 @@ var WasmRuntime = class WasmRuntime {
|
|
|
119
212
|
*/
|
|
120
213
|
async freeResources() {
|
|
121
214
|
this.loadedModels.clear();
|
|
215
|
+
const stream = this.unprotectedStream;
|
|
216
|
+
const modelsBuffers = this.modelsBuffers;
|
|
217
|
+
const workflowApiUtilities = this.workflowApiUtilities;
|
|
218
|
+
const utilityApi = this.utilityApi;
|
|
219
|
+
const idCaptureWasmApi = this.idCaptureWasmApi;
|
|
220
|
+
const faceProcessingWasmApi = this.faceProcessingWasmApi;
|
|
221
|
+
const cameraCycleApi = this.cameraCycleApi;
|
|
222
|
+
const webApi = this.webApi;
|
|
223
|
+
const storageFallbackLease = this.storageFallbackLease;
|
|
224
|
+
this.unprotectedStream = null;
|
|
225
|
+
this.workflowApiUtilities = null;
|
|
226
|
+
this.utilityApi = null;
|
|
227
|
+
this.idCaptureWasmApi = null;
|
|
228
|
+
this.faceProcessingWasmApi = null;
|
|
229
|
+
this.cameraCycleApi = null;
|
|
230
|
+
this.webApi = null;
|
|
231
|
+
this.storageFallbackLease = null;
|
|
232
|
+
this.wasmModule = null;
|
|
122
233
|
this.modelsBuffers = null;
|
|
123
234
|
this.inputImageBuffer = null;
|
|
124
235
|
this.imageWidth_ = null;
|
|
125
236
|
this.imageHeight_ = null;
|
|
126
237
|
this.pipelines_ = null;
|
|
127
|
-
if (typeof window !== "undefined") window.wasmArrayBuffer = null;
|
|
128
|
-
if (this.workflowApiUtilities && typeof this.workflowApiUtilities.delete === "function") {
|
|
129
|
-
this.workflowApiUtilities.delete();
|
|
130
|
-
this.workflowApiUtilities = null;
|
|
131
|
-
}
|
|
132
|
-
if (this.utilityApi && typeof this.utilityApi.delete === "function") {
|
|
133
|
-
this.utilityApi.delete();
|
|
134
|
-
this.utilityApi = null;
|
|
135
|
-
}
|
|
136
|
-
if (this.idCaptureWasmApi && typeof this.idCaptureWasmApi.delete === "function") {
|
|
137
|
-
this.idCaptureWasmApi.delete();
|
|
138
|
-
this.idCaptureWasmApi = null;
|
|
139
|
-
}
|
|
140
|
-
if (this.faceProcessingWasmApi && typeof this.faceProcessingWasmApi.delete === "function") {
|
|
141
|
-
this.faceProcessingWasmApi.delete();
|
|
142
|
-
this.faceProcessingWasmApi = null;
|
|
143
|
-
}
|
|
144
|
-
if (this.webApi && typeof this.webApi.delete === "function") this.webApi.delete();
|
|
145
|
-
this.webApi = null;
|
|
146
|
-
this.wasmModule = null;
|
|
147
238
|
this.isInitialized_ = false;
|
|
239
|
+
if (typeof window !== "undefined") window.wasmArrayBuffer = null;
|
|
240
|
+
let firstFailure = releaseCameraCycleResources(stream, cameraCycleApi);
|
|
241
|
+
firstFailure = deleteWasmHandle(firstFailure, modelsBuffers);
|
|
242
|
+
firstFailure = deleteWasmHandle(firstFailure, workflowApiUtilities);
|
|
243
|
+
firstFailure = deleteWasmHandle(firstFailure, utilityApi);
|
|
244
|
+
firstFailure = deleteWasmHandle(firstFailure, idCaptureWasmApi);
|
|
245
|
+
firstFailure = deleteWasmHandle(firstFailure, faceProcessingWasmApi);
|
|
246
|
+
firstFailure = deleteWasmHandle(firstFailure, cameraCycleApi);
|
|
247
|
+
firstFailure = deleteWasmHandle(firstFailure, webApi);
|
|
248
|
+
firstFailure = attemptCleanup(firstFailure, () => storageFallbackLease?.release());
|
|
249
|
+
if (firstFailure) throw firstFailure.error;
|
|
148
250
|
}
|
|
149
251
|
/**
|
|
150
252
|
* Clear pipeline state
|
|
@@ -160,20 +262,23 @@ var WasmRuntime = class WasmRuntime {
|
|
|
160
262
|
if (!this.isInitialized() || pipelines === null) throw new Error("Unable to reset pipelines, cpp API hasn't been initialized");
|
|
161
263
|
for (const [type] of pipelines) this.resetPipeline(type);
|
|
162
264
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* @returns
|
|
168
|
-
*/
|
|
169
|
-
async process(image, type) {
|
|
265
|
+
async process(typeOrImage, imageOrType) {
|
|
266
|
+
const legacyOrder = typeof typeOrImage !== "number";
|
|
267
|
+
const type = legacyOrder ? typeof imageOrType === "number" ? imageOrType : void 0 : typeOrImage;
|
|
268
|
+
const image = legacyOrder ? typeOrImage : typeof imageOrType === "number" ? void 0 : imageOrType;
|
|
170
269
|
const message = "Unable to process the image, cpp API hasn't been initialized";
|
|
171
270
|
const idCaptureWasmApi = this.requireIdCaptureApi(message);
|
|
172
271
|
const faceProcessingWasmApi = this.requireFaceProcessingApi(message);
|
|
173
|
-
|
|
272
|
+
if (image) {
|
|
273
|
+
await this.allocateImageBuffers(image.width, image.height);
|
|
274
|
+
this.writeFrame(image);
|
|
275
|
+
}
|
|
174
276
|
switch (type) {
|
|
175
277
|
case 0:
|
|
176
|
-
case 1:
|
|
278
|
+
case 1:
|
|
279
|
+
case 6:
|
|
280
|
+
case 7:
|
|
281
|
+
case 8: return idCaptureWasmApi.runIdCaptureWorkflow(this.pipelineTypeToWasmEnum(type));
|
|
177
282
|
case 2: return idCaptureWasmApi.runIdVideoSelfieWorkflow();
|
|
178
283
|
case 3:
|
|
179
284
|
case 4:
|
|
@@ -186,38 +291,53 @@ var WasmRuntime = class WasmRuntime {
|
|
|
186
291
|
const buffSizes = new (this.requireWasmModule(message)).WorkflowTypeToIntMap();
|
|
187
292
|
const modelData = /* @__PURE__ */ new Map();
|
|
188
293
|
const sizeVectors = [];
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.
|
|
294
|
+
let operationFailure = null;
|
|
295
|
+
let cleanupFailure = null;
|
|
296
|
+
try {
|
|
297
|
+
if (pipelines === null) throw new Error(message);
|
|
298
|
+
for (const [type, modelsPaths] of pipelines) {
|
|
299
|
+
const wasmType = this.pipelineTypeToWasmEnum(type);
|
|
300
|
+
const pipelineBuffers = [];
|
|
301
|
+
const sizes = new (this.requireWasmModule(message)).VectorInt();
|
|
302
|
+
sizeVectors.push(sizes);
|
|
303
|
+
for (const path of modelsPaths) {
|
|
304
|
+
const resolvedSource = this.resolveModelSource(path);
|
|
305
|
+
let model = this.loadedModels.get(resolvedSource);
|
|
306
|
+
if (!model) {
|
|
307
|
+
model = await resolveWasmSource(resolvedSource, "model");
|
|
308
|
+
this.loadedModels.set(resolvedSource, model);
|
|
309
|
+
}
|
|
310
|
+
sizes.push_back(model.byteLength);
|
|
311
|
+
pipelineBuffers.push(model);
|
|
200
312
|
}
|
|
201
|
-
|
|
202
|
-
|
|
313
|
+
buffSizes.set(wasmType, sizes);
|
|
314
|
+
modelData.set(wasmType, pipelineBuffers);
|
|
203
315
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
316
|
+
const modelsBuffers = this.requireWorkflowApiUtilities(message).allocateModelsBuffers(buffSizes);
|
|
317
|
+
for (const [type, paths] of pipelines) this.pipelines_?.set(type, paths);
|
|
318
|
+
this.modelsBuffers = modelsBuffers;
|
|
319
|
+
for (const [type, data] of modelData) {
|
|
320
|
+
let buffers = null;
|
|
321
|
+
try {
|
|
322
|
+
buffers = modelsBuffers.get(type) ?? null;
|
|
323
|
+
if (!buffers) throw new Error("Unable to get model buffer from shared memory!");
|
|
324
|
+
for (let k = 0; k < buffers.size(); k++) {
|
|
325
|
+
const buffer = buffers.get(k);
|
|
326
|
+
if (buffer) buffer.set(data[k]);
|
|
327
|
+
else throw new Error("Unable to get model buffer from shared memory!");
|
|
328
|
+
}
|
|
329
|
+
} finally {
|
|
330
|
+
cleanupFailure = deleteWasmHandle(cleanupFailure, buffers);
|
|
331
|
+
}
|
|
219
332
|
}
|
|
333
|
+
} catch (error) {
|
|
334
|
+
operationFailure = { error };
|
|
335
|
+
} finally {
|
|
336
|
+
for (const sizes of sizeVectors) cleanupFailure = deleteWasmHandle(cleanupFailure, sizes);
|
|
337
|
+
cleanupFailure = deleteWasmHandle(cleanupFailure, buffSizes);
|
|
220
338
|
}
|
|
339
|
+
if (operationFailure) throw operationFailure.error;
|
|
340
|
+
if (cleanupFailure) throw cleanupFailure.error;
|
|
221
341
|
}
|
|
222
342
|
async initializePipelines() {
|
|
223
343
|
const message = "Unable to initialize pipelines, cpp API hasn't been initialized";
|
|
@@ -232,9 +352,46 @@ var WasmRuntime = class WasmRuntime {
|
|
|
232
352
|
const workflowApiUtilities = this.requireWorkflowApiUtilities("Unable to get current pipeline, cpp API hasn't been initialized");
|
|
233
353
|
return this.pipelineTypeFromWasmEnum(workflowApiUtilities.getCurrentWorkflow());
|
|
234
354
|
}
|
|
235
|
-
setOnDeviceMode(
|
|
236
|
-
|
|
237
|
-
|
|
355
|
+
setOnDeviceMode(_enabled) {}
|
|
356
|
+
adoptCameraStream(stream, constraints, options = {}) {
|
|
357
|
+
return this.requireCameraCycleApi("Unable to adopt stream, cpp API hasn't been initialized").ads(stream, constraints, options);
|
|
358
|
+
}
|
|
359
|
+
setWorkflowConsuming(type, consuming) {
|
|
360
|
+
const accepted = this.requireWorkflowApiUtilities("Unable to set workflow consuming, cpp API hasn't been initialized").setWorkflowConsuming(this.pipelineTypeToWasmEnum(type), consuming);
|
|
361
|
+
return consuming ? accepted : true;
|
|
362
|
+
}
|
|
363
|
+
captureProtectedFrame(target) {
|
|
364
|
+
return this.requireCameraCycleApi("Unable to capture protected frame, cpp API hasn't been initialized").mcp(target);
|
|
365
|
+
}
|
|
366
|
+
paintFrameToCanvas(canvas, options) {
|
|
367
|
+
return this.requireCameraCycleApi("Unable to paint frame, cpp API hasn't been initialized").pfc(canvas, options);
|
|
368
|
+
}
|
|
369
|
+
getCaptureSize() {
|
|
370
|
+
return this.requireCameraCycleApi("Unable to get capture size, cpp API hasn't been initialized").gcs();
|
|
371
|
+
}
|
|
372
|
+
getUnprotectedStream() {
|
|
373
|
+
const nextStream = this.requireCameraCycleApi("Unable to get unprotected stream, cpp API hasn't been initialized").gus();
|
|
374
|
+
const previousStream = this.unprotectedStream;
|
|
375
|
+
this.unprotectedStream = nextStream;
|
|
376
|
+
if (previousStream && previousStream !== nextStream) {
|
|
377
|
+
const failure = stopStreamTracks(previousStream);
|
|
378
|
+
if (failure) throw failure.error;
|
|
379
|
+
}
|
|
380
|
+
return nextStream;
|
|
381
|
+
}
|
|
382
|
+
postProtectedRequest(request) {
|
|
383
|
+
const extras = "extras" in request ? request.extras : {};
|
|
384
|
+
return this.requireWebApi("Unable to post protected request, cpp API hasn't been initialized").pse(request.target, extras, request.config ?? {});
|
|
385
|
+
}
|
|
386
|
+
releaseCameraCycle() {
|
|
387
|
+
const stream = this.unprotectedStream;
|
|
388
|
+
this.unprotectedStream = null;
|
|
389
|
+
const firstFailure = releaseCameraCycleResources(stream, this.cameraCycleApi);
|
|
390
|
+
if (firstFailure) throw firstFailure.error;
|
|
391
|
+
}
|
|
392
|
+
resolveModelSource(source) {
|
|
393
|
+
if (typeof source === "object" && !(source instanceof ArrayBuffer) && !(source instanceof Uint8Array)) return this.usedSimd_ ? source.current : source.legacy;
|
|
394
|
+
return source;
|
|
238
395
|
}
|
|
239
396
|
pipelineTypeToWasmEnum(type) {
|
|
240
397
|
return pipelineTypeToWasmEnum(this.requireWasmModule(WasmRuntime.UNINITIALIZED_ENUM_MAP_MESSAGE), type);
|
|
@@ -284,6 +441,10 @@ var WasmRuntime = class WasmRuntime {
|
|
|
284
441
|
if (!this.isInitialized() || this.faceProcessingWasmApi === null) throw new Error(message);
|
|
285
442
|
return this.faceProcessingWasmApi;
|
|
286
443
|
}
|
|
444
|
+
requireCameraCycleApi(message) {
|
|
445
|
+
if (!this.isInitialized() || this.cameraCycleApi === null) throw new Error(message);
|
|
446
|
+
return this.cameraCycleApi;
|
|
447
|
+
}
|
|
287
448
|
requireWasmModule(message) {
|
|
288
449
|
if (!this.isInitialized() || this.wasmModule === null) throw new Error(message);
|
|
289
450
|
return this.wasmModule;
|
|
@@ -310,6 +471,7 @@ let loadingPromise = null;
|
|
|
310
471
|
let wasmError = null;
|
|
311
472
|
let loadedPipelines = [];
|
|
312
473
|
let lastConfig = null;
|
|
474
|
+
let lastModelVariant = null;
|
|
313
475
|
let pipelinesInFlight = [];
|
|
314
476
|
function mapPipelineToWasmType(pipeline) {
|
|
315
477
|
switch (pipeline) {
|
|
@@ -345,12 +507,35 @@ function getResolvedModelsBasePath() {
|
|
|
345
507
|
}
|
|
346
508
|
function getResolvedModelSource(fileName, pipeline) {
|
|
347
509
|
if (!lastConfig) return;
|
|
348
|
-
const explicit = lastConfig.modelUrls?.[fileName];
|
|
510
|
+
const explicit = lastModelVariant === "legacy" ? lastConfig.legacyModelUrls?.[fileName] ?? lastConfig.modelUrls?.[fileName] : lastConfig.modelUrls?.[fileName];
|
|
349
511
|
if (explicit !== void 0) return explicit;
|
|
350
512
|
if (lastConfig.selfHosted) throw missingWasmModelError(fileName, pipeline);
|
|
351
513
|
const basePath = getResolvedModelsBasePath();
|
|
352
514
|
if (!basePath) return;
|
|
353
|
-
|
|
515
|
+
const source = buildModelVariantSources(basePath, fileName);
|
|
516
|
+
if (typeof source === "string") return source;
|
|
517
|
+
return lastModelVariant === "legacy" ? source.legacy : source.current;
|
|
518
|
+
}
|
|
519
|
+
function resolveConfiguredModelSource(config, modelFile, pipeline, modelsBasePath) {
|
|
520
|
+
const current = config.modelUrls?.[modelFile];
|
|
521
|
+
if (current === void 0) {
|
|
522
|
+
if (config.selfHosted) throw missingWasmModelError(modelFile, pipeline);
|
|
523
|
+
if (!modelsBasePath) throw new Error("[Incode SDK] modelsBasePath is required when wasmPath is a byte source.");
|
|
524
|
+
return buildModelVariantSources(modelsBasePath, modelFile);
|
|
525
|
+
}
|
|
526
|
+
const legacy = config.legacyModelUrls?.[modelFile];
|
|
527
|
+
return legacy === void 0 ? current : {
|
|
528
|
+
current,
|
|
529
|
+
legacy
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Warns once per warmup that an optional model listed in
|
|
534
|
+
* {@link WASM_PIPELINE_OPTIONAL_MODEL_NAMES} was not supplied, so the Core
|
|
535
|
+
* profile that needs it is skipped instead of failing the whole warmup.
|
|
536
|
+
*/
|
|
537
|
+
function warnMissingOptionalModel(pipeline, models) {
|
|
538
|
+
console.warn(`[Incode SDK] The "${pipeline}" self-hosted WASM configuration omits ${models.join(", ")}. The protected ID face-quality workflow stays unavailable; ID capture is unaffected.`);
|
|
354
539
|
}
|
|
355
540
|
/**
|
|
356
541
|
* Builds the pipelines map with model paths for WASM initialization.
|
|
@@ -363,14 +548,20 @@ function buildPipelinesMap(pipelines, config) {
|
|
|
363
548
|
for (const pipeline of pipelines) {
|
|
364
549
|
const wasmType = mapPipelineToWasmType(pipeline);
|
|
365
550
|
if (!pipelinesMap.has(wasmType)) {
|
|
366
|
-
const modelPaths = (config.pipelineModels?.[pipeline] ?? WASM_PIPELINE_MODELS[pipeline]).map((modelFile) =>
|
|
367
|
-
const explicit = config.modelUrls?.[modelFile];
|
|
368
|
-
if (explicit !== void 0) return explicit;
|
|
369
|
-
if (config.selfHosted) throw missingWasmModelError(modelFile, pipeline);
|
|
370
|
-
if (!modelsBasePath) throw new Error("[Incode SDK] modelsBasePath is required when wasmPath is a byte source.");
|
|
371
|
-
return `${modelsBasePath}/${modelFile}`;
|
|
372
|
-
});
|
|
551
|
+
const modelPaths = (config.pipelineModels?.[pipeline] ?? WASM_PIPELINE_MODELS[pipeline]).map((modelFile) => resolveConfiguredModelSource(config, modelFile, pipeline, modelsBasePath));
|
|
373
552
|
pipelinesMap.set(wasmType, modelPaths);
|
|
553
|
+
if (pipeline === "idCapture") {
|
|
554
|
+
const resolveIdModels = (modelFiles) => modelFiles.map((modelFile) => resolveConfiguredModelSource(config, modelFile, pipeline, modelsBasePath));
|
|
555
|
+
pipelinesMap.set(6, resolveIdModels([WASM_MODEL_FILES.idCapture]));
|
|
556
|
+
pipelinesMap.set(7, resolveIdModels([WASM_MODEL_FILES.idCapture]));
|
|
557
|
+
const missingOptional = WASM_PIPELINE_OPTIONAL_MODEL_NAMES[pipeline].filter((name) => config.selfHosted === true && config.modelUrls?.[WASM_MODEL_FILES[name]] === void 0);
|
|
558
|
+
if (missingOptional.length === 0) pipelinesMap.set(8, resolveIdModels([
|
|
559
|
+
WASM_MODEL_FILES.idCapture,
|
|
560
|
+
WASM_MODEL_FILES.idFiqa,
|
|
561
|
+
WASM_MODEL_FILES.idFaceDetector
|
|
562
|
+
]));
|
|
563
|
+
else warnMissingOptionalModel(pipeline, missingOptional);
|
|
564
|
+
}
|
|
374
565
|
}
|
|
375
566
|
}
|
|
376
567
|
return pipelinesMap;
|
|
@@ -449,13 +640,14 @@ async function warmupWasm(config) {
|
|
|
449
640
|
try {
|
|
450
641
|
const pipelinesMap = buildPipelinesMap(pipelines, config);
|
|
451
642
|
if (config.onDeviceMode !== void 0) wasmRuntime.setOnDeviceMode(config.onDeviceMode);
|
|
452
|
-
await wasmRuntime.initialize({
|
|
643
|
+
const simdUsed = await wasmRuntime.initialize({
|
|
453
644
|
module: config,
|
|
454
645
|
pipelines: pipelinesMap
|
|
455
646
|
});
|
|
456
647
|
await wasmRuntime.loadModels();
|
|
457
648
|
await wasmRuntime.initializePipelines();
|
|
458
649
|
state = "ready";
|
|
650
|
+
lastModelVariant = simdUsed ? "current" : "legacy";
|
|
459
651
|
loadedPipelines = [...pipelines];
|
|
460
652
|
lastConfig = {
|
|
461
653
|
...config,
|
|
@@ -464,6 +656,7 @@ async function warmupWasm(config) {
|
|
|
464
656
|
loadingPromise = null;
|
|
465
657
|
} catch (error) {
|
|
466
658
|
state = "error";
|
|
659
|
+
lastModelVariant = null;
|
|
467
660
|
wasmError = error instanceof Error ? error : new Error(String(error));
|
|
468
661
|
loadingPromise = null;
|
|
469
662
|
pipelinesInFlight = [];
|
|
@@ -510,13 +703,12 @@ function waitForWasm() {
|
|
|
510
703
|
return Promise.reject(/* @__PURE__ */ new Error("WASM warmup was not started. Call warmupWasm() first."));
|
|
511
704
|
}
|
|
512
705
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* the intent is honored even by lazy warmups whose config does not carry it.
|
|
706
|
+
* Retained compatibility surface for callers that used the removed native
|
|
707
|
+
* on-device-mode setter. Both values are native-free no-ops for the pinned
|
|
708
|
+
* runtime and do not alter initialization, capture, or fingerprint lifecycle.
|
|
517
709
|
*/
|
|
518
710
|
function setWasmOnDeviceMode(enabled) {
|
|
519
711
|
wasmRuntime.setOnDeviceMode(enabled);
|
|
520
712
|
}
|
|
521
713
|
//#endregion
|
|
522
|
-
export { waitForWasm as a, setWasmOnDeviceMode as i, getWasmStatus as n, warmupWasm as o, isWasmReady as r, wasmRuntime as s, getResolvedModelSource as t };
|
|
714
|
+
export { waitForWasm as a, CAMERA_CYCLE_OWNERSHIP_DOMAIN as c, setWasmOnDeviceMode as i, getCameraCycleOwnershipDomain as l, getWasmStatus as n, warmupWasm as o, isWasmReady as r, wasmRuntime as s, getResolvedModelSource as t };
|
|
@@ -8,6 +8,7 @@ type WasmPipeline = 'selfie' | 'onDeviceSelfie' | 'idCapture' | 'videoSelfie' |
|
|
|
8
8
|
declare const WASM_MODEL_FILES: {
|
|
9
9
|
readonly idCapture: "id_capture_2_01_fp16.ortmodelv2";
|
|
10
10
|
readonly idFiqa: "id_fiqa_19a81a0b9bf6492eb03b4667f6db4c85_fp16.ortmodelv2";
|
|
11
|
+
readonly idFaceDetector: "id_facedetector_v2_1_fp16.ortmodelv2";
|
|
11
12
|
readonly barcode: "barcode_enhance_896x224_fp16.ortmodelv2";
|
|
12
13
|
readonly selfie: "selfie_bf_angles_192x192_opset9_fp16.ortmodelv2";
|
|
13
14
|
readonly faceAttributes: "face_attributes_v1_3_fp16.ortmodelv2";
|
|
@@ -27,7 +28,9 @@ declare global {
|
|
|
27
28
|
}
|
|
28
29
|
/** Opaque handle for the loaded WASM module instance. */
|
|
29
30
|
type WasmModule = Record<string, unknown>;
|
|
30
|
-
type WasmGlueFactory = (
|
|
31
|
+
type WasmGlueFactory = (options?: Readonly<{
|
|
32
|
+
wasmBinary?: Uint8Array;
|
|
33
|
+
}>) => Promise<WasmModule>;
|
|
31
34
|
/**
|
|
32
35
|
* Binary and glue configuration for one WASM module instance.
|
|
33
36
|
*
|
|
@@ -71,6 +74,11 @@ type WasmModelsConfig = {
|
|
|
71
74
|
modelsBasePath?: string;
|
|
72
75
|
/** Fully resolved source for each model filename. */
|
|
73
76
|
modelUrls?: Readonly<Record<string, WasmSource>>;
|
|
77
|
+
/**
|
|
78
|
+
* Optional non-SIMD model sources paired with {@link modelUrls}. Used only
|
|
79
|
+
* when SIMD initialization falls back to the standard WASM binary.
|
|
80
|
+
*/
|
|
81
|
+
legacyModelUrls?: Readonly<Record<string, WasmSource>>;
|
|
74
82
|
/** Prevents unresolved models from falling back to the Incode CDN. */
|
|
75
83
|
selfHosted?: boolean;
|
|
76
84
|
};
|
|
@@ -81,7 +89,10 @@ type WarmupConfig = WasmModuleConfig & WasmModelsConfig & {
|
|
|
81
89
|
pipelines?: readonly WasmPipeline[];
|
|
82
90
|
/** Model filename overrides for individual pipelines. */
|
|
83
91
|
pipelineModels?: Partial<Record<WasmPipeline, string[]>>;
|
|
84
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Compatibility-only hint. The pinned runtime accepts either
|
|
94
|
+
* value without changing native initialization or fingerprint lifecycle.
|
|
95
|
+
*/
|
|
85
96
|
onDeviceMode?: boolean;
|
|
86
97
|
};
|
|
87
98
|
/**
|
package/dist/wasm.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as WASM_MODEL_FILES, c as WasmPipeline, l as WasmSource, o as WasmGlueLoader, r as warmupWasm, s as WasmModelName, t as WarmupConfig } from "./warmup-
|
|
2
|
-
import { c as setWasmConfig, i as initializeWasmUtil, n as WasmConfig, r as ensureWasmPipelines, s as resolveWasmConfigForPipelines, u as upgradeToWasmHttpClient } from "./setup-
|
|
1
|
+
import { a as WASM_MODEL_FILES, c as WasmPipeline, l as WasmSource, o as WasmGlueLoader, r as warmupWasm, s as WasmModelName, t as WarmupConfig } from "./warmup-Cis2p6O0.js";
|
|
2
|
+
import { c as setWasmConfig, i as initializeWasmUtil, n as WasmConfig, r as ensureWasmPipelines, s as resolveWasmConfigForPipelines, u as upgradeToWasmHttpClient } from "./setup-CEX95gJ1.js";
|
|
3
3
|
//#region ../infra/src/wasm/wasmDefaults.d.ts
|
|
4
4
|
/** The WASM version bundled and tested with this SDK release. */
|
|
5
|
-
declare const DEFAULT_WASM_VERSION = "v2.14.
|
|
5
|
+
declare const DEFAULT_WASM_VERSION = "v2.14.49-post1";
|
|
6
6
|
type UrlWasmConfig = WarmupConfig & {
|
|
7
7
|
wasmPath: string;
|
|
8
8
|
wasmSimdPath: string;
|
|
@@ -28,6 +28,12 @@ type DefineWasmOptions = {
|
|
|
28
28
|
glue: WasmGlueLoader;
|
|
29
29
|
glueSimd?: WasmGlueLoader;
|
|
30
30
|
models: Partial<Record<WasmModelName, WasmSource>>;
|
|
31
|
+
/**
|
|
32
|
+
* Optional non-SIMD model package. When supplied, it must include the same
|
|
33
|
+
* eager and lazy models as {@link models}; the loader selects it only after
|
|
34
|
+
* a failed SIMD initialization.
|
|
35
|
+
*/
|
|
36
|
+
legacyModels?: Partial<Record<WasmModelName, WasmSource>>;
|
|
31
37
|
};
|
|
32
38
|
declare function defineWasm(options: DefineWasmOptions): WasmConfig;
|
|
33
39
|
//#endregion
|
package/dist/wasm.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as resolveWasmConfigForPipelines, c as upgradeToWasmHttpClient, d as buildDefaultWasmConfig, f as buildWasmConfigFromBasePath, m as resolveWasmConfig, n as initializeWasmUtil, o as setWasmConfig, t as ensureWasmPipelines, u as DEFAULT_WASM_VERSION } from "./setup-
|
|
3
|
-
import { o as warmupWasm } from "./warmup-
|
|
1
|
+
import { g as WASM_PIPELINE_MODEL_NAMES, m as WASM_PIPELINE_LAZY_MODEL_NAMES, p as WASM_MODEL_FILES } from "./wasmWebClient-B7baE-Wf.esm.js";
|
|
2
|
+
import { a as resolveWasmConfigForPipelines, c as upgradeToWasmHttpClient, d as buildDefaultWasmConfig, f as buildWasmConfigFromBasePath, m as resolveWasmConfig, n as initializeWasmUtil, o as setWasmConfig, t as ensureWasmPipelines, u as DEFAULT_WASM_VERSION } from "./setup-CfNAVG-d.esm.js";
|
|
3
|
+
import { o as warmupWasm } from "./warmup-CUUnwYxe.esm.js";
|
|
4
4
|
//#region src/defineWasm.ts
|
|
5
5
|
function requiredModels(pipelines) {
|
|
6
6
|
const models = /* @__PURE__ */ new Set();
|
|
@@ -12,9 +12,14 @@ function requiredModels(pipelines) {
|
|
|
12
12
|
}
|
|
13
13
|
function defineWasm(options) {
|
|
14
14
|
if (options.wasmSimd === void 0 !== (options.glueSimd === void 0)) throw new Error("[Incode SDK] wasmSimd and glueSimd must be provided together.");
|
|
15
|
-
for (const model of requiredModels(options.pipelines))
|
|
15
|
+
for (const model of requiredModels(options.pipelines)) {
|
|
16
|
+
if (options.models[model] === void 0) throw new Error(`[Incode SDK] The self-hosted WASM configuration is missing the "${model}" model.`);
|
|
17
|
+
if (options.legacyModels !== void 0 && options.legacyModels[model] === void 0) throw new Error(`[Incode SDK] The self-hosted non-SIMD WASM configuration is missing the "${model}" model.`);
|
|
18
|
+
}
|
|
16
19
|
const modelUrls = {};
|
|
17
20
|
for (const [name, source] of Object.entries(options.models)) if (source !== void 0) modelUrls[WASM_MODEL_FILES[name]] = source;
|
|
21
|
+
const legacyModelUrls = {};
|
|
22
|
+
for (const [name, source] of Object.entries(options.legacyModels ?? {})) if (source !== void 0) legacyModelUrls[WASM_MODEL_FILES[name]] = source;
|
|
18
23
|
return {
|
|
19
24
|
wasmPath: options.wasm,
|
|
20
25
|
wasmSimdPath: options.wasmSimd,
|
|
@@ -23,6 +28,7 @@ function defineWasm(options) {
|
|
|
23
28
|
useSimd: options.wasmSimd !== void 0,
|
|
24
29
|
pipelines: [...options.pipelines],
|
|
25
30
|
modelUrls,
|
|
31
|
+
legacyModelUrls: options.legacyModels === void 0 ? void 0 : legacyModelUrls,
|
|
26
32
|
selfHosted: true
|
|
27
33
|
};
|
|
28
34
|
}
|