mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
refactor(asr): [PKG-ASR-04] preserve old declarations and add precise runtime types
This commit is contained in:
1 parent
0cf2af4840
commit
93208e59e1
24 files changed
+1224
-19
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
|
||||
interface AudioChunk {
|
||||
export interface AudioChunk {
|
||||
pcm: ArrayBuffer
|
||||
wav: ArrayBuffer
|
||||
}
|
||||
|
||||
interface AsrPluginOption {
|
||||
export interface AsrPluginOption {
|
||||
length?: number
|
||||
interval?: number
|
||||
sampleRate?: number
|
||||
@@ -13,13 +13,30 @@ interface AsrPluginOption {
|
||||
onAudioChunk?: (chunk: AudioChunk) => void | Promise<void>
|
||||
}
|
||||
|
||||
interface AsrPluginInstance {
|
||||
export interface AsrPluginInstance {
|
||||
name: 'artplayerPluginAsr'
|
||||
stop: () => void
|
||||
hide: () => void
|
||||
append: (subtitle: string) => void
|
||||
}
|
||||
|
||||
/** Historical factory shape, including void stop and callback results. */
|
||||
export type Factory = (option?: AsrPluginOption) => (art: Artplayer) => AsrPluginInstance
|
||||
|
||||
/** Accurate asynchronous view available through the /runtime entry. */
|
||||
export interface RuntimeOption extends Omit<AsrPluginOption, 'onAudioChunk'> {
|
||||
onAudioChunk?: (chunk: AudioChunk) => string | void | null | Promise<string | void | null>
|
||||
}
|
||||
|
||||
export interface RuntimeResult extends Omit<AsrPluginInstance, 'stop'> {
|
||||
stop: () => Promise<void>
|
||||
}
|
||||
|
||||
export interface RuntimeFactory {
|
||||
(option?: RuntimeOption): (art: Artplayer) => RuntimeResult
|
||||
readonly default: RuntimeFactory
|
||||
}
|
||||
|
||||
declare function artplayerPluginAsr(option?: AsrPluginOption): (art: Artplayer) => AsrPluginInstance
|
||||
|
||||
export default artplayerPluginAsr
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { RuntimeFactory } from './artplayer-plugin-asr.js'
|
||||
|
||||
declare const artplayerPluginAsr: RuntimeFactory
|
||||
// eslint-disable-next-line ts/no-redeclare -- Ambient merge exposes types on the CommonJS factory.
|
||||
declare namespace artplayerPluginAsr {
|
||||
type AudioChunk = import('./artplayer-plugin-asr.js').AudioChunk
|
||||
type RuntimeFactory = import('./artplayer-plugin-asr.js').RuntimeFactory
|
||||
type RuntimeOption = import('./artplayer-plugin-asr.js').RuntimeOption
|
||||
type RuntimeResult = import('./artplayer-plugin-asr.js').RuntimeResult
|
||||
}
|
||||
export = artplayerPluginAsr
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { RuntimeFactory } from './artplayer-plugin-asr.js'
|
||||
|
||||
declare const artplayerPluginAsr: RuntimeFactory
|
||||
export default artplayerPluginAsr
|
||||
export type { AudioChunk, RuntimeFactory, RuntimeOption, RuntimeResult } from './artplayer-plugin-asr.js'
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { RuntimeFactory } from './artplayer-plugin-asr.js'
|
||||
|
||||
declare const artplayerPluginAsr: RuntimeFactory
|
||||
// eslint-disable-next-line ts/no-redeclare -- Ambient merge exposes types on the CommonJS factory.
|
||||
declare namespace artplayerPluginAsr {
|
||||
type AudioChunk = import('./artplayer-plugin-asr.js').AudioChunk
|
||||
type RuntimeFactory = import('./artplayer-plugin-asr.js').RuntimeFactory
|
||||
type RuntimeOption = import('./artplayer-plugin-asr.js').RuntimeOption
|
||||
type RuntimeResult = import('./artplayer-plugin-asr.js').RuntimeResult
|
||||
}
|
||||
export = artplayerPluginAsr
|
||||
Reference in new issue
Block a user