@lucaismyname/ginger 0.0.1
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/LICENSE +21 -0
- package/dist/audio/GingerPlayer.d.ts +9 -0
- package/dist/audio/GingerPlayer.d.ts.map +1 -0
- package/dist/components/controls/Controls.d.ts +38 -0
- package/dist/components/controls/Controls.d.ts.map +1 -0
- package/dist/components/current/Artwork.d.ts +10 -0
- package/dist/components/current/Artwork.d.ts.map +1 -0
- package/dist/components/current/FileUrl.d.ts +10 -0
- package/dist/components/current/FileUrl.d.ts.map +1 -0
- package/dist/components/current/Lyrics.d.ts +12 -0
- package/dist/components/current/Lyrics.d.ts.map +1 -0
- package/dist/components/current/Playback.d.ts +17 -0
- package/dist/components/current/Playback.d.ts.map +1 -0
- package/dist/components/current/QueueMeta.d.ts +31 -0
- package/dist/components/current/QueueMeta.d.ts.map +1 -0
- package/dist/components/current/Time.d.ts +38 -0
- package/dist/components/current/Time.d.ts.map +1 -0
- package/dist/components/current/Year.d.ts +9 -0
- package/dist/components/current/Year.d.ts.map +1 -0
- package/dist/components/current/createTextDisplay.d.ts +8 -0
- package/dist/components/current/createTextDisplay.d.ts.map +1 -0
- package/dist/components/current/index.d.ts +9 -0
- package/dist/components/current/index.d.ts.map +1 -0
- package/dist/components/current/texts.d.ts +10 -0
- package/dist/components/current/texts.d.ts.map +1 -0
- package/dist/components/playlist/GingerPlaylist.d.ts +13 -0
- package/dist/components/playlist/GingerPlaylist.d.ts.map +1 -0
- package/dist/components/queue/QueueDisplay.d.ts +14 -0
- package/dist/components/queue/QueueDisplay.d.ts.map +1 -0
- package/dist/context/GingerContext.d.ts +27 -0
- package/dist/context/GingerContext.d.ts.map +1 -0
- package/dist/context/GingerProvider.d.ts +3 -0
- package/dist/context/GingerProvider.d.ts.map +1 -0
- package/dist/core/playbackReducer.d.ts +11 -0
- package/dist/core/playbackReducer.d.ts.map +1 -0
- package/dist/core/queue.d.ts +5 -0
- package/dist/core/queue.d.ts.map +1 -0
- package/dist/core/transitions.d.ts +20 -0
- package/dist/core/transitions.d.ts.map +1 -0
- package/dist/ginger.d.ts +52 -0
- package/dist/ginger.d.ts.map +1 -0
- package/dist/hooks/useGinger.d.ts +27 -0
- package/dist/hooks/useGinger.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +897 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/formatTime.d.ts +2 -0
- package/dist/internal/formatTime.d.ts.map +1 -0
- package/dist/internal/selectors.d.ts +9 -0
- package/dist/internal/selectors.d.ts.map +1 -0
- package/dist/types.d.ts +141 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LucaIsMyName
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AudioHTMLAttributes, CSSProperties } from 'react';
|
|
2
|
+
export type GingerPlayerProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
preload?: AudioHTMLAttributes<HTMLAudioElement>["preload"];
|
|
6
|
+
crossOrigin?: AudioHTMLAttributes<HTMLAudioElement>["crossOrigin"];
|
|
7
|
+
};
|
|
8
|
+
export declare function GingerPlayer({ className, style, preload, crossOrigin }: GingerPlayerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=GingerPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GingerPlayer.d.ts","sourceRoot":"","sources":["../../src/audio/GingerPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGhF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3D,WAAW,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,CAAC;CACpE,CAAC;AAQF,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAoB,EAAE,WAAW,EAAE,EAAE,iBAAiB,2CAoEtG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, CSSProperties, InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type PlayPauseProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
3
|
+
/** Optional labels; still headless—defaults are text for a11y */
|
|
4
|
+
playLabel?: ReactNode;
|
|
5
|
+
pauseLabel?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare function PlayPause({ playLabel, pauseLabel, type, ...rest }: PlayPauseProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare namespace PlayPause {
|
|
9
|
+
var displayName: string;
|
|
10
|
+
}
|
|
11
|
+
export type RepeatProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
12
|
+
export declare function Repeat({ type, ...rest }: RepeatProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare namespace Repeat {
|
|
14
|
+
var displayName: string;
|
|
15
|
+
}
|
|
16
|
+
export type NextProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
17
|
+
export declare function Next({ type, children, ...rest }: NextProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare namespace Next {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
export type PreviousProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
22
|
+
export declare function Previous({ type, children, ...rest }: PreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare namespace Previous {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
export type ShuffleProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
27
|
+
export declare function Shuffle({ type, children, ...rest }: ShuffleProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare namespace Shuffle {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
31
|
+
export type SeekBarProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange"> & {
|
|
32
|
+
inputStyle?: CSSProperties;
|
|
33
|
+
};
|
|
34
|
+
export declare function SeekBar({ inputStyle, style, ...rest }: SeekBarProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare namespace SeekBar {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../../src/components/controls/Controls.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIjG,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IACrE,iEAAiE;IACjE,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,SAAkB,EAAE,UAAoB,EAAE,IAAe,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,2CAO/G;yBAPe,SAAS;;;AAiBzB,MAAM,MAAM,WAAW,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAElE,wBAAgB,MAAM,CAAC,EAAE,IAAe,EAAE,GAAG,IAAI,EAAE,EAAE,WAAW,2CAO/D;yBAPe,MAAM;;;AAWtB,MAAM,MAAM,SAAS,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAChE,wBAAgB,IAAI,CAAC,EAAE,IAAe,EAAE,QAAiB,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,2CAO9E;yBAPe,IAAI;;;AAUpB,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AACpE,wBAAgB,QAAQ,CAAC,EAAE,IAAe,EAAE,QAAqB,EAAE,GAAG,IAAI,EAAE,EAAE,aAAa,2CAO1F;yBAPe,QAAQ;;;AAUxB,MAAM,MAAM,YAAY,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AACnE,wBAAgB,OAAO,CAAC,EAAE,IAAe,EAAE,QAAoB,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,2CAOvF;yBAPe,OAAO;;;AAUvB,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IACtG,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,2CAiBnE;yBAjBe,OAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSProperties, ImgHTMLAttributes } from 'react';
|
|
2
|
+
import { DisplayBaseProps } from '../../types';
|
|
3
|
+
export type ArtworkProps = DisplayBaseProps & Pick<ImgHTMLAttributes<HTMLImageElement>, "sizes" | "loading" | "onError" | "decoding"> & {
|
|
4
|
+
imgStyle?: CSSProperties;
|
|
5
|
+
};
|
|
6
|
+
export declare function Artwork({ className, style, fallback, empty, sizes, loading, onError, decoding, imgStyle }: ArtworkProps): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export declare namespace Artwork {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Artwork.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Artwork.d.ts","sourceRoot":"","sources":["../../../src/components/current/Artwork.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,MAAM,MAAM,YAAY,GAAG,gBAAgB,GACzC,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG;IACxF,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B,CAAC;AAEJ,wBAAgB,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,YAAY,kDAqCvH;yBArCe,OAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TextDisplayProps } from './createTextDisplay';
|
|
2
|
+
export type FileUrlProps = TextDisplayProps & {
|
|
3
|
+
/** When false (default), renders nothing unless you explicitly opt in */
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function FileUrl({ visible, className, style, fallback, empty, children }: FileUrlProps): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export declare namespace FileUrl {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=FileUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUrl.d.ts","sourceRoot":"","sources":["../../../src/components/current/FileUrl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,OAAe,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,YAAY,kDAcrG;yBAde,OAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DisplayBaseProps, GingerState } from '../../types';
|
|
3
|
+
export type LyricsProps = DisplayBaseProps & {
|
|
4
|
+
children?: (value: string, state: GingerState) => ReactNode;
|
|
5
|
+
/** When true, preserves internal newlines; trims only leading/trailing whitespace */
|
|
6
|
+
preserveWhitespace?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function Lyrics({ className, style, fallback, empty, children, preserveWhitespace }: LyricsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export declare namespace Lyrics {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=Lyrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lyrics.d.ts","sourceRoot":"","sources":["../../../src/components/current/Lyrics.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIjE,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG;IAC3C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;IAC5D,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,wBAAgB,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,kBAAyB,EAAE,EAAE,WAAW,kDAe7G;yBAfe,MAAM"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DisplayBaseProps, GingerState, PlaybackUiState } from '../../types';
|
|
3
|
+
export type PlaybackStateProps = DisplayBaseProps & {
|
|
4
|
+
children?: (value: PlaybackUiState, state: GingerState) => ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare function PlaybackState({ className, style, fallback, empty, children }: PlaybackStateProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace PlaybackState {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export type ErrorMessageProps = DisplayBaseProps & {
|
|
11
|
+
children?: (value: string, state: GingerState) => ReactNode;
|
|
12
|
+
};
|
|
13
|
+
export declare function ErrorMessage({ className, style, fallback, empty, children }: ErrorMessageProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export declare namespace ErrorMessage {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Playback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Playback.d.ts","sourceRoot":"","sources":["../../../src/components/current/Playback.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIlF,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CACtE,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAShG;yBATe,aAAa;;;AAa7B,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CAC7D,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,kDAa9F;yBAbe,YAAY"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DisplayBaseProps, GingerState } from '../../types';
|
|
3
|
+
export type QueueIndexProps = DisplayBaseProps & {
|
|
4
|
+
base?: 0 | 1;
|
|
5
|
+
children?: (value: string, state: GingerState) => ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare function QueueIndex({ base, className, style, fallback, empty, children }: QueueIndexProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export declare namespace QueueIndex {
|
|
9
|
+
var displayName: string;
|
|
10
|
+
}
|
|
11
|
+
export type QueueLengthProps = DisplayBaseProps & {
|
|
12
|
+
children?: (value: string, state: GingerState) => ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export declare function QueueLength({ className, style, fallback, empty, children }: QueueLengthProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export declare namespace QueueLength {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
export type QueuePositionProps = DisplayBaseProps & {
|
|
19
|
+
base?: 0 | 1;
|
|
20
|
+
separator?: string;
|
|
21
|
+
children?: (value: {
|
|
22
|
+
index: string;
|
|
23
|
+
length: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}, state: GingerState) => ReactNode;
|
|
26
|
+
};
|
|
27
|
+
export declare function QueuePosition({ base, separator, className, style, fallback, empty, children, }: QueuePositionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
28
|
+
export declare namespace QueuePosition {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=QueueMeta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueMeta.d.ts","sourceRoot":"","sources":["../../../src/components/current/QueueMeta.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGjE,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG;IAC/C,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CAC7D,CAAC;AAEF,wBAAgB,UAAU,CAAC,EAAE,IAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,eAAe,kDAcpG;yBAde,UAAU;;;AAkB1B,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CAC7D,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gBAAgB,kDAa5F;yBAbe,WAAW;;;AAiB3B,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CACvG,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,IAAQ,EACR,SAAiB,EACjB,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,GACT,EAAE,kBAAkB,kDAqBpB;yBA7Be,aAAa"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { DisplayBaseProps, GingerState } from '../../types';
|
|
3
|
+
export type TimeTextProps = DisplayBaseProps & {
|
|
4
|
+
format?: (seconds: number) => string;
|
|
5
|
+
children?: (value: string, state: GingerState) => ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare function Elapsed(props: TimeTextProps): ReactElement<any, string | import('react').JSXElementConstructor<any>> | null;
|
|
8
|
+
export declare namespace Elapsed {
|
|
9
|
+
var displayName: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function Duration(props: TimeTextProps): ReactElement<any, string | import('react').JSXElementConstructor<any>> | null;
|
|
12
|
+
export declare namespace Duration {
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function Remaining(props: TimeTextProps): ReactElement<any, string | import('react').JSXElementConstructor<any>> | null;
|
|
16
|
+
export declare namespace Remaining {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
19
|
+
export type ProgressProps = DisplayBaseProps & {
|
|
20
|
+
children?: (value: {
|
|
21
|
+
fraction: number;
|
|
22
|
+
currentTime: number;
|
|
23
|
+
duration: number;
|
|
24
|
+
}, state: GingerState) => ReactNode;
|
|
25
|
+
};
|
|
26
|
+
export declare function Progress({ className, style, fallback, empty, children }: ProgressProps): import("react/jsx-runtime").JSX.Element | null;
|
|
27
|
+
export declare namespace Progress {
|
|
28
|
+
var displayName: string;
|
|
29
|
+
}
|
|
30
|
+
export type TimeRailProps = DisplayBaseProps & {
|
|
31
|
+
/** 0-1 height in px for the rail */
|
|
32
|
+
height?: number;
|
|
33
|
+
};
|
|
34
|
+
export declare function TimeRail({ className, style, height }: TimeRailProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare namespace TimeRail {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Time.d.ts","sourceRoot":"","sources":["../../../src/components/current/Time.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAKjE,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG;IAC7C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CAC7D,CAAC;AAqBF,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,iFAG3C;yBAHe,OAAO;;;AAOvB,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,iFAG5C;yBAHe,QAAQ;;;AAOxB,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,iFAG7C;yBAHe,SAAS;;;AAOzB,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CAClH,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,aAAa,kDAmBtF;yBAnBe,QAAQ;;;AAuBxB,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG;IAC7C,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAU,EAAE,EAAE,aAAa,2CAmBvE;yBAnBe,QAAQ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextDisplayProps } from './createTextDisplay';
|
|
2
|
+
export type YearProps = TextDisplayProps & {
|
|
3
|
+
format?: (year: number) => string;
|
|
4
|
+
};
|
|
5
|
+
export declare function Year({ className, style, fallback, empty, children, format }: YearProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare namespace Year {
|
|
7
|
+
var displayName: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=Year.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Year.d.ts","sourceRoot":"","sources":["../../../src/components/current/Year.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG;IACzC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACnC,CAAC;AAEF,wBAAgB,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,kDActF;yBAde,IAAI"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { DisplayBaseProps, GingerState, Track } from '../../types';
|
|
3
|
+
export type TextDisplayProps = DisplayBaseProps & {
|
|
4
|
+
children?: (value: string, state: GingerState) => ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare function createTextDisplay(displayName: string, select: (state: GingerState) => string | undefined): (props: TextDisplayProps) => ReactElement | null;
|
|
7
|
+
export declare function createTrackFieldDisplay(displayName: string, select: (track: Track | null) => string | undefined): (props: TextDisplayProps) => ReactElement | null;
|
|
8
|
+
//# sourceMappingURL=createTextDisplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTextDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/current/createTextDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC;CAC7D,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,MAAM,GAAG,SAAS,GACjD,CAAC,KAAK,EAAE,gBAAgB,KAAK,YAAY,GAAG,IAAI,CAmBlD;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,MAAM,GAAG,SAAS,GAClD,CAAC,KAAK,EAAE,gBAAgB,KAAK,YAAY,GAAG,IAAI,CAElD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './texts';
|
|
2
|
+
export { Year } from './Year';
|
|
3
|
+
export { Lyrics } from './Lyrics';
|
|
4
|
+
export { FileUrl } from './FileUrl';
|
|
5
|
+
export { Artwork } from './Artwork';
|
|
6
|
+
export { QueueIndex, QueueLength, QueuePosition } from './QueueMeta';
|
|
7
|
+
export { Elapsed, Duration, Remaining, Progress, TimeRail } from './Time';
|
|
8
|
+
export { PlaybackState, ErrorMessage } from './Playback';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/current/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const Title: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
2
|
+
export declare const Artist: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
3
|
+
export declare const Album: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
4
|
+
export declare const Description: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
5
|
+
export declare const Copyright: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
6
|
+
export declare const Genre: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
7
|
+
export declare const Label: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
8
|
+
export declare const Isrc: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
9
|
+
export declare const TrackNumber: (props: import('./createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
10
|
+
//# sourceMappingURL=texts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texts.d.ts","sourceRoot":"","sources":["../../../src/components/current/texts.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,gGAAmE,CAAC;AACtF,eAAO,MAAM,MAAM,gGAAqE,CAAC;AACzF,eAAO,MAAM,KAAK,gGAAyE,CAAC;AAC5F,eAAO,MAAM,WAAW,gGAA+E,CAAC;AACxG,eAAO,MAAM,SAAS,gGAGpB,CAAC;AACH,eAAO,MAAM,KAAK,gGAAmE,CAAC;AACtF,eAAO,MAAM,KAAK,gGAAmE,CAAC;AACtF,eAAO,MAAM,IAAI,gGAAiE,CAAC;AACnF,eAAO,MAAM,WAAW,gGAEvB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { Track } from '../../types';
|
|
3
|
+
export type GingerPlaylistProps = HTMLAttributes<HTMLUListElement> & {
|
|
4
|
+
rowStyle?: CSSProperties;
|
|
5
|
+
renderTrack?: (track: Track, index: number, isActive: boolean) => ReactNode;
|
|
6
|
+
/** When true (default), clicking a row selects that index and starts playback */
|
|
7
|
+
playOnSelect?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function GingerPlaylist({ rowStyle, renderTrack, playOnSelect, style, ...rest }: GingerPlaylistProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare namespace GingerPlaylist {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=GingerPlaylist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GingerPlaylist.d.ts","sourceRoot":"","sources":["../../../src/components/playlist/GingerPlaylist.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,gBAAgB,CAAC,GAAG;IACnE,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC;IAC5E,iFAAiF;IACjF,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,WAAW,EACX,YAAmB,EACnB,KAAK,EACL,GAAG,IAAI,EACR,EAAE,mBAAmB,2CAmDrB;yBAzDe,cAAc"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { DisplayBaseProps } from '../../types';
|
|
3
|
+
export declare const Title: (props: import('../current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
4
|
+
export declare const Subtitle: (props: import('../current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
5
|
+
export declare const Description: (props: import('../current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
6
|
+
export declare const Copyright: (props: import('../current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
7
|
+
export type QueueArtworkProps = DisplayBaseProps & {
|
|
8
|
+
imgStyle?: CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export declare function Artwork({ className, style, fallback, empty, imgStyle }: QueueArtworkProps): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
export declare namespace Artwork {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=QueueDisplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/queue/QueueDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,eAAO,MAAM,KAAK,yGAAwE,CAAC;AAC3F,eAAO,MAAM,QAAQ,yGAA8E,CAAC;AACpG,eAAO,MAAM,WAAW,yGAAoF,CAAC;AAC7G,eAAO,MAAM,SAAS,yGAAgF,CAAC;AAEvG,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,kDAgCzF;yBAhCe,OAAO"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Dispatch, MutableRefObject } from 'react';
|
|
2
|
+
import { GingerAction, GingerState, PlaylistMeta, RepeatMode, Track } from '../types';
|
|
3
|
+
export type GingerContextValue = {
|
|
4
|
+
state: GingerState;
|
|
5
|
+
dispatch: Dispatch<GingerAction>;
|
|
6
|
+
audioRef: MutableRefObject<HTMLAudioElement | null>;
|
|
7
|
+
notifyEnded: () => void;
|
|
8
|
+
play: () => void;
|
|
9
|
+
pause: () => void;
|
|
10
|
+
togglePlayPause: () => void;
|
|
11
|
+
seek: (timeSeconds: number) => void;
|
|
12
|
+
setVolume: (volume: number) => void;
|
|
13
|
+
setMuted: (muted: boolean) => void;
|
|
14
|
+
next: () => void;
|
|
15
|
+
prev: () => void;
|
|
16
|
+
setRepeatMode: (mode: RepeatMode) => void;
|
|
17
|
+
cycleRepeat: () => void;
|
|
18
|
+
toggleShuffle: () => void;
|
|
19
|
+
setQueue: (tracks: Track[], currentIndex?: number) => void;
|
|
20
|
+
playTrackAt: (index: number) => void;
|
|
21
|
+
selectTrackAt: (index: number) => void;
|
|
22
|
+
setPlaylistMeta: (meta: PlaylistMeta | null) => void;
|
|
23
|
+
};
|
|
24
|
+
declare const GingerContext: import('react').Context<GingerContextValue | null>;
|
|
25
|
+
export declare function useGingerContext(): GingerContextValue;
|
|
26
|
+
export { GingerContext };
|
|
27
|
+
//# sourceMappingURL=GingerContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GingerContext.d.ts","sourceRoot":"","sources":["../../src/context/GingerContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE3F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACpD,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,aAAa,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,QAAA,MAAM,aAAa,oDAAiD,CAAC;AAErE,wBAAgB,gBAAgB,IAAI,kBAAkB,CAIrD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GingerProviderProps } from '../types';
|
|
2
|
+
export declare function GingerProvider({ children, initialTracks, initialIndex, initialPlaylistMeta, initialShuffle, initialRepeatMode, initialPaused, className, style, onTrackChange, onPlay, onPause, onQueueEnd, onError, }: GingerProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=GingerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GingerProvider.d.ts","sourceRoot":"","sources":["../../src/context/GingerProvider.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAmC,MAAM,UAAU,CAAC;AAarF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,aAAkB,EAClB,YAAgB,EAChB,mBAA0B,EAC1B,cAAsB,EACtB,iBAAyB,EACzB,aAAoB,EACpB,SAAS,EACT,KAAK,EACL,aAAa,EACb,MAAM,EACN,OAAO,EACP,UAAU,EACV,OAAO,GACR,EAAE,mBAAmB,2CA8MrB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GingerAction, GingerState, RepeatMode, Track } from '../types';
|
|
2
|
+
export declare function createInitialState(params: {
|
|
3
|
+
tracks: Track[];
|
|
4
|
+
currentIndex?: number;
|
|
5
|
+
playlistMeta?: GingerState["playlistMeta"];
|
|
6
|
+
isPaused?: boolean;
|
|
7
|
+
isShuffled?: boolean;
|
|
8
|
+
repeatMode?: RepeatMode;
|
|
9
|
+
}): GingerState;
|
|
10
|
+
export declare function gingerReducer(state: GingerState, action: GingerAction): GingerState;
|
|
11
|
+
//# sourceMappingURL=playbackReducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbackReducer.d.ts","sourceRoot":"","sources":["../../src/core/playbackReducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAY7E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,GAAG,WAAW,CAsBd;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,WAAW,CAgInF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Track } from '../types';
|
|
2
|
+
export declare function clampIndex(index: number, length: number): number;
|
|
3
|
+
export declare function shuffleWithAnchor(tracks: Track[], anchorIndex: number): Track[];
|
|
4
|
+
export declare function findIndexByFileUrl(tracks: Track[], fileUrl: string): number;
|
|
5
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/core/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,KAAK,EAAE,CAU/E;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG3E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GingerState, RepeatMode, Track } from '../types';
|
|
2
|
+
export type EndedTransition = {
|
|
3
|
+
kind: "replay_same";
|
|
4
|
+
} | {
|
|
5
|
+
kind: "advance";
|
|
6
|
+
nextIndex: number;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "wrap";
|
|
9
|
+
nextIndex: number;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "stop";
|
|
12
|
+
nextIndex: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function computeEndedTransition(state: GingerState): EndedTransition;
|
|
15
|
+
export declare function computeNextIndex(state: GingerState): number;
|
|
16
|
+
export declare function computePrevIndex(state: GingerState): number;
|
|
17
|
+
export declare function cycleRepeatMode(mode: RepeatMode): RepeatMode;
|
|
18
|
+
export declare function resolveArtworkUrl(track: Track | null, playlistArtwork?: string | null): string | undefined;
|
|
19
|
+
export declare function resolveAlbumLine(track: Track | null, playlistSubtitle?: string | null): string | undefined;
|
|
20
|
+
//# sourceMappingURL=transitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../src/core/transitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAG/D,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,CAQ1E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAO3D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAO3D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAI5D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAE1G;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAE1G"}
|
package/dist/ginger.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { GingerPlayer } from './audio/GingerPlayer';
|
|
2
|
+
import { GingerPlaylist } from './components/playlist/GingerPlaylist';
|
|
3
|
+
import { GingerProvider } from './context/GingerProvider';
|
|
4
|
+
import * as Current from "./components/current";
|
|
5
|
+
import * as Control from "./components/controls/Controls";
|
|
6
|
+
import * as Queue from "./components/queue/QueueDisplay";
|
|
7
|
+
export declare const Ginger: {
|
|
8
|
+
readonly Provider: typeof GingerProvider;
|
|
9
|
+
readonly Player: typeof GingerPlayer;
|
|
10
|
+
readonly Current: {
|
|
11
|
+
readonly Title: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
12
|
+
readonly Artist: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
13
|
+
readonly Album: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
14
|
+
readonly Description: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
15
|
+
readonly Copyright: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
16
|
+
readonly Genre: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
17
|
+
readonly Label: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
18
|
+
readonly Isrc: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
19
|
+
readonly TrackNumber: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
20
|
+
readonly Year: typeof Current.Year;
|
|
21
|
+
readonly Lyrics: typeof Current.Lyrics;
|
|
22
|
+
readonly FileUrl: typeof Current.FileUrl;
|
|
23
|
+
readonly Artwork: typeof Current.Artwork;
|
|
24
|
+
readonly QueueIndex: typeof Current.QueueIndex;
|
|
25
|
+
readonly QueueLength: typeof Current.QueueLength;
|
|
26
|
+
readonly QueuePosition: typeof Current.QueuePosition;
|
|
27
|
+
readonly Elapsed: typeof Current.Elapsed;
|
|
28
|
+
readonly Duration: typeof Current.Duration;
|
|
29
|
+
readonly Remaining: typeof Current.Remaining;
|
|
30
|
+
readonly Progress: typeof Current.Progress;
|
|
31
|
+
readonly TimeRail: typeof Current.TimeRail;
|
|
32
|
+
readonly PlaybackState: typeof Current.PlaybackState;
|
|
33
|
+
readonly ErrorMessage: typeof Current.ErrorMessage;
|
|
34
|
+
};
|
|
35
|
+
readonly Queue: {
|
|
36
|
+
readonly Title: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
37
|
+
readonly Subtitle: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
38
|
+
readonly Description: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
39
|
+
readonly Copyright: (props: import('./components/current/createTextDisplay').TextDisplayProps) => import('react').ReactElement | null;
|
|
40
|
+
readonly Artwork: typeof Queue.Artwork;
|
|
41
|
+
};
|
|
42
|
+
readonly Control: {
|
|
43
|
+
readonly PlayPause: typeof Control.PlayPause;
|
|
44
|
+
readonly Repeat: typeof Control.Repeat;
|
|
45
|
+
readonly Next: typeof Control.Next;
|
|
46
|
+
readonly Previous: typeof Control.Previous;
|
|
47
|
+
readonly Shuffle: typeof Control.Shuffle;
|
|
48
|
+
readonly SeekBar: typeof Control.SeekBar;
|
|
49
|
+
};
|
|
50
|
+
readonly Playlist: typeof GingerPlaylist;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=ginger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ginger.d.ts","sourceRoot":"","sources":["../src/ginger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,KAAK,KAAK,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CT,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare function useGinger(): {
|
|
2
|
+
state: import('..').GingerState;
|
|
3
|
+
currentTrack: import('..').Track | null;
|
|
4
|
+
playbackUi: import('..').PlaybackUiState;
|
|
5
|
+
duration: number;
|
|
6
|
+
remaining: number;
|
|
7
|
+
progress: number;
|
|
8
|
+
artworkUrl: string | undefined;
|
|
9
|
+
albumLine: string | undefined;
|
|
10
|
+
play: () => void;
|
|
11
|
+
pause: () => void;
|
|
12
|
+
togglePlayPause: () => void;
|
|
13
|
+
seek: (timeSeconds: number) => void;
|
|
14
|
+
setVolume: (volume: number) => void;
|
|
15
|
+
setMuted: (muted: boolean) => void;
|
|
16
|
+
next: () => void;
|
|
17
|
+
prev: () => void;
|
|
18
|
+
setRepeatMode: (mode: import('..').RepeatMode) => void;
|
|
19
|
+
cycleRepeat: () => void;
|
|
20
|
+
toggleShuffle: () => void;
|
|
21
|
+
setQueue: (tracks: import('..').Track[], currentIndex?: number) => void;
|
|
22
|
+
playTrackAt: (index: number) => void;
|
|
23
|
+
selectTrackAt: (index: number) => void;
|
|
24
|
+
setPlaylistMeta: (meta: import('..').PlaylistMeta | null) => void;
|
|
25
|
+
dispatch: import('react').Dispatch<import('../types').GingerAction>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useGinger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGinger.d.ts","sourceRoot":"","sources":["../../src/hooks/useGinger.ts"],"names":[],"mappings":"AAYA,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;EAmDxB"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),p=require("react"),J=p.createContext(null);function y(){const e=p.useContext(J);if(!e)throw new Error("Ginger components must be used within <Ginger.Provider>");return e}function H(e){const{buffered:r,duration:n}=e;return!(n>0)||r.length===0?0:Math.min(1,r.end(r.length-1)/n)}function Re({className:e,style:r,preload:n="metadata",crossOrigin:t}){var d;const{audioRef:i,dispatch:u,state:s,notifyEnded:l}=y(),c=((d=s.tracks[s.currentIndex])==null?void 0:d.fileUrl)??"";return p.useEffect(()=>{const o=i.current;if(o){if(!c){o.removeAttribute("src");return}o.getAttribute("src")!==c&&(o.src=c,o.load())}},[i,s.currentIndex,s.tracks,c]),a.jsx("audio",{ref:i,className:e,style:r,preload:n,crossOrigin:t,controls:!1,onTimeUpdate:o=>{const g=o.currentTarget;u({type:"MEDIA_TIME_UPDATE",payload:{currentTime:g.currentTime,duration:g.duration,bufferedFraction:H(g)}})},onLoadedMetadata:o=>{const g=o.currentTarget;u({type:"MEDIA_LOADED_METADATA",payload:{duration:g.duration,bufferedFraction:H(g)}})},onEnded:()=>l(),onPlay:()=>u({type:"MEDIA_PLAY"}),onPause:()=>u({type:"MEDIA_PAUSE"}),onWaiting:()=>u({type:"MEDIA_WAITING"}),onCanPlay:()=>u({type:"MEDIA_CANPLAY"}),onError:()=>{var m;const o=i.current,g=(m=o==null?void 0:o.error)==null?void 0:m.code;u({type:"MEDIA_ERROR",payload:{message:g===1?"MEDIA_ERR_ABORTED":g===2?"MEDIA_ERR_NETWORK":g===3?"MEDIA_ERR_DECODE":g===4?"MEDIA_ERR_SRC_NOT_SUPPORTED":"MEDIA_ERR_UNKNOWN"}})}})}function I(e,r){return r<=0?0:Math.max(0,Math.min(r-1,e))}function Z(e,r){if(e.length<=1)return[...e];const n=e[r];if(!n)return[...e];const t=e.filter((i,u)=>u!==r);for(let i=t.length-1;i>0;i--){const u=Math.floor(Math.random()*(i+1));[t[i],t[u]]=[t[u],t[i]]}return[n,...t]}function je(e,r){const n=e.findIndex(t=>t.fileUrl===r);return n===-1?0:n}function Ge(e){const{tracks:r,currentIndex:n,repeatMode:t}=e,i=r.length;return i===0?{kind:"stop",nextIndex:0}:t==="one"?{kind:"replay_same"}:n<i-1?{kind:"advance",nextIndex:n+1}:t==="all"?{kind:"wrap",nextIndex:0}:{kind:"stop",nextIndex:I(n,i)}}function _e(e){const{tracks:r,currentIndex:n,repeatMode:t}=e,i=r.length;return i===0?0:n<i-1?n+1:t==="all"?0:I(n,i)}function De(e){const{tracks:r,currentIndex:n,repeatMode:t}=e,i=r.length;return i===0?0:n>0?n-1:t==="all"?i-1:0}function Ne(e){return e==="off"?"all":e==="all"?"one":"off"}function we(e,r){return(e==null?void 0:e.artworkUrl)??r??void 0}function Ue(e,r){return(e==null?void 0:e.album)??r??void 0}function A(e){return e.tracks[e.currentIndex]??null}function ee(e){return e.errorMessage?"error":e.tracks.length===0?"idle":e.isBuffering?"loading":e.isPaused?Number.isFinite(e.duration)&&e.duration>0&&e.currentTime>=e.duration-.05?"ended":"paused":"playing"}function C(e){var t;const r=e.duration;if(Number.isFinite(r)&&r>0)return r;const n=(t=e.tracks[e.currentIndex])==null?void 0:t.durationSeconds;return typeof n=="number"&&Number.isFinite(n)&&n>0?n:0}function re(e){const n=C(e)-e.currentTime;return Number.isFinite(n)?Math.max(0,n):0}function G(e){const r=C(e);return r>0?Math.min(1,Math.max(0,e.currentTime/r)):0}function ne(e){var n;const r=A(e);return we(r,(n=e.playlistMeta)==null?void 0:n.artworkUrl)}function te(e){var n;const r=A(e);return Ue(r,(n=e.playlistMeta)==null?void 0:n.subtitle)}function T(e,r){function n(t){const{state:i}=y(),s=(r(i)??"").trim(),{className:l,style:c,fallback:d,empty:o,children:g}=t;if(!s){const k=o??d??null;return k?a.jsx("span",{className:l,style:c,children:k}):null}return g?a.jsx("span",{className:l,style:c,children:g(s,i)}):a.jsx("span",{className:l,style:c,children:s})}return n.displayName=e,n}function E(e,r){return T(e,n=>r(A(n)))}const Fe=E("Ginger.Current.Title",e=>e==null?void 0:e.title),Le=E("Ginger.Current.Artist",e=>e==null?void 0:e.artist),Qe=T("Ginger.Current.Album",e=>te(e)),Be=E("Ginger.Current.Description",e=>e==null?void 0:e.description),$e=T("Ginger.Current.Copyright",e=>{var n;const r=A(e);return(r==null?void 0:r.copyright)??((n=e.playlistMeta)==null?void 0:n.copyright)}),Oe=E("Ginger.Current.Genre",e=>e==null?void 0:e.genre),Ye=E("Ginger.Current.Label",e=>e==null?void 0:e.label),Ve=E("Ginger.Current.Isrc",e=>e==null?void 0:e.isrc),Xe=E("Ginger.Current.TrackNumber",e=>(e==null?void 0:e.trackNumber)!=null?String(e.trackNumber):void 0);function ie({className:e,style:r,fallback:n,empty:t,children:i,format:u}){var d;const{state:s}=y(),l=(d=A(s))==null?void 0:d.year;if(typeof l!="number"||!Number.isFinite(l)){const o=t??n??null;return o?a.jsx("span",{className:e,style:r,children:o}):null}const c=u?u(l):String(l);return i?a.jsx("span",{className:e,style:r,children:i(c,s)}):a.jsx("span",{className:e,style:r,children:c})}ie.displayName="Ginger.Current.Year";function ue({className:e,style:r,fallback:n,empty:t,children:i,preserveWhitespace:u=!0}){var o;const{state:s}=y(),l=((o=A(s))==null?void 0:o.lyrics)??"",c=u?l.replace(/^\s+|\s+$/g,""):l.trim();if(!c){const g=t??n??null;return g?a.jsx("span",{className:e,style:r,children:g}):null}const d=u?{whiteSpace:"pre-wrap"}:void 0;return i?a.jsx("span",{className:e,style:{...d,...r},children:i(c,s)}):a.jsx("span",{className:e,style:{...d,...r},children:c})}ue.displayName="Ginger.Current.Lyrics";function se({visible:e=!1,className:r,style:n,fallback:t,empty:i,children:u}){var c;const{state:s}=y();if(!e)return null;const l=((c=A(s))==null?void 0:c.fileUrl)??"";if(!l){const d=i??t??null;return d?a.jsx("span",{className:r,style:n,children:d}):null}return u?a.jsx("span",{className:r,style:n,children:u(l,s)}):a.jsx("span",{className:r,style:n,children:l})}se.displayName="Ginger.Current.FileUrl";function ae({className:e,style:r,fallback:n,empty:t,sizes:i,loading:u,onError:s,decoding:l,imgStyle:c}){const{state:d}=y(),o=A(d),g=ne(d);if(!g){const m=t??n??null;return m?a.jsx("span",{className:e,style:r,children:m}):null}const k=[o==null?void 0:o.title,o==null?void 0:o.artist].filter(Boolean).join(" — ")||"Artwork";return a.jsx("span",{className:e,style:{display:"inline-block",background:"var(--ginger-artwork-bg, #f3f4f6)",borderRadius:"var(--ginger-artwork-radius, 6px)",overflow:"hidden",...r},children:a.jsx("img",{src:g,alt:k,sizes:i,loading:u,decoding:l,onError:s,style:{display:"block",width:"100%",height:"100%",objectFit:"cover",...c}})})}ae.displayName="Ginger.Current.Artwork";function le({base:e=0,className:r,style:n,fallback:t,empty:i,children:u}){const{state:s}=y();if(s.tracks.length===0){const d=i??t??null;return d?a.jsx("span",{className:r,style:n,children:d}):null}const c=String(s.currentIndex+e);return u?a.jsx("span",{className:r,style:n,children:u(c,s)}):a.jsx("span",{className:r,style:n,children:c})}le.displayName="Ginger.Current.QueueIndex";function oe({className:e,style:r,fallback:n,empty:t,children:i}){const{state:u}=y(),s=String(u.tracks.length);if(u.tracks.length===0){const l=t??n??null;return l?a.jsx("span",{className:e,style:r,children:l}):null}return i?a.jsx("span",{className:e,style:r,children:i(s,u)}):a.jsx("span",{className:e,style:r,children:s})}oe.displayName="Ginger.Current.QueueLength";function ce({base:e=0,separator:r=" / ",className:n,style:t,fallback:i,empty:u,children:s}){const{state:l}=y(),c=l.tracks.length;if(c===0){const k=u??i??null;return k?a.jsx("span",{className:n,style:t,children:k}):null}const d=String(l.currentIndex+e),o=String(c),g=`${d}${r}${o}`;return s?a.jsx("span",{className:n,style:t,children:s({index:d,length:o,label:g},l)}):a.jsx("span",{className:n,style:t,children:g})}ce.displayName="Ginger.Current.QueuePosition";function We(e){if(!Number.isFinite(e)||e<0)return"0:00";const r=Math.floor(e%60);return`${Math.floor(e/60)}:${r.toString().padStart(2,"0")}`}function _(e,r,n){const{className:t,style:i,fallback:u,empty:s,children:l,format:c=We}=n;if(!(e>=0)||!Number.isFinite(e)){const o=s??u??null;return o?a.jsx("span",{className:t,style:i,children:o}):null}const d=c(e);return l?a.jsx("span",{className:t,style:i,children:l(d,r)}):a.jsx("span",{className:t,style:i,children:d})}function de(e){const{state:r}=y();return _(r.currentTime,r,e)}de.displayName="Ginger.Current.Elapsed";function fe(e){const{state:r}=y();return _(C(r),r,e)}fe.displayName="Ginger.Current.Duration";function pe(e){const{state:r}=y();return _(re(r),r,e)}pe.displayName="Ginger.Current.Remaining";function ge({className:e,style:r,fallback:n,empty:t,children:i}){const{state:u}=y(),s=C(u),l=G(u);if(!(s>0)){const c=t??n??null;return c?a.jsx("span",{className:e,style:r,children:c}):null}return i?a.jsx("span",{className:e,style:r,children:i({fraction:l,currentTime:u.currentTime,duration:s},u)}):a.jsx("span",{className:e,style:r,children:`${Math.round(l*100)}%`})}ge.displayName="Ginger.Current.Progress";function ye({className:e,style:r,height:n=4}){const{state:t}=y(),i=`${Math.round(G(t)*100)}%`;return a.jsx("div",{className:e,style:{width:"100%",height:n,background:"var(--ginger-muted-color, #e5e7eb)",borderRadius:999,overflow:"hidden",...r},"aria-hidden":!0,children:a.jsx("div",{style:{width:i,height:"100%",background:"var(--ginger-primary-color, #111827)"}})})}ye.displayName="Ginger.Current.TimeRail";function xe({className:e,style:r,fallback:n,empty:t,children:i}){const{state:u}=y(),s=ee(u);return i?a.jsx("span",{className:e,style:r,children:i(s,u)}):a.jsx("span",{className:e,style:r,children:s})}xe.displayName="Ginger.Current.PlaybackState";function he({className:e,style:r,fallback:n,empty:t,children:i}){const{state:u}=y(),s=u.errorMessage??"";if(!s){const l=t??n??null;return l?a.jsx("span",{className:e,style:r,children:l}):null}return i?a.jsx("span",{className:e,style:r,children:i(s,u)}):a.jsx("span",{className:e,style:r,children:s})}he.displayName="Ginger.Current.ErrorMessage";function me({playLabel:e="Play",pauseLabel:r="Pause",type:n="button",...t}){const{state:i,togglePlayPause:u}=y();return a.jsx("button",{type:n,"aria-label":i.isPaused?"Play":"Pause",onClick:u,...t,children:i.isPaused?e:r})}me.displayName="Ginger.Control.PlayPause";const K={off:"Repeat off",all:"Repeat all",one:"Repeat one"};function be({type:e="button",...r}){const{state:n,cycleRepeat:t}=y();return a.jsx("button",{type:e,"aria-label":K[n.repeatMode],onClick:t,...r,children:K[n.repeatMode]})}be.displayName="Ginger.Control.Repeat";function ke({type:e="button",children:r="Next",...n}){const{next:t}=y();return a.jsx("button",{type:e,"aria-label":"Next track",onClick:t,...n,children:r})}ke.displayName="Ginger.Control.Next";function Pe({type:e="button",children:r="Previous",...n}){const{prev:t}=y();return a.jsx("button",{type:e,"aria-label":"Previous track",onClick:t,...n,children:r})}Pe.displayName="Ginger.Control.Previous";function Me({type:e="button",children:r="Shuffle",...n}){const{state:t,toggleShuffle:i}=y();return a.jsx("button",{type:e,"aria-pressed":t.isShuffled,"aria-label":"Shuffle",onClick:i,...n,children:r})}Me.displayName="Ginger.Control.Shuffle";function Ae({inputStyle:e,style:r,...n}){const{state:t,seek:i}=y(),u=Number.isFinite(t.duration)&&t.duration>0?t.duration:0,s=u>0?t.currentTime:0;return a.jsx("input",{type:"range",min:0,max:u>0?u:1,step:"any",value:Number.isFinite(s)?s:0,"aria-label":"Seek",onChange:l=>i(Number(l.currentTarget.value)),style:{width:"100%",...r,...e},...n})}Ae.displayName="Ginger.Control.SeekBar";function Te({rowStyle:e,renderTrack:r,playOnSelect:n=!0,style:t,...i}){const{state:u,playTrackAt:s,selectTrackAt:l}=y();return a.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,fontFamily:"var(--ginger-font-family, system-ui, sans-serif)",fontSize:"var(--ginger-font-size, 14px)",color:"var(--ginger-primary-color, #111827)",...t},...i,children:u.tracks.map((c,d)=>{const o=d===u.currentIndex;return a.jsx("li",{children:a.jsx("button",{type:"button",onClick:()=>{n?s(d):l(d)},style:{width:"100%",textAlign:"left",border:"none",background:o?"rgba(17, 24, 39, 0.06)":"transparent",color:"inherit",font:"inherit",cursor:"pointer",padding:"var(--ginger-playlist-row-padding, 6px 8px)",...e},children:r?r(c,d,o):a.jsxs("span",{children:[c.title,c.artist?` — ${c.artist}`:""]})})},`${c.fileUrl}-${d}`)})})}Te.displayName="Ginger.Playlist";const qe=T("Ginger.Queue.Title",e=>{var r;return(r=e.playlistMeta)==null?void 0:r.title}),ze=T("Ginger.Queue.Subtitle",e=>{var r;return(r=e.playlistMeta)==null?void 0:r.subtitle}),He=T("Ginger.Queue.Description",e=>{var r;return(r=e.playlistMeta)==null?void 0:r.description}),Ke=T("Ginger.Queue.Copyright",e=>{var r;return(r=e.playlistMeta)==null?void 0:r.copyright});function Ee({className:e,style:r,fallback:n,empty:t,imgStyle:i}){var c,d;const{state:u}=y(),s=(c=u.playlistMeta)==null?void 0:c.artworkUrl;if(!s){const o=t??n??null;return o?a.jsx("span",{className:e,style:r,children:o}):null}const l=((d=u.playlistMeta)==null?void 0:d.title)??"Playlist artwork";return a.jsx("span",{className:e,style:{display:"inline-block",background:"var(--ginger-artwork-bg, #f3f4f6)",borderRadius:"var(--ginger-artwork-radius, 6px)",overflow:"hidden",...r},children:a.jsx("img",{src:s,alt:l,style:{display:"block",width:"100%",height:"100%",objectFit:"cover",...i}})})}Ee.displayName="Ginger.Queue.Artwork";const S={currentTime:0,duration:0,bufferedFraction:0,isBuffering:!1,errorMessage:null};function Ie(e){const r=[...e.tracks];let n=I(e.currentIndex??0,r.length),t=null,i=r;return e.isShuffled&&r.length>1&&(t=[...r],i=Z(r,n),n=0),{tracks:i,currentIndex:n,isPaused:e.isPaused??!0,isShuffled:!!(e.isShuffled&&i.length>1),repeatMode:e.repeatMode??"off",originalTracks:t,playlistMeta:e.playlistMeta??null,...S}}function Je(e,r){switch(r.type){case"INIT":{const{tracks:n,currentIndex:t,playlistMeta:i,isPaused:u,isShuffled:s,repeatMode:l}=r.payload;return Ie({tracks:n,currentIndex:t,playlistMeta:i??null,isPaused:u??!0,isShuffled:s??!1,repeatMode:l??"off"})}case"SET_QUEUE":{const{tracks:n,currentIndex:t}=r.payload,i=[...n],u=I(t??e.currentIndex,i.length);return{...e,tracks:i,currentIndex:u,...S}}case"SET_INDEX":{const n=I(r.payload.index,e.tracks.length),t=r.payload.autoPlay,i=t===!0?!1:t===!1?!0:e.isPaused;return{...e,currentIndex:n,...S,isPaused:i}}case"PLAY":return{...e,isPaused:!1};case"PAUSE":return{...e,isPaused:!0};case"TOGGLE_PAUSE":return{...e,isPaused:!e.isPaused};case"SET_REPEAT":return{...e,repeatMode:r.payload};case"CYCLE_REPEAT":return{...e,repeatMode:Ne(e.repeatMode)};case"TOGGLE_SHUFFLE":{if(e.tracks.length<=1)return{...e,isShuffled:!1,originalTracks:null};if(!e.isShuffled){const s=[...e.tracks],l=Z(s,e.currentIndex);return{...e,isShuffled:!0,originalTracks:s,tracks:l,currentIndex:0}}const n=e.originalTracks?[...e.originalTracks]:[...e.tracks],t=e.tracks[e.currentIndex],i=(t==null?void 0:t.fileUrl)??"",u=je(n,i);return{...e,isShuffled:!1,originalTracks:null,tracks:n,currentIndex:I(u,n.length)}}case"NEXT":{const n=_e(e),t=n===e.currentIndex;return{...e,currentIndex:n,...t?{}:S,isPaused:t?e.isPaused:!1}}case"PREV":{const n=De(e),t=n===e.currentIndex;return{...e,currentIndex:n,...t?{}:S,isPaused:t?e.isPaused:!1}}case"MEDIA_TIME_UPDATE":return{...e,currentTime:r.payload.currentTime,duration:Number.isFinite(r.payload.duration)?r.payload.duration:e.duration,bufferedFraction:r.payload.bufferedFraction,isBuffering:!1};case"MEDIA_LOADED_METADATA":return{...e,duration:Number.isFinite(r.payload.duration)?r.payload.duration:e.duration,bufferedFraction:r.payload.bufferedFraction,errorMessage:null};case"SET_PLAYLIST_META":return{...e,playlistMeta:r.payload};case"MEDIA_ERROR":return{...e,errorMessage:r.payload.message,isPaused:!0,isBuffering:!1};case"MEDIA_WAITING":return{...e,isBuffering:!0};case"MEDIA_CANPLAY":return{...e,isBuffering:!1,errorMessage:null};case"MEDIA_PLAY":return{...e,isPaused:!1,isBuffering:!1};case"MEDIA_PAUSE":return{...e,isPaused:!0};case"RESET_MEDIA_TIMES":return{...e,currentTime:0,duration:0,bufferedFraction:0};default:return e}}const Ze={"--ginger-primary-color":"#111827","--ginger-muted-color":"#6b7280","--ginger-font-size":"14px","--ginger-font-family":"system-ui, sans-serif","--ginger-playlist-row-padding":"6px 8px","--ginger-artwork-radius":"6px","--ginger-artwork-bg":"#f3f4f6"};function er({children:e,initialTracks:r=[],initialIndex:n=0,initialPlaylistMeta:t=null,initialShuffle:i=!1,initialRepeatMode:u="off",initialPaused:s=!0,className:l,style:c,onTrackChange:d,onPlay:o,onPause:g,onQueueEnd:k,onError:m}){var z;const P=p.useRef(null),[x,b]=p.useReducer(Je,void 0,()=>Ie({tracks:r,currentIndex:n,playlistMeta:t,isPaused:s,isShuffled:i,repeatMode:u})),D=x.tracks[x.currentIndex]??null;p.useEffect(()=>{d==null||d(D,x.currentIndex)},[D,x.currentIndex,d]),p.useEffect(()=>{x.errorMessage&&(m==null||m(x.errorMessage))},[x.errorMessage,m]);const v=p.useRef(void 0);p.useEffect(()=>{if(v.current===void 0){v.current=x.isPaused;return}v.current!==x.isPaused&&(x.isPaused?g==null||g():o==null||o()),v.current=x.isPaused},[x.isPaused,g,o]);const R=p.useCallback(()=>{var f;b({type:"PLAY"}),(f=P.current)==null||f.play().catch(h=>{b({type:"PAUSE"});const M=h instanceof Error?h.message:"Playback failed";m==null||m(M)})},[m]),j=p.useCallback(()=>{var f;b({type:"PAUSE"}),(f=P.current)==null||f.pause()},[]),N=p.useCallback(()=>{x.isPaused?R():j()},[j,R,x.isPaused]),w=p.useCallback(f=>{const h=P.current;h&&Number.isFinite(f)&&(h.currentTime=Math.max(0,f))},[]),U=p.useCallback(f=>{const h=P.current;h&&(h.volume=Math.min(1,Math.max(0,f)))},[]),F=p.useCallback(f=>{const h=P.current;h&&(h.muted=f)},[]),L=p.useCallback(()=>{b({type:"NEXT"})},[]),Q=p.useCallback(()=>{b({type:"PREV"})},[]),B=p.useCallback(f=>{b({type:"SET_REPEAT",payload:f})},[]),$=p.useCallback(()=>{b({type:"CYCLE_REPEAT"})},[]),O=p.useCallback(()=>{b({type:"TOGGLE_SHUFFLE"})},[]),Y=p.useCallback((f,h)=>{b({type:"SET_QUEUE",payload:{tracks:f,currentIndex:h}})},[]),V=p.useCallback(f=>{b({type:"SET_INDEX",payload:{index:f,autoPlay:!0}}),queueMicrotask(()=>{var h;(h=P.current)==null||h.play().catch(()=>{})})},[]),X=p.useCallback(f=>{b({type:"SET_INDEX",payload:{index:f,autoPlay:!1}})},[]),W=p.useCallback(f=>{b({type:"SET_PLAYLIST_META",payload:f})},[]),Se=(z=x.tracks[x.currentIndex])==null?void 0:z.fileUrl;p.useEffect(()=>{const f=P.current;f&&(x.isPaused?f.pause():f.play().catch(h=>{b({type:"PAUSE"});const M=h instanceof Error?h.message:"Playback failed";m==null||m(M)}))},[x.isPaused,Se,m]);const q=p.useCallback(()=>{const f=Ge(x);if(f.kind==="replay_same"){const M=P.current;M&&(M.currentTime=0,M.play().catch(()=>{})),b({type:"PLAY"});return}if(f.kind==="stop"){b({type:"PAUSE"}),k==null||k();return}const h=f.nextIndex;b({type:"SET_INDEX",payload:{index:h,autoPlay:!0}}),queueMicrotask(()=>{var M;(M=P.current)==null||M.play().catch(()=>{})})},[k,x]),Ce=p.useMemo(()=>({state:x,dispatch:b,audioRef:P,notifyEnded:q,play:R,pause:j,togglePlayPause:N,seek:w,setVolume:U,setMuted:F,next:L,prev:Q,setRepeatMode:B,cycleRepeat:$,toggleShuffle:O,setQueue:Y,playTrackAt:V,selectTrackAt:X,setPlaylistMeta:W}),[$,b,L,q,j,R,V,X,Q,w,F,Y,B,W,U,x,N,O]),ve=p.useMemo(()=>({...Ze,...c}),[c]);return a.jsx(J.Provider,{value:Ce,children:a.jsx("div",{className:l,style:ve,children:e})})}const rr={Provider:er,Player:Re,Current:{Title:Fe,Artist:Le,Album:Qe,Description:Be,Copyright:$e,Genre:Oe,Label:Ye,Isrc:Ve,TrackNumber:Xe,Year:ie,Lyrics:ue,FileUrl:se,Artwork:ae,QueueIndex:le,QueueLength:oe,QueuePosition:ce,Elapsed:de,Duration:fe,Remaining:pe,Progress:ge,TimeRail:ye,PlaybackState:xe,ErrorMessage:he},Queue:{Title:qe,Subtitle:ze,Description:He,Copyright:Ke,Artwork:Ee},Control:{PlayPause:me,Repeat:be,Next:ke,Previous:Pe,Shuffle:Me,SeekBar:Ae},Playlist:Te};function nr(){const e=y(),{state:r}=e;return p.useMemo(()=>({state:r,currentTrack:A(r),playbackUi:ee(r),duration:C(r),remaining:re(r),progress:G(r),artworkUrl:ne(r),albumLine:te(r),play:e.play,pause:e.pause,togglePlayPause:e.togglePlayPause,seek:e.seek,setVolume:e.setVolume,setMuted:e.setMuted,next:e.next,prev:e.prev,setRepeatMode:e.setRepeatMode,cycleRepeat:e.cycleRepeat,toggleShuffle:e.toggleShuffle,setQueue:e.setQueue,playTrackAt:e.playTrackAt,selectTrackAt:e.selectTrackAt,setPlaylistMeta:e.setPlaylistMeta,dispatch:e.dispatch}),[e.cycleRepeat,e.dispatch,e.next,e.pause,e.play,e.playTrackAt,e.selectTrackAt,e.prev,e.seek,e.setMuted,e.setPlaylistMeta,e.setQueue,e.setRepeatMode,e.setVolume,e.togglePlayPause,e.toggleShuffle,r])}exports.Ginger=rr;exports.useGinger=nr;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|