@incodetech/core 2.0.0-alpha.1 → 2.0.0-alpha.11
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/Manager-Cy9-TMC9.d.ts +19 -0
- package/dist/OpenViduLogger-20ZYS-mT.esm.js +3 -0
- package/dist/OpenViduLogger-5b7KqNTo.esm.js +803 -0
- package/dist/StateMachine-BqPpBhOz.d.ts +2 -0
- package/dist/addEvent-s2Za-pK3.esm.js +16 -0
- package/dist/chunk-C_Yo44FK.esm.js +49 -0
- package/dist/deepsightLoader-Bn2D0REl.esm.js +25 -0
- package/dist/email.d.ts +264 -0
- package/dist/email.esm.js +479 -0
- package/dist/endpoints-B0ltwtb5.esm.js +2335 -0
- package/dist/flow.d.ts +578 -0
- package/dist/flow.esm.js +628 -0
- package/dist/getBrowser-CLEzz0Hi.esm.js +8 -0
- package/dist/index.d.ts +226 -0
- package/dist/index.esm.js +156 -0
- package/dist/lib-CykGFCEr.esm.js +11700 -0
- package/dist/permissionServices-BhD0KxsO.esm.js +66 -0
- package/dist/phone.d.ts +292 -0
- package/dist/phone.esm.js +550 -0
- package/dist/recordingsRepository-CTjaf-ER.esm.js +256 -0
- package/dist/selfie.d.ts +821 -0
- package/dist/selfie.esm.js +1087 -0
- package/dist/types-Dif6MQmX.d.ts +5 -0
- package/dist/warmup-Cijuyvoc.d.ts +55 -0
- package/dist/xstate.esm-2T5fOCTq.esm.js +3261 -0
- package/package.json +14 -11
- package/src/camera/cameraActor.ts +0 -21
- package/src/camera/cameraService.test.ts +0 -437
- package/src/camera/cameraService.ts +0 -165
- package/src/camera/cameraServices.test.ts +0 -66
- package/src/camera/cameraServices.ts +0 -26
- package/src/camera/cameraStateMachine.test.ts +0 -602
- package/src/camera/cameraStateMachine.ts +0 -264
- package/src/camera/index.ts +0 -5
- package/src/camera/types.ts +0 -17
- package/src/device/getBrowser.ts +0 -31
- package/src/device/getDeviceClass.ts +0 -29
- package/src/device/index.ts +0 -2
- package/src/email/__mocks__/emailMocks.ts +0 -59
- package/src/email/emailActor.ts +0 -15
- package/src/email/emailManager.test.ts +0 -573
- package/src/email/emailManager.ts +0 -427
- package/src/email/emailServices.ts +0 -66
- package/src/email/emailStateMachine.test.ts +0 -741
- package/src/email/emailStateMachine.ts +0 -367
- package/src/email/index.ts +0 -39
- package/src/email/types.ts +0 -60
- package/src/events/addEvent.ts +0 -20
- package/src/events/types.ts +0 -7
- package/src/flow/__mocks__/flowMocks.ts +0 -84
- package/src/flow/flowActor.ts +0 -13
- package/src/flow/flowAnalyzer.test.ts +0 -266
- package/src/flow/flowAnalyzer.ts +0 -37
- package/src/flow/flowCompletionService.ts +0 -21
- package/src/flow/flowManager.test.ts +0 -560
- package/src/flow/flowManager.ts +0 -235
- package/src/flow/flowServices.test.ts +0 -109
- package/src/flow/flowServices.ts +0 -13
- package/src/flow/flowStateMachine.test.ts +0 -334
- package/src/flow/flowStateMachine.ts +0 -182
- package/src/flow/index.ts +0 -21
- package/src/flow/moduleLoader.test.ts +0 -136
- package/src/flow/moduleLoader.ts +0 -73
- package/src/flow/orchestratedFlowManager.test.ts +0 -240
- package/src/flow/orchestratedFlowManager.ts +0 -231
- package/src/flow/orchestratedFlowStateMachine.test.ts +0 -199
- package/src/flow/orchestratedFlowStateMachine.ts +0 -325
- package/src/flow/types.ts +0 -434
- package/src/http/__mocks__/api.ts +0 -88
- package/src/http/api.test.ts +0 -231
- package/src/http/api.ts +0 -90
- package/src/http/endpoints.ts +0 -17
- package/src/index.ts +0 -33
- package/src/permissions/index.ts +0 -2
- package/src/permissions/permissionServices.ts +0 -31
- package/src/permissions/types.ts +0 -3
- package/src/phone/__mocks__/phoneMocks.ts +0 -71
- package/src/phone/index.ts +0 -39
- package/src/phone/phoneActor.ts +0 -15
- package/src/phone/phoneManager.test.ts +0 -393
- package/src/phone/phoneManager.ts +0 -458
- package/src/phone/phoneServices.ts +0 -98
- package/src/phone/phoneStateMachine.test.ts +0 -918
- package/src/phone/phoneStateMachine.ts +0 -422
- package/src/phone/types.ts +0 -83
- package/src/recordings/recordingsRepository.test.ts +0 -87
- package/src/recordings/recordingsRepository.ts +0 -48
- package/src/recordings/streamingEvents.ts +0 -10
- package/src/selfie/__mocks__/selfieMocks.ts +0 -26
- package/src/selfie/index.ts +0 -14
- package/src/selfie/selfieActor.ts +0 -17
- package/src/selfie/selfieErrorUtils.test.ts +0 -116
- package/src/selfie/selfieErrorUtils.ts +0 -66
- package/src/selfie/selfieManager.test.ts +0 -297
- package/src/selfie/selfieManager.ts +0 -301
- package/src/selfie/selfieServices.ts +0 -362
- package/src/selfie/selfieStateMachine.test.ts +0 -283
- package/src/selfie/selfieStateMachine.ts +0 -804
- package/src/selfie/selfieUploadService.test.ts +0 -90
- package/src/selfie/selfieUploadService.ts +0 -81
- package/src/selfie/types.ts +0 -103
- package/src/session/index.ts +0 -5
- package/src/session/sessionService.ts +0 -78
- package/src/setup.test.ts +0 -61
- package/src/setup.ts +0 -171
- package/tsconfig.json +0 -13
- package/tsdown.config.ts +0 -22
- package/vitest.config.ts +0 -37
- package/vitest.setup.ts +0 -135
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { n as warmupWasm, t as WasmPipeline } from "./warmup-Cijuyvoc.js";
|
|
2
|
+
import { n as PermissionStatus, t as PermissionResult } from "./types-Dif6MQmX.js";
|
|
3
|
+
|
|
4
|
+
//#region ../infra/src/http/types.d.ts
|
|
5
|
+
type CreateApiConfig = {
|
|
6
|
+
apiURL: string;
|
|
7
|
+
customHeaders?: Record<string, string>;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
};
|
|
10
|
+
type RequestConfig = {
|
|
11
|
+
method?: string;
|
|
12
|
+
url: string;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
15
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
16
|
+
body?: unknown;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
parse?: 'json' | 'text' | 'blob' | 'arrayBuffer' | 'response';
|
|
20
|
+
};
|
|
21
|
+
type HttpResponse<T = unknown> = {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
status: number;
|
|
24
|
+
statusText: string;
|
|
25
|
+
url: string;
|
|
26
|
+
headers: Record<string, string>;
|
|
27
|
+
data: T;
|
|
28
|
+
};
|
|
29
|
+
type HttpClient = {
|
|
30
|
+
defaults: {
|
|
31
|
+
baseURL: string;
|
|
32
|
+
headers: Record<string, string>;
|
|
33
|
+
};
|
|
34
|
+
request<T = unknown>(config: RequestConfig): Promise<HttpResponse<T>>;
|
|
35
|
+
get<T = unknown>(url: string, config?: Omit<RequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
|
|
36
|
+
post<T = unknown>(url: string, body?: unknown, config?: Omit<RequestConfig, 'method' | 'url' | 'body'>): Promise<HttpResponse<T>>;
|
|
37
|
+
put<T = unknown>(url: string, body?: unknown, config?: Omit<RequestConfig, 'method' | 'url' | 'body'>): Promise<HttpResponse<T>>;
|
|
38
|
+
patch<T = unknown>(url: string, body?: unknown, config?: Omit<RequestConfig, 'method' | 'url' | 'body'>): Promise<HttpResponse<T>>;
|
|
39
|
+
delete<T = unknown>(url: string, config?: Omit<RequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
|
|
40
|
+
head<T = unknown>(url: string, config?: Omit<RequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
|
|
41
|
+
options<T = unknown>(url: string, config?: Omit<RequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
|
|
42
|
+
setHeader(name: string, value: string): void;
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region ../infra/src/http/createApi.d.ts
|
|
46
|
+
declare const createApi: (config: CreateApiConfig) => HttpClient;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/internal/device/getBrowser.d.ts
|
|
49
|
+
type Browser = 'chrome' | 'firefox' | 'safari' | 'edge' | 'other';
|
|
50
|
+
declare function getBrowser(): Browser;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/internal/device/getDeviceClass.d.ts
|
|
53
|
+
type DeviceClass = 'ios' | 'android' | 'desktop';
|
|
54
|
+
declare function getDeviceClass(): DeviceClass;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/internal/http/api.d.ts
|
|
57
|
+
type MethodConfig = {
|
|
58
|
+
headers?: Record<string, string>;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
timeout?: number;
|
|
61
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
62
|
+
};
|
|
63
|
+
type ApiClient = {
|
|
64
|
+
get<T>(url: string, config?: MethodConfig): Promise<HttpResponse<T>>;
|
|
65
|
+
post<T>(url: string, data?: unknown, config?: MethodConfig): Promise<HttpResponse<T>>;
|
|
66
|
+
put<T>(url: string, data?: unknown, config?: MethodConfig): Promise<HttpResponse<T>>;
|
|
67
|
+
patch<T>(url: string, data?: unknown, config?: MethodConfig): Promise<HttpResponse<T>>;
|
|
68
|
+
delete<T>(url: string, config?: MethodConfig): Promise<HttpResponse<T>>;
|
|
69
|
+
};
|
|
70
|
+
declare function getApi(): HttpClient;
|
|
71
|
+
declare const api: ApiClient;
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/internal/permissions/permissionServices.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* Checks the current camera permission state without prompting the user.
|
|
76
|
+
*/
|
|
77
|
+
declare function checkPermission(): Promise<PermissionResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Requests camera permission by attempting to access the camera, then immediately
|
|
80
|
+
* stops the obtained stream. This function does not keep or return the stream.
|
|
81
|
+
*/
|
|
82
|
+
declare function requestPermission(): Promise<PermissionResult>;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/internal/session/sessionService.d.ts
|
|
85
|
+
type CreateSessionOptions = {
|
|
86
|
+
/** The configuration/flow ID from the Incode dashboard */
|
|
87
|
+
configurationId: string;
|
|
88
|
+
/** External ID to associate with this session */
|
|
89
|
+
externalId?: string;
|
|
90
|
+
/** External customer ID */
|
|
91
|
+
externalCustomerId?: string;
|
|
92
|
+
/** Language for the session (e.g., 'en-US', 'es-MX') */
|
|
93
|
+
language?: string;
|
|
94
|
+
/** Custom fields to attach to the session */
|
|
95
|
+
customFields?: Record<string, unknown>;
|
|
96
|
+
/** UUID for continuing an existing session */
|
|
97
|
+
uuid?: string;
|
|
98
|
+
/** Interview ID for continuing an existing interview */
|
|
99
|
+
interviewId?: string;
|
|
100
|
+
};
|
|
101
|
+
type Session = {
|
|
102
|
+
token: string;
|
|
103
|
+
interviewId: string;
|
|
104
|
+
uuid?: string;
|
|
105
|
+
regulationType?: string;
|
|
106
|
+
showMandatoryConsent?: boolean;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Creates a new onboarding session.
|
|
110
|
+
*
|
|
111
|
+
* @param apiKey - The API key from the Incode dashboard
|
|
112
|
+
* @param options - Session creation options
|
|
113
|
+
* @param signal - Optional AbortSignal for request cancellation
|
|
114
|
+
* @returns The created session with token
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const session = await createSession('your-api-key', {
|
|
119
|
+
* configurationId: 'your-flow-id',
|
|
120
|
+
* language: 'en-US',
|
|
121
|
+
* });
|
|
122
|
+
* console.log(session.token); // Use this token for subsequent API calls
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function createSession(apiKey: string, options: CreateSessionOptions, signal?: AbortSignal): Promise<Session>;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/setup.d.ts
|
|
128
|
+
/**
|
|
129
|
+
* WASM warmup configuration.
|
|
130
|
+
*/
|
|
131
|
+
type WasmConfig = {
|
|
132
|
+
/** Path to the WASM binary */
|
|
133
|
+
wasmPath: string;
|
|
134
|
+
/** Path to the SIMD-optimized WASM binary (optional) */
|
|
135
|
+
wasmSimdPath?: string;
|
|
136
|
+
/** Path to the WASM glue code */
|
|
137
|
+
glueCodePath: string;
|
|
138
|
+
/** Whether to use SIMD optimizations (default: true) */
|
|
139
|
+
useSimd?: boolean;
|
|
140
|
+
/** Which pipelines to preload models for */
|
|
141
|
+
pipelines?: WasmPipeline[];
|
|
142
|
+
/**
|
|
143
|
+
* Base path for ML model files. Models will be loaded from `${modelsBasePath}/${modelFileName}`.
|
|
144
|
+
* If not provided, models are expected in a 'models' subdirectory relative to the WASM binary.
|
|
145
|
+
*/
|
|
146
|
+
modelsBasePath?: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Configuration options for the SDK setup.
|
|
150
|
+
*/
|
|
151
|
+
type SetupOptions = {
|
|
152
|
+
/** The base URL for the API */
|
|
153
|
+
apiURL: string;
|
|
154
|
+
/** The session token for API requests (optional - can be set later or omitted for createSession calls) */
|
|
155
|
+
token?: string;
|
|
156
|
+
/** Custom headers to include in all requests */
|
|
157
|
+
customHeaders?: Record<string, string>;
|
|
158
|
+
/** Request timeout in milliseconds */
|
|
159
|
+
timeout?: number;
|
|
160
|
+
/** Optional WASM warmup config - if provided, preloads WASM and ML models */
|
|
161
|
+
wasm?: WasmConfig;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Initializes the SDK with the provided configuration.
|
|
165
|
+
* Must be called before using any SDK functionality.
|
|
166
|
+
*
|
|
167
|
+
* If `wasm` config is provided, this function becomes async and will
|
|
168
|
+
* preload WASM binary and ML models. Otherwise, it's synchronous.
|
|
169
|
+
*
|
|
170
|
+
* @param options - Configuration options for the SDK
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* import { setup, createSession } from '@incodetech/core';
|
|
175
|
+
*
|
|
176
|
+
* // Setup with API URL first (for session creation)
|
|
177
|
+
* await setup({ apiURL: 'https://api.incode.com' });
|
|
178
|
+
* const session = await createSession('api-key', { configurationId: 'flow-id' });
|
|
179
|
+
*
|
|
180
|
+
* // Basic setup with token
|
|
181
|
+
* await setup({
|
|
182
|
+
* apiURL: 'https://api.incode.com',
|
|
183
|
+
* token: 'session-token',
|
|
184
|
+
* });
|
|
185
|
+
*
|
|
186
|
+
* // Setup with WASM warmup
|
|
187
|
+
* await setup({
|
|
188
|
+
* apiURL: 'https://api.incode.com',
|
|
189
|
+
* token: 'session-token',
|
|
190
|
+
* wasm: {
|
|
191
|
+
* wasmPath: '/wasm/ml-wasm.wasm',
|
|
192
|
+
* glueCodePath: '/wasm/ml-wasm.js',
|
|
193
|
+
* pipelines: ['selfie', 'idCapture'],
|
|
194
|
+
* },
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function setup(options: SetupOptions): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Sets the WASM configuration without performing warmup.
|
|
201
|
+
* Useful when WASM warmup is handled separately (e.g., conditionally based on flow).
|
|
202
|
+
*
|
|
203
|
+
* @param config - WASM configuration to store
|
|
204
|
+
*/
|
|
205
|
+
declare function setWasmConfig(config: WasmConfig): void;
|
|
206
|
+
/**
|
|
207
|
+
* Initializes WasmUtilProvider with the stored WASM configuration.
|
|
208
|
+
* Should be called after warmupWasm() completes when using conditional warmup.
|
|
209
|
+
* This ensures image encryption works properly.
|
|
210
|
+
*
|
|
211
|
+
* @param config - Optional WASM configuration. If not provided, uses the stored config from setWasmConfig().
|
|
212
|
+
* @throws Error if no config is provided and none is stored
|
|
213
|
+
*/
|
|
214
|
+
declare function initializeWasmUtil(config?: WasmConfig): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Checks if the SDK has been configured.
|
|
217
|
+
*
|
|
218
|
+
* @returns true if setup() has been called, false otherwise
|
|
219
|
+
*/
|
|
220
|
+
declare function isConfigured(): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Resets the SDK configuration. Useful for testing.
|
|
223
|
+
*/
|
|
224
|
+
declare function reset(): void;
|
|
225
|
+
//#endregion
|
|
226
|
+
export { type Browser, type CreateSessionOptions, type DeviceClass, type HttpClient, type PermissionResult, type PermissionStatus, type Session, type SetupOptions, type WasmConfig, type WasmPipeline, api, checkPermission as checkCameraPermission, createApi, createSession, getApi, getBrowser, getDeviceClass, initializeWasmUtil, isConfigured, requestPermission as requestCameraPermission, reset, setWasmConfig, setup, warmupWasm };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { a as resetApi, c as WasmUtilProvider, n as api, o as setClient, r as getApi, s as setToken, t as endpoints, u as warmupWasm, x as createApi_default } from "./endpoints-B0ltwtb5.esm.js";
|
|
2
|
+
import "./getBrowser-CLEzz0Hi.esm.js";
|
|
3
|
+
import { i as getBrowser, n as requestPermission, r as getDeviceClass, t as checkPermission } from "./permissionServices-BhD0KxsO.esm.js";
|
|
4
|
+
|
|
5
|
+
//#region src/internal/session/sessionService.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new onboarding session.
|
|
8
|
+
*
|
|
9
|
+
* @param apiKey - The API key from the Incode dashboard
|
|
10
|
+
* @param options - Session creation options
|
|
11
|
+
* @param signal - Optional AbortSignal for request cancellation
|
|
12
|
+
* @returns The created session with token
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const session = await createSession('your-api-key', {
|
|
17
|
+
* configurationId: 'your-flow-id',
|
|
18
|
+
* language: 'en-US',
|
|
19
|
+
* });
|
|
20
|
+
* console.log(session.token); // Use this token for subsequent API calls
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
async function createSession(apiKey, options, signal) {
|
|
24
|
+
const res = await getApi().post(endpoints.createSession, {
|
|
25
|
+
configurationId: options.configurationId,
|
|
26
|
+
externalId: options.externalId,
|
|
27
|
+
externalCustomerId: options.externalCustomerId,
|
|
28
|
+
language: options.language ?? "en-US",
|
|
29
|
+
customFields: options.customFields,
|
|
30
|
+
uuid: options.uuid ?? null,
|
|
31
|
+
interviewId: options.interviewId ?? null
|
|
32
|
+
}, {
|
|
33
|
+
headers: {
|
|
34
|
+
"x-api-key": apiKey,
|
|
35
|
+
"api-version": "1.0"
|
|
36
|
+
},
|
|
37
|
+
signal
|
|
38
|
+
});
|
|
39
|
+
if (!res.ok) throw new Error(`POST ${endpoints.createSession} failed: ${res.status} ${res.statusText}`);
|
|
40
|
+
return res.data;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/setup.ts
|
|
45
|
+
let wasmConfig;
|
|
46
|
+
let configured = false;
|
|
47
|
+
/**
|
|
48
|
+
* Initializes the SDK with the provided configuration.
|
|
49
|
+
* Must be called before using any SDK functionality.
|
|
50
|
+
*
|
|
51
|
+
* If `wasm` config is provided, this function becomes async and will
|
|
52
|
+
* preload WASM binary and ML models. Otherwise, it's synchronous.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Configuration options for the SDK
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { setup, createSession } from '@incodetech/core';
|
|
59
|
+
*
|
|
60
|
+
* // Setup with API URL first (for session creation)
|
|
61
|
+
* await setup({ apiURL: 'https://api.incode.com' });
|
|
62
|
+
* const session = await createSession('api-key', { configurationId: 'flow-id' });
|
|
63
|
+
*
|
|
64
|
+
* // Basic setup with token
|
|
65
|
+
* await setup({
|
|
66
|
+
* apiURL: 'https://api.incode.com',
|
|
67
|
+
* token: 'session-token',
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Setup with WASM warmup
|
|
71
|
+
* await setup({
|
|
72
|
+
* apiURL: 'https://api.incode.com',
|
|
73
|
+
* token: 'session-token',
|
|
74
|
+
* wasm: {
|
|
75
|
+
* wasmPath: '/wasm/ml-wasm.wasm',
|
|
76
|
+
* glueCodePath: '/wasm/ml-wasm.js',
|
|
77
|
+
* pipelines: ['selfie', 'idCapture'],
|
|
78
|
+
* },
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async function setup(options) {
|
|
83
|
+
setClient(createApi_default({
|
|
84
|
+
apiURL: options.apiURL,
|
|
85
|
+
customHeaders: options.customHeaders,
|
|
86
|
+
timeout: options.timeout
|
|
87
|
+
}));
|
|
88
|
+
if (options.token) setToken(options.token);
|
|
89
|
+
configured = true;
|
|
90
|
+
if (options.wasm) {
|
|
91
|
+
await warmupWasm({
|
|
92
|
+
wasmPath: options.wasm.wasmPath,
|
|
93
|
+
wasmSimdPath: options.wasm.wasmSimdPath,
|
|
94
|
+
glueCodePath: options.wasm.glueCodePath,
|
|
95
|
+
useSimd: options.wasm.useSimd,
|
|
96
|
+
pipelines: options.wasm.pipelines,
|
|
97
|
+
modelsBasePath: options.wasm.modelsBasePath
|
|
98
|
+
});
|
|
99
|
+
await (await WasmUtilProvider.getInstance()).initialize({
|
|
100
|
+
wasmPath: options.wasm.wasmPath,
|
|
101
|
+
wasmSimdPath: options.wasm.wasmSimdPath,
|
|
102
|
+
glueCodePath: options.wasm.glueCodePath,
|
|
103
|
+
useSimd: options.wasm.useSimd,
|
|
104
|
+
pipelines: options.wasm.pipelines,
|
|
105
|
+
modelsBasePath: options.wasm.modelsBasePath
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Sets the WASM configuration without performing warmup.
|
|
111
|
+
* Useful when WASM warmup is handled separately (e.g., conditionally based on flow).
|
|
112
|
+
*
|
|
113
|
+
* @param config - WASM configuration to store
|
|
114
|
+
*/
|
|
115
|
+
function setWasmConfig(config) {
|
|
116
|
+
wasmConfig = config;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Initializes WasmUtilProvider with the stored WASM configuration.
|
|
120
|
+
* Should be called after warmupWasm() completes when using conditional warmup.
|
|
121
|
+
* This ensures image encryption works properly.
|
|
122
|
+
*
|
|
123
|
+
* @param config - Optional WASM configuration. If not provided, uses the stored config from setWasmConfig().
|
|
124
|
+
* @throws Error if no config is provided and none is stored
|
|
125
|
+
*/
|
|
126
|
+
async function initializeWasmUtil(config) {
|
|
127
|
+
const wasmConfigToUse = config ?? wasmConfig;
|
|
128
|
+
if (!wasmConfigToUse) throw new Error("WASM config is required. Provide config parameter or call setWasmConfig() first.");
|
|
129
|
+
await (await WasmUtilProvider.getInstance()).initialize({
|
|
130
|
+
wasmPath: wasmConfigToUse.wasmPath,
|
|
131
|
+
wasmSimdPath: wasmConfigToUse.wasmSimdPath,
|
|
132
|
+
glueCodePath: wasmConfigToUse.glueCodePath,
|
|
133
|
+
useSimd: wasmConfigToUse.useSimd,
|
|
134
|
+
pipelines: wasmConfigToUse.pipelines,
|
|
135
|
+
modelsBasePath: wasmConfigToUse.modelsBasePath
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks if the SDK has been configured.
|
|
140
|
+
*
|
|
141
|
+
* @returns true if setup() has been called, false otherwise
|
|
142
|
+
*/
|
|
143
|
+
function isConfigured() {
|
|
144
|
+
return configured;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resets the SDK configuration. Useful for testing.
|
|
148
|
+
*/
|
|
149
|
+
function reset() {
|
|
150
|
+
resetApi();
|
|
151
|
+
configured = false;
|
|
152
|
+
WasmUtilProvider.resetInstance();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
export { api, checkPermission as checkCameraPermission, createApi_default as createApi, createSession, getApi, getBrowser, getDeviceClass, initializeWasmUtil, isConfigured, requestPermission as requestCameraPermission, reset, setWasmConfig, setup, warmupWasm };
|