mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 12:46:15 -08:00
- Removed the old ArtplayerPluginIframe implementation. - Added ArtplayerToolIframe class with methods for iframe communication. - Implemented postMessage and onMessage methods for message handling. - Created a new TypeScript definition file for ArtplayerToolIframe. - Updated documentation links to point to the new iframe tool. - Added npm ignore file and README for the new package. - Included compiled and uncompiled versions of the new iframe tool. - Updated package.json with relevant metadata and exports.
33 lines
971 B
TypeScript
33 lines
971 B
TypeScript
interface Message {
|
|
type: string
|
|
data: any
|
|
id?: number
|
|
}
|
|
|
|
declare class ArtplayerToolIframe {
|
|
constructor(option: { iframe: HTMLIFrameElement, url: string })
|
|
|
|
static iframe: boolean
|
|
static postMessage(message: Message): void
|
|
static onMessage(event: MessageEvent & { data: Message }): void
|
|
static inject(): void
|
|
|
|
readonly promises: Record<number, { resove: (...args: any[]) => any, reject: (...args: any[]) => any }>
|
|
readonly injected: boolean
|
|
readonly destroyed: boolean
|
|
readonly $iframe: HTMLIFrameElement
|
|
readonly url: string
|
|
readonly messageCallback: (...args: any[]) => any
|
|
|
|
onMessage(event: MessageEvent & { data: Message }): void
|
|
postMessage(message: Message): Promise<any>
|
|
commit<T extends (...args: any[]) => any>(callback: T): Promise<ReturnType<T>>
|
|
message(callback: (...args: any[]) => any): void
|
|
destroy(): void
|
|
}
|
|
|
|
export default ArtplayerToolIframe
|
|
|
|
export = artplayerToolIframe
|
|
export as namespace artplayerToolIframe;
|