@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/types.d.cts
CHANGED
|
@@ -42,6 +42,19 @@ export interface SpeechOSCoreConfig {
|
|
|
42
42
|
* If not provided, uses the native WebSocket constructor.
|
|
43
43
|
*/
|
|
44
44
|
webSocketFactory?: WebSocketFactory;
|
|
45
|
+
/**
|
|
46
|
+
* Custom fetch handler for making HTTP requests.
|
|
47
|
+
* Used by the Chrome extension to route fetch traffic through the
|
|
48
|
+
* service worker, bypassing page CSP restrictions.
|
|
49
|
+
* If not provided, uses the native fetch function.
|
|
50
|
+
*/
|
|
51
|
+
fetchHandler?: FetchHandler;
|
|
52
|
+
/**
|
|
53
|
+
* JWT token for server-side settings persistence.
|
|
54
|
+
* When provided, user settings (language, vocabulary, snippets) are synced to the server.
|
|
55
|
+
* Generate this token server-side via POST /api/user-settings-token/ with your UserAPIKey.
|
|
56
|
+
*/
|
|
57
|
+
settingsToken?: string;
|
|
45
58
|
}
|
|
46
59
|
/**
|
|
47
60
|
* Session settings passed when starting a voice session
|
|
@@ -223,11 +236,21 @@ export interface SpeechOSEventMap {
|
|
|
223
236
|
editedContent: string;
|
|
224
237
|
element: HTMLElement;
|
|
225
238
|
};
|
|
226
|
-
/** Emitted when user settings change (language, snippets, vocabulary, smartFormat) */
|
|
239
|
+
/** Emitted when user settings change (language, snippets, vocabulary, smartFormat, history) */
|
|
227
240
|
"settings:changed": {
|
|
228
241
|
/** Type of setting that changed */
|
|
229
|
-
setting: "language" | "snippets" | "vocabulary" | "smartFormat";
|
|
242
|
+
setting: "language" | "snippets" | "vocabulary" | "smartFormat" | "history";
|
|
243
|
+
};
|
|
244
|
+
/** Emitted when settings are loaded from the server */
|
|
245
|
+
"settings:loaded": void;
|
|
246
|
+
/** Emitted when settings are synced to the server */
|
|
247
|
+
"settings:synced": void;
|
|
248
|
+
/** Emitted when settings sync fails */
|
|
249
|
+
"settings:syncFailed": {
|
|
250
|
+
error: string;
|
|
230
251
|
};
|
|
252
|
+
/** Emitted when the settings token expires (user should request a new one) */
|
|
253
|
+
"settings:tokenExpired": void;
|
|
231
254
|
/** Emitted when an error occurs */
|
|
232
255
|
error: {
|
|
233
256
|
code: string;
|
|
@@ -271,3 +294,38 @@ export interface WebSocketLike {
|
|
|
271
294
|
* Used by extensions to provide a proxy WebSocket that bypasses page CSP.
|
|
272
295
|
*/
|
|
273
296
|
export type WebSocketFactory = (url: string) => WebSocketLike;
|
|
297
|
+
/**
|
|
298
|
+
* Options for fetch requests (subset of RequestInit used by settings sync).
|
|
299
|
+
* Used by extensions to route fetch traffic through the service worker.
|
|
300
|
+
*/
|
|
301
|
+
export interface FetchOptions {
|
|
302
|
+
/** HTTP method (GET, POST, PUT, DELETE, etc.) */
|
|
303
|
+
method?: string;
|
|
304
|
+
/** Request headers */
|
|
305
|
+
headers?: Record<string, string>;
|
|
306
|
+
/** Request body (JSON string) */
|
|
307
|
+
body?: string;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Response from fetch handler (subset of Response used by settings sync).
|
|
311
|
+
* Provides a Response-like interface that can be serialized through message passing.
|
|
312
|
+
*/
|
|
313
|
+
export interface FetchResponse {
|
|
314
|
+
/** Whether the response was successful (status 200-299) */
|
|
315
|
+
ok: boolean;
|
|
316
|
+
/** HTTP status code */
|
|
317
|
+
status: number;
|
|
318
|
+
/** HTTP status text */
|
|
319
|
+
statusText: string;
|
|
320
|
+
/** Parse response body as JSON */
|
|
321
|
+
json(): Promise<unknown>;
|
|
322
|
+
/** Get response body as text */
|
|
323
|
+
text(): Promise<string>;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Custom fetch handler for making HTTP requests.
|
|
327
|
+
* Used by the Chrome extension to route fetch traffic through the
|
|
328
|
+
* service worker, bypassing page CSP restrictions.
|
|
329
|
+
* If not provided, uses the native fetch function.
|
|
330
|
+
*/
|
|
331
|
+
export type FetchHandler = (url: string, options?: FetchOptions) => Promise<FetchResponse>;
|
package/dist/types.d.ts
CHANGED
|
@@ -42,6 +42,19 @@ export interface SpeechOSCoreConfig {
|
|
|
42
42
|
* If not provided, uses the native WebSocket constructor.
|
|
43
43
|
*/
|
|
44
44
|
webSocketFactory?: WebSocketFactory;
|
|
45
|
+
/**
|
|
46
|
+
* Custom fetch handler for making HTTP requests.
|
|
47
|
+
* Used by the Chrome extension to route fetch traffic through the
|
|
48
|
+
* service worker, bypassing page CSP restrictions.
|
|
49
|
+
* If not provided, uses the native fetch function.
|
|
50
|
+
*/
|
|
51
|
+
fetchHandler?: FetchHandler;
|
|
52
|
+
/**
|
|
53
|
+
* JWT token for server-side settings persistence.
|
|
54
|
+
* When provided, user settings (language, vocabulary, snippets) are synced to the server.
|
|
55
|
+
* Generate this token server-side via POST /api/user-settings-token/ with your UserAPIKey.
|
|
56
|
+
*/
|
|
57
|
+
settingsToken?: string;
|
|
45
58
|
}
|
|
46
59
|
/**
|
|
47
60
|
* Session settings passed when starting a voice session
|
|
@@ -223,11 +236,21 @@ export interface SpeechOSEventMap {
|
|
|
223
236
|
editedContent: string;
|
|
224
237
|
element: HTMLElement;
|
|
225
238
|
};
|
|
226
|
-
/** Emitted when user settings change (language, snippets, vocabulary, smartFormat) */
|
|
239
|
+
/** Emitted when user settings change (language, snippets, vocabulary, smartFormat, history) */
|
|
227
240
|
"settings:changed": {
|
|
228
241
|
/** Type of setting that changed */
|
|
229
|
-
setting: "language" | "snippets" | "vocabulary" | "smartFormat";
|
|
242
|
+
setting: "language" | "snippets" | "vocabulary" | "smartFormat" | "history";
|
|
243
|
+
};
|
|
244
|
+
/** Emitted when settings are loaded from the server */
|
|
245
|
+
"settings:loaded": void;
|
|
246
|
+
/** Emitted when settings are synced to the server */
|
|
247
|
+
"settings:synced": void;
|
|
248
|
+
/** Emitted when settings sync fails */
|
|
249
|
+
"settings:syncFailed": {
|
|
250
|
+
error: string;
|
|
230
251
|
};
|
|
252
|
+
/** Emitted when the settings token expires (user should request a new one) */
|
|
253
|
+
"settings:tokenExpired": void;
|
|
231
254
|
/** Emitted when an error occurs */
|
|
232
255
|
error: {
|
|
233
256
|
code: string;
|
|
@@ -271,3 +294,38 @@ export interface WebSocketLike {
|
|
|
271
294
|
* Used by extensions to provide a proxy WebSocket that bypasses page CSP.
|
|
272
295
|
*/
|
|
273
296
|
export type WebSocketFactory = (url: string) => WebSocketLike;
|
|
297
|
+
/**
|
|
298
|
+
* Options for fetch requests (subset of RequestInit used by settings sync).
|
|
299
|
+
* Used by extensions to route fetch traffic through the service worker.
|
|
300
|
+
*/
|
|
301
|
+
export interface FetchOptions {
|
|
302
|
+
/** HTTP method (GET, POST, PUT, DELETE, etc.) */
|
|
303
|
+
method?: string;
|
|
304
|
+
/** Request headers */
|
|
305
|
+
headers?: Record<string, string>;
|
|
306
|
+
/** Request body (JSON string) */
|
|
307
|
+
body?: string;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Response from fetch handler (subset of Response used by settings sync).
|
|
311
|
+
* Provides a Response-like interface that can be serialized through message passing.
|
|
312
|
+
*/
|
|
313
|
+
export interface FetchResponse {
|
|
314
|
+
/** Whether the response was successful (status 200-299) */
|
|
315
|
+
ok: boolean;
|
|
316
|
+
/** HTTP status code */
|
|
317
|
+
status: number;
|
|
318
|
+
/** HTTP status text */
|
|
319
|
+
statusText: string;
|
|
320
|
+
/** Parse response body as JSON */
|
|
321
|
+
json(): Promise<unknown>;
|
|
322
|
+
/** Get response body as text */
|
|
323
|
+
text(): Promise<string>;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Custom fetch handler for making HTTP requests.
|
|
327
|
+
* Used by the Chrome extension to route fetch traffic through the
|
|
328
|
+
* service worker, bypassing page CSP restrictions.
|
|
329
|
+
* If not provided, uses the native fetch function.
|
|
330
|
+
*/
|
|
331
|
+
export type FetchHandler = (url: string, options?: FetchOptions) => Promise<FetchResponse>;
|