优化++
This commit is contained in:
132
dist/index.d.ts
vendored
132
dist/index.d.ts
vendored
@@ -45,6 +45,58 @@ interface ScanConfigOptions {
|
||||
* 2. 结束扫码的方法名称为:stopScan
|
||||
*/
|
||||
bridgeName?: string,
|
||||
/**
|
||||
* 桥接扫码超时(毫秒),超时后回退 Web/图片识别,默认 5000
|
||||
*/
|
||||
bridgeScanTimeout?: number,
|
||||
/**
|
||||
* 是否允许 H5 摄像头扫码:true 强制开启(仍需有媒体 API),false 强制关闭
|
||||
*/
|
||||
webScanCameraEnabled?: boolean,
|
||||
/**
|
||||
* @deprecated 请用 webScanCameraEnabled;保留兼容
|
||||
*/
|
||||
webScanCameraInWechat?: boolean,
|
||||
/**
|
||||
* @deprecated 摄像头权限已后置到 startScan,请用 webScanVideoAccessTimeout
|
||||
*/
|
||||
webScanCameraProbeTimeout?: number,
|
||||
/**
|
||||
* startScan 走 Web 摄像头前是否展示权限说明弹窗,默认 true
|
||||
*/
|
||||
webScanCameraPermissionDialogEnabled?: boolean,
|
||||
/**
|
||||
* 摄像头权限说明弹窗标题
|
||||
*/
|
||||
webScanCameraPermissionTitle?: string,
|
||||
/**
|
||||
* 摄像头权限说明弹窗正文
|
||||
*/
|
||||
webScanCameraPermissionMessage?: string,
|
||||
/**
|
||||
* 摄像头权限说明弹窗确认按钮文案
|
||||
*/
|
||||
webScanCameraPermissionConfirmText?: string,
|
||||
/**
|
||||
* 摄像头权限说明弹窗取消按钮文案
|
||||
*/
|
||||
webScanCameraPermissionCancelText?: string,
|
||||
/**
|
||||
* 选图后延迟读取 file 对象(毫秒),微信/安卓 WebView 默认 100
|
||||
*/
|
||||
webScanFileReadDelay?: number,
|
||||
/**
|
||||
* 强制使用 WASM ponyfill 识别(微信/部分 WebView 建议开启,默认微信内自动开启)
|
||||
*/
|
||||
webScanPreferPonyfill?: boolean,
|
||||
/**
|
||||
* WASM 文件完整 URL;未配置时相对 SDK 脚本地址解析 lib/reader.wasm
|
||||
*/
|
||||
webScanWasmUrl?: string,
|
||||
/**
|
||||
* WASM 基准路径(SDK 脚本 URL 或目录);用于 async/defer 加载时修正 reader.wasm 路径
|
||||
*/
|
||||
webScanWasmBaseUrl?: string,
|
||||
/**
|
||||
* webScan是否启用,默认启用
|
||||
*/
|
||||
@@ -101,6 +153,41 @@ interface ScanConfigOptions {
|
||||
* 摄像头已打开但长时间无画面时触发图片回退(毫秒),默认 8000
|
||||
*/
|
||||
webScanVideoReadyTimeout?: number,
|
||||
/**
|
||||
* 图片/回退识别时 detect 超时(毫秒),默认 15000
|
||||
*/
|
||||
webScanDetectTimeout?: number,
|
||||
/**
|
||||
* 图片识别是否优先使用 ZXing ponyfill(原生 detect 在部分 WebView 可能卡住),默认 true
|
||||
*/
|
||||
webScanImagePreferPonyfill?: boolean,
|
||||
/**
|
||||
* 移动端图片回退是否使用 capture 拍照(false 为相册选图,兼容性更好),默认 false
|
||||
*/
|
||||
webScanImagePreferCapture?: boolean,
|
||||
/**
|
||||
* 图片识别是否优先 canvas 解码(安卓 WebView 建议开启),默认在安卓/微信内自动开启
|
||||
*/
|
||||
webScanImageDetectPreferCanvas?: boolean,
|
||||
/**
|
||||
* ZXing WASM 加载超时(毫秒),默认 20000
|
||||
*/
|
||||
webScanPrepareTimeout?: number,
|
||||
/**
|
||||
* 选图等待超时(毫秒),默认 120000
|
||||
*/
|
||||
webScanChooseImageTimeout?: number,
|
||||
/**
|
||||
* 选图方式:button=显示「选择图片」按钮(安卓/微信默认,需用户点击);auto=自动弹出系统选图
|
||||
*/
|
||||
webScanImagePickerMode?: 'auto' | 'button',
|
||||
webScanImagePickerTitle?: string,
|
||||
webScanImagePickerButtonText?: string,
|
||||
webScanImagePickerCancelText?: string,
|
||||
/**
|
||||
* 单次扫码会话超时(毫秒),超时后状态恢复 ready,默认 90000
|
||||
*/
|
||||
scanSessionTimeout?: number,
|
||||
/**
|
||||
* 扫码成功提示音地址,默认使用内置提示音;任意识别模式匹配成功时播放
|
||||
*/
|
||||
@@ -161,6 +248,16 @@ interface ScanResult {
|
||||
key: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码错误
|
||||
*/
|
||||
interface ScanErrorInfo {
|
||||
error: string,
|
||||
key: string,
|
||||
source?: string,
|
||||
cancel?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听key
|
||||
*/
|
||||
@@ -197,6 +294,22 @@ type ScanStatus = "scanning" | "ready";
|
||||
*/
|
||||
type ScanResultCallback = (result: ScanResult) => any;
|
||||
|
||||
/**
|
||||
* 监听扫码错误回调
|
||||
*/
|
||||
type ScanErrorCallback = (error: ScanErrorInfo) => any;
|
||||
|
||||
/**
|
||||
* 扫码错误监听信息
|
||||
*/
|
||||
interface ScanErrorListenerInfo {
|
||||
key?: string;
|
||||
match?: string;
|
||||
level?: number;
|
||||
listener: ScanErrorCallback;
|
||||
cancel: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听状态回调
|
||||
*/
|
||||
@@ -227,6 +340,19 @@ interface IScan {
|
||||
* @param callback 监听回调,或监听key
|
||||
*/
|
||||
offScanListener(callback: ScanResultCallback | string): void;
|
||||
/**
|
||||
* 添加监听扫码错误(如图片识别失败)
|
||||
* @param callback 错误回调
|
||||
* @param key 监听 key
|
||||
* @param match 可选正则,匹配 error 文本后回调
|
||||
* @param level 优先级
|
||||
*/
|
||||
onScanErrorListener(callback: ScanErrorCallback, key: string, match?: string, level?: number): ScanErrorListenerInfo;
|
||||
/**
|
||||
* 取消监听扫码错误
|
||||
* @param callback 监听回调,或监听 key
|
||||
*/
|
||||
offScanErrorListener(callback: ScanErrorCallback | string): void;
|
||||
/**
|
||||
* 获取扫码状态
|
||||
* @returns ScanStatus
|
||||
@@ -240,14 +366,12 @@ interface IScan {
|
||||
* 开启扫码
|
||||
*/
|
||||
startScan(): void;
|
||||
/**
|
||||
* 开启视频扫码
|
||||
*/
|
||||
scanVideo(): void;
|
||||
/**
|
||||
* 选择图片进行识别
|
||||
*/
|
||||
scanImage(): void;
|
||||
/** 由业务/原生传入已选图片 File 识别(WebView input.files 异常时使用) */
|
||||
scanImageFromFile(file: File | Blob): void;
|
||||
/**
|
||||
* 清除全部监听
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user