@touchcastllc/napster-companion-api-dev 1.0.0-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +830 -0
  3. package/lib/components/Avatar/index.d.ts +35 -0
  4. package/lib/components/Embed/index.d.ts +25 -0
  5. package/lib/components/InactiveOverlay/index.d.ts +15 -0
  6. package/lib/components/Preview/index.d.ts +18 -0
  7. package/lib/components/StyledTooltip/index.d.ts +16 -0
  8. package/lib/components/VolumeControl/index.d.ts +18 -0
  9. package/lib/components/WaveForm/index.d.ts +19 -0
  10. package/lib/components/index.d.ts +2 -0
  11. package/lib/constants/events.d.ts +52 -0
  12. package/lib/constants/greenscreen.d.ts +28 -0
  13. package/lib/constants/index.d.ts +6 -0
  14. package/lib/constants/waveform.d.ts +34 -0
  15. package/lib/index.css +1 -0
  16. package/lib/index.d.ts +34 -0
  17. package/lib/index.esm.js +1 -0
  18. package/lib/index.js +1 -0
  19. package/lib/index.standalone.js +1 -0
  20. package/lib/services/analytics.d.ts +148 -0
  21. package/lib/services/faceTracking.d.ts +13 -0
  22. package/lib/services/screenShare.d.ts +15 -0
  23. package/lib/services/webrtc.d.ts +29 -0
  24. package/lib/setupTests.d.ts +1 -0
  25. package/lib/stores/index.d.ts +8 -0
  26. package/lib/stores/middleware/featuresUpdateMiddleware.d.ts +4 -0
  27. package/lib/stores/selectors.d.ts +30 -0
  28. package/lib/stores/slices/appSlice.d.ts +12 -0
  29. package/lib/stores/slices/avatarSlice.d.ts +26 -0
  30. package/lib/stores/store.d.ts +11 -0
  31. package/lib/types/abstract-typing.d.ts +35 -0
  32. package/lib/types/analytics.d.ts +95 -0
  33. package/lib/types/errors.d.ts +143 -0
  34. package/lib/types/index.d.ts +354 -0
  35. package/lib/umd.d.ts +1 -0
  36. package/lib/utils/InactiveOverlayManager.d.ts +77 -0
  37. package/lib/utils/MediaCapture.d.ts +13 -0
  38. package/lib/utils/classnames.d.ts +50 -0
  39. package/lib/utils/debug.d.ts +84 -0
  40. package/lib/utils/domFactory.d.ts +56 -0
  41. package/lib/utils/greenscreen/GreenScreenProcessor.d.ts +25 -0
  42. package/lib/utils/greenscreen/index.d.ts +1 -0
  43. package/lib/utils/index.d.ts +25 -0
  44. package/lib/utils/mouthDetection.d.ts +33 -0
  45. package/lib/utils/sendCommand.d.ts +2 -0
  46. package/lib/utils/svg.d.ts +34 -0
  47. package/package.json +56 -0
@@ -0,0 +1,148 @@
1
+ import type { AnalyticsConfig } from "../types/analytics";
2
+ /**
3
+ * Analytics service class
4
+ */
5
+ export declare class AnalyticsService {
6
+ private config;
7
+ private eventQueue;
8
+ private performanceQueue;
9
+ private errorQueue;
10
+ private flushTimer?;
11
+ private sessionId;
12
+ private providers;
13
+ constructor(config?: Partial<AnalyticsConfig>);
14
+ /**
15
+ * Setup analytics providers from configuration
16
+ */
17
+ private setupProviders;
18
+ /**
19
+ * Generate a unique session ID
20
+ */
21
+ private generateSessionId;
22
+ /**
23
+ * Start the flush timer for batched sending
24
+ */
25
+ private startFlushTimer;
26
+ /**
27
+ * Setup automatic error tracking
28
+ */
29
+ private setupErrorTracking;
30
+ /**
31
+ * Setup performance tracking
32
+ */
33
+ private setupPerformanceTracking;
34
+ /**
35
+ * Track an analytics event
36
+ */
37
+ trackEvent(name: string, properties?: Record<string, unknown>): void;
38
+ /**
39
+ * Track a performance metric
40
+ */
41
+ trackPerformance(name: string, value: number, unit: "ms" | "bytes" | "count" | "percentage", context?: Record<string, unknown>): void;
42
+ /**
43
+ * Track an error
44
+ */
45
+ trackError(error: Error, context?: Record<string, unknown>): void;
46
+ /**
47
+ * Track user interaction
48
+ */
49
+ trackInteraction(action: string, target?: string, properties?: Record<string, unknown>): void;
50
+ /**
51
+ * Flush all queued data
52
+ */
53
+ flush(): void;
54
+ /**
55
+ * Flush events queue
56
+ */
57
+ private flushEvents;
58
+ /**
59
+ * Flush performance queue
60
+ */
61
+ private flushPerformance;
62
+ /**
63
+ * Flush errors queue
64
+ */
65
+ private flushErrors;
66
+ /**
67
+ * Send data to analytics endpoint
68
+ */
69
+ private sendData;
70
+ /**
71
+ * Send data to a specific analytics provider
72
+ */
73
+ private sendToProvider;
74
+ /**
75
+ * Send to custom endpoint (backward compatible)
76
+ */
77
+ private sendToCustomEndpoint;
78
+ /**
79
+ * Provider-specific send methods
80
+ */
81
+ private sendToGA4;
82
+ private sendToMixpanel;
83
+ private sendToSegment;
84
+ private sendToAmplitude;
85
+ private sendToPostHog;
86
+ private sendToAzureInsights;
87
+ /**
88
+ * Update configuration
89
+ */
90
+ updateConfig(newConfig: Partial<AnalyticsConfig>): void;
91
+ /**
92
+ * Destroy the analytics service
93
+ */
94
+ destroy(): void;
95
+ }
96
+ /**
97
+ * Initialize analytics service
98
+ *
99
+ * @example
100
+ * // Single provider configuration
101
+ * const analytics = initializeAnalytics({
102
+ * enabled: true,
103
+ * provider: {
104
+ * type: 'google-analytics-4',
105
+ * measurementId: 'G-XXXXXXXXXX',
106
+ * apiKey: 'your-api-secret'
107
+ * }
108
+ * });
109
+ *
110
+ * @example
111
+ * // Multiple providers configuration
112
+ * const analytics = initializeAnalytics({
113
+ * enabled: true,
114
+ * providers: [
115
+ * {
116
+ * type: 'google-analytics-4',
117
+ * measurementId: 'G-XXXXXXXXXX',
118
+ * apiKey: 'your-api-secret'
119
+ * },
120
+ * {
121
+ * type: 'mixpanel',
122
+ * projectToken: 'your-mixpanel-token'
123
+ * }
124
+ * ]
125
+ * });
126
+ *
127
+ * @example
128
+ * // Backward compatible legacy configuration
129
+ * const analytics = initializeAnalytics({
130
+ * enabled: true,
131
+ * endpoint: 'https://your-api.com/analytics',
132
+ * apiKey: 'your-api-key'
133
+ * });
134
+ */
135
+ export declare function initializeAnalytics(config: Partial<AnalyticsConfig>): AnalyticsService;
136
+ /**
137
+ * Get the global analytics instance
138
+ */
139
+ export declare function getAnalytics(): AnalyticsService | null;
140
+ /**
141
+ * Convenience functions for common tracking
142
+ */
143
+ export declare const analytics: {
144
+ track: (name: string, properties?: Record<string, unknown>) => void;
145
+ performance: (name: string, value: number, unit: "ms" | "bytes" | "count" | "percentage", context?: Record<string, unknown>) => void;
146
+ error: (error: Error, context?: Record<string, unknown>) => void;
147
+ interaction: (action: string, target?: string, properties?: Record<string, unknown>) => void;
148
+ };
@@ -0,0 +1,13 @@
1
+ import type { FaceTrackingConfig, FaceTrackingData, FaceTrackingController } from "../types";
2
+ interface FaceTrackingCallbacks {
3
+ onData?: (data: FaceTrackingData | null) => void;
4
+ onError?: (error: Error) => void;
5
+ }
6
+ /**
7
+ * Creates a vanilla-JS face tracking service using TensorFlow.js + MediaPipe Face Mesh.
8
+ *
9
+ * Lazy-loads @tensorflow/tfjs and @tensorflow-models/face-landmarks-detection
10
+ * only when start() is called, keeping the main bundle small (~2MB deferred).
11
+ */
12
+ export declare function createFaceTrackingService(config?: FaceTrackingConfig, callbacks?: FaceTrackingCallbacks): FaceTrackingController;
13
+ export {};
@@ -0,0 +1,15 @@
1
+ import { MediaCapture } from "../utils/MediaCapture";
2
+ export interface ScreenShareController {
3
+ start: () => Promise<void>;
4
+ stop: () => void;
5
+ toggle: () => Promise<void>;
6
+ isSharing: () => boolean;
7
+ isSupported: () => boolean;
8
+ getCapture: () => MediaCapture;
9
+ destroy: () => void;
10
+ }
11
+ export declare function checkScreenShareSupport(): boolean;
12
+ export interface ScreenShareControllerOptions {
13
+ onStateChange?: (isSharing: boolean) => void;
14
+ }
15
+ export declare function createScreenShareController(options?: ScreenShareControllerOptions): ScreenShareController;
@@ -0,0 +1,29 @@
1
+ import { type EventMessage, type CompanionFunction } from "../types";
2
+ import type { MediaCapture } from "../utils/MediaCapture";
3
+ export interface WebRTCController {
4
+ startWithToken: (token: string) => Promise<void>;
5
+ close: () => void;
6
+ forceReconnect: () => Promise<void>;
7
+ getConnectionStatus: () => string;
8
+ getReconnectAttempts: () => number;
9
+ getError: () => Error | null;
10
+ updateAudioDevice: (deviceId: string) => Promise<void>;
11
+ }
12
+ interface WebRTCParams {
13
+ currentAudioDeviceId?: string;
14
+ functions?: CompanionFunction[];
15
+ screenShareCapture?: MediaCapture | null;
16
+ onChatMessage?: (data: EventMessage) => void;
17
+ onConnectionSuccess?: () => void;
18
+ onConnectionError?: (error: Error) => void;
19
+ onStreams?: (streams: {
20
+ videoStream?: MediaStream | null;
21
+ audioStream?: MediaStream | null;
22
+ userMicrophoneStream?: MediaStream | null;
23
+ }) => void;
24
+ onDataChannel?: (dc: RTCDataChannel) => void;
25
+ maxReconnectAttempts?: number;
26
+ reconnectInterval?: number;
27
+ }
28
+ export declare function createWebRTCController(params?: WebRTCParams): WebRTCController;
29
+ export {};
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
@@ -0,0 +1,8 @@
1
+ export { store } from "./store";
2
+ export type { RootState, AppDispatch } from "./store";
3
+ export { setOnFeaturesUpdateCallback } from "./middleware/featuresUpdateMiddleware";
4
+ export * from "./selectors";
5
+ export { setSessionId, setAvatarReady, setDataChannel, setAvatarId, setVideoId, setStopInteraction, setMuted, addTranscript, setCustomVoiceId, setDefaultVoiceId, setConnectionToken, setCloseConnectionHandler, avatarReducer, } from "./slices/avatarSlice";
6
+ export type { WebRTCStatus, AvatarState, Transcript, } from "./slices/avatarSlice";
7
+ export { appReducer, setFeatures, resetFeatures, setPosition, setShowExperience, setDebugMode, } from "./slices/appSlice";
8
+ export type { AppState } from "./slices/appSlice";
@@ -0,0 +1,4 @@
1
+ import type { Middleware } from "@reduxjs/toolkit";
2
+ import type { FeatureConfig } from "../../types";
3
+ export declare const setOnFeaturesUpdateCallback: (callback: ((features: FeatureConfig) => void) | null) => void;
4
+ export declare const featuresUpdateMiddleware: Middleware;
@@ -0,0 +1,30 @@
1
+ import { RootState } from "./index";
2
+ import { FeatureConfig, Position } from "../types";
3
+ import { Transcript } from "./slices/avatarSlice";
4
+ /**
5
+ * Avatar state selectors
6
+ */
7
+ export declare const selectSessionId: (state: RootState) => string | undefined;
8
+ export declare const selectAvatarReady: (state: RootState) => boolean;
9
+ export declare const selectDataChannel: (state: RootState) => RTCDataChannel | null;
10
+ export declare const selectAvatarId: (state: RootState) => string | undefined;
11
+ export declare const selectVideoId: (state: RootState) => string | undefined;
12
+ export declare const selectMuted: (state: RootState) => boolean;
13
+ export declare const selectTranscript: (state: RootState) => Transcript | undefined;
14
+ export declare const selectCustomVoiceId: (state: RootState) => string | undefined;
15
+ export declare const selectDefaultVoiceId: (state: RootState) => string | undefined;
16
+ export declare const selectConnectionToken: (state: RootState) => string | undefined;
17
+ export declare const selectCompanionId: (state: RootState) => string | undefined;
18
+ export declare const selectStopInteraction: (state: RootState) => boolean;
19
+ export declare const selectCloseConnectionHandler: (state: RootState) => (() => void) | undefined;
20
+ /**
21
+ * App state selectors
22
+ */
23
+ export declare const selectFeatures: (state: RootState) => FeatureConfig;
24
+ export declare const selectPosition: (state: RootState) => Position | undefined;
25
+ export declare const selectShowExperience: (state: RootState) => boolean;
26
+ /**
27
+ * Composite selectors
28
+ */
29
+ export declare const selectIsConnected: (state: RootState) => boolean;
30
+ export declare const selectCanSendMessage: (state: RootState) => boolean;
@@ -0,0 +1,12 @@
1
+ import { Position, FeatureConfig } from "../../types";
2
+ export interface AppState {
3
+ features: FeatureConfig;
4
+ position?: Position;
5
+ showExperience: boolean;
6
+ debugMode?: boolean;
7
+ }
8
+ export declare const setFeatures: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
9
+ feature: keyof FeatureConfig;
10
+ config: FeatureConfig[keyof FeatureConfig];
11
+ }, "app/setFeatures">, resetFeatures: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"app/resetFeatures">, setPosition: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<Position | undefined, "app/setPosition">, setShowExperience: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "app/setShowExperience">, setDebugMode: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<boolean | undefined, "app/setDebugMode">;
12
+ export declare const appReducer: import("redux").Reducer<AppState>;
@@ -0,0 +1,26 @@
1
+ export interface WebRTCStatus {
2
+ blocked: boolean;
3
+ reason: string;
4
+ message: string;
5
+ }
6
+ export interface Transcript {
7
+ role: string;
8
+ content: string;
9
+ }
10
+ export interface AvatarState {
11
+ sessionId?: string;
12
+ avatarReady: boolean;
13
+ dataChannel: RTCDataChannel | null;
14
+ avatarId?: string;
15
+ videoId?: string;
16
+ stopInteraction: boolean;
17
+ muted: boolean;
18
+ transcript?: Transcript;
19
+ customVoiceId: string | undefined;
20
+ defaultVoiceId: string | undefined;
21
+ connectionToken?: string;
22
+ companionId?: string;
23
+ closeConnectionHandler?: () => void;
24
+ }
25
+ export declare const setSessionId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setSessionId">, setAvatarReady: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setAvatarReady">, setDataChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<RTCDataChannel | null, "avatar/setDataChannel">, setAvatarId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setAvatarId">, setVideoId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setVideoId">, setStopInteraction: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setStopInteraction">, setMuted: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setMuted">, addTranscript: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<Transcript | undefined, "avatar/addTranscript">, setCustomVoiceId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setCustomVoiceId">, setDefaultVoiceId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setDefaultVoiceId">, setConnectionToken: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setConnectionToken">, setCloseConnectionHandler: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<(() => void) | undefined, "avatar/setCloseConnectionHandler">;
26
+ export declare const avatarReducer: import("redux").Reducer<AvatarState>;
@@ -0,0 +1,11 @@
1
+ export declare const store: import("@reduxjs/toolkit").EnhancedStore<{
2
+ avatar: import(".").AvatarState;
3
+ app: import(".").AppState;
4
+ }, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
5
+ dispatch: import("redux-thunk").ThunkDispatch<{
6
+ avatar: import(".").AvatarState;
7
+ app: import(".").AppState;
8
+ }, undefined, import("redux").UnknownAction>;
9
+ }>, import("redux").StoreEnhancer]>>;
10
+ export type RootState = ReturnType<typeof store.getState>;
11
+ export type AppDispatch = typeof store.dispatch;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Base controller interface for all component controllers
3
+ */
4
+ export interface BaseController<TOptions = unknown> {
5
+ /**
6
+ * Update controller with new options
7
+ */
8
+ update(options: Partial<TOptions>): void;
9
+ /**
10
+ * Destroy controller and clean up resources
11
+ */
12
+ destroy(silent?: boolean): void;
13
+ }
14
+ /**
15
+ * Extended controller interface with lifecycle hooks
16
+ */
17
+ export interface LifecycleController<TOptions = unknown> extends BaseController<TOptions> {
18
+ /**
19
+ * Initialize controller (called after construction)
20
+ */
21
+ initialize?(): void;
22
+ /**
23
+ * Hook called before destroy
24
+ */
25
+ beforeDestroy?(): void;
26
+ }
27
+ /**
28
+ * Controller with render capabilities
29
+ */
30
+ export interface RenderController<TOptions = unknown> extends LifecycleController<TOptions> {
31
+ /**
32
+ * Render or re-render the component
33
+ */
34
+ render(): void;
35
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Analytics and monitoring service for SDK usage tracking
3
+ */
4
+ export interface AnalyticsEvent {
5
+ /** Name of the analytics event */
6
+ name: string;
7
+ /** Properties associated with the event */
8
+ properties?: Record<string, unknown>;
9
+ /** Timestamp of the event */
10
+ timestamp?: number;
11
+ /** User identifier */
12
+ userId?: string;
13
+ /** Session identifier */
14
+ sessionId?: string;
15
+ }
16
+ /**
17
+ * Supported analytics providers
18
+ */
19
+ export type AnalyticsProvider = "custom" | "google-analytics-4" | "mixpanel" | "segment" | "amplitude" | "posthog" | "azure-insights";
20
+ /**
21
+ * Analytics provider configuration
22
+ */
23
+ export interface ProviderConfig {
24
+ /** Type of analytics provider */
25
+ type: AnalyticsProvider;
26
+ /** Measurement ID for Google Analytics 4 */
27
+ measurementId?: string;
28
+ /** Project token for Mixpanel */
29
+ projectToken?: string;
30
+ /** Write key for Segment */
31
+ writeKey?: string;
32
+ /** Generic API key */
33
+ apiKey?: string;
34
+ /** Custom endpoint */
35
+ endpoint?: string;
36
+ /** Regional endpoint */
37
+ region?: string;
38
+ }
39
+ /**
40
+ * Performance metric data structure
41
+ */
42
+ export interface PerformanceMetric {
43
+ /** Name of the performance metric */
44
+ name: string;
45
+ /** Value of the metric */
46
+ value: number;
47
+ /** Unit of the metric value */
48
+ unit: "ms" | "bytes" | "count" | "percentage";
49
+ /** Timestamp of the metric */
50
+ timestamp?: number;
51
+ /** Additional context for the metric */
52
+ context?: Record<string, unknown>;
53
+ }
54
+ /**
55
+ * Error event data structure
56
+ */
57
+ export interface ErrorEvent {
58
+ /** Error object */
59
+ error: Error;
60
+ /** Additional context for the error */
61
+ context?: Record<string, unknown>;
62
+ /** Timestamp of the error event */
63
+ timestamp?: number;
64
+ /** User identifier */
65
+ userId?: string;
66
+ /** Session identifier */
67
+ sessionId?: string;
68
+ /** Stack trace of the error */
69
+ stack?: string;
70
+ }
71
+ /**
72
+ * Analytics configuration options
73
+ */
74
+ export interface AnalyticsConfig {
75
+ /** Enable or disable analytics tracking */
76
+ enabled: boolean;
77
+ /** Analytics service provider configuration */
78
+ provider?: ProviderConfig;
79
+ /** Support multiple analytics service providers */
80
+ providers?: ProviderConfig[];
81
+ /** Unique user identifier for tracking purposes */
82
+ userId?: string;
83
+ /** Unique session identifier for tracking purposes */
84
+ sessionId?: string;
85
+ /** Batch size for sending analytics events */
86
+ batchSize?: number;
87
+ /** Interval in milliseconds for flushing analytics data */
88
+ flushInterval?: number;
89
+ /** Enable or disable performance tracking */
90
+ enablePerformanceTracking?: boolean;
91
+ /** Enable or disable error tracking */
92
+ enableErrorTracking?: boolean;
93
+ /** Enable or disable user interaction tracking */
94
+ enableUserInteractionTracking?: boolean;
95
+ }
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Base error class for all SDK errors
3
+ */
4
+ export declare class SDKError extends Error {
5
+ readonly code: string;
6
+ readonly timestamp: Date;
7
+ context?: Record<string, unknown>;
8
+ constructor(message: string, code: string, context?: Record<string, unknown>);
9
+ /**
10
+ * Serializes the error for logging or transmission
11
+ */
12
+ toJSON(): {
13
+ name: string;
14
+ message: string;
15
+ code: string;
16
+ timestamp: string;
17
+ context: Record<string, unknown> | undefined;
18
+ stack: string | undefined;
19
+ };
20
+ }
21
+ /**
22
+ * Initialization related errors
23
+ */
24
+ export declare class InitializationError extends SDKError {
25
+ constructor(message: string, context?: Record<string, unknown>);
26
+ }
27
+ /**
28
+ * Token related errors
29
+ */
30
+ export declare class TokenError extends SDKError {
31
+ constructor(message: string, context?: Record<string, unknown>);
32
+ }
33
+ /**
34
+ * React version compatibility errors
35
+ */
36
+ export declare class ReactVersionError extends SDKError {
37
+ constructor(message: string, context?: Record<string, unknown>);
38
+ }
39
+ /**
40
+ * Connection related errors
41
+ */
42
+ export declare class ConnectionError extends SDKError {
43
+ constructor(message: string, context?: Record<string, unknown>);
44
+ }
45
+ /**
46
+ * WebRTC related errors
47
+ */
48
+ export declare class WebRTCError extends SDKError {
49
+ constructor(message: string, context?: Record<string, unknown>);
50
+ }
51
+ /**
52
+ * API related errors
53
+ */
54
+ export declare class APIError extends SDKError {
55
+ readonly status?: number;
56
+ readonly response?: unknown;
57
+ constructor(message: string, status?: number, response?: unknown, context?: Record<string, unknown>);
58
+ toJSON(): {
59
+ status: number | undefined;
60
+ response: unknown;
61
+ name: string;
62
+ message: string;
63
+ code: string;
64
+ timestamp: string;
65
+ context: Record<string, unknown> | undefined;
66
+ stack: string | undefined;
67
+ };
68
+ }
69
+ /**
70
+ * Configuration related errors
71
+ */
72
+ export declare class ConfigurationError extends SDKError {
73
+ constructor(message: string, context?: Record<string, unknown>);
74
+ }
75
+ /**
76
+ * Feature related errors
77
+ */
78
+ export declare class FeatureError extends SDKError {
79
+ constructor(message: string, context?: Record<string, unknown>);
80
+ }
81
+ /**
82
+ * Media related errors (video, audio)
83
+ */
84
+ export declare class MediaError extends SDKError {
85
+ constructor(message: string, context?: Record<string, unknown>);
86
+ }
87
+ /**
88
+ * Face tracking related errors
89
+ */
90
+ export declare class FaceTrackingError extends SDKError {
91
+ constructor(message: string, code: string, context?: Record<string, unknown>);
92
+ }
93
+ /**
94
+ * Error codes enum for consistent error identification
95
+ */
96
+ export declare enum ErrorCodes {
97
+ ALREADY_INITIALIZED = "ALREADY_INITIALIZED",
98
+ INVALID_TOKEN = "INVALID_TOKEN",
99
+ REACT_VERSION_UNSUPPORTED = "REACT_VERSION_UNSUPPORTED",
100
+ CONTAINER_NOT_FOUND = "CONTAINER_NOT_FOUND",
101
+ CONNECTION_FAILED = "CONNECTION_FAILED",
102
+ TOKEN_GENERATION_FAILED = "TOKEN_GENERATION_FAILED",
103
+ MISSING_CREDENTIALS = "MISSING_CREDENTIALS",
104
+ WEBRTC_NOT_SUPPORTED = "WEBRTC_NOT_SUPPORTED",
105
+ PEER_CONNECTION_FAILED = "PEER_CONNECTION_FAILED",
106
+ DATA_CHANNEL_ERROR = "DATA_CHANNEL_ERROR",
107
+ API_REQUEST_FAILED = "API_REQUEST_FAILED",
108
+ INVALID_RESPONSE = "INVALID_RESPONSE",
109
+ RATE_LIMITED = "RATE_LIMITED",
110
+ INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
111
+ MISSING_REQUIRED_CONFIG = "MISSING_REQUIRED_CONFIG",
112
+ FEATURE_NOT_SUPPORTED = "FEATURE_NOT_SUPPORTED",
113
+ FEATURE_DISABLED = "FEATURE_DISABLED",
114
+ MEDIA_ACCESS_DENIED = "MEDIA_ACCESS_DENIED",
115
+ MEDIA_DEVICE_ERROR = "MEDIA_DEVICE_ERROR",
116
+ VIDEO_LOAD_ERROR = "VIDEO_LOAD_ERROR",
117
+ CAMERA_PERMISSION_DENIED = "CAMERA_PERMISSION_DENIED",
118
+ CAMERA_NOT_FOUND = "CAMERA_NOT_FOUND",
119
+ MODEL_LOAD_FAILED = "MODEL_LOAD_FAILED",
120
+ DETECTION_FAILED = "DETECTION_FAILED"
121
+ }
122
+ /**
123
+ * Type guard to check if an error is an SDK error
124
+ */
125
+ export declare function isSDKError(error: unknown): error is SDKError;
126
+ /**
127
+ * Helper function to create appropriate error based on context
128
+ */
129
+ export declare function createError(type: "initialization" | "token" | "react" | "connection" | "webrtc" | "api" | "config" | "feature" | "media" | "faceTracking", message: string, context?: Record<string, unknown>): SDKError;
130
+ /**
131
+ * Error handler utility for consistent error processing
132
+ */
133
+ export declare class ErrorHandler {
134
+ private static onError?;
135
+ /**
136
+ * Set global error handler
137
+ */
138
+ static setErrorHandler(handler: (error: SDKError) => void): void;
139
+ /**
140
+ * Handle an error with optional context
141
+ */
142
+ static handle(error: unknown, context?: Record<string, unknown>): SDKError;
143
+ }