waveframe 0.2.1 → 0.3.0
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/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +3 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +491 -0
- package/dist/index.d.ts +491 -2
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/package.json +8 -8
- package/dist/src/App.d.ts +0 -2
- package/dist/src/__tests__/WaveframePlayer.test.d.ts +0 -1
- package/dist/src/atoms/CodeBlock.d.ts +0 -9
- package/dist/src/components/WaveframePlayer.d.ts +0 -83
- package/dist/src/core/PeakAnalyzer.d.ts +0 -41
- package/dist/src/core/PlayerCore.d.ts +0 -92
- package/dist/src/core/WaveframeEngine.d.ts +0 -122
- package/dist/src/hooks/usePersistentSettings.d.ts +0 -1
- package/dist/src/hooks/useResampledPeaks.d.ts +0 -1
- package/dist/src/hooks/useResizeObserver.d.ts +0 -1
- package/dist/src/hooks/useWaveframe.d.ts +0 -51
- package/dist/src/hooks/useWaveframeStore.d.ts +0 -27
- package/dist/src/index.d.ts +0 -7
- package/dist/src/main.d.ts +0 -0
- package/dist/src/molecules/ArtworkOverlay.d.ts +0 -20
- package/dist/src/organisms/SettingsPanel.d.ts +0 -29
- package/dist/src/organisms/Waveform.d.ts +0 -15
- package/dist/src/types/index.d.ts +0 -75
- package/dist/src/utils/audio.d.ts +0 -33
- package/dist/src/utils/index.d.ts +0 -13
- package/dist/waveframe.css +0 -3
- package/dist/waveframe.es.js +0 -603
- package/dist/waveframe.umd.js +0 -7
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waveframe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A high-performance, customizable React audio player with SoundCloud-style waveforms and built-in audio analysis.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
7
|
-
"module": "./dist/
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"homepage": "https://gradippp.github.io/waveframe",
|
|
10
10
|
"bugs": {
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"import": "./dist/
|
|
17
|
-
"require": "./dist/
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
18
|
},
|
|
19
|
-
"./style.css": "./dist/
|
|
19
|
+
"./style.css": "./dist/index.css"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"react-dom": "^19.2.6",
|
|
66
66
|
"tailwindcss": "^4.3.0",
|
|
67
67
|
"tsc-alias": "^1.8.17",
|
|
68
|
+
"tsup": "^8.5.1",
|
|
68
69
|
"typedoc": "^0.28.19",
|
|
69
70
|
"typedoc-material-theme": "^1.4.1",
|
|
70
71
|
"typedoc-plugin-extras": "^4.0.1",
|
|
71
72
|
"typescript": "^6.0.3",
|
|
72
73
|
"vite": "^8.0.11",
|
|
73
|
-
"vite-plugin-dts": "^5.0.0",
|
|
74
74
|
"vitest": "^4.1.5"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"scripts": {
|
|
81
81
|
"dev": "vite",
|
|
82
82
|
"build": "pnpm run build:lib && pnpm run build:app",
|
|
83
|
-
"build:lib": "
|
|
83
|
+
"build:lib": "tsup && node scripts/prepend-use-client.js",
|
|
84
84
|
"build:app": "tsc && cross-env BUILD_MODE=app vite build",
|
|
85
85
|
"preview": "vite preview",
|
|
86
86
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
package/dist/src/App.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { WaveframeTheme } from '../types.js';
|
|
3
|
-
import { WaveframeEngine } from '../core/WaveframeEngine.js';
|
|
4
|
-
/**
|
|
5
|
-
* Props for the WaveframePlayer component
|
|
6
|
-
*/
|
|
7
|
-
export interface WaveframePlayerProps {
|
|
8
|
-
/**
|
|
9
|
-
* The audio source to play. Can be a URL string or a Blob/File object.
|
|
10
|
-
*/
|
|
11
|
-
media?: string | Blob;
|
|
12
|
-
/**
|
|
13
|
-
* Optional pre-generated peaks for the waveform (0-1 range).
|
|
14
|
-
* If omitted or empty, the player will automatically analyze the media.
|
|
15
|
-
*/
|
|
16
|
-
peaks?: number[];
|
|
17
|
-
/**
|
|
18
|
-
* The artwork source to display. Can be a URL string or a Blob/File object.
|
|
19
|
-
*/
|
|
20
|
-
artwork?: string | Blob;
|
|
21
|
-
/**
|
|
22
|
-
* The title of the track
|
|
23
|
-
*/
|
|
24
|
-
title?: string;
|
|
25
|
-
/**
|
|
26
|
-
* The artist of the track
|
|
27
|
-
*/
|
|
28
|
-
artist?: string;
|
|
29
|
-
/**
|
|
30
|
-
* The base color of the waveform bars
|
|
31
|
-
* @default "#e5e7eb" (light) or "#374151" (dark)
|
|
32
|
-
*/
|
|
33
|
-
waveColor?: string;
|
|
34
|
-
/**
|
|
35
|
-
* The color of the played progress part of the waveform
|
|
36
|
-
* @default theme.primary or "#3b82f6"
|
|
37
|
-
*/
|
|
38
|
-
progressColor?: string;
|
|
39
|
-
/**
|
|
40
|
-
* The height of the waveform in pixels
|
|
41
|
-
* @default 80
|
|
42
|
-
*/
|
|
43
|
-
height?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Additional CSS classes for the container
|
|
46
|
-
*/
|
|
47
|
-
className?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Inline styles for the container
|
|
50
|
-
*/
|
|
51
|
-
style?: React.CSSProperties;
|
|
52
|
-
/**
|
|
53
|
-
* The number of bars to render. Use 'auto' to fit the container width.
|
|
54
|
-
* @default "auto"
|
|
55
|
-
*/
|
|
56
|
-
resolution?: number | 'auto';
|
|
57
|
-
/**
|
|
58
|
-
* The width of each bar in pixels (if resolution is 'auto')
|
|
59
|
-
* @default 2
|
|
60
|
-
*/
|
|
61
|
-
barWidth?: number;
|
|
62
|
-
/**
|
|
63
|
-
* The gap between bars in pixels (if resolution is 'auto')
|
|
64
|
-
* @default 1
|
|
65
|
-
*/
|
|
66
|
-
barGap?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Custom theme configuration
|
|
69
|
-
*/
|
|
70
|
-
theme?: WaveframeTheme;
|
|
71
|
-
/**
|
|
72
|
-
* Optional WaveframeEngine instance for external control.
|
|
73
|
-
* If provided, the player will sync with this engine instead of creating its own.
|
|
74
|
-
*/
|
|
75
|
-
engine?: WaveframeEngine;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* The standard "all-in-one" Waveframe player component.
|
|
79
|
-
*
|
|
80
|
-
* This component features a SoundCloud-inspired layout with a prominent
|
|
81
|
-
* play/pause button positioned next to the track metadata.
|
|
82
|
-
*/
|
|
83
|
-
export declare const WaveframePlayer: React.FC<WaveframePlayerProps>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A specialized class for decoding audio data and generating waveform peaks.
|
|
3
|
-
*
|
|
4
|
-
* It leverages the Web Audio API (`AudioContext`) to process audio buffers
|
|
5
|
-
* and extract amplitude data for visualization.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PeakAnalyzer {
|
|
8
|
-
private audioCtx;
|
|
9
|
-
/**
|
|
10
|
-
* Initializes the analyzer. AudioContext creation is deferred to the first use
|
|
11
|
-
* to comply with browser autoplay and resource management policies.
|
|
12
|
-
*/
|
|
13
|
-
constructor();
|
|
14
|
-
/**
|
|
15
|
-
* Lazily creates or returns the existing AudioContext.
|
|
16
|
-
*/
|
|
17
|
-
private getContext;
|
|
18
|
-
/**
|
|
19
|
-
* Processes media (URL or Blob) and generates a set of normalized peaks.
|
|
20
|
-
*
|
|
21
|
-
* @param media The URL string or Blob object to analyze.
|
|
22
|
-
* @param samples The number of peaks (bars) to generate. Defaults to 512.
|
|
23
|
-
* @returns A promise resolving to an array of normalized peak values (0 to 1).
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const analyzer = new PeakAnalyzer();
|
|
28
|
-
*
|
|
29
|
-
* // Analyze from URL
|
|
30
|
-
* const peaksFromUrl = await analyzer.generatePeaks('https://example.com/audio.mp3');
|
|
31
|
-
*
|
|
32
|
-
* // Analyze from Blob
|
|
33
|
-
* const peaksFromBlob = await analyzer.generatePeaks(myAudioBlob);
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
generatePeaks(media: string | Blob, samples?: number): Promise<number[]>;
|
|
37
|
-
/**
|
|
38
|
-
* Closes the AudioContext and releases system audio resources.
|
|
39
|
-
*/
|
|
40
|
-
dispose(): void;
|
|
41
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the low-level playback state of the audio element.
|
|
3
|
-
*/
|
|
4
|
-
export type PlayerState = {
|
|
5
|
-
/** Whether the audio is currently playing */
|
|
6
|
-
isPlaying: boolean;
|
|
7
|
-
/** The current playback time in seconds */
|
|
8
|
-
currentTime: number;
|
|
9
|
-
/** The total duration of the track in seconds */
|
|
10
|
-
duration: number;
|
|
11
|
-
/** The current volume level (0 to 1) */
|
|
12
|
-
volume: number;
|
|
13
|
-
/** Whether the audio is currently muted */
|
|
14
|
-
muted: boolean;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* A callback function that receives the latest PlayerState.
|
|
18
|
-
*/
|
|
19
|
-
export type PlayerListener = (state: PlayerState) => void;
|
|
20
|
-
/**
|
|
21
|
-
* The internal core class responsible for managing the HTMLAudioElement.
|
|
22
|
-
*
|
|
23
|
-
* It handles raw playback logic, volume control, and synchronizes the
|
|
24
|
-
* internal `PlayerState` with DOM events from the underlying `Audio` instance.
|
|
25
|
-
*/
|
|
26
|
-
export declare class PlayerCore {
|
|
27
|
-
private audio;
|
|
28
|
-
private listeners;
|
|
29
|
-
private _state;
|
|
30
|
-
/**
|
|
31
|
-
* Initializes a new PlayerCore instance and sets up event listeners on a new Audio object.
|
|
32
|
-
*/
|
|
33
|
-
constructor();
|
|
34
|
-
/**
|
|
35
|
-
* Subscribes to various HTMLMediaElement events to keep the internal state in sync.
|
|
36
|
-
*/
|
|
37
|
-
private initListeners;
|
|
38
|
-
/**
|
|
39
|
-
* Updates the internal state and notifies subscribers.
|
|
40
|
-
*/
|
|
41
|
-
private updateState;
|
|
42
|
-
/**
|
|
43
|
-
* Triggers all registered listener callbacks.
|
|
44
|
-
*/
|
|
45
|
-
private notify;
|
|
46
|
-
/**
|
|
47
|
-
* Registers a listener for state updates.
|
|
48
|
-
* @param listener The callback function.
|
|
49
|
-
* @returns An unsubscribe function.
|
|
50
|
-
*/
|
|
51
|
-
subscribe(listener: PlayerListener): () => boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Returns the current playback state.
|
|
54
|
-
*/
|
|
55
|
-
get state(): PlayerState;
|
|
56
|
-
/**
|
|
57
|
-
* Updates the source URL of the underlying audio element.
|
|
58
|
-
* @param url The audio source URL.
|
|
59
|
-
*/
|
|
60
|
-
setSource(url: string): void;
|
|
61
|
-
/**
|
|
62
|
-
* Starts playback. Returns a promise that resolves when playback begins.
|
|
63
|
-
*/
|
|
64
|
-
play(): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Pauses playback.
|
|
67
|
-
*/
|
|
68
|
-
pause(): void;
|
|
69
|
-
/**
|
|
70
|
-
* Toggles between play and pause states.
|
|
71
|
-
*/
|
|
72
|
-
togglePlay(): void;
|
|
73
|
-
/**
|
|
74
|
-
* Seeks to a specific time.
|
|
75
|
-
* @param time Time in seconds.
|
|
76
|
-
*/
|
|
77
|
-
seek(time: number): void;
|
|
78
|
-
/**
|
|
79
|
-
* Sets the volume level.
|
|
80
|
-
* @param volume Level from 0 to 1.
|
|
81
|
-
*/
|
|
82
|
-
setVolume(volume: number): void;
|
|
83
|
-
/**
|
|
84
|
-
* Mutes or unmutes the audio element.
|
|
85
|
-
* @param muted Mute status.
|
|
86
|
-
*/
|
|
87
|
-
setMuted(muted: boolean): void;
|
|
88
|
-
/**
|
|
89
|
-
* Cleans up the audio element and removes all listeners.
|
|
90
|
-
*/
|
|
91
|
-
dispose(): void;
|
|
92
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { PlayerState } from './PlayerCore.js';
|
|
2
|
-
/**
|
|
3
|
-
* Represents the complete state of the Waveframe engine, combining playback and analysis.
|
|
4
|
-
*/
|
|
5
|
-
export type EngineState = PlayerState & {
|
|
6
|
-
/** The current set of generated or provided waveform peaks (0-1 range) */
|
|
7
|
-
peaks: number[];
|
|
8
|
-
/** Whether an audio analysis process is currently in progress */
|
|
9
|
-
isAnalyzing: boolean;
|
|
10
|
-
/** Any error message encountered during playback or analysis */
|
|
11
|
-
error: string | null;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* A callback function that receives the latest EngineState.
|
|
15
|
-
*/
|
|
16
|
-
export type EngineListener = (state: EngineState) => void;
|
|
17
|
-
/**
|
|
18
|
-
* The orchestrator class for Waveframe.
|
|
19
|
-
*
|
|
20
|
-
* It manages the lifecycle of audio playback and waveform analysis, providing a unified
|
|
21
|
-
* store-like interface that can be easily consumed by React or other frameworks.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const engine = new WaveframeEngine();
|
|
26
|
-
*
|
|
27
|
-
* // Load from URL (automatic analysis if peaks omitted)
|
|
28
|
-
* engine.load('https://example.com/audio.mp3');
|
|
29
|
-
*
|
|
30
|
-
* // Load from Blob with pre-computed peaks
|
|
31
|
-
* engine.load(myBlob, [0.1, 0.5, 0.8]);
|
|
32
|
-
*
|
|
33
|
-
* // Subscription
|
|
34
|
-
* const unsubscribe = engine.subscribe((state) => {
|
|
35
|
-
* console.log('Current time:', state.currentTime);
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare class WaveframeEngine {
|
|
40
|
-
private player;
|
|
41
|
-
private analyzer;
|
|
42
|
-
private listeners;
|
|
43
|
-
private _state;
|
|
44
|
-
private _media;
|
|
45
|
-
private _objectUrl;
|
|
46
|
-
/**
|
|
47
|
-
* Creates a new instance of the WaveframeEngine.
|
|
48
|
-
* Initializes internal PlayerCore and PeakAnalyzer.
|
|
49
|
-
*/
|
|
50
|
-
constructor();
|
|
51
|
-
/**
|
|
52
|
-
* Internal method to update the state and notify all subscribers.
|
|
53
|
-
*/
|
|
54
|
-
private updateState;
|
|
55
|
-
/**
|
|
56
|
-
* Notifies all registered listeners of a state change.
|
|
57
|
-
*/
|
|
58
|
-
private notify;
|
|
59
|
-
/**
|
|
60
|
-
* Registers a listener to be called whenever the engine state changes.
|
|
61
|
-
* @param listener The callback function.
|
|
62
|
-
* @returns An unsubscribe function.
|
|
63
|
-
*/
|
|
64
|
-
subscribe(listener: EngineListener): () => boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Returns a snapshot of the current engine state.
|
|
67
|
-
* Useful for `useSyncExternalStore`.
|
|
68
|
-
*/
|
|
69
|
-
getSnapshot(): EngineState;
|
|
70
|
-
/**
|
|
71
|
-
* Revokes any existing Object URLs to prevent memory leaks.
|
|
72
|
-
*/
|
|
73
|
-
private revokeOldSource;
|
|
74
|
-
/**
|
|
75
|
-
* Loads media (URL or Blob) into the player.
|
|
76
|
-
*
|
|
77
|
-
* If a string is passed, it's treated as a URL and used directly for playback.
|
|
78
|
-
* If a Blob is passed, an Object URL is created for playback.
|
|
79
|
-
*
|
|
80
|
-
* If `peaks` are not provided, it automatically triggers an analysis.
|
|
81
|
-
*
|
|
82
|
-
* @param media The audio source (URL string or Blob/File object).
|
|
83
|
-
* @param peaks Optional pre-generated peaks for the waveform.
|
|
84
|
-
*/
|
|
85
|
-
load(media: string | Blob, peaks?: number[]): void;
|
|
86
|
-
/**
|
|
87
|
-
* Analyzes the current media to generate waveform peaks.
|
|
88
|
-
* @param samples The number of peaks to generate. Defaults to 512.
|
|
89
|
-
*/
|
|
90
|
-
analyze(samples?: number): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Toggles playback between playing and paused.
|
|
93
|
-
*/
|
|
94
|
-
togglePlay(): void;
|
|
95
|
-
/**
|
|
96
|
-
* Starts audio playback.
|
|
97
|
-
*/
|
|
98
|
-
play(): void;
|
|
99
|
-
/**
|
|
100
|
-
* Pauses audio playback.
|
|
101
|
-
*/
|
|
102
|
-
pause(): void;
|
|
103
|
-
/**
|
|
104
|
-
* Seeks to a specific position in the track.
|
|
105
|
-
* @param percentage The seek position as a decimal (0 to 1).
|
|
106
|
-
*/
|
|
107
|
-
seek(percentage: number): void;
|
|
108
|
-
/**
|
|
109
|
-
* Sets the playback volume.
|
|
110
|
-
* @param volume The volume level (0 to 1).
|
|
111
|
-
*/
|
|
112
|
-
setVolume(volume: number): void;
|
|
113
|
-
/**
|
|
114
|
-
* Mutes or unmutes the audio.
|
|
115
|
-
* @param muted Whether the audio should be muted.
|
|
116
|
-
*/
|
|
117
|
-
setMuted(muted: boolean): void;
|
|
118
|
-
/**
|
|
119
|
-
* Disposes of the engine, pausing playback and clearing all listeners and resources.
|
|
120
|
-
*/
|
|
121
|
-
dispose(): void;
|
|
122
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const usePersistentSettings: (key: string, defaultValue: any) => any[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useResampledPeaks: (peaks: number[], targetCount: number) => number[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useResizeObserver: (ref: React.RefObject<HTMLElement | null>) => number;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { WaveframeEngine, EngineState } from '../core/WaveframeEngine.js';
|
|
2
|
-
/**
|
|
3
|
-
* Configuration options for the `useWaveframe` hook.
|
|
4
|
-
*/
|
|
5
|
-
export interface UseWaveframeOptions {
|
|
6
|
-
/** Optional pre-computed peaks to skip automatic analysis */
|
|
7
|
-
peaks?: number[];
|
|
8
|
-
/** Optional external engine instance for shared playback across components */
|
|
9
|
-
engine?: WaveframeEngine;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A headless hook that provides full control over the Waveframe engine.
|
|
13
|
-
*
|
|
14
|
-
* It manages the engine's lifecycle, loads the provided media, and returns
|
|
15
|
-
* the current state along with playback controls.
|
|
16
|
-
*
|
|
17
|
-
* @param media The audio source (URL string or Blob/File object).
|
|
18
|
-
* @param options Additional configuration and an optional external engine.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* const { state, togglePlay, seek } = useWaveframe('https://example.com/audio.mp3');
|
|
23
|
-
*
|
|
24
|
-
* return (
|
|
25
|
-
* <div>
|
|
26
|
-
* <button onClick={togglePlay}>{state.isPlaying ? 'Pause' : 'Play'}</button>
|
|
27
|
-
* <div onClick={(e) => seek(0.5)}>Seek to Middle</div>
|
|
28
|
-
* </div>
|
|
29
|
-
* );
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare const useWaveframe: (media: string | Blob | undefined, options?: UseWaveframeOptions) => {
|
|
33
|
-
/** The current reactive state of the engine */
|
|
34
|
-
state: EngineState;
|
|
35
|
-
/** The raw WaveframeEngine instance for advanced usage */
|
|
36
|
-
engine: WaveframeEngine;
|
|
37
|
-
/** Toggles playback between playing and paused */
|
|
38
|
-
togglePlay: () => void;
|
|
39
|
-
/** Starts audio playback */
|
|
40
|
-
play: () => void;
|
|
41
|
-
/** Pauses audio playback */
|
|
42
|
-
pause: () => void;
|
|
43
|
-
/** Seeks to a specific percentage (0-1) */
|
|
44
|
-
seek: (percentage: number) => void;
|
|
45
|
-
/** Sets the playback volume (0-1) */
|
|
46
|
-
setVolume: (v: number) => void;
|
|
47
|
-
/** Mutes or unmutes the audio */
|
|
48
|
-
setMuted: (m: boolean) => void;
|
|
49
|
-
/** Manually triggers a re-analysis of the current media */
|
|
50
|
-
analyze: (samples?: number) => Promise<void>;
|
|
51
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { WaveframeEngine, EngineState } from '../core/WaveframeEngine.js';
|
|
2
|
-
/**
|
|
3
|
-
* A React hook that synchronizes a WaveframeEngine's state with a React component.
|
|
4
|
-
*
|
|
5
|
-
* It uses `useSyncExternalStore` for high-performance updates, ensuring that
|
|
6
|
-
* the component only re-renders when the engine's state snapshot actually changes.
|
|
7
|
-
*
|
|
8
|
-
* @param engine The WaveframeEngine instance to subscribe to.
|
|
9
|
-
* @returns The current EngineState (isPlaying, currentTime, peaks, etc.).
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* const MyPlayer = ({ engine }: { engine: WaveframeEngine }) => {
|
|
14
|
-
* const { isPlaying, currentTime, duration } = useWaveframeStore(engine);
|
|
15
|
-
*
|
|
16
|
-
* return (
|
|
17
|
-
* <div>
|
|
18
|
-
* <button onClick={() => engine.togglePlay()}>
|
|
19
|
-
* {isPlaying ? 'Pause' : 'Play'}
|
|
20
|
-
* </button>
|
|
21
|
-
* <p>{currentTime.toFixed(2)} / {duration.toFixed(2)}</p>
|
|
22
|
-
* </div>
|
|
23
|
-
* );
|
|
24
|
-
* };
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const useWaveframeStore: (engine: WaveframeEngine) => EngineState;
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './components/WaveframePlayer.js';
|
|
2
|
-
export * from './core/WaveframeEngine.js';
|
|
3
|
-
export * from './core/PlayerCore.js';
|
|
4
|
-
export * from './core/PeakAnalyzer.js';
|
|
5
|
-
export * from './hooks/useWaveframeStore.js';
|
|
6
|
-
export * from './types.js';
|
|
7
|
-
export * from './utils.js';
|
package/dist/src/main.d.ts
DELETED
|
File without changes
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Props for the ArtworkOverlay component.
|
|
4
|
-
*/
|
|
5
|
-
interface ArtworkOverlayProps {
|
|
6
|
-
/** The URL or Object URL of the artwork image */
|
|
7
|
-
artworkUrl?: string;
|
|
8
|
-
/** The title of the track (used for alt text) */
|
|
9
|
-
title?: string;
|
|
10
|
-
/** Whether the artwork is currently being processed or the audio is analyzing */
|
|
11
|
-
isLoading?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A purely visual component for displaying track artwork.
|
|
15
|
-
*
|
|
16
|
-
* It handles loading states with a blur effect and provides a consistent
|
|
17
|
-
* container for the track image.
|
|
18
|
-
*/
|
|
19
|
-
export declare const ArtworkOverlay: React.FC<ArtworkOverlayProps>;
|
|
20
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { WaveframeTheme, TrackInfo, WaveformConfig } from '../types.js';
|
|
3
|
-
interface SettingsPanelProps {
|
|
4
|
-
theme: WaveframeTheme;
|
|
5
|
-
trackInfo: TrackInfo;
|
|
6
|
-
config: WaveformConfig;
|
|
7
|
-
scale: number;
|
|
8
|
-
engineState: {
|
|
9
|
-
isPlaying: boolean;
|
|
10
|
-
volume: number;
|
|
11
|
-
muted: boolean;
|
|
12
|
-
isAnalyzing: boolean;
|
|
13
|
-
};
|
|
14
|
-
onAnalyze: () => void;
|
|
15
|
-
onThemeChange: (theme: Partial<WaveframeTheme>) => void;
|
|
16
|
-
onTrackChange: (track: Partial<TrackInfo>) => void;
|
|
17
|
-
onConfigChange: (config: Partial<WaveformConfig>) => void;
|
|
18
|
-
onScaleChange: (scale: number) => void;
|
|
19
|
-
onTogglePreset: (type: 'light' | 'dark') => void;
|
|
20
|
-
onClearPeaks: () => void;
|
|
21
|
-
onFileUpload: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
22
|
-
onArtworkUpload: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
23
|
-
onReset: () => void;
|
|
24
|
-
onTogglePlay: () => void;
|
|
25
|
-
onSetVolume: (v: number) => void;
|
|
26
|
-
onSetMuted: (m: boolean) => void;
|
|
27
|
-
}
|
|
28
|
-
export declare const SettingsPanel: React.FC<SettingsPanelProps>;
|
|
29
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
interface WaveformProps {
|
|
3
|
-
peaks: number[];
|
|
4
|
-
currentTime: number;
|
|
5
|
-
duration: number;
|
|
6
|
-
waveColor: string;
|
|
7
|
-
progressColor: string;
|
|
8
|
-
height: number;
|
|
9
|
-
onSeek: (percentage: number) => void;
|
|
10
|
-
resolution?: number | 'auto';
|
|
11
|
-
barWidth?: number;
|
|
12
|
-
barGap?: number;
|
|
13
|
-
}
|
|
14
|
-
export declare const Waveform: React.FC<WaveformProps>;
|
|
15
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines the core color palette for the Waveframe component.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```tsx
|
|
6
|
-
* const darkTheme: WaveframeTheme = {
|
|
7
|
-
* bg: '#111827',
|
|
8
|
-
* primary: '#ec4899',
|
|
9
|
-
* text: '#f9fafb',
|
|
10
|
-
* border: '#1f2937'
|
|
11
|
-
* };
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export interface WaveframeTheme {
|
|
15
|
-
/** The main background color of the player */
|
|
16
|
-
bg: string;
|
|
17
|
-
/** The primary accent color (used for play button and progress) */
|
|
18
|
-
primary: string;
|
|
19
|
-
/** The color of the text elements (title, artist, time) */
|
|
20
|
-
text: string;
|
|
21
|
-
/** The color of borders and dividers */
|
|
22
|
-
border: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Metadata associated with an audio track.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* const track: TrackInfo = {
|
|
30
|
-
* title: 'Electronic Sunset',
|
|
31
|
-
* artist: 'Digital Nomad',
|
|
32
|
-
* artwork: 'https://example.com/art.jpg', // or a Blob object
|
|
33
|
-
* audioUrl: 'https://example.com/audio.mp3'
|
|
34
|
-
* };
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export interface TrackInfo {
|
|
38
|
-
/** The title of the track */
|
|
39
|
-
title: string;
|
|
40
|
-
/** The artist of the track */
|
|
41
|
-
artist: string;
|
|
42
|
-
/** The artwork source (URL string or Blob/File object) */
|
|
43
|
-
artwork: string | Blob;
|
|
44
|
-
/** The URL to the actual audio file */
|
|
45
|
-
audioUrl: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Defines the resolution of the waveform.
|
|
49
|
-
* - `number`: A fixed number of bars to render.
|
|
50
|
-
* - `'auto'`: Compute the number of bars dynamically based on the container width.
|
|
51
|
-
*/
|
|
52
|
-
export type Resolution = number | 'auto';
|
|
53
|
-
/**
|
|
54
|
-
* Configuration options for how the waveform is rendered visually.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```tsx
|
|
58
|
-
* const config: WaveformConfig = {
|
|
59
|
-
* resolution: 'auto',
|
|
60
|
-
* barWidth: 2,
|
|
61
|
-
* barGap: 1,
|
|
62
|
-
* height: 100
|
|
63
|
-
* };
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export interface WaveformConfig {
|
|
67
|
-
/** The number of bars to render, or 'auto' to compute based on container width */
|
|
68
|
-
resolution: Resolution;
|
|
69
|
-
/** The width of each individual bar in pixels */
|
|
70
|
-
barWidth: number;
|
|
71
|
-
/** The spacing between each bar in pixels */
|
|
72
|
-
barGap: number;
|
|
73
|
-
/** The total height of the waveform in pixels */
|
|
74
|
-
height: number;
|
|
75
|
-
}
|