@types/wavesurfer.js
Advanced tools
Comparing version 3.3.2 to 4.6.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for wavesurfer.js 3.3 | ||
// Type definitions for wavesurfer.js 4.6 | ||
// Project: https://github.com/katspaugh/wavesurfer.js | ||
@@ -6,5 +6,15 @@ // Definitions by: Yusuke Higuchi <https://github.com/higuri> | ||
// Ben Nordstrom <https://github.com/bennordgengo> | ||
// Claas Augner <https://github.com/caugner> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.2 | ||
import CursorPlugin = require("./src/plugin/cursor"); | ||
import ElanPlugin = require("./src/plugin/elan"); | ||
import MarkersPlugin = require("./src/plugin/markers"); | ||
import MediaSessionPlugin = require("./src/plugin/mediasession"); | ||
import MicrophonePlugin = require("./src/plugin/microphone"); | ||
import MinimapPlugin = require("./src/plugin/minimap"); | ||
import RegionsPlugin = require("./src/plugin/regions"); | ||
import SpectogramPlugin = require("./src/plugin/spectogram"); | ||
import TimelinePlugin = require("./src/plugin/timeline"); | ||
export as namespace WaveSurfer; | ||
@@ -17,19 +27,48 @@ | ||
fireEvent(eventName: string, ...args: any[]): void; | ||
on(eventName: string, callback: (...args: any[]) => void): WaveSurfer.ListenerDescriptor; | ||
once(eventName: string, callback: (...args: any[]) => void): WaveSurfer.ListenerDescriptor; | ||
un(eventName: string, callback: (...args: any[]) => void): void; | ||
on(eventName: string, callback: EventHandler): WaveSurfer.ListenerDescriptor; | ||
once(eventName: string, callback: EventHandler): WaveSurfer.ListenerDescriptor; | ||
setDisabledEventEmissions(eventNames: string[]): void; | ||
un(eventName: string, callback: EventHandler): void; | ||
unAll(): void; | ||
readonly handlers: { [eventName: string]: EventHandler[] }; | ||
} | ||
type EventHandler = (...args: any[]) => void; | ||
declare class WaveSurfer extends Observer { | ||
constructor(params: WaveSurfer.WaveSurferParams); | ||
static VERSION: string; | ||
static util: WaveSurfer.WaveSurferUtil; | ||
static create(params: WaveSurfer.WaveSurferParams): WaveSurfer; | ||
// [x: string]: any | ||
// pluginName -> WaveSurferPlugin | ||
// propertyNameAddedByPlugin -> any | ||
[x: string]: any; | ||
backend: WaveSurfer.WaveSurferBackend; | ||
util: WaveSurfer.WaveSurferUtil; | ||
[x: string]: any; | ||
// pluginName -> WaveSurferPlugin | ||
/** Only available in WaveSurfer instances with CursorPlugin. */ | ||
cursor: CursorPlugin; | ||
/** Only available in WaveSurfer instances with ElanPlugin. */ | ||
elan: ElanPlugin; | ||
/** Only available in WaveSurfer instances with MarkersPlugin. */ | ||
markers: MarkersPlugin; | ||
/** Only available in WaveSurfer instances with MediaSessionPlugin. */ | ||
mediasession: MediaSessionPlugin; | ||
/** Only available in WaveSurfer instances with MicrophonePlugin. */ | ||
microphone: MicrophonePlugin; | ||
/** Only available in WaveSurfer instances with MinimapPlugin. */ | ||
minimap: MinimapPlugin; | ||
/** Only available in WaveSurfer instances with RegionsPlugin. */ | ||
regions: RegionsPlugin; | ||
/** Only available in WaveSurfer instances with SpectogramPlugin. */ | ||
spectogram: SpectogramPlugin; | ||
/** Only available in WaveSurfer instances with TimelinePlugin. */ | ||
timeline: TimelinePlugin; | ||
// propertyNameAddedByPlugin -> any | ||
addPlugin(plugin: WaveSurfer.PluginDefinition): WaveSurfer; | ||
@@ -40,5 +79,5 @@ cancelAjax(): void; | ||
empty(): void; | ||
exportImage(format?: string, quality?: number, type?: "dataURL" | "blob"): string | string[] | Promise<Blob[]>; | ||
exportPCM(length?: number, accuracy?: number, noWindow?: boolean, start?: number, end?: number): Promise<string>; | ||
exportImage(format?: string, quality?: number, type?: 'dataURL' | 'blob'): string | string[] | Promise<Blob[]>; | ||
getActivePlugins(): object; | ||
getActivePlugins(): { [pluginName: string]: boolean }; | ||
getBackgroundColor(): string; | ||
@@ -50,5 +89,5 @@ getCurrentTime(): number; | ||
getHeight(): number; | ||
getMute(): boolean; | ||
getPlaybackRate(): number; | ||
getProgressColor(): string; | ||
getMute(): boolean; | ||
getVolume(): number; | ||
@@ -60,8 +99,3 @@ getWaveColor(): CanvasGradient | string; | ||
isReady: boolean; | ||
load( | ||
url: string | HTMLMediaElement, | ||
peaks?: ReadonlyArray<number> | ReadonlyArray<ReadonlyArray<number>>, | ||
preload?: string, | ||
duration?: number, | ||
): void; | ||
load(url: string | HTMLMediaElement, peaks?: Peaks, preload?: string, duration?: number): void; | ||
loadBlob(url: Blob | File): void; | ||
@@ -81,5 +115,5 @@ pause(): Promise<void> | undefined; | ||
setPlayEnd(position: number): void; | ||
setSinkId(deviceId: string): Promise<any>; | ||
setVolume(newVolume: number): void; | ||
setWaveColor(color: string | CanvasGradient): void; | ||
setSinkId(deviceId: string): Promise<any>; | ||
skip(offset: number): void; | ||
@@ -95,55 +129,13 @@ skipBackward(seconds?: number): void; | ||
type Peaks = ReadonlyArray<number> | ReadonlyArray<ReadonlyArray<number>>; | ||
declare namespace WaveSurfer { | ||
class WaveRenderer extends Observer { | ||
constructor(container: HTMLElement, params: WaveSurferParams); | ||
height: number; | ||
width: number; | ||
wrapper: HTMLElement; | ||
clearWave(): void; | ||
createWrapper(): void; | ||
destroy(): void; | ||
drawBars( | ||
peaks: ReadonlyArray<number> | ReadonlyArray<ReadonlyArray<number>>, | ||
channelIndex: number, | ||
start: number, | ||
end: number, | ||
): void; | ||
drawPeaks( | ||
peaks: ReadonlyArray<number> | ReadonlyArray<ReadonlyArray<number>>, | ||
length: number, | ||
start: number, | ||
end: number, | ||
): void; | ||
drawWave( | ||
peaks: ReadonlyArray<number> | ReadonlyArray<ReadonlyArray<number>>, | ||
channelIndex: number, | ||
start: number, | ||
end: number, | ||
): void; | ||
getScrollX(): number; | ||
getWidth(): number; | ||
handleEvent(e: Event, noPrevent: boolean): number; | ||
progress(progress: number): void; | ||
recenter(percent: number): void; | ||
recenterOnPosition(position: number, immediate: boolean): void; | ||
resetScroll(): void; | ||
setHeight(height: number): boolean; | ||
setWidth(width: number): boolean; | ||
style(el: HTMLElement, styles: { [x: string]: string }): HTMLElement; | ||
updateProgress(position: number): void; | ||
updateSize(): void; | ||
} | ||
class WaveSurferObserver extends Observer {} | ||
class WaveSurferPlugin { | ||
constructor(params: object, ws: WaveSurfer); | ||
static create(params: object): PluginDefinition; | ||
init(): void; | ||
destroy(): void; | ||
} | ||
interface WaveSurferUtil { | ||
ajax(options: { xhr?: XHROptions }): Observer; | ||
extend(dest: object, ...sources: object[]): object; | ||
frame(fn: (...args: any[]) => void): (...args: any[]) => number; | ||
getId(): string; | ||
absMax(values: ReadonlyArray<number>): number; | ||
clamp(val: number, min: number, max: number): number; | ||
fetchFile(options: XHROptions): Observer; | ||
frame<T>(fn: (arg: T) => void): (arg: T) => void; | ||
getId(prefix: string): string; | ||
max(values: ReadonlyArray<number>): number; | ||
@@ -154,5 +146,9 @@ min(values: ReadonlyArray<number>): number; | ||
requestAnimationFrame(): (fn: (t: number) => void) => number; | ||
style(el: HTMLElement, styles: { [x: string]: string }): HTMLElement; | ||
style<T extends HTMLElement>(el: T, styles: Styles): T; | ||
} | ||
interface Styles { | ||
[styleName: string]: string; | ||
} | ||
interface WaveSurferParams { | ||
@@ -165,3 +161,3 @@ audioContext?: AudioContext; | ||
autoCenterImmediately?: boolean; | ||
backend?: 'WebAudio' | 'MediaElement' | 'MediaElementWebAudio'; | ||
backend?: "WebAudio" | "MediaElement" | "MediaElementWebAudio"; | ||
backgroundColor?: string; | ||
@@ -177,3 +173,3 @@ barHeight?: number; | ||
cursorWidth?: number; | ||
drawingContextAttributes?: object; | ||
drawingContextAttributes?: DrawingContextAttributes; | ||
duration?: number; | ||
@@ -196,3 +192,3 @@ fillParent?: boolean; | ||
removeMediaElementOnDestroy?: boolean; | ||
renderer?: { new (container: HTMLElement, params: WaveSurferParams): WaveRenderer }; | ||
renderer?: MultiCanvas; | ||
responsive?: boolean | number; | ||
@@ -203,2 +199,3 @@ rtl?: boolean; | ||
splitChannels?: boolean; | ||
splitChannelsOptions?: SplitChannelsOptions; | ||
waveColor?: string | CanvasGradient; | ||
@@ -208,10 +205,249 @@ xhr?: XHROptions; | ||
interface SplitChannelsOptions { | ||
overlay?: boolean; | ||
channelColors?: { [channel: number]: ChannelColor }; | ||
filterChannels?: number[]; | ||
relativeNormalization?: boolean; | ||
} | ||
interface ChannelColor { | ||
progressColor: string; | ||
waveColor: string; | ||
} | ||
class CanvasEntry { | ||
constructor(); | ||
clearWave(): void; | ||
destroy(): void; | ||
drawLineToContext( | ||
ctx: CanvasRenderingContext2D, | ||
peaks: number[], | ||
absmax: number, | ||
halfH: number, | ||
offsetY: number, | ||
start: number, | ||
end: number, | ||
): void; | ||
drawLines(peaks: number[], absmax: number, halfH: number, offsetY: number, start: number, end: number): void; | ||
drawRoundedRect( | ||
ctx: CanvasRenderingContext2D, | ||
x: number, | ||
y: number, | ||
width: number, | ||
height: number, | ||
radius: number, | ||
): void; | ||
fillRectToContext( | ||
ctx: CanvasRenderingContext2D, | ||
x: number, | ||
y: number, | ||
width: number, | ||
height: number, | ||
radius: number, | ||
): void; | ||
fillRects(x: number, y: number, width: number, height: number, radius: number): void; | ||
getImage(format: string, quality: number, type: string): string | Promise<string>; | ||
initProgress(element: HTMLCanvasElement): string; | ||
initWave(element: HTMLCanvasElement): string; | ||
setFillStyles(waveColor: string, progressColor: string): void; | ||
updateDimensions(elementWidth: number, totalWidth: number, width: number, height: number): void; | ||
readonly canvasContextAttributes: DrawingContextAttributes; | ||
readonly end: number; | ||
readonly id: string; | ||
readonly progress: HTMLCanvasElement; | ||
readonly progressCtx: CanvasRenderingContext2D; | ||
readonly start: number; | ||
readonly wave: HTMLCanvasElement; | ||
readonly waveCtx: CanvasRenderingContext2D; | ||
} | ||
class Drawer extends Observer { | ||
constructor(container: HTMLElement, params: WaveSurferParams); | ||
readonly wrapper: HTMLElement; | ||
} | ||
class MultiCanvas extends Drawer { | ||
constructor(container: HTMLElement, params: WaveSurferParams); | ||
addCanvas(): void; | ||
clearWave(): void; | ||
createElements(): void; | ||
drawBars(peaks: Peaks, channelIndex: number, start: number, end: number): void; | ||
drawLine( | ||
peaks: number[], | ||
absmax: number, | ||
halfH: number, | ||
offsetY: number, | ||
start: number, | ||
end: number, | ||
channelIndex: number, | ||
): void; | ||
drawWave(peaks: Peaks, channelIndex: number, start: number, end: number): void; | ||
fillRectToContext( | ||
x: number, | ||
y: number, | ||
width: number, | ||
height: number, | ||
radius: number, | ||
channelIndex: number, | ||
): void; | ||
getImage(format: string, quality: number, type: string): string | string[] | Promise<string | string[]>; | ||
hideChannel(channelIndex: number): void; | ||
init(): void; | ||
prepareDraw( | ||
peaks: Peaks, | ||
channelIndex: number, | ||
start: number, | ||
end: number, | ||
fn: (arg: DrawParams) => void, | ||
drawIndex: number, | ||
normalizedMax: number, | ||
): void; | ||
removeCanvas(): void; | ||
setFillStyles(entry: CanvasEntry, waveColor: string, progressColor: string): void; | ||
updateCursor(): void; | ||
updateDimensions(entry: CanvasEntry, width: number, heihgt: number): void; | ||
updateProgress(position: number): void; | ||
updateSize(): void; | ||
readonly EntryClass: typeof CanvasEntry; | ||
readonly barRadius: number; | ||
readonly canvasContextAttributes: DrawingContextAttributes; | ||
readonly canvases: CanvasEntry[]; | ||
readonly halfPixel: number; | ||
readonly hasProgressCanvas: boolean; | ||
readonly maxCanvasElementWidth: number; | ||
readonly maxCanvasWidth: number; | ||
readonly overlap: number; | ||
readonly progressWave: HTMLElement; | ||
} | ||
interface DrawingContextAttributes { | ||
desynchronized: boolean; | ||
} | ||
interface DrawParams { | ||
absmax: number; | ||
hasMinVals: boolean; | ||
height: number; | ||
offsetY: number; | ||
halfH: number; | ||
peaks: Peaks; | ||
channelIndex: number; | ||
} | ||
class PeakCache { | ||
constructor(); | ||
addRangeToPeakCache(length: number, start: number, end: number): number[][]; | ||
clearPeakCache(): void; | ||
getCacheRanges(): number[][]; | ||
} | ||
class MediaElementWebAudio extends MediaElement { | ||
constructor(params: WaveSurferParams); | ||
createMediaElementSource(mediaElement: HTMLMediaElement): void; | ||
destroy(): void; | ||
init(): void; | ||
play(start: number, end: number): Promise<void>; | ||
} | ||
class MediaElement extends WebAudioBackend { | ||
constructor(params: WaveSurferParams); | ||
static scriptBufferSize: number; | ||
createTimer(): void; | ||
destroy(): void; | ||
getCurrentTime(): number; | ||
getDuration(): number; | ||
getPeaks(length: number, first: number, last: number): Peaks; | ||
getPlaybackRate(): number; | ||
getPlayedPercents(): number; | ||
getVolume(): number; | ||
init(): void; | ||
isPaused(): boolean; | ||
load(url: string, container: HTMLElement, peaks: Peaks, preload: string): void; | ||
loadElt(elt: HTMLMediaElement, peaks: Peaks): void; | ||
pause(): Promise<void>; | ||
play(start: number, end: number): Promise<void>; | ||
seekTo(start: number): void; | ||
setMute(muted: boolean): void; | ||
setPlayEnd(end: number): void; | ||
setPlaybackRate(value: number): void; | ||
setSinkId(deviceId: string): Promise<void>; | ||
setVolume(value: number): void; | ||
readonly destroyed: boolean; | ||
} | ||
class WebAudio extends WebAudioBackend { | ||
load(buffer: AudioBuffer): void; | ||
seekTo(start: number, end: number): { start: number; end: number }; | ||
readonly ac: AudioContext; | ||
readonly analyser: AnalyserNode | null; | ||
readonly destroyed: boolean; | ||
readonly gainNode: GainNode | null; | ||
readonly scriptNode: null; | ||
} | ||
abstract class WebAudioBackend extends Observer { | ||
constructor(params: WaveSurferParams); | ||
static scriptBufferSize: number; | ||
createAnalyserNode(): void; | ||
createScriptNode(): void; | ||
createVolumeNode(): void; | ||
destroy(): void; | ||
destroyWebAudio(): void; | ||
getAudioContext(): AudioContext; | ||
getCurrentTime(): number; | ||
getDuration(): number; | ||
getOfflineAudioContext(sampleRate: number): OfflineAudioContext; | ||
getPeaks(length: number, first: number, last: number): Peaks; | ||
getPlaybackRate(): number; | ||
getPlayedPercents(): number; | ||
getPlayedTime(): number; | ||
getVolume(): number; | ||
init(): void; | ||
isPaused(): boolean; | ||
pause(): void; | ||
play(start: number, end: number): void; | ||
setFilter(...filters: AudioNode[]): void; | ||
setFilters(filters: AudioNode[]): void; | ||
setLength(length: number): void; | ||
setPeaks(peaks: Peaks, duration: number): void; | ||
setPlayEnd(end: number): void; | ||
setPlaybackRate(value: number): void; | ||
setSinkId(deviceId: string): Promise<void>; | ||
setVolume(value: number): void; | ||
supportsWebAudio(): boolean; | ||
} | ||
class WaveSurferPlugin { | ||
constructor(params: Record<string, unknown>, ws: WaveSurfer); | ||
static create(params: Record<string, unknown>): PluginDefinition; | ||
init(): void; | ||
destroy(): void; | ||
} | ||
interface PluginDefinition { | ||
name: string; | ||
staticProps?: object; | ||
staticProps?: { [staticPropName: string]: unknown }; | ||
deferInit?: boolean; | ||
params: object; | ||
instance: { new (params: object, ws: WaveSurfer): WaveSurferPlugin }; | ||
params: PluginParams; | ||
instance: { new (params: PluginDefinition["params"], ws: WaveSurfer): WaveSurferPlugin }; | ||
} | ||
interface PluginParams { | ||
[paramName: string]: unknown; | ||
deferInit?: boolean; | ||
} | ||
interface ListenerDescriptor { | ||
@@ -223,4 +459,20 @@ name: string; | ||
interface Attributes { | ||
[attributeName: string]: string; | ||
} | ||
interface Datas { | ||
[dataName: string]: string; | ||
} | ||
interface XHROptions { | ||
url?: string; | ||
method?: string; | ||
mode?: string; | ||
credentials?: string; | ||
cache?: string; | ||
responseType?: "arraybuffer" | "blob" | "json" | "text"; | ||
requestHeaders?: XHRRequestHeader[]; | ||
redirect?: string; | ||
referrer?: string; | ||
withCredentials?: boolean; | ||
@@ -235,8 +487,4 @@ } | ||
interface WaveSurferBackend { | ||
getPeaks( | ||
length: number, | ||
first?: number, | ||
last?: number, | ||
): ReadonlyArray<number> | ReadonlyArray<ReadonlyArray<number>>; | ||
getPeaks(length: number, first?: number, last?: number): Peaks; | ||
} | ||
} |
{ | ||
"name": "@types/wavesurfer.js", | ||
"version": "3.3.2", | ||
"version": "4.6.0", | ||
"description": "TypeScript definitions for wavesurfer.js", | ||
@@ -21,2 +21,7 @@ "license": "MIT", | ||
"githubUsername": "bennordgengo" | ||
}, | ||
{ | ||
"name": "Claas Augner", | ||
"url": "https://github.com/caugner", | ||
"githubUsername": "caugner" | ||
} | ||
@@ -33,4 +38,4 @@ ], | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "14ed84be9c3618cb956d7e6de7659d013b04e43595a379b7721f04f6db4b1401", | ||
"typeScriptVersion": "3.4" | ||
"typesPublisherContentHash": "4377f1a1f5e1bf7c36ef48497f1a33ef60fdec3bafec88786f3ee5d0e6b5e8bd", | ||
"typeScriptVersion": "3.5" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Fri, 05 Mar 2021 10:21:37 GMT | ||
* Last updated: Wed, 28 Apr 2021 13:01:22 GMT | ||
* Dependencies: none | ||
@@ -17,2 +17,2 @@ * Global values: `WaveSurfer` | ||
# Credits | ||
These definitions were written by [Yusuke Higuchi](https://github.com/higuri), [Egor Gorbachev](https://github.com/kubk), and [Ben Nordstrom](https://github.com/bennordgengo). | ||
These definitions were written by [Yusuke Higuchi](https://github.com/higuri), [Egor Gorbachev](https://github.com/kubk), [Ben Nordstrom](https://github.com/bennordgengo), and [Claas Augner](https://github.com/caugner). |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35166
13
851
1