@ikonai/sdk 0.0.41 → 0.0.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.
@@ -26,3 +26,8 @@ export declare const AUDIO_CAPTURE_DEFAULT_BITRATE = 32000;
26
26
  export declare const AUDIO_CAPTURE_DEFAULT_COMPLEXITY = 5;
27
27
  export declare const AUDIO_CAPTURE_MIN_BITRATE = 8000;
28
28
  export declare const AUDIO_CAPTURE_MAX_BITRATE = 128000;
29
+ export declare const VISEME_BUFFER_MAX_FRAMES = 1500;
30
+ export declare const VISEME_BUFFER_DELAY_MS = -20;
31
+ export declare const VISEME_BUFFER_DELAY_MIN_MS = -100;
32
+ export declare const VISEME_BUFFER_DELAY_MAX_MS = 200;
33
+ export declare const VISEME_INTERPOLATION_ENABLED = true;
@@ -18,6 +18,8 @@ export interface IkonAudioCaptureRequest {
18
18
  }
19
19
  export interface IkonAudioCaptureHandle {
20
20
  captureId: string;
21
+ /** Whether the capture is still active (not stopped). On iOS, this becomes false after endSegment. */
22
+ readonly isActive: boolean;
21
23
  startSegment(): void;
22
24
  endSegment(): void;
23
25
  stop(): Promise<void>;
@@ -76,6 +76,10 @@ export declare class IkonAudioPlayback {
76
76
  private readonly fallbackQueues;
77
77
  private readonly activeStreams;
78
78
  private mediaSessionConfig;
79
+ private readonly streamShapeSets;
80
+ private readonly currentShapeSetValues;
81
+ private readonly visemeBuffers;
82
+ private readonly _visemeResult;
79
83
  constructor(client: IkonClient, config?: IkonAudioPlaybackConfig);
80
84
  /**
81
85
  * Set Media Session metadata for OS-level media controls (lock screen, notifications).
@@ -115,10 +119,71 @@ export declare class IkonAudioPlayback {
115
119
  * Fast operation - reconnects nodes to destination.
116
120
  */
117
121
  resume(): void;
122
+ /**
123
+ * Request recovery of the AudioContext. Call this when external factors
124
+ * (like audio capture stopping on iOS) may have disrupted playback.
125
+ *
126
+ * IMPORTANT: On iOS, this must be called synchronously from a user gesture handler
127
+ * (e.g., button click/release) to ensure the AudioContext can be recreated.
128
+ */
129
+ requestRecovery(): void;
130
+ /**
131
+ * Set up audio worklet after recreating AudioContext on iOS.
132
+ */
133
+ private setupAudioGraphAfterRecreate;
118
134
  /**
119
135
  * Dispose of resources. After calling this, the instance should not be reused.
120
136
  */
121
137
  dispose(): void;
138
+ /**
139
+ * Get the shape set declarations for a stream.
140
+ * Shape sets are declared at stream begin and contain metadata about the
141
+ * shape values that will be included in audio frames.
142
+ *
143
+ * @param streamId - The stream ID to get shape sets for
144
+ * @returns Array of shape set declarations, or null if stream not found
145
+ */
146
+ getShapeSets(streamId: string): {
147
+ SetId: number;
148
+ Name: string;
149
+ ShapeNames: string[];
150
+ }[] | null;
151
+ /**
152
+ * Get the current shape set values for a named shape set on a stream.
153
+ * Values are updated with each audio frame and represent the latest
154
+ * analysis results (e.g., viseme data).
155
+ *
156
+ * @param streamId - The stream ID to get values for
157
+ * @param setName - The name of the shape set (e.g., "Viseme")
158
+ * @returns Array of float values, or null if not found
159
+ */
160
+ getShapeSetValues(streamId: string, setName: string): number[] | null;
161
+ /**
162
+ * Get the current shape set values by set ID for a stream.
163
+ *
164
+ * @param streamId - The stream ID to get values for
165
+ * @param setId - The numeric ID of the shape set
166
+ * @returns Array of float values, or null if not found
167
+ */
168
+ getShapeSetValuesById(streamId: string, setId: number): number[] | null;
169
+ /**
170
+ * Get all current shape set values for a stream.
171
+ *
172
+ * @param streamId - The stream ID to get values for
173
+ * @returns Map of set ID to values, or null if stream not found
174
+ */
175
+ getAllShapeSetValues(streamId: string): Map<number, number[]> | null;
176
+ /**
177
+ * Get current viseme values from any active stream.
178
+ * Uses sample-based timing for precise synchronization with audio playback.
179
+ * Interpolates between viseme keyframes for smooth animation.
180
+ *
181
+ * @returns Object with mouthOpenY (0-1) and mouthForm (-1 to +1), or null if no viseme data
182
+ */
183
+ getCurrentVisemeValues(): {
184
+ mouthOpenY: number;
185
+ mouthForm: number;
186
+ } | null;
122
187
  private resolveDiagnosticsConfig;
123
188
  private resolveBackgroundConfig;
124
189
  private ensureAudioGraph;
@@ -28,5 +28,4 @@ export declare class IkonVideoCapture {
28
28
  startScreen(options?: Omit<IkonVideoCaptureRequest, 'source'>): Promise<IkonVideoCaptureHandle>;
29
29
  stop(captureId: string): Promise<boolean>;
30
30
  dispose(): void;
31
- private pumpFrames;
32
31
  }
@@ -46,7 +46,6 @@ export declare class IkonVideoPlayback {
46
46
  */
47
47
  dispose(): void;
48
48
  private canUseOffscreenCanvas;
49
- private hasDemand;
50
49
  private ensureWorker;
51
50
  private onWorkerMessage;
52
51
  private syncAllStreamsToWorker;
@@ -55,7 +54,6 @@ export declare class IkonVideoPlayback {
55
54
  private parseStreamId;
56
55
  private detachProtocolPort;
57
56
  private ensureProtocolPort;
58
- private maybeStopWorker;
59
57
  private stopWorker;
60
58
  private ensureStateSubscription;
61
59
  }
@@ -0,0 +1,42 @@
1
+ export declare const VIDEO_CAPTURE_DEFAULT_WIDTH = 1280;
2
+ export declare const VIDEO_CAPTURE_DEFAULT_HEIGHT = 720;
3
+ export declare const VIDEO_CAPTURE_DEFAULT_FRAMERATE = 30;
4
+ export declare const VIDEO_CAPTURE_DEFAULT_KEY_FRAME_INTERVAL: number;
5
+ export declare const VIDEO_CODEC_STRINGS_H264: string[];
6
+ export declare const VIDEO_CODEC_STRING_H264: string;
7
+ export declare const VIDEO_CODEC_STRING_VP8 = "vp8";
8
+ export declare const VIDEO_CODEC_STRINGS_VP9: string[];
9
+ export declare const VIDEO_CODEC_STRING_VP9: string;
10
+ export declare const VIDEO_CODEC_STRINGS_AV1: string[];
11
+ export declare const VIDEO_CODEC_STRING_AV1: string;
12
+ export declare const VIDEO_DECODE_CODEC_H264 = "avc1.42E01E";
13
+ export declare const VIDEO_DECODE_CODEC_VP8 = "vp8";
14
+ export declare const VIDEO_DECODE_CODEC_VP9 = "vp09.00.10.08";
15
+ export declare const VIDEO_DECODE_CODEC_AV1 = "av01.0.04M.08";
16
+ export declare const VIDEO_CAPTURE_DEFAULT_CODEC_PREFERENCES: readonly ('h264' | 'vp8' | 'vp9' | 'av1')[];
17
+ export declare const VIDEO_RESOLUTION_FALLBACKS: readonly [{
18
+ readonly width: 1920;
19
+ readonly height: 1080;
20
+ }, {
21
+ readonly width: 1280;
22
+ readonly height: 720;
23
+ }, {
24
+ readonly width: 960;
25
+ readonly height: 540;
26
+ }, {
27
+ readonly width: 640;
28
+ readonly height: 480;
29
+ }, {
30
+ readonly width: 640;
31
+ readonly height: 360;
32
+ }];
33
+ export declare const VIDEO_CAPTURE_BITS_PER_PIXEL = 0.1;
34
+ export declare const VIDEO_CAPTURE_BITRATE_FRAMERATE_BASELINE = 30;
35
+ export declare const VIDEO_CAPTURE_MIN_BITRATE = 50000;
36
+ export declare const VIDEO_CAPTURE_DEFAULT_BITRATE_MIN = 500000;
37
+ export declare const VIDEO_CAPTURE_DEFAULT_BITRATE_MAX = 8000000;
38
+ export declare const VIDEO_ENCODER_MAX_POOLED_BUFFERS = 8;
39
+ export declare const VIDEO_ENCODER_MAX_QUEUE_DEPTH = 3;
40
+ export declare const VIDEO_DECODER_MAX_PENDING_DECODES = 3;
41
+ export declare const IMAGE_CAPTURE_DEFAULT_MIME_TYPE = "image/jpeg";
42
+ export declare const IMAGE_CAPTURE_DEFAULT_JPEG_QUALITY = 0.92;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Detect if running on iOS (iPhone, iPad, iPod).
3
+ * Also detects iPadOS which reports as "Macintosh" but has touch support.
4
+ */
5
+ export declare const isIOS: () => boolean;
@@ -1,3 +1,4 @@
1
+ import { AudioShapeSetValues, AudioShapeSet } from '../../../../shared/protocol/src/index.ts';
1
2
  export type AudioPlaybackWorkerTransport = 'sab' | 'pcm';
2
3
  export type AudioPlaybackWorkerConfigureMessage = {
3
4
  type: 'configure';
@@ -24,6 +25,7 @@ export type AudioPlaybackWorkerOut = {
24
25
  type: 'streamBegin';
25
26
  streamId: string;
26
27
  sharedArrayBuffer?: SharedArrayBuffer;
28
+ shapeSets?: AudioShapeSet[];
27
29
  } | {
28
30
  type: 'streamEnd';
29
31
  streamId: string;
@@ -48,4 +50,5 @@ export type AudioPlaybackWorkerOut = {
48
50
  isFirst: boolean;
49
51
  isLast: boolean;
50
52
  jitterMs: number;
53
+ shapeSetValues?: AudioShapeSetValues[];
51
54
  };
@@ -1,4 +1,5 @@
1
- type CodecPreference = 'h264' | 'vp8' | 'hevc';
1
+ type CodecPreference = 'h264' | 'vp8' | 'vp9' | 'av1';
2
+ type HardwareAcceleration = 'preferHardware' | 'preferSoftware';
2
3
  export type VideoCaptureWorkerOptions = {
3
4
  preferredCodecs?: CodecPreference[];
4
5
  width?: number;
@@ -6,5 +7,6 @@ export type VideoCaptureWorkerOptions = {
6
7
  framerate?: number;
7
8
  bitrate?: number;
8
9
  keyFrameIntervalFrames?: number;
10
+ hardwareAcceleration?: HardwareAcceleration;
9
11
  };
10
12
  export {};
@@ -56,4 +56,7 @@ export type VideoPlaybackWorkerOut = {
56
56
  message: string;
57
57
  stack?: string;
58
58
  };
59
+ } | {
60
+ type: 'log';
61
+ message: string;
59
62
  };