@speechos/core 0.2.0

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.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Configuration management for SpeechOS SDK
3
+ */
4
+ import type { SpeechOSConfig } from "./types.js";
5
+ /**
6
+ * Default host - can be overridden by SPEECHOS_HOST env var at build time
7
+ */
8
+ export declare const DEFAULT_HOST: string;
9
+ /**
10
+ * Default configuration values
11
+ */
12
+ export declare const defaultConfig: Required<SpeechOSConfig>;
13
+ /**
14
+ * Validates and merges user config with defaults
15
+ * @param userConfig - User-provided configuration
16
+ * @returns Validated and merged configuration
17
+ */
18
+ export declare function validateConfig(userConfig?: SpeechOSConfig): Required<SpeechOSConfig>;
19
+ /**
20
+ * Get the current configuration
21
+ */
22
+ export declare function getConfig(): Required<SpeechOSConfig>;
23
+ /**
24
+ * Set the current configuration
25
+ * @param config - Configuration to set
26
+ */
27
+ export declare function setConfig(config: SpeechOSConfig): void;
28
+ /**
29
+ * Reset configuration to defaults
30
+ */
31
+ export declare function resetConfig(): void;
32
+ /**
33
+ * Update the userId in the current configuration
34
+ * @param userId - The user identifier to set
35
+ */
36
+ export declare function updateUserId(userId: string): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Configuration management for SpeechOS SDK
3
+ */
4
+ import type { SpeechOSConfig } from "./types.js";
5
+ /**
6
+ * Default host - can be overridden by SPEECHOS_HOST env var at build time
7
+ */
8
+ export declare const DEFAULT_HOST: string;
9
+ /**
10
+ * Default configuration values
11
+ */
12
+ export declare const defaultConfig: Required<SpeechOSConfig>;
13
+ /**
14
+ * Validates and merges user config with defaults
15
+ * @param userConfig - User-provided configuration
16
+ * @returns Validated and merged configuration
17
+ */
18
+ export declare function validateConfig(userConfig?: SpeechOSConfig): Required<SpeechOSConfig>;
19
+ /**
20
+ * Get the current configuration
21
+ */
22
+ export declare function getConfig(): Required<SpeechOSConfig>;
23
+ /**
24
+ * Set the current configuration
25
+ * @param config - Configuration to set
26
+ */
27
+ export declare function setConfig(config: SpeechOSConfig): void;
28
+ /**
29
+ * Reset configuration to defaults
30
+ */
31
+ export declare function resetConfig(): void;
32
+ /**
33
+ * Update the userId in the current configuration
34
+ * @param userId - The user identifier to set
35
+ */
36
+ export declare function updateUserId(userId: string): void;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Typed event system for SpeechOS SDK
3
+ * Provides a type-safe event emitter for cross-component communication
4
+ */
5
+ import type { SpeechOSEventMap, UnsubscribeFn } from "./types.js";
6
+ type EventCallback<K extends keyof SpeechOSEventMap> = (payload: SpeechOSEventMap[K]) => void;
7
+ /**
8
+ * Type-safe event emitter for SpeechOS events
9
+ */
10
+ export declare class SpeechOSEventEmitter {
11
+ private listeners;
12
+ /**
13
+ * Subscribe to an event
14
+ * @param event - Event name to listen to
15
+ * @param callback - Function to call when event is emitted
16
+ * @returns Unsubscribe function
17
+ */
18
+ on<K extends keyof SpeechOSEventMap>(event: K, callback: EventCallback<K>): UnsubscribeFn;
19
+ /**
20
+ * Subscribe to an event once (automatically unsubscribes after first call)
21
+ * @param event - Event name to listen to
22
+ * @param callback - Function to call when event is emitted
23
+ * @returns Unsubscribe function
24
+ */
25
+ once<K extends keyof SpeechOSEventMap>(event: K, callback: EventCallback<K>): UnsubscribeFn;
26
+ /**
27
+ * Emit an event to all subscribers
28
+ * @param event - Event name to emit
29
+ * @param payload - Event payload data
30
+ */
31
+ emit<K extends keyof SpeechOSEventMap>(event: K, payload: SpeechOSEventMap[K]): void;
32
+ /**
33
+ * Remove all listeners for a specific event or all events
34
+ * @param event - Optional event name to clear listeners for
35
+ */
36
+ clear(event?: keyof SpeechOSEventMap): void;
37
+ /**
38
+ * Get the number of listeners for an event
39
+ * @param event - Event name
40
+ * @returns Number of listeners
41
+ */
42
+ listenerCount(event: keyof SpeechOSEventMap): number;
43
+ }
44
+ export declare const events: SpeechOSEventEmitter;
45
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Typed event system for SpeechOS SDK
3
+ * Provides a type-safe event emitter for cross-component communication
4
+ */
5
+ import type { SpeechOSEventMap, UnsubscribeFn } from "./types.js";
6
+ type EventCallback<K extends keyof SpeechOSEventMap> = (payload: SpeechOSEventMap[K]) => void;
7
+ /**
8
+ * Type-safe event emitter for SpeechOS events
9
+ */
10
+ export declare class SpeechOSEventEmitter {
11
+ private listeners;
12
+ /**
13
+ * Subscribe to an event
14
+ * @param event - Event name to listen to
15
+ * @param callback - Function to call when event is emitted
16
+ * @returns Unsubscribe function
17
+ */
18
+ on<K extends keyof SpeechOSEventMap>(event: K, callback: EventCallback<K>): UnsubscribeFn;
19
+ /**
20
+ * Subscribe to an event once (automatically unsubscribes after first call)
21
+ * @param event - Event name to listen to
22
+ * @param callback - Function to call when event is emitted
23
+ * @returns Unsubscribe function
24
+ */
25
+ once<K extends keyof SpeechOSEventMap>(event: K, callback: EventCallback<K>): UnsubscribeFn;
26
+ /**
27
+ * Emit an event to all subscribers
28
+ * @param event - Event name to emit
29
+ * @param payload - Event payload data
30
+ */
31
+ emit<K extends keyof SpeechOSEventMap>(event: K, payload: SpeechOSEventMap[K]): void;
32
+ /**
33
+ * Remove all listeners for a specific event or all events
34
+ * @param event - Optional event name to clear listeners for
35
+ */
36
+ clear(event?: keyof SpeechOSEventMap): void;
37
+ /**
38
+ * Get the number of listeners for an event
39
+ * @param event - Event name
40
+ * @returns Number of listeners
41
+ */
42
+ listenerCount(event: keyof SpeechOSEventMap): number;
43
+ }
44
+ export declare const events: SpeechOSEventEmitter;
45
+ export {};