@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.
- package/LICENSE +21 -0
- package/README.md +830 -0
- package/lib/components/Avatar/index.d.ts +35 -0
- package/lib/components/Embed/index.d.ts +25 -0
- package/lib/components/InactiveOverlay/index.d.ts +15 -0
- package/lib/components/Preview/index.d.ts +18 -0
- package/lib/components/StyledTooltip/index.d.ts +16 -0
- package/lib/components/VolumeControl/index.d.ts +18 -0
- package/lib/components/WaveForm/index.d.ts +19 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/constants/events.d.ts +52 -0
- package/lib/constants/greenscreen.d.ts +28 -0
- package/lib/constants/index.d.ts +6 -0
- package/lib/constants/waveform.d.ts +34 -0
- package/lib/index.css +1 -0
- package/lib/index.d.ts +34 -0
- package/lib/index.esm.js +1 -0
- package/lib/index.js +1 -0
- package/lib/index.standalone.js +1 -0
- package/lib/services/analytics.d.ts +148 -0
- package/lib/services/faceTracking.d.ts +13 -0
- package/lib/services/screenShare.d.ts +15 -0
- package/lib/services/webrtc.d.ts +29 -0
- package/lib/setupTests.d.ts +1 -0
- package/lib/stores/index.d.ts +8 -0
- package/lib/stores/middleware/featuresUpdateMiddleware.d.ts +4 -0
- package/lib/stores/selectors.d.ts +30 -0
- package/lib/stores/slices/appSlice.d.ts +12 -0
- package/lib/stores/slices/avatarSlice.d.ts +26 -0
- package/lib/stores/store.d.ts +11 -0
- package/lib/types/abstract-typing.d.ts +35 -0
- package/lib/types/analytics.d.ts +95 -0
- package/lib/types/errors.d.ts +143 -0
- package/lib/types/index.d.ts +354 -0
- package/lib/umd.d.ts +1 -0
- package/lib/utils/InactiveOverlayManager.d.ts +77 -0
- package/lib/utils/MediaCapture.d.ts +13 -0
- package/lib/utils/classnames.d.ts +50 -0
- package/lib/utils/debug.d.ts +84 -0
- package/lib/utils/domFactory.d.ts +56 -0
- package/lib/utils/greenscreen/GreenScreenProcessor.d.ts +25 -0
- package/lib/utils/greenscreen/index.d.ts +1 -0
- package/lib/utils/index.d.ts +25 -0
- package/lib/utils/mouthDetection.d.ts +33 -0
- package/lib/utils/sendCommand.d.ts +2 -0
- package/lib/utils/svg.d.ts +34 -0
- package/package.json +56 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import type { AnalyticsConfig } from "./analytics";
|
|
2
|
+
import { DataChannelMessageType } from "../constants/events";
|
|
3
|
+
export * from "./errors";
|
|
4
|
+
export * from "./analytics";
|
|
5
|
+
export * from "./abstract-typing";
|
|
6
|
+
/**
|
|
7
|
+
* Placement positions used to anchor the UI on screen.
|
|
8
|
+
* Use these values when passing `position` in the top-level config
|
|
9
|
+
* or when calling `setPosition` on the instance.
|
|
10
|
+
*/
|
|
11
|
+
export declare enum Position {
|
|
12
|
+
BOTTOM_RIGHT = "bottom-right",
|
|
13
|
+
BOTTOM_CENTER = "bottom-center",
|
|
14
|
+
BOTTOM_LEFT = "bottom-left",
|
|
15
|
+
TOP_RIGHT = "top-right",
|
|
16
|
+
TOP_CENTER = "top-center",
|
|
17
|
+
TOP_LEFT = "top-left",
|
|
18
|
+
CENTER = "center"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Function definition for AI companion function calling.
|
|
22
|
+
* Functions allow the AI companion to invoke external tools or actions
|
|
23
|
+
* during a conversation.
|
|
24
|
+
*/
|
|
25
|
+
export interface CompanionFunction {
|
|
26
|
+
/** Unique function name the AI can invoke. */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Human-readable description of what the function does. */
|
|
29
|
+
description?: string;
|
|
30
|
+
/** JSON-Schema style parameter definitions. */
|
|
31
|
+
parameters?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface SendMessageData {
|
|
34
|
+
/** The text message to send */
|
|
35
|
+
text: string;
|
|
36
|
+
/** The role of the message sender */
|
|
37
|
+
role: "user" | "system";
|
|
38
|
+
/** Whether to trigger an avatar response */
|
|
39
|
+
trigger_response: boolean;
|
|
40
|
+
/** Optional ID of the previous message in the conversation thread */
|
|
41
|
+
previous_item_id?: string;
|
|
42
|
+
/** Whether to delay the response (reserved for future use) */
|
|
43
|
+
delay?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Data channel command types
|
|
47
|
+
*/
|
|
48
|
+
export type SendMessageCommand = {
|
|
49
|
+
type: DataChannelMessageType.SEND_MESSAGE;
|
|
50
|
+
data: SendMessageData;
|
|
51
|
+
};
|
|
52
|
+
export type CancelCommand = {
|
|
53
|
+
type: DataChannelMessageType.CANCEL;
|
|
54
|
+
};
|
|
55
|
+
export type SetSettingsCommand = {
|
|
56
|
+
type: DataChannelMessageType.SET_SETTINGS;
|
|
57
|
+
data: {
|
|
58
|
+
functions: CompanionFunction[];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export type StartVideoCommand = {
|
|
62
|
+
type: DataChannelMessageType.START_VIDEO;
|
|
63
|
+
data: null;
|
|
64
|
+
};
|
|
65
|
+
export type StopVideoCommand = {
|
|
66
|
+
type: DataChannelMessageType.STOP_VIDEO;
|
|
67
|
+
data: null;
|
|
68
|
+
};
|
|
69
|
+
export type DataChannelCommand = SendMessageCommand | CancelCommand | SetSettingsCommand | StartVideoCommand | StopVideoCommand;
|
|
70
|
+
export declare const maxInactiveTimeoutDuration = 180000;
|
|
71
|
+
export declare const defaultCountdownDuration = 30;
|
|
72
|
+
export interface EventMessage {
|
|
73
|
+
event: string;
|
|
74
|
+
data?: {
|
|
75
|
+
state?: string;
|
|
76
|
+
message?: {
|
|
77
|
+
action?: string;
|
|
78
|
+
content?: string;
|
|
79
|
+
role?: string;
|
|
80
|
+
};
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Feature-specific configuration flags and optional parameters.
|
|
86
|
+
* Each feature contains its own small config object; toggle `enabled`
|
|
87
|
+
* to turn the feature on/off and provide small optional tuning values
|
|
88
|
+
* (for example `inactiveTimeout.duration`).
|
|
89
|
+
*/
|
|
90
|
+
export interface FeatureConfig {
|
|
91
|
+
/** Background removal feature. When enabled, the avatar background should be removed. */
|
|
92
|
+
backgroundRemoval?: {
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
};
|
|
95
|
+
/** Waveform display settings shown during audio playback/recording. */
|
|
96
|
+
waveform?: {
|
|
97
|
+
enabled: boolean;
|
|
98
|
+
/** Optional CSS color value for the waveform. Defaults are applied by the SDK if omitted. */
|
|
99
|
+
color?: string;
|
|
100
|
+
};
|
|
101
|
+
/** Automatically hide or perform actions after a period of inactivity. */
|
|
102
|
+
inactiveTimeout?: {
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
/** Duration in milliseconds used by the SDK when `enabled` is true
|
|
105
|
+
*
|
|
106
|
+
* Max: 180000ms
|
|
107
|
+
*
|
|
108
|
+
* Default: 180000ms
|
|
109
|
+
*/
|
|
110
|
+
duration?: number;
|
|
111
|
+
/** Countdown duration before close connection in seconds, shown to users when inactive timeout is triggered
|
|
112
|
+
*
|
|
113
|
+
* Max: 60 seconds
|
|
114
|
+
*
|
|
115
|
+
* Default: 30 seconds
|
|
116
|
+
*/
|
|
117
|
+
countdown?: number;
|
|
118
|
+
};
|
|
119
|
+
/** Small disclaimer shown to users, often used for legal text or usage hints. */
|
|
120
|
+
disclaimer?: {
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
/** Optional text shown when the disclaimer is enabled. */
|
|
123
|
+
text?: string;
|
|
124
|
+
color?: string;
|
|
125
|
+
};
|
|
126
|
+
/** Loader overlay shown while the SDK/Avatar is loading. */
|
|
127
|
+
showSDKLoader?: {
|
|
128
|
+
enabled: boolean;
|
|
129
|
+
/** Optional background color for the loader overlay. */
|
|
130
|
+
bgColor?: string;
|
|
131
|
+
/** Optional color for the loader animation. */
|
|
132
|
+
color?: string;
|
|
133
|
+
/** Optional loader animation type. */
|
|
134
|
+
type?: "spinner" | "pulse";
|
|
135
|
+
};
|
|
136
|
+
/** Screen sharing feature. When enabled, users can share their screen during a session. */
|
|
137
|
+
screenShare?: {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
};
|
|
140
|
+
/** Face tracking feature. When enabled, opens the user's camera and runs
|
|
141
|
+
* real-time face mesh detection via TensorFlow.js + MediaPipe. */
|
|
142
|
+
faceTracking?: {
|
|
143
|
+
enabled: boolean;
|
|
144
|
+
/** Detection rate in FPS. Default 15, max 30. */
|
|
145
|
+
fps?: number;
|
|
146
|
+
/** Mouth opening ratio threshold. Default 0.015. */
|
|
147
|
+
talkingThreshold?: number;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Configuration for the face tracking service.
|
|
152
|
+
*/
|
|
153
|
+
export interface FaceTrackingConfig {
|
|
154
|
+
/** Detection rate in frames per second. Default 15, max 30. */
|
|
155
|
+
fps?: number;
|
|
156
|
+
/** Mouth opening ratio threshold to determine talking state. Default 0.015. */
|
|
157
|
+
talkingThreshold?: number;
|
|
158
|
+
/** Number of frames for rolling average smoothing. Default 5. */
|
|
159
|
+
smoothingFrames?: number;
|
|
160
|
+
/** Camera video width. Default 640. */
|
|
161
|
+
videoWidth?: number;
|
|
162
|
+
/** Camera video height. Default 480. */
|
|
163
|
+
videoHeight?: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Normalized mouth landmark positions (0–1 range).
|
|
167
|
+
*/
|
|
168
|
+
export interface MouthLandmarks {
|
|
169
|
+
topLip: {
|
|
170
|
+
x: number;
|
|
171
|
+
y: number;
|
|
172
|
+
};
|
|
173
|
+
bottomLip: {
|
|
174
|
+
x: number;
|
|
175
|
+
y: number;
|
|
176
|
+
};
|
|
177
|
+
leftCorner: {
|
|
178
|
+
x: number;
|
|
179
|
+
y: number;
|
|
180
|
+
};
|
|
181
|
+
rightCorner: {
|
|
182
|
+
x: number;
|
|
183
|
+
y: number;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Face tracking data emitted on each detection frame.
|
|
188
|
+
*/
|
|
189
|
+
export interface FaceTrackingData {
|
|
190
|
+
/** 468 normalized face landmarks (x, y, z in 0–1 range). */
|
|
191
|
+
landmarks: Array<{
|
|
192
|
+
x: number;
|
|
193
|
+
y: number;
|
|
194
|
+
z: number;
|
|
195
|
+
}>;
|
|
196
|
+
/** Normalized mouth landmark positions, or null if not detected. */
|
|
197
|
+
mouthLandmarks: MouthLandmarks | null;
|
|
198
|
+
/** Whether the user is currently talking based on smoothed mouth-opening ratio. */
|
|
199
|
+
isTalking: boolean;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Controller returned by createFaceTrackingService for managing the detection lifecycle.
|
|
203
|
+
*/
|
|
204
|
+
export interface FaceTrackingController {
|
|
205
|
+
/** Initialize camera + model and start the detection loop. */
|
|
206
|
+
start(): Promise<void>;
|
|
207
|
+
/** Pause detection and stop camera, but keep the model loaded for fast restart. */
|
|
208
|
+
stop(): void;
|
|
209
|
+
/** Whether the detection loop is currently running. */
|
|
210
|
+
isActive(): boolean;
|
|
211
|
+
/** Full teardown: stop + dispose model + null all refs. */
|
|
212
|
+
destroy(): void;
|
|
213
|
+
}
|
|
214
|
+
export interface avatarStyleConfig {
|
|
215
|
+
/** Avatar visual style: "round" | "rectangle" | "silhouette" (Default: "round").
|
|
216
|
+
*
|
|
217
|
+
* Use "rectangle" when applying custom styling that requires a rectangular container.
|
|
218
|
+
*/
|
|
219
|
+
view: "round" | "rectangle" | "silhouette";
|
|
220
|
+
/** Border width in pixels. */
|
|
221
|
+
borderWidth?: CSSStyleDeclaration["borderWidth"];
|
|
222
|
+
/** Border color as a CSS color string. */
|
|
223
|
+
borderColor?: CSSStyleDeclaration["borderColor"];
|
|
224
|
+
/** Border style as a CSS border-style string (e.g., "solid", "dashed"). */
|
|
225
|
+
borderStyle?: CSSStyleDeclaration["borderStyle"];
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* CSS style object that works with vanilla JS.
|
|
229
|
+
* Compatible with CSSStyleDeclaration.
|
|
230
|
+
* Allows both string and number values for CSS properties.
|
|
231
|
+
*/
|
|
232
|
+
export type StyleObject = Partial<CSSStyleDeclaration>;
|
|
233
|
+
/**
|
|
234
|
+
* Main configuration object passed to `init(token, config)`.
|
|
235
|
+
* All fields are optional; sensible defaults are used by the SDK.
|
|
236
|
+
*/
|
|
237
|
+
export interface NapsterCompanionApiConfig {
|
|
238
|
+
/** Position of the avatar on screen. See `Position` enum. */
|
|
239
|
+
position?: Position;
|
|
240
|
+
/** CSS class name(s) to add to the SDK root container. Useful for theming. */
|
|
241
|
+
className?: string;
|
|
242
|
+
/** Inline style object applied to the SDK root container. It supports only vanilla JS style objects. */
|
|
243
|
+
style?: StyleObject;
|
|
244
|
+
/** Avatar visual style configuration. */
|
|
245
|
+
avatarStyle?: avatarStyleConfig;
|
|
246
|
+
/** Per-feature configuration object to toggle features and set options. */
|
|
247
|
+
features?: FeatureConfig;
|
|
248
|
+
/**
|
|
249
|
+
* Mount target for the SDK. Provide an actual HTMLElement or a selector
|
|
250
|
+
* string; defaults to `document.body` when omitted.
|
|
251
|
+
*/
|
|
252
|
+
mountContainer?: HTMLElement | string | null;
|
|
253
|
+
/**
|
|
254
|
+
* AI companion function definitions for function calling support.
|
|
255
|
+
* These functions are sent to the server when the connection is established,
|
|
256
|
+
* allowing the AI to invoke them during conversation.
|
|
257
|
+
*/
|
|
258
|
+
functions?: CompanionFunction[];
|
|
259
|
+
/** Enable debug logging throughout the SDK. When enabled, detailed logs will be output to the console. */
|
|
260
|
+
debug?: boolean;
|
|
261
|
+
/** Analytics configuration controls analytics delivery and tracking. */
|
|
262
|
+
analytics?: AnalyticsConfig;
|
|
263
|
+
/** Lifecycle callbacks. All are optional. */
|
|
264
|
+
/** Called when the SDK has finished initialization and is ready to render. */
|
|
265
|
+
onReady?: () => void;
|
|
266
|
+
/** Called when a runtime or network error occurs; receives the Error. */
|
|
267
|
+
onError?: (error: Error) => void;
|
|
268
|
+
/** Called when arbitrary data arrives over the SDK's socket/connection. */
|
|
269
|
+
onData?: (data: EventMessage) => void;
|
|
270
|
+
/** Called when the visual avatar is fully prepared and rendered. */
|
|
271
|
+
onAvatarReady?: (isReady?: boolean) => void;
|
|
272
|
+
/** Called when the avatar inactivity status changes; receives the new status. */
|
|
273
|
+
onInactivityStatusChange?: (isInactive: boolean) => void;
|
|
274
|
+
/** Called when the SDK is destroyed via the public API. */
|
|
275
|
+
onDestroy?: () => void;
|
|
276
|
+
/** Called whenever feature configuration is changed at runtime. */
|
|
277
|
+
onFeaturesUpdate?: (features: FeatureConfig) => void;
|
|
278
|
+
/** Called on each face tracking detection frame with face data (or null if no face detected). */
|
|
279
|
+
onFaceTrackingData?: (data: FaceTrackingData | null) => void;
|
|
280
|
+
/** Called when the screen share state changes (started or stopped). */
|
|
281
|
+
onScreenShareStateChange?: (isSharing: boolean) => void;
|
|
282
|
+
/** Called when a face tracking error occurs (camera denied, model load failure, etc.). */
|
|
283
|
+
onFaceTrackingError?: (error: Error) => void;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Public instance returned by `init`. Use these methods to control the
|
|
287
|
+
* running SDK after initialization.
|
|
288
|
+
*/
|
|
289
|
+
export interface NapsterCompanionApiInstance {
|
|
290
|
+
/** Show the Avatar in screen (if hidden). */
|
|
291
|
+
showAvatar: () => void;
|
|
292
|
+
/** Hide the Avatar from screen. */
|
|
293
|
+
hideAvatar: () => void;
|
|
294
|
+
/** Check whether the Avatar is currently visible on screen. */
|
|
295
|
+
avatarIsVisible: () => boolean;
|
|
296
|
+
/** Tear down the SDK, remove DOM nodes and clean up resources. */
|
|
297
|
+
destroy: () => void;
|
|
298
|
+
/** Update the inline style object applied to the SDK root container. */
|
|
299
|
+
updateStyles: (styles: NapsterCompanionApiConfig["style"]) => void;
|
|
300
|
+
/** Set the position of the SDK on screen (see `Position`). */
|
|
301
|
+
setPosition: (position: Position) => void;
|
|
302
|
+
/** Clear any programmatic position and revert to the configured/default position. */
|
|
303
|
+
clearPosition: () => void;
|
|
304
|
+
/** Update avatar style configuration (e.g., view: round/silhouette/rectangle). */
|
|
305
|
+
updateAvatarStyle: (newAvatarStyle: Partial<NonNullable<NapsterCompanionApiConfig["avatarStyle"]>>) => void;
|
|
306
|
+
/** Enable a named feature (one of the keys from `FeatureConfig`).
|
|
307
|
+
*
|
|
308
|
+
* e.g. `enableFeature("disclaimer")`
|
|
309
|
+
*/
|
|
310
|
+
enableFeature: (feature: keyof FeatureConfig) => void;
|
|
311
|
+
/** Disable a named feature (one of the keys from `FeatureConfig`).
|
|
312
|
+
*
|
|
313
|
+
* e.g. `disableFeature("disclaimer")`
|
|
314
|
+
*/
|
|
315
|
+
disableFeature: (feature: keyof FeatureConfig) => void;
|
|
316
|
+
/**
|
|
317
|
+
* Update a single feature's configuration. `config` may be partial; only the
|
|
318
|
+
* supplied keys will be changed.
|
|
319
|
+
*
|
|
320
|
+
* e.g. to change only the disclaimer text:
|
|
321
|
+
*
|
|
322
|
+
* `updateFeatureConfig("disclaimer", { text: "New disclaimer text" })`
|
|
323
|
+
*/
|
|
324
|
+
updateFeatureConfig: (feature: keyof FeatureConfig, config: NonNullable<FeatureConfig[keyof FeatureConfig]>) => void;
|
|
325
|
+
/** Send a command to the avatar via the data channel. */
|
|
326
|
+
sendCommand: (command: DataChannelCommand) => void;
|
|
327
|
+
/** Start screen sharing. Captures the user's screen and sends frames to the avatar. */
|
|
328
|
+
startScreenShare: () => Promise<void>;
|
|
329
|
+
/** Stop screen sharing. */
|
|
330
|
+
stopScreenShare: () => void;
|
|
331
|
+
/** Toggle screen sharing on/off. */
|
|
332
|
+
toggleScreenShare: () => Promise<void>;
|
|
333
|
+
/** Whether screen sharing is currently active. */
|
|
334
|
+
readonly isScreenSharing: boolean;
|
|
335
|
+
/** Whether screen sharing is supported by the browser and enabled in config. */
|
|
336
|
+
readonly isScreenShareSupported: boolean;
|
|
337
|
+
/** Start face tracking (opens camera, loads model, begins detection loop). */
|
|
338
|
+
startFaceTracking: () => Promise<void>;
|
|
339
|
+
/** Stop face tracking (pauses detection, stops camera; model stays loaded for fast restart). */
|
|
340
|
+
stopFaceTracking: () => void;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Top-level SDK object exposed by the package. Call `init(token, config)` to
|
|
344
|
+
* bootstrap the SDK and receive a `NapsterCompanionApiInstance` for runtime control.
|
|
345
|
+
*/
|
|
346
|
+
export interface NapsterCompanionApiSDK {
|
|
347
|
+
/**
|
|
348
|
+
* Initialize the SDK using the provided connection token and optional config.
|
|
349
|
+
* Returns a Promise that resolves to a controllable `NapsterCompanionApiInstance`.
|
|
350
|
+
*/
|
|
351
|
+
init(token: string, config?: Partial<NapsterCompanionApiConfig>): Promise<NapsterCompanionApiInstance>;
|
|
352
|
+
/** The SDK version string (useful for diagnostics). */
|
|
353
|
+
version: string;
|
|
354
|
+
}
|
package/lib/umd.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./index";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of triggers that can show the inactive overlay
|
|
3
|
+
*/
|
|
4
|
+
export declare enum InactiveOverlayTriggerType {
|
|
5
|
+
/** Local SDK timeout based on user inactivity */
|
|
6
|
+
LOCAL_TIMEOUT = "local_timeout",
|
|
7
|
+
/** Server-side warning about avatar disconnection */
|
|
8
|
+
SERVER_WARNING = "server_warning"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for showing the inactive overlay
|
|
12
|
+
*/
|
|
13
|
+
export interface InactiveOverlayTrigger {
|
|
14
|
+
/** Type of trigger that initiated the overlay */
|
|
15
|
+
type: InactiveOverlayTriggerType;
|
|
16
|
+
/** Duration in seconds for the countdown */
|
|
17
|
+
duration: number;
|
|
18
|
+
/** Optional custom message to display */
|
|
19
|
+
message?: string;
|
|
20
|
+
/** Whether user interaction is needed to continue */
|
|
21
|
+
isInteractionNeeded: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Callbacks for overlay lifecycle events
|
|
25
|
+
*/
|
|
26
|
+
export interface InactiveOverlayCallbacks {
|
|
27
|
+
/** Called when user clicks "Continue" */
|
|
28
|
+
onContinue?: () => void;
|
|
29
|
+
/** Called when countdown ends */
|
|
30
|
+
onEnd?: () => void;
|
|
31
|
+
/** Called when overlay is shown */
|
|
32
|
+
onShow?: (trigger: InactiveOverlayTrigger) => void;
|
|
33
|
+
/** Called when overlay is hidden */
|
|
34
|
+
onHide?: () => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Manager class that handles all inactive overlay logic
|
|
38
|
+
* Follows Single Responsibility Principle - only manages overlay state and lifecycle
|
|
39
|
+
*/
|
|
40
|
+
export declare class InactiveOverlayManager {
|
|
41
|
+
private overlayController;
|
|
42
|
+
private currentTrigger;
|
|
43
|
+
private isVisible;
|
|
44
|
+
private readonly mountElement;
|
|
45
|
+
private readonly callbacks;
|
|
46
|
+
constructor(mountElement: HTMLElement, callbacks?: InactiveOverlayCallbacks);
|
|
47
|
+
/**
|
|
48
|
+
* Show the inactive overlay with the given trigger configuration
|
|
49
|
+
* This is the single entry point for showing the overlay
|
|
50
|
+
*/
|
|
51
|
+
show(trigger: InactiveOverlayTrigger): void;
|
|
52
|
+
/**
|
|
53
|
+
* Hide the inactive overlay
|
|
54
|
+
* This is the single entry point for hiding the overlay
|
|
55
|
+
*/
|
|
56
|
+
hide(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Check if overlay is currently visible
|
|
59
|
+
*/
|
|
60
|
+
isShowing(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Get the current trigger type if overlay is visible
|
|
63
|
+
*/
|
|
64
|
+
getCurrentTrigger(): InactiveOverlayTrigger | null;
|
|
65
|
+
/**
|
|
66
|
+
* Handle continue button click
|
|
67
|
+
*/
|
|
68
|
+
private handleContinue;
|
|
69
|
+
/**
|
|
70
|
+
* Handle countdown end
|
|
71
|
+
*/
|
|
72
|
+
private handleEnd;
|
|
73
|
+
/**
|
|
74
|
+
* Cleanup resources
|
|
75
|
+
*/
|
|
76
|
+
destroy(): void;
|
|
77
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class MediaCapture {
|
|
2
|
+
private video;
|
|
3
|
+
private canvas;
|
|
4
|
+
private ctx;
|
|
5
|
+
private worker;
|
|
6
|
+
private interval;
|
|
7
|
+
constructor(interval?: number);
|
|
8
|
+
private initWorker;
|
|
9
|
+
private drawFrame;
|
|
10
|
+
getCanvas(): HTMLCanvasElement;
|
|
11
|
+
setStream(stream: MediaStream | null): void;
|
|
12
|
+
terminate(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility for building CSS class names programmatically
|
|
3
|
+
*/
|
|
4
|
+
type ClassValue = string | number | boolean | undefined | null;
|
|
5
|
+
type ClassArray = ClassValue[];
|
|
6
|
+
type ClassObject = Record<string, boolean | undefined | null>;
|
|
7
|
+
type ClassInput = ClassValue | ClassArray | ClassObject;
|
|
8
|
+
/**
|
|
9
|
+
* Combines multiple class names into a single string
|
|
10
|
+
* Supports: strings, arrays, objects with boolean values
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* cn('foo', 'bar') // 'foo bar'
|
|
14
|
+
* cn(['foo', 'bar']) // 'foo bar'
|
|
15
|
+
* cn({ foo: true, bar: false }) // 'foo'
|
|
16
|
+
* cn('foo', ['bar', 'baz'], { qux: true }) // 'foo bar baz qux'
|
|
17
|
+
*/
|
|
18
|
+
export declare function cn(...inputs: ClassInput[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* Common CSS class name constants for the WaveForm component
|
|
21
|
+
*/
|
|
22
|
+
export declare const WaveFormClasses: {
|
|
23
|
+
readonly icon: "np_companion-action-btn-container-icon";
|
|
24
|
+
readonly persistFillColor: "np_companion-persist-fill-color";
|
|
25
|
+
readonly alignMiddle: "np_companion-align-middle";
|
|
26
|
+
readonly alignBetween: "np_companion-align-between";
|
|
27
|
+
readonly darkGreyBg: "np_companion-dark-grey-bg";
|
|
28
|
+
readonly callEnd: "np_companion-action-btn-container-call-end";
|
|
29
|
+
readonly container: "np_companion-action-btn-container-container";
|
|
30
|
+
readonly wrapper: "np_companion-action-btn-container-wrapper";
|
|
31
|
+
readonly canvas: "np_companion-action-btn-container-canvas";
|
|
32
|
+
readonly controls: "np_companion-action-btn-container-controls";
|
|
33
|
+
readonly left: "np_companion-action-btn-container-left";
|
|
34
|
+
readonly middle: "np_companion-action-btn-container-middle";
|
|
35
|
+
readonly right: "np_companion-action-btn-container-right";
|
|
36
|
+
readonly wave: "np_companion-action-btn-container-wave";
|
|
37
|
+
readonly stop: "np_companion-action-btn-container-stop";
|
|
38
|
+
readonly questionBar: "np_companion-chat-question-bar-container";
|
|
39
|
+
readonly talking: "np_companion-talking";
|
|
40
|
+
readonly muted: "muted";
|
|
41
|
+
readonly hidden: "np_companion-hidden";
|
|
42
|
+
readonly expanded: "np_companion-action-btn-container-expanded";
|
|
43
|
+
readonly collapse: "np_companion-action-btn-container-collapse";
|
|
44
|
+
readonly mobileMode: "np_companion-mobile-mode";
|
|
45
|
+
readonly displayNone: "np_companion__d-none";
|
|
46
|
+
readonly iconButton: () => string;
|
|
47
|
+
readonly iconButtonEnd: () => string;
|
|
48
|
+
readonly iconButtonWithState: (isMuted: boolean) => string;
|
|
49
|
+
};
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log levels for different types of debug output
|
|
3
|
+
*/
|
|
4
|
+
export declare enum LogLevel {
|
|
5
|
+
INFO = "info",
|
|
6
|
+
WARN = "warn",
|
|
7
|
+
ERROR = "error",
|
|
8
|
+
DEBUG = "debug"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Debug logger class that checks the Redux store for debug mode
|
|
12
|
+
*/
|
|
13
|
+
declare class DebugLogger {
|
|
14
|
+
private prefix;
|
|
15
|
+
/**
|
|
16
|
+
* Check if debug mode is currently enabled
|
|
17
|
+
*/
|
|
18
|
+
private isDebugEnabled;
|
|
19
|
+
/**
|
|
20
|
+
* Generic log method that checks debug mode
|
|
21
|
+
*/
|
|
22
|
+
private log;
|
|
23
|
+
/**
|
|
24
|
+
* Log general information
|
|
25
|
+
*/
|
|
26
|
+
info(...args: unknown[]): void;
|
|
27
|
+
/**
|
|
28
|
+
* Log debug information
|
|
29
|
+
*/
|
|
30
|
+
debug(...args: unknown[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* Log warning information
|
|
33
|
+
*/
|
|
34
|
+
warn(...args: unknown[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Log error information
|
|
37
|
+
*/
|
|
38
|
+
error(...args: unknown[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Log warnings - these are shown regardless of debug mode
|
|
41
|
+
*/
|
|
42
|
+
critical_warn(...args: unknown[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Log errors - these are shown regardless of debug mode
|
|
45
|
+
*/
|
|
46
|
+
critical_error(...args: unknown[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* Log WebRTC-related debug information
|
|
49
|
+
*/
|
|
50
|
+
webrtc(...args: unknown[]): void;
|
|
51
|
+
/**
|
|
52
|
+
* Log Avatar-related debug information
|
|
53
|
+
*/
|
|
54
|
+
avatar(...args: unknown[]): void;
|
|
55
|
+
/**
|
|
56
|
+
* Log connection-related debug information
|
|
57
|
+
*/
|
|
58
|
+
connection(...args: unknown[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* Log features-related debug information
|
|
61
|
+
*/
|
|
62
|
+
features(...args: unknown[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* Log data/messaging-related debug information
|
|
65
|
+
*/
|
|
66
|
+
data(...args: unknown[]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Log timeout/timer-related debug information
|
|
69
|
+
*/
|
|
70
|
+
timer(...args: unknown[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Log cleanup-related debug information
|
|
73
|
+
*/
|
|
74
|
+
cleanup(...args: unknown[]): void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Global debug logger instance
|
|
78
|
+
*/
|
|
79
|
+
export declare const debugLogger: DebugLogger;
|
|
80
|
+
/**
|
|
81
|
+
* Convenience export for common usage
|
|
82
|
+
*/
|
|
83
|
+
export declare const debug: DebugLogger;
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory for creating DOM elements with consistent configuration
|
|
3
|
+
*/
|
|
4
|
+
export declare class DOMFactory {
|
|
5
|
+
/**
|
|
6
|
+
* Create a generic HTML element with optional configuration
|
|
7
|
+
*/
|
|
8
|
+
static createElement<K extends keyof HTMLElementTagNameMap>(tag: K, options?: {
|
|
9
|
+
className?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
attributes?: Record<string, string>;
|
|
12
|
+
styles?: Partial<CSSStyleDeclaration>;
|
|
13
|
+
}): HTMLElementTagNameMap[K];
|
|
14
|
+
/**
|
|
15
|
+
* Create a video element with common configuration
|
|
16
|
+
*/
|
|
17
|
+
static createVideo(options: {
|
|
18
|
+
className?: string;
|
|
19
|
+
autoplay?: boolean;
|
|
20
|
+
muted?: boolean;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
playsInline?: boolean;
|
|
23
|
+
crossOrigin?: string;
|
|
24
|
+
poster?: string;
|
|
25
|
+
src?: string;
|
|
26
|
+
}): HTMLVideoElement;
|
|
27
|
+
/**
|
|
28
|
+
* Create an audio element with common configuration
|
|
29
|
+
*/
|
|
30
|
+
static createAudio(options: {
|
|
31
|
+
className?: string;
|
|
32
|
+
autoplay?: boolean;
|
|
33
|
+
}): HTMLAudioElement;
|
|
34
|
+
/**
|
|
35
|
+
* Create a canvas element with dimensions
|
|
36
|
+
*/
|
|
37
|
+
static createCanvas(options: {
|
|
38
|
+
className?: string;
|
|
39
|
+
width?: number;
|
|
40
|
+
height?: number;
|
|
41
|
+
styles?: Partial<CSSStyleDeclaration>;
|
|
42
|
+
}): HTMLCanvasElement;
|
|
43
|
+
/**
|
|
44
|
+
* Create a button element with content
|
|
45
|
+
*/
|
|
46
|
+
static createButton(options: {
|
|
47
|
+
className?: string;
|
|
48
|
+
textContent?: string;
|
|
49
|
+
attributes?: Record<string, string>;
|
|
50
|
+
onClick?: () => void;
|
|
51
|
+
}): HTMLButtonElement;
|
|
52
|
+
/**
|
|
53
|
+
* Create a div element (most common case)
|
|
54
|
+
*/
|
|
55
|
+
static createDiv(className?: string): HTMLDivElement;
|
|
56
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processor for removing green screen background from video frames
|
|
3
|
+
*/
|
|
4
|
+
export declare class GreenScreenProcessor {
|
|
5
|
+
/**
|
|
6
|
+
* Process image data to remove green screen and reduce green spill
|
|
7
|
+
*/
|
|
8
|
+
static process(imageData: ImageData): ImageData;
|
|
9
|
+
/**
|
|
10
|
+
* Check if the image contains any green screen pixels
|
|
11
|
+
*/
|
|
12
|
+
private static hasGreenScreen;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a pixel matches green screen color range
|
|
15
|
+
*/
|
|
16
|
+
private static isGreenPixel;
|
|
17
|
+
/**
|
|
18
|
+
* Remove green screen and reduce green spill from image data
|
|
19
|
+
*/
|
|
20
|
+
private static removeGreenScreen;
|
|
21
|
+
/**
|
|
22
|
+
* Reduce green color spill on edges of foreground objects
|
|
23
|
+
*/
|
|
24
|
+
private static reduceGreenSpill;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GreenScreenProcessor";
|