@ikonai/sdk 0.0.32 → 0.0.34

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.
@@ -18,3 +18,6 @@ export declare const JITTER_EMA_DIVISOR = 10;
18
18
  export declare const PCM_POST_TARGET_MS = 80;
19
19
  export declare const PCM_POST_MAX_INTERVAL_MS = 50;
20
20
  export declare const MAX_PENDING_FRAMES = 64;
21
+ export declare const MULTI_STREAM_NORMALIZATION_ENABLED = true;
22
+ export declare const AUDIO_CAPTURE_FRAME_DURATION_MS = 20;
23
+ export declare const AUDIO_CAPTURE_DEFAULT_BITRATE = 32000;
@@ -4,11 +4,12 @@ export interface IkonAudioCaptureRequest {
4
4
  constraints?: MediaTrackConstraints;
5
5
  options?: {
6
6
  bitrate?: number;
7
- frameDurationMs?: number;
8
7
  };
9
8
  }
10
9
  export interface IkonAudioCaptureHandle {
11
10
  captureId: string;
11
+ startSegment(): void;
12
+ endSegment(): void;
12
13
  stop(): Promise<void>;
13
14
  }
14
15
  export declare class IkonAudioCapture {
@@ -30,5 +31,7 @@ export declare class IkonAudioCapture {
30
31
  private ensureWorklet;
31
32
  startMic(request?: IkonAudioCaptureRequest): Promise<IkonAudioCaptureHandle>;
32
33
  stop(captureId: string): Promise<boolean>;
34
+ startSegment(captureId: string): boolean;
35
+ endSegment(captureId: string): boolean;
33
36
  dispose(): void;
34
37
  }
@@ -1,29 +1,5 @@
1
1
  import { IkonClient } from '../client/ikon-client';
2
- export interface IkonAudioOutputConfig {
3
- /**
4
- * Multi-stream normalization configuration.
5
- *
6
- * When enabled, normalizes mixed output by the number of active streams.
7
- */
8
- multiStreamNormalization?: {
9
- enabled: boolean;
10
- };
11
- /**
12
- * Audio debugging/diagnostics configuration.
13
- *
14
- * When enabled, logs audio events and periodic status information.
15
- */
16
- diagnostics?: {
17
- enabled: boolean;
18
- /** Interval for periodic status logs in seconds. Default: 5 */
19
- statusInterval?: number;
20
- };
21
- }
22
2
  export interface IkonAudioPlaybackConfig {
23
- /**
24
- * Output format used by the mixing graph.
25
- */
26
- output?: IkonAudioOutputConfig;
27
3
  /**
28
4
  * Worker and transport preferences.
29
5
  *
@@ -39,6 +15,36 @@ export interface IkonAudioPlaybackConfig {
39
15
  preferAudioWorklet?: boolean;
40
16
  preferWebCodecs?: boolean;
41
17
  };
18
+ /**
19
+ * Background audio playback configuration.
20
+ *
21
+ * Controls whether audio continues playing when the tab/app is backgrounded.
22
+ * When background audio is allowed, the SDK sets up Media Session API for
23
+ * OS-level media controls (lock screen, media keys).
24
+ */
25
+ background?: {
26
+ /** Allow background audio on desktop. Default: true */
27
+ allowOnDesktop?: boolean;
28
+ /** Allow background audio on mobile. Default: false */
29
+ allowOnMobile?: boolean;
30
+ };
31
+ /**
32
+ * Media Session metadata for notifications/lock screen.
33
+ */
34
+ mediaSession?: {
35
+ /** Title shown in media notifications. Default: 'Audio' */
36
+ title?: string;
37
+ /** Artist shown in media notifications. Default: 'Ikon AI App' */
38
+ artist?: string;
39
+ };
40
+ /**
41
+ * Audio debugging/diagnostics configuration.
42
+ */
43
+ diagnostics?: {
44
+ enabled?: boolean;
45
+ /** Interval for periodic status logs in milliseconds. Default: 1000 */
46
+ statusIntervalMs?: number;
47
+ };
42
48
  }
43
49
  /**
44
50
  * Audio playback pipeline for Ikon protocol audio streams.
@@ -56,9 +62,9 @@ export declare class IkonAudioPlayback {
56
62
  private readonly config;
57
63
  private enabled;
58
64
  private stateUnsubscribe;
59
- private readonly isIos;
60
- private recreateOnNextResume;
65
+ private readonly isMobile;
61
66
  private boundVisibilityChange;
67
+ private boundPageHide;
62
68
  private unlockHandler;
63
69
  private awaitingUnlock;
64
70
  private recoveryTask;
@@ -75,6 +81,7 @@ export declare class IkonAudioPlayback {
75
81
  private pendingWorkletMessages;
76
82
  private audioWorker;
77
83
  private protocolPort;
84
+ private silentAudioElement;
78
85
  private readonly fallbackQueues;
79
86
  private readonly activeStreams;
80
87
  constructor(client: IkonClient, config?: IkonAudioPlaybackConfig);
@@ -98,14 +105,28 @@ export declare class IkonAudioPlayback {
98
105
  * Convenience wrapper for `setEnabled(false)`.
99
106
  */
100
107
  disable(): Promise<void>;
108
+ /**
109
+ * Pause audio output without tearing down the audio graph.
110
+ * Fast operation - just disconnects nodes from destination.
111
+ * Use this for temporary muting (e.g., Media Session pause).
112
+ */
113
+ pause(): void;
114
+ /**
115
+ * Resume audio output after pause().
116
+ * Fast operation - reconnects nodes to destination.
117
+ */
118
+ resume(): void;
101
119
  /**
102
120
  * Dispose of resources. After calling this, the instance should not be reused.
103
121
  */
104
122
  dispose(): void;
105
- private resolveOutputConfig;
123
+ private resolveDiagnosticsConfig;
124
+ private resolveBackgroundConfig;
106
125
  private ensureAudioGraph;
107
126
  private attachAudioContextHealthHandlers;
108
127
  private attachVisibilityHandler;
128
+ private setupMediaSession;
129
+ private cleanupMediaSession;
109
130
  private removeVisibilityHandler;
110
131
  private getContextState;
111
132
  private addUnlockHandler;
@@ -126,11 +147,11 @@ export declare class IkonAudioPlayback {
126
147
  private resumeAudioContextIfPossible;
127
148
  private recoverAudioContext;
128
149
  private recoverAudioContextInternal;
129
- private recreateAudioGraph;
130
150
  private rebindWorkerTransportIfNeeded;
131
151
  private ensureWorkers;
132
152
  private onAudioWorkerMessage;
133
153
  private postToWorklet;
154
+ private notifyPlaybackActive;
134
155
  private enqueuePendingWorkletMessage;
135
156
  private stopAudioWorklet;
136
157
  private stopScriptProcessor;
package/media/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { IkonMedia } from './ikon-media';
2
2
  export type { IkonMediaConfig } from './ikon-media';
3
3
  export { IkonAudioPlayback } from './ikon-audio-playback';
4
- export type { IkonAudioPlaybackConfig, IkonAudioOutputConfig } from './ikon-audio-playback';
4
+ export type { IkonAudioPlaybackConfig } from './ikon-audio-playback';
5
5
  export { IkonVideoPlayback } from './ikon-video-playback';
6
6
  export type { IkonVideoPlaybackConfig } from './ikon-video-playback';
7
7
  export { isSharedArrayBufferSupported, isAudioWorkletSupported } from './capabilities';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",