@somecat/ai-assist-sdk 1.3.1 → 1.3.3
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/chunks/{index-BZPlXfol.mjs → index-2loQl224.mjs} +2 -2
- package/dist/chunks/{index-Da2hiup1.mjs → index-5fjEwBkV.mjs} +2174 -2141
- package/dist/core/voice/engine.d.ts +16 -1
- package/dist/core/voice/index.d.ts +1 -1
- package/dist/core/voice/types.d.ts +7 -0
- package/dist/index.mjs +1 -1
- package/dist/react/components/answer/components/ChatInput.d.ts +0 -1
- package/dist/react/index.mjs +7753 -7697
- package/dist/vue/index.mjs +1364 -1303
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VoiceConfig, VoiceStatus, VoiceEventCallbacks } from './types';
|
|
1
|
+
import { VoiceConfig, VoiceStatus, VoiceEventCallbacks, VoicePermissionResult } from './types';
|
|
2
2
|
export declare class VoiceEngine {
|
|
3
3
|
private config;
|
|
4
4
|
private callbacks;
|
|
@@ -9,6 +9,21 @@ export declare class VoiceEngine {
|
|
|
9
9
|
static isSupported(): boolean;
|
|
10
10
|
/** 当前状态 */
|
|
11
11
|
getStatus(): VoiceStatus;
|
|
12
|
+
/** 已确认麦克风可用(授权完成 / 无需预检),后续调用直接放行 */
|
|
13
|
+
private static micGranted;
|
|
14
|
+
/**
|
|
15
|
+
* 预请求麦克风权限(需在用户手势中调用)。
|
|
16
|
+
*
|
|
17
|
+
* 动机:若把授权弹窗留到 `start()` 阶段,用户必须松开指针去操作浏览器授权 UI,
|
|
18
|
+
* 松手事件会被浏览器 UI 抢走,「按住说话」就会一直停在聆听态。
|
|
19
|
+
* 因此首次使用前主动完成授权,让 `start()` 不再弹窗。
|
|
20
|
+
*
|
|
21
|
+
* - 已授权:直接返回 `granted`,无弹窗、无副作用
|
|
22
|
+
* - 未授权:用 `getUserMedia` 触发一次授权(拿到流后立即释放)
|
|
23
|
+
* - 明确被拒绝:返回 `granted: false`
|
|
24
|
+
* - 无法预检(权限查询 API 不支持 / 非安全上下文):返回 `granted: true`,交给 SpeechRecognition 自行处理
|
|
25
|
+
*/
|
|
26
|
+
static ensurePermission(): Promise<VoicePermissionResult>;
|
|
12
27
|
/**
|
|
13
28
|
* 开始语音识别。
|
|
14
29
|
* 创建 SpeechRecognition 实例并绑定事件,start 后等待 onstart 进入识别态。
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { VoiceEngine } from './engine';
|
|
2
|
-
export type { VoiceConfig, VoiceStatus, VoiceResult, VoiceResultType, VoiceError, VoiceErrorType, VoiceEventCallbacks, } from './types';
|
|
2
|
+
export type { VoiceConfig, VoiceStatus, VoiceResult, VoiceResultType, VoicePermissionResult, VoiceError, VoiceErrorType, VoiceEventCallbacks, } from './types';
|
|
@@ -24,6 +24,13 @@ export interface VoiceConfig {
|
|
|
24
24
|
}
|
|
25
25
|
/** 错误分类 */
|
|
26
26
|
export type VoiceErrorType = 'not-allowed' | 'service-not-allowed' | 'no-speech' | 'aborted' | 'audio-capture' | 'network' | 'language-not-supported' | 'unsupported' | 'unknown';
|
|
27
|
+
/** 麦克风权限预检结果 */
|
|
28
|
+
export interface VoicePermissionResult {
|
|
29
|
+
/** 是否可用(已授权,或无法预检时交给 SpeechRecognition 自行处理) */
|
|
30
|
+
granted: boolean;
|
|
31
|
+
/** 本次调用是否弹出了授权请求(授权完成时用户手势已丢失,调用方需提示重新发起) */
|
|
32
|
+
prompted: boolean;
|
|
33
|
+
}
|
|
27
34
|
/** 语音识别错误 */
|
|
28
35
|
export interface VoiceError {
|
|
29
36
|
/** 错误码(浏览器原始 error 字符串或自定义) */
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V as a, m as t, v as o, b as n, c as r, k as i, e as g, x as p, h as u, y as C, f as c, j as f, g as h, z as l, l as v, A as d, B as m, C as x, D as S, r as T, E, n as y, t as A, F as M, s as w, G as D, d as Q, u as b, w as k } from "./chunks/index-
|
|
1
|
+
import { V as a, m as t, v as o, b as n, c as r, k as i, e as g, x as p, h as u, y as C, f as c, j as f, g as h, z as l, l as v, A as d, B as m, C as x, D as S, r as T, E, n as y, t as A, F as M, s as w, G as D, d as Q, u as b, w as k } from "./chunks/index-5fjEwBkV.mjs";
|
|
2
2
|
export {
|
|
3
3
|
a as VoiceEngine,
|
|
4
4
|
t as applyTheme,
|