@speechos/core 0.2.7 → 0.2.8
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/dist/config.d.cts +19 -1
- package/dist/config.d.ts +19 -1
- package/dist/index.cjs +32 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/types.d.cts +60 -2
- package/dist/types.d.ts +60 -2
- package/package.json +1 -1
package/dist/config.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration management for SpeechOS Core SDK
|
|
3
3
|
*/
|
|
4
|
-
import type { SpeechOSCoreConfig, WebSocketFactory } from "./types.js";
|
|
4
|
+
import type { SpeechOSCoreConfig, WebSocketFactory, FetchHandler } from "./types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Default host - can be overridden by SPEECHOS_HOST env var at build time
|
|
7
7
|
*/
|
|
@@ -16,6 +16,10 @@ interface ResolvedConfig {
|
|
|
16
16
|
debug: boolean;
|
|
17
17
|
/** Custom WebSocket factory (undefined means use native WebSocket) */
|
|
18
18
|
webSocketFactory: WebSocketFactory | undefined;
|
|
19
|
+
/** Custom fetch handler (undefined means use native fetch) */
|
|
20
|
+
fetchHandler: FetchHandler | undefined;
|
|
21
|
+
/** JWT token for server-side settings persistence (undefined means no sync) */
|
|
22
|
+
settingsToken: string | undefined;
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* Validates and merges user config with defaults
|
|
@@ -41,6 +45,20 @@ export declare function resetConfig(): void;
|
|
|
41
45
|
* @param userId - The user identifier to set
|
|
42
46
|
*/
|
|
43
47
|
export declare function updateUserId(userId: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the settings token from the current configuration
|
|
50
|
+
* @returns The settings token or undefined if not configured
|
|
51
|
+
*/
|
|
52
|
+
export declare function getSettingsToken(): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Clear the settings token (e.g., when it expires)
|
|
55
|
+
*/
|
|
56
|
+
export declare function clearSettingsToken(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Get the fetch handler from the current configuration
|
|
59
|
+
* @returns The fetch handler or undefined if not configured
|
|
60
|
+
*/
|
|
61
|
+
export declare function getFetchHandler(): FetchHandler | undefined;
|
|
44
62
|
/**
|
|
45
63
|
* Get or generate a persistent anonymous ID for Mixpanel tracking.
|
|
46
64
|
*
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration management for SpeechOS Core SDK
|
|
3
3
|
*/
|
|
4
|
-
import type { SpeechOSCoreConfig, WebSocketFactory } from "./types.js";
|
|
4
|
+
import type { SpeechOSCoreConfig, WebSocketFactory, FetchHandler } from "./types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Default host - can be overridden by SPEECHOS_HOST env var at build time
|
|
7
7
|
*/
|
|
@@ -16,6 +16,10 @@ interface ResolvedConfig {
|
|
|
16
16
|
debug: boolean;
|
|
17
17
|
/** Custom WebSocket factory (undefined means use native WebSocket) */
|
|
18
18
|
webSocketFactory: WebSocketFactory | undefined;
|
|
19
|
+
/** Custom fetch handler (undefined means use native fetch) */
|
|
20
|
+
fetchHandler: FetchHandler | undefined;
|
|
21
|
+
/** JWT token for server-side settings persistence (undefined means no sync) */
|
|
22
|
+
settingsToken: string | undefined;
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* Validates and merges user config with defaults
|
|
@@ -41,6 +45,20 @@ export declare function resetConfig(): void;
|
|
|
41
45
|
* @param userId - The user identifier to set
|
|
42
46
|
*/
|
|
43
47
|
export declare function updateUserId(userId: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the settings token from the current configuration
|
|
50
|
+
* @returns The settings token or undefined if not configured
|
|
51
|
+
*/
|
|
52
|
+
export declare function getSettingsToken(): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Clear the settings token (e.g., when it expires)
|
|
55
|
+
*/
|
|
56
|
+
export declare function clearSettingsToken(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Get the fetch handler from the current configuration
|
|
59
|
+
* @returns The fetch handler or undefined if not configured
|
|
60
|
+
*/
|
|
61
|
+
export declare function getFetchHandler(): FetchHandler | undefined;
|
|
44
62
|
/**
|
|
45
63
|
* Get or generate a persistent anonymous ID for Mixpanel tracking.
|
|
46
64
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,9 @@ const defaultConfig = {
|
|
|
36
36
|
userId: "",
|
|
37
37
|
host: DEFAULT_HOST,
|
|
38
38
|
debug: false,
|
|
39
|
-
webSocketFactory: void 0
|
|
39
|
+
webSocketFactory: void 0,
|
|
40
|
+
fetchHandler: void 0,
|
|
41
|
+
settingsToken: void 0
|
|
40
42
|
};
|
|
41
43
|
/**
|
|
42
44
|
* Validates and merges user config with defaults
|
|
@@ -50,7 +52,9 @@ function validateConfig(userConfig) {
|
|
|
50
52
|
userId: userConfig.userId ?? defaultConfig.userId,
|
|
51
53
|
host: userConfig.host ?? defaultConfig.host,
|
|
52
54
|
debug: userConfig.debug ?? defaultConfig.debug,
|
|
53
|
-
webSocketFactory: userConfig.webSocketFactory ?? defaultConfig.webSocketFactory
|
|
55
|
+
webSocketFactory: userConfig.webSocketFactory ?? defaultConfig.webSocketFactory,
|
|
56
|
+
fetchHandler: userConfig.fetchHandler ?? defaultConfig.fetchHandler,
|
|
57
|
+
settingsToken: userConfig.settingsToken ?? defaultConfig.settingsToken
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
@@ -87,6 +91,29 @@ function updateUserId(userId) {
|
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
/**
|
|
94
|
+
* Get the settings token from the current configuration
|
|
95
|
+
* @returns The settings token or undefined if not configured
|
|
96
|
+
*/
|
|
97
|
+
function getSettingsToken() {
|
|
98
|
+
return currentConfig.settingsToken;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Clear the settings token (e.g., when it expires)
|
|
102
|
+
*/
|
|
103
|
+
function clearSettingsToken() {
|
|
104
|
+
currentConfig = {
|
|
105
|
+
...currentConfig,
|
|
106
|
+
settingsToken: void 0
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the fetch handler from the current configuration
|
|
111
|
+
* @returns The fetch handler or undefined if not configured
|
|
112
|
+
*/
|
|
113
|
+
function getFetchHandler() {
|
|
114
|
+
return currentConfig.fetchHandler;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
90
117
|
* LocalStorage key for anonymous ID persistence
|
|
91
118
|
*/
|
|
92
119
|
const ANONYMOUS_ID_KEY = "speechos_anonymous_id";
|
|
@@ -2270,10 +2297,13 @@ exports.DEFAULT_HOST = DEFAULT_HOST;
|
|
|
2270
2297
|
exports.Deferred = Deferred;
|
|
2271
2298
|
exports.SpeechOSEventEmitter = SpeechOSEventEmitter;
|
|
2272
2299
|
exports.VERSION = VERSION;
|
|
2300
|
+
exports.clearSettingsToken = clearSettingsToken;
|
|
2273
2301
|
exports.createStateManager = createStateManager;
|
|
2274
2302
|
exports.events = events;
|
|
2275
2303
|
exports.getBackend = getBackend;
|
|
2276
2304
|
exports.getConfig = getConfig;
|
|
2305
|
+
exports.getFetchHandler = getFetchHandler;
|
|
2306
|
+
exports.getSettingsToken = getSettingsToken;
|
|
2277
2307
|
exports.livekit = livekit;
|
|
2278
2308
|
exports.resetConfig = resetConfig;
|
|
2279
2309
|
exports.setConfig = setConfig;
|