react-modern-audio-player 2.1.0 → 2.2.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/README.md +138 -3
- package/dist/index.es.js +1288 -1163
- package/dist/types/components/AudioPlayer/Context/StateContext/index.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Context/UIContext.d.ts +1 -0
- package/dist/types/{hooks/context → components/AudioPlayer/Context/hooks}/index.d.ts +0 -1
- package/dist/types/components/AudioPlayer/Context/hooks/useAudioAttrsContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/usePlaybackContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useResourceContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useTimeContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useTrackContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useUIContext.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Context/index.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Interface/Controller/Button/RepeatTypeBtn.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Button/TransportControls/index.d.ts +4 -0
- package/dist/types/components/AudioPlayer/Interface/Controller/Button/index.d.ts +4 -3
- package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/index.d.ts +5 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/index.d.ts +12 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/index.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/Information/Artwork.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/Information/TrackInfo.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/index.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/PlayListEmpty/index.d.ts +6 -0
- package/dist/types/components/AudioPlayer/Interface/compound/index.d.ts +3 -0
- package/dist/types/components/AudioPlayer/Interface/compound/slotMetaMap.d.ts +10 -0
- package/dist/types/components/AudioPlayer/Interface/compound/useCompoundSlots.d.ts +6 -0
- package/dist/types/components/AudioPlayer/Interface/compound/useDuplicateSlotWarning.d.ts +7 -0
- package/dist/types/components/AudioPlayer/Interface/contexts/index.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Interface/contexts/playListEmptyContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Interface/contexts/playListPortalContext.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/index.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/useGridTemplate.d.ts +3 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/useResolvedGridArea.d.ts +2 -0
- package/dist/types/components/AudioPlayer/index.d.ts +23 -2
- package/dist/types/components/Drawer/Drawer.d.ts +1 -0
- package/dist/types/components/Grid/Item.d.ts +3 -2
- package/dist/types/components/Grid/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils/ssr.d.ts +0 -2
- package/llms.txt +61 -0
- package/package.json +4 -2
- package/dist/types/hooks/context/useAudioAttrsContext.d.ts +0 -2
- package/dist/types/hooks/context/usePlaybackContext.d.ts +0 -2
- package/dist/types/hooks/context/useResourceContext.d.ts +0 -2
- package/dist/types/hooks/context/useTimeContext.d.ts +0 -2
- package/dist/types/hooks/context/useTrackContext.d.ts +0 -2
- package/dist/types/hooks/context/useUIContext.d.ts +0 -1
- package/dist/types/hooks/useGridTemplate.d.ts +0 -2
- /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{NextBtn.d.ts → TransportControls/NextBtn.d.ts} +0 -0
- /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{PlayBtn.d.ts → TransportControls/PlayBtn.d.ts} +0 -0
- /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{PrevBtn.d.ts → TransportControls/PrevBtn.d.ts} +0 -0
- /package/dist/types/{utils → components/AudioPlayer/utils}/clampVolume.d.ts +0 -0
- /package/dist/types/hooks/{context/useNonNullableContext.d.ts → useNonNullableContext.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useUIContext: () => import('../UIContext').UIContext;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './TransportControls';
|
|
2
|
+
export * from './TransportControls/PlayBtn';
|
|
3
|
+
export * from './TransportControls/PrevBtn';
|
|
4
|
+
export * from './TransportControls/NextBtn';
|
|
4
5
|
export * from './RepeatTypeBtn';
|
|
5
6
|
export * from './VolumeIcon';
|
package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
|
|
2
|
+
import { GridItemLayoutProps } from '../../../../../Grid';
|
|
3
|
+
export interface SortablePlayListProps extends GridItemLayoutProps {
|
|
4
|
+
initialExpanded?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const SortablePlayList: FC<SortablePlayListProps>;
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
import { GridItemLayoutProps } from '../../../../../Grid';
|
|
1
2
|
import { FC } from 'react';
|
|
2
|
-
export
|
|
3
|
+
export type ProgressType = "bar" | "waveform";
|
|
4
|
+
export interface ProgressProps extends GridItemLayoutProps {
|
|
5
|
+
/**
|
|
6
|
+
* Override which progress renderer to show. When omitted, falls back to
|
|
7
|
+
* `activeUI.progress`. Used when the preset is disabled but the compound
|
|
8
|
+
* `<AudioPlayer.Progress />` is still placed explicitly — without this,
|
|
9
|
+
* the component would render an empty grid slot.
|
|
10
|
+
*/
|
|
11
|
+
type?: ProgressType;
|
|
12
|
+
}
|
|
13
|
+
export declare const Progress: FC<ProgressProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ActiveUI } from '../../Context/StateContext';
|
|
3
|
+
export type ActiveUIKey = keyof ActiveUI;
|
|
4
|
+
export interface SlotMeta {
|
|
5
|
+
displayName: string;
|
|
6
|
+
activeUIKey: ActiveUIKey;
|
|
7
|
+
}
|
|
8
|
+
export declare const compoundSlotMetaMap: Record<string, SlotMeta>;
|
|
9
|
+
export declare function isPresetActive(activeUI: ActiveUI, key: ActiveUIKey): boolean;
|
|
10
|
+
export declare function resolveSlotKey(child: ReactElement): string | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ActiveUI } from '../../Context/StateContext';
|
|
3
|
+
export interface DuplicateSlotWarningArgs {
|
|
4
|
+
compoundChildren: ReactElement[];
|
|
5
|
+
activeUI: ActiveUI;
|
|
6
|
+
}
|
|
7
|
+
export declare function useDuplicateSlotWarning({ compoundChildren, activeUI, }: DuplicateSlotWarningArgs): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const playListPortalContext: import('react').Context<HTMLDivElement | null>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ActiveUI, InterfacePlacement } from '../../Context';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export declare const useGridTemplate: (activeUI: ActiveUI, templateArea: InterfacePlacement["templateArea"] | undefined, customComponentsArea?: InterfacePlacement["customComponentsArea"], compoundChildren?: ReactElement[]) => readonly [string[], string[]];
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { AudioPlayerContainerProps } from './Container';
|
|
2
2
|
import { defaultInterfacePlacementMaxLength } from './Context';
|
|
3
|
+
import { CustomComponent } from './Interface/CustomComponent';
|
|
4
|
+
import { PlayListEmpty } from './Interface/PlayListEmpty';
|
|
3
5
|
import { AudioPlayerProps } from './Player';
|
|
6
|
+
import { Progress } from './Interface/Controller/Input';
|
|
7
|
+
import { Volume } from './Interface/Controller/Tooltip';
|
|
8
|
+
import { SortablePlayList } from './Interface/Controller/Drawer';
|
|
9
|
+
import { TransportControls, RepeatTypeBtn } from './Interface/Controller/Button';
|
|
10
|
+
import { Artwork } from './Interface/Information/Artwork';
|
|
11
|
+
import { TrackInfo } from './Interface/Information/TrackInfo';
|
|
12
|
+
import { TrackTime } from './Interface/Information/TrackTime';
|
|
4
13
|
export type RMAudioPlayerProps<TInterfacePlacementLength extends number = typeof defaultInterfacePlacementMaxLength> = AudioPlayerProps<TInterfacePlacementLength> & AudioPlayerContainerProps;
|
|
5
14
|
declare function AudioPlayerWithProviders<TInterfacePlacementLength extends number = typeof defaultInterfacePlacementMaxLength>({ rootContainerProps, ...audioPlayProps }: RMAudioPlayerProps<TInterfacePlacementLength>): import("react/jsx-runtime").JSX.Element;
|
|
6
15
|
declare namespace AudioPlayerWithProviders {
|
|
7
16
|
var displayName: string;
|
|
8
|
-
var CustomComponent: import("react").FC<import("./Interface/CustomComponent").CustomComponentProps>;
|
|
9
17
|
}
|
|
10
|
-
|
|
18
|
+
type AudioPlayerComponent = typeof AudioPlayerWithProviders & {
|
|
19
|
+
Progress: typeof Progress;
|
|
20
|
+
Volume: typeof Volume;
|
|
21
|
+
PlayList: typeof SortablePlayList;
|
|
22
|
+
PlayListEmpty: typeof PlayListEmpty;
|
|
23
|
+
PlayButton: typeof TransportControls;
|
|
24
|
+
RepeatButton: typeof RepeatTypeBtn;
|
|
25
|
+
Artwork: typeof Artwork;
|
|
26
|
+
TrackInfo: typeof TrackInfo;
|
|
27
|
+
TrackTime: typeof TrackTime;
|
|
28
|
+
CustomComponent: typeof CustomComponent;
|
|
29
|
+
};
|
|
30
|
+
declare const AudioPlayerCompound: AudioPlayerComponent;
|
|
31
|
+
export default AudioPlayerCompound;
|
|
@@ -5,6 +5,7 @@ import { DrawerContent } from './DrawerContent';
|
|
|
5
5
|
export interface DrawerProps extends Omit<Partial<DrawerContext>, "setIsOpen"> {
|
|
6
6
|
outboundClickActive?: boolean;
|
|
7
7
|
placement?: "bottom" | "top";
|
|
8
|
+
initialOpen?: boolean;
|
|
8
9
|
}
|
|
9
10
|
declare const Drawer: FC<PropsWithChildren<DrawerProps>>;
|
|
10
11
|
type DrawerComponent = typeof Drawer & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, HTMLAttributes } from 'react';
|
|
2
|
-
export interface
|
|
2
|
+
export interface GridItemLayoutProps {
|
|
3
3
|
gridArea?: string;
|
|
4
4
|
width?: CSSProperties["width"];
|
|
5
5
|
visible?: boolean;
|
|
@@ -7,4 +7,5 @@ export interface GridItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
justifySelf?: CSSProperties["justifySelf"];
|
|
8
8
|
padding?: CSSProperties["padding"];
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type GridItemProps = GridItemLayoutProps & HTMLAttributes<HTMLDivElement>;
|
|
11
|
+
export declare const GridItem: import('react').ForwardRefExoticComponent<GridItemLayoutProps & HTMLAttributes<HTMLDivElement> & import('react').RefAttributes<HTMLDivElement>>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
export default
|
|
1
|
+
import { default as AudioPlayer } from './components/AudioPlayer';
|
|
2
|
+
export default AudioPlayer;
|
|
3
3
|
export * from './components/AudioPlayer';
|
|
4
4
|
export * from './components/AudioPlayer/Context';
|
|
5
5
|
export * from './components/AudioPlayer/Player';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
|
-
/** true when running in a browser environment */
|
|
3
2
|
export declare const isBrowser: boolean;
|
|
4
|
-
/** useLayoutEffect that falls back to useEffect during SSR */
|
|
5
3
|
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
package/llms.txt
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# React Modern Audio Player
|
|
2
|
+
|
|
3
|
+
> Modern, customizable React audio player with waveform visualization, drag-and-drop playlist, WAI-ARIA accessibility, TypeScript-first API, and Next.js App Router (Server Components) support. Published on npm as `react-modern-audio-player`.
|
|
4
|
+
|
|
5
|
+
This library exports a single default `<AudioPlayer>` component driven by declarative props, plus a compound `<AudioPlayer.CustomComponent>` and a family of `useAudioPlayer*` hooks for programmatic control. Runtime requirements: React 18 or higher, `react-dom` 18 or higher. `wavesurfer.js` 6.x is an internal dependency (no peer install needed). The library entry point ships a `'use client'` directive so it can be imported directly from Next.js Server Components; hook consumers and compound children must themselves be Client Components.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install react-modern-audio-player
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import AudioPlayer from "react-modern-audio-player";
|
|
17
|
+
|
|
18
|
+
const playList = [
|
|
19
|
+
{ id: 1, src: "audio.mp3", name: "Track 1", writer: "Artist", img: "cover.jpg" },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export default function Page() {
|
|
23
|
+
return <AudioPlayer playList={playList} />;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Core API
|
|
28
|
+
|
|
29
|
+
- `AudioPlayer` (default export) — accepts `playList`, `audioInitialState`, `activeUI`, `placement`, `colorScheme`, `customIcons`, `coverImgsCss`, `rootContainerProps`, `audioRef`.
|
|
30
|
+
- `AudioPlayer.CustomComponent` — compound child that slots custom nodes into a named grid area (`placement.interface.customComponentsArea`). Requires `'use client'` in the consumer file.
|
|
31
|
+
- `useAudioPlayer()` — control hook. Returns `{ isPlaying, volume, currentTime, duration, repeatType, muted, currentTrack, currentIndex, playList, play, pause, togglePlay, next, prev, seek, setVolume, toggleMute, setTrack }`.
|
|
32
|
+
- Sub-hooks for minimal re-renders: `useAudioPlayerPlayback`, `useAudioPlayerTrack`, `useAudioPlayerVolume`, `useAudioPlayerTime`, `useAudioPlayerElement`.
|
|
33
|
+
- Low-level context hooks (advanced): `usePlaybackContext`, `useTrackContext`, `useUIContext`, `useResourceContext`.
|
|
34
|
+
|
|
35
|
+
## Key types
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
type AudioData = {
|
|
39
|
+
src: string;
|
|
40
|
+
id: number;
|
|
41
|
+
name?: string;
|
|
42
|
+
writer?: string;
|
|
43
|
+
img?: string;
|
|
44
|
+
description?: string | ReactNode;
|
|
45
|
+
customTrackInfo?: string | ReactNode;
|
|
46
|
+
};
|
|
47
|
+
type PlayList = AudioData[];
|
|
48
|
+
type RepeatType = "ALL" | "ONE" | "NONE" | "SHUFFLE";
|
|
49
|
+
type ProgressUI = "waveform" | "bar" | false;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Docs
|
|
53
|
+
|
|
54
|
+
- [README.md](https://unpkg.com/react-modern-audio-player/README.md): full reference — props tables, theme CSS variables, grid placement syntax, keyboard shortcuts, common integration pitfalls ("Gotchas"), and end-to-end examples.
|
|
55
|
+
- [CHANGELOG.md](https://raw.githubusercontent.com/slash9494/react-modern-audio-player/main/package/CHANGELOG.md): version history, breaking changes, migration notes (served from GitHub — not shipped in the npm tarball).
|
|
56
|
+
|
|
57
|
+
## Optional
|
|
58
|
+
|
|
59
|
+
- [GitHub repository](https://github.com/slash9494/react-modern-audio-player)
|
|
60
|
+
- [CodeSandbox demo](https://codesandbox.io/p/sandbox/basic-nfrpfq)
|
|
61
|
+
- [npm page](https://www.npmjs.com/package/react-modern-audio-player)
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-modern-audio-player",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "Modern, customizable React audio player with waveform visualization, drag-and-drop playlist, WAI-ARIA accessibility, TypeScript-first API, and Next.js App Router (Server Components) support.",
|
|
4
5
|
"author": {
|
|
5
6
|
"name": "MAXX",
|
|
6
7
|
"email": "slash9494@gmail.com",
|
|
@@ -12,7 +13,8 @@
|
|
|
12
13
|
"esnext": "dist/index.es.js",
|
|
13
14
|
"typings": "dist/types/index.d.ts",
|
|
14
15
|
"files": [
|
|
15
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"llms.txt"
|
|
16
18
|
],
|
|
17
19
|
"license": "MIT",
|
|
18
20
|
"repository": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useUIContext: () => import('../../components/AudioPlayer/Context/UIContext').UIContext;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { ActiveUI, InterfacePlacement } from '../components/AudioPlayer/Context';
|
|
2
|
-
export declare const useGridTemplate: (activeUI: ActiveUI, templateArea: InterfacePlacement["templateArea"] | undefined, customComponentsArea?: InterfacePlacement["customComponentsArea"]) => readonly [string[], string[]];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|