@aigamo/hydrangean-diva 0.0.1-alpha.4

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.
Files changed (38) hide show
  1. package/LICENSE +93 -0
  2. package/dist/App.d.ts +3 -0
  3. package/dist/AppRoutes.d.ts +4 -0
  4. package/dist/common/components/Compose.d.ts +7 -0
  5. package/dist/favicon.svg +39 -0
  6. package/dist/features/media-player/components/AddVideoButton.d.ts +7 -0
  7. package/dist/features/media-player/components/BottomBar.d.ts +12 -0
  8. package/dist/features/media-player/components/Header.d.ts +2 -0
  9. package/dist/features/media-player/components/HydrangeanDiva.d.ts +11 -0
  10. package/dist/features/media-player/components/MediaPlayerLayout.d.ts +8 -0
  11. package/dist/features/media-player/components/MiniPlayer.d.ts +15 -0
  12. package/dist/features/media-player/components/PlayQueueStoreContext.d.ts +8 -0
  13. package/dist/features/media-player/components/PlayQueueTable.d.ts +9 -0
  14. package/dist/features/media-player/components/PlayerStoreContext.d.ts +8 -0
  15. package/dist/features/media-player/components/index.d.ts +6 -0
  16. package/dist/features/media-player/index.d.ts +2 -0
  17. package/dist/features/media-player/pages/PlayQueuePage.d.ts +2 -0
  18. package/dist/features/media-player/stores/IObservableStateProvider.d.ts +4 -0
  19. package/dist/features/media-player/stores/IPlayQueueItemStore.d.ts +33 -0
  20. package/dist/features/media-player/stores/IPlayQueueStore.d.ts +15 -0
  21. package/dist/features/media-player/stores/MobXObservableStateProvider.d.ts +5 -0
  22. package/dist/features/media-player/stores/ObservableStateProvider.d.ts +5 -0
  23. package/dist/features/media-player/stores/PlayQueueItemStore.d.ts +39 -0
  24. package/dist/features/media-player/stores/PlayQueueLocalStorageState.d.ts +10 -0
  25. package/dist/features/media-player/stores/PlayQueueStore.d.ts +55 -0
  26. package/dist/features/media-player/stores/PlayerStore.d.ts +15 -0
  27. package/dist/features/media-player/stores/RepeatMode.d.ts +5 -0
  28. package/dist/features/media-player/stores/getOrAddSchema.d.ts +2 -0
  29. package/dist/features/media-player/stores/index.d.ts +6 -0
  30. package/dist/icons.d.ts +1 -0
  31. package/dist/index.cjs.js +2 -0
  32. package/dist/index.cjs.js.map +1 -0
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.es.js +1322 -0
  35. package/dist/index.es.js.map +1 -0
  36. package/dist/main.d.ts +1 -0
  37. package/dist/sw.d.ts +1 -0
  38. package/package.json +109 -0
package/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that
84
+ organization. **control** means ownership of substantially all the assets of an
85
+ entity, or the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
package/dist/App.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { ReactElement } from 'react';
2
+ declare const App: () => ReactElement;
3
+ export default App;
@@ -0,0 +1,4 @@
1
+ import { ReactElement } from 'react';
2
+ export declare const AppRoutes: (() => ReactElement) & {
3
+ displayName: string;
4
+ };
@@ -0,0 +1,7 @@
1
+ import { JSXElementConstructor, PropsWithChildren, ReactElement, ReactNode } from 'react';
2
+ interface ComposeProps {
3
+ components: Array<JSXElementConstructor<PropsWithChildren<unknown>>>;
4
+ children?: ReactNode;
5
+ }
6
+ export declare const Compose: ({ components, children, }: ComposeProps) => ReactElement;
7
+ export {};
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
4
+ viewBox="0 0 512.001 512.001" xml:space="preserve">
5
+ <path style="fill:#78A5FF;" d="M501.042,221.512c-29.412-42.161-63.315-62.652-103.645-62.652
6
+ c-41.188,0-66.774,28.277-85.457,48.922c-10.857,11.995-21.111,23.328-29.342,23.328c-0.759,0-1.436,0.252-2.139,0.432
7
+ c0.18-0.703,0.432-1.38,0.432-2.139c0-8.236,11.332-18.489,23.328-29.338c20.645-18.688,48.922-44.274,48.922-85.462
8
+ c0-40.333-20.494-74.233-62.647-103.641c-20.951-14.608-48.022-14.608-68.981,0c-42.154,29.407-62.648,63.308-62.648,103.641
9
+ c0,41.188,28.277,66.774,48.922,85.462c11.995,10.849,23.327,21.102,23.327,29.338c0,0.759,0.252,1.436,0.432,2.139
10
+ c-0.703-0.18-1.38-0.432-2.139-0.432c-8.231,0-18.485-11.332-29.342-23.328c-18.684-20.645-44.27-48.922-85.457-48.922
11
+ c-40.329,0-74.233,20.49-103.645,62.652c-14.613,20.948-14.613,48.026,0,68.973c29.412,42.161,63.315,62.652,103.645,62.652
12
+ c41.188,0,66.774-28.277,85.457-48.922c10.857-11.995,21.111-23.328,29.342-23.328c0.759,0,1.436-0.252,2.139-0.432
13
+ c-0.18,0.703-0.432,1.38-0.432,2.139c0,8.236-11.332,18.489-23.327,29.338c-20.645,18.688-48.922,44.274-48.922,85.462
14
+ c0,40.324,20.49,74.225,62.648,103.641c10.478,7.304,22.482,10.961,34.491,10.961s24.013-3.657,34.491-10.961
15
+ c42.157-29.415,62.647-63.315,62.647-103.641c0-41.188-28.277-66.774-48.922-85.462c-11.995-10.849-23.328-21.102-23.328-29.338
16
+ c0-0.759-0.252-1.436-0.432-2.139c0.703,0.18,1.38,0.432,2.139,0.432c8.231,0,18.485,11.332,29.342,23.328
17
+ c18.684,20.645,44.27,48.922,85.457,48.922c40.329,0,74.233-20.491,103.645-62.652C515.654,269.538,515.654,242.458,501.042,221.512
18
+ z"/>
19
+ <path style="fill:#6993F2;" d="M213.528,306.688c11.5,9.627,26.302,15.437,42.474,15.437s30.974-5.811,42.474-15.437
20
+ c-9.621-8.886-17.585-17.201-17.585-24.095c0-0.759-0.252-1.436-0.432-2.139c0.703,0.18,1.38,0.432,2.139,0.432
21
+ c6.89,0,15.207,7.965,24.1,17.59c9.683-11.515,15.535-26.359,15.535-42.582c0-16.172-5.812-30.976-15.441-42.476
22
+ c-8.929,9.67-17.28,17.691-24.194,17.691c-0.759,0-1.436,0.252-2.139,0.432c0.18-0.703,0.432-1.38,0.432-2.139
23
+ c0-6.92,8.025-15.273,17.698-24.198c-11.516-9.685-26.361-15.54-42.586-15.54s-31.07,5.855-42.586,15.54
24
+ c9.673,8.926,17.698,17.278,17.698,24.198c0,0.759,0.252,1.436,0.432,2.139c-0.703-0.18-1.38-0.432-2.139-0.432
25
+ c-6.916,0-15.266-8.022-24.194-17.691c-9.629,11.5-15.441,26.305-15.441,42.476c0,16.223,5.853,31.067,15.535,42.582
26
+ c8.893-9.624,17.209-17.59,24.1-17.59c0.759,0,1.436-0.252,2.139-0.432c-0.18,0.703-0.432,1.38-0.432,2.139
27
+ C231.113,289.486,223.15,297.802,213.528,306.688z"/>
28
+ <g>
29
+ <circle style="fill:#5A82E6;" cx="256.005" cy="255.893" r="26.492"/>
30
+ <rect x="185.359" y="247.062" style="fill:#5A82E6;" width="141.292" height="17.661"/>
31
+ <rect x="247.174" y="185.247" style="fill:#5A82E6;" width="17.661" height="141.292"/>
32
+ </g>
33
+ <g>
34
+ <circle style="fill:#BEDCFF;" cx="185.359" cy="255.893" r="17.661"/>
35
+ <circle style="fill:#BEDCFF;" cx="326.651" cy="255.893" r="17.661"/>
36
+ <circle style="fill:#BEDCFF;" cx="256.005" cy="326.539" r="17.661"/>
37
+ <circle style="fill:#BEDCFF;" cx="256.005" cy="185.247" r="17.661"/>
38
+ </g>
39
+ </svg>
@@ -0,0 +1,7 @@
1
+ import { ReactElement } from 'react';
2
+ import { PlayQueueStore } from '../stores/PlayQueueStore';
3
+ interface AddVideoButtonProps {
4
+ playQueueStore: PlayQueueStore;
5
+ }
6
+ export declare const AddVideoButton: import('react').MemoExoticComponent<({ playQueueStore }: AddVideoButtonProps) => ReactElement>;
7
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ReactElement } from 'react';
2
+ import { PlayerStore } from '../stores/PlayerStore';
3
+ import { PlayQueueStore } from '../stores/PlayQueueStore';
4
+ export declare const bottomBarHeight = 80;
5
+ interface BottomBarProps {
6
+ playerStore: PlayerStore;
7
+ playQueueStore: PlayQueueStore;
8
+ }
9
+ export declare const BottomBar: (({ playerStore, playQueueStore }: BottomBarProps) => ReactElement) & {
10
+ displayName: string;
11
+ };
12
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ReactElement } from 'react';
2
+ export declare const Header: () => ReactElement;
@@ -0,0 +1,11 @@
1
+ import { ReactElement } from 'react';
2
+ import { PlayerStore } from '../stores/PlayerStore';
3
+ import { PlayQueueStore } from '../stores/PlayQueueStore';
4
+ interface HydrangeanDivaProps {
5
+ playerStore: PlayerStore;
6
+ playQueueStore: PlayQueueStore;
7
+ }
8
+ export declare const HydrangeanDiva: (({ playerStore, playQueueStore }: HydrangeanDivaProps) => ReactElement) & {
9
+ displayName: string;
10
+ };
11
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ interface MediaPlayerLayoutProps {
3
+ children?: ReactNode;
4
+ }
5
+ export declare const MediaPlayerLayout: (({ children }: MediaPlayerLayoutProps) => ReactElement) & {
6
+ displayName: string;
7
+ };
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import { ReactElement } from 'react';
2
+ import { PlayerStore } from '../stores/PlayerStore';
3
+ import { PlayQueueStore } from '../stores/PlayQueueStore';
4
+ export declare const miniPlayerSize: {
5
+ readonly width: number;
6
+ readonly height: number;
7
+ };
8
+ interface MiniPlayerProps {
9
+ playerStore: PlayerStore;
10
+ playQueueStore: PlayQueueStore;
11
+ }
12
+ export declare const MiniPlayer: (({ playerStore, playQueueStore }: MiniPlayerProps) => ReactElement) & {
13
+ displayName: string;
14
+ };
15
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { PlayQueueStore } from '../stores/PlayQueueStore';
3
+ interface PlayQueueStoreProviderProps {
4
+ children?: ReactNode;
5
+ }
6
+ export declare const PlayQueueStoreProvider: ({ children, }: PlayQueueStoreProviderProps) => ReactElement;
7
+ export declare const usePlayQueueStore: () => PlayQueueStore;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ReactElement } from 'react';
2
+ import { PlayQueueStore } from '../stores/PlayQueueStore';
3
+ interface PlayQueueTableProps {
4
+ playQueueStore: PlayQueueStore;
5
+ }
6
+ export declare const PlayQueueTable: (({ playQueueStore }: PlayQueueTableProps) => ReactElement) & {
7
+ displayName: string;
8
+ };
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { PlayerStore } from '../stores/PlayerStore';
3
+ interface PlayerStoreProviderProps {
4
+ children?: ReactNode;
5
+ }
6
+ export declare const PlayerStoreProvider: ({ children, }: PlayerStoreProviderProps) => ReactElement;
7
+ export declare const usePlayerStore: () => PlayerStore;
8
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from './BottomBar';
2
+ export * from './HydrangeanDiva';
3
+ export * from './MediaPlayerLayout';
4
+ export * from './MiniPlayer';
5
+ export * from './PlayerStoreContext';
6
+ export * from './PlayQueueStoreContext';
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './stores';
@@ -0,0 +1,2 @@
1
+ import { ReactElement } from 'react';
2
+ export declare const PlayQueuePage: () => ReactElement;
@@ -0,0 +1,4 @@
1
+ import { AnnotationsMap } from 'mobx';
2
+ export interface IObservableStateProvider {
3
+ makeObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, annotations?: AnnotationsMap<T, AdditionalKeys>): T;
4
+ }
@@ -0,0 +1,33 @@
1
+ import { PlayerType } from '@aigamo/nostalgic-diva';
2
+ export interface PlayQueueItemDto {
3
+ readonly url: string;
4
+ readonly type: PlayerType;
5
+ readonly videoId: string;
6
+ readonly title: string;
7
+ }
8
+ export interface IPlayQueueItemStore {
9
+ readonly id: number;
10
+ isSelected: boolean;
11
+ readonly dto: PlayQueueItemDto;
12
+ readonly url: string;
13
+ readonly type: PlayerType;
14
+ readonly videoId: string;
15
+ readonly title: string;
16
+ readonly canMoveToTop: boolean;
17
+ readonly canMoveToBottom: boolean;
18
+ readonly canRemoveToTop: boolean;
19
+ readonly canRemoveOthers: boolean;
20
+ readonly isCurrent: boolean;
21
+ clone(): IPlayQueueItemStore;
22
+ unselect(): void;
23
+ toggleSelected(): void;
24
+ play(): void;
25
+ remove(): Promise<void>;
26
+ playFirst(): Promise<void>;
27
+ playNext(): Promise<void>;
28
+ addToPlayQueue(): Promise<void>;
29
+ moveToTop(): void;
30
+ moveToBottom(): void;
31
+ removeToTop(): Promise<void>;
32
+ removeOthers(): Promise<void>;
33
+ }
@@ -0,0 +1,15 @@
1
+ import { IPlayQueueItemStore, PlayQueueItemDto } from './IPlayQueueItemStore';
2
+ export interface IPlayQueueStore {
3
+ items: IPlayQueueItemStore[];
4
+ createItem(dto: PlayQueueItemDto): IPlayQueueItemStore;
5
+ readonly currentItem: IPlayQueueItemStore | undefined;
6
+ readonly hasMultipleItems: boolean;
7
+ setCurrentItem(item: IPlayQueueItemStore | undefined): void;
8
+ playNext(items: IPlayQueueItemStore[]): Promise<void>;
9
+ addItems(items: IPlayQueueItemStore[]): Promise<void>;
10
+ playFirst(items: IPlayQueueItemStore[]): Promise<void>;
11
+ moveItem(item: IPlayQueueItemStore, index: number): void;
12
+ removeItems(items: IPlayQueueItemStore[]): Promise<void>;
13
+ removeItemsAbove(item: IPlayQueueItemStore): Promise<void>;
14
+ removeOtherItems(item: IPlayQueueItemStore): Promise<void>;
15
+ }
@@ -0,0 +1,5 @@
1
+ import { AnnotationsMap } from 'mobx';
2
+ import { IObservableStateProvider } from './IObservableStateProvider';
3
+ export declare class MobXObservableStateProvider implements IObservableStateProvider {
4
+ makeObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, annotations?: AnnotationsMap<T, AdditionalKeys>): T;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { AnnotationsMap } from 'mobx';
2
+ import { IObservableStateProvider } from './IObservableStateProvider';
3
+ export declare class ObservableStateProvider implements IObservableStateProvider {
4
+ makeObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, annotations?: AnnotationsMap<T, AdditionalKeys>): T;
5
+ }
@@ -0,0 +1,39 @@
1
+ import { PlayerType } from '@aigamo/nostalgic-diva';
2
+ import { IObservableStateProvider } from './IObservableStateProvider';
3
+ import { IPlayQueueItemStore, PlayQueueItemDto } from './IPlayQueueItemStore';
4
+ import { IPlayQueueStore } from './IPlayQueueStore';
5
+ import { PlayQueueStore } from './PlayQueueStore';
6
+ export declare class PlayQueueItemStore implements IPlayQueueItemStore {
7
+ readonly observableStateProvider: IObservableStateProvider;
8
+ readonly playQueueStore: IPlayQueueStore;
9
+ readonly dto: PlayQueueItemDto;
10
+ static nextId: number;
11
+ readonly id: number;
12
+ isSelected: boolean;
13
+ constructor(observableStateProvider: IObservableStateProvider, playQueueStore: IPlayQueueStore, dto: PlayQueueItemDto);
14
+ static fromDto(observableStateProvider: IObservableStateProvider, playQueueStore: PlayQueueStore, dto: PlayQueueItemDto): IPlayQueueItemStore;
15
+ get url(): string;
16
+ get type(): PlayerType;
17
+ get videoId(): string;
18
+ get title(): string;
19
+ get isCurrent(): boolean;
20
+ get index(): number;
21
+ get isFirst(): boolean;
22
+ get isLast(): boolean;
23
+ get canMoveToTop(): boolean;
24
+ get canMoveToBottom(): boolean;
25
+ get canRemoveToTop(): boolean;
26
+ get canRemoveOthers(): boolean;
27
+ clone(): IPlayQueueItemStore;
28
+ unselect(): void;
29
+ toggleSelected(): void;
30
+ play(): void;
31
+ remove(): Promise<void>;
32
+ playFirst(): Promise<void>;
33
+ playNext(): Promise<void>;
34
+ addToPlayQueue(): Promise<void>;
35
+ moveToTop(): void;
36
+ moveToBottom(): void;
37
+ removeToTop(): Promise<void>;
38
+ removeOthers(): Promise<void>;
39
+ }
@@ -0,0 +1,10 @@
1
+ import { PlayQueueItemDto } from './IPlayQueueItemStore';
2
+ import { RepeatMode } from './RepeatMode';
3
+ export interface PlayQueueLocalStorageState {
4
+ version?: '1.0';
5
+ repeat?: RepeatMode;
6
+ shuffle?: boolean;
7
+ items?: PlayQueueItemDto[];
8
+ currentIndex?: number;
9
+ }
10
+ export declare const validatePlayQueueLocalStorageState: import('ajv').ValidateFunction<PlayQueueLocalStorageState>;
@@ -0,0 +1,55 @@
1
+ import { LocalStorageStateStore } from '@aigamo/route-sphere';
2
+ import { IObservableStateProvider } from './IObservableStateProvider';
3
+ import { IPlayQueueItemStore, PlayQueueItemDto } from './IPlayQueueItemStore';
4
+ import { IPlayQueueStore } from './IPlayQueueStore';
5
+ import { PlayQueueLocalStorageState } from './PlayQueueLocalStorageState';
6
+ import { RepeatMode } from './RepeatMode';
7
+ export declare class PlayQueueStore implements IPlayQueueStore, LocalStorageStateStore<PlayQueueLocalStorageState> {
8
+ readonly observableStateProvider: IObservableStateProvider;
9
+ interacted: boolean;
10
+ items: IPlayQueueItemStore[];
11
+ currentId: number | undefined;
12
+ repeat: RepeatMode;
13
+ shuffle: boolean;
14
+ constructor(observableStateProvider: IObservableStateProvider);
15
+ createItem(dto: PlayQueueItemDto): IPlayQueueItemStore;
16
+ get localStorageState(): PlayQueueLocalStorageState;
17
+ set localStorageState(value: PlayQueueLocalStorageState);
18
+ validateLocalStorageState(localStorageState: any): localStorageState is PlayQueueLocalStorageState;
19
+ get isEmpty(): boolean;
20
+ get currentItem(): IPlayQueueItemStore | undefined;
21
+ get canPlay(): boolean;
22
+ get canPause(): boolean;
23
+ get hasMultipleItems(): boolean;
24
+ get currentIndex(): number | undefined;
25
+ set currentIndex(value: number | undefined);
26
+ get hasPreviousItem(): boolean;
27
+ get hasNextItem(): boolean;
28
+ get isLastItem(): boolean;
29
+ get selectedItems(): IPlayQueueItemStore[];
30
+ get allItemsSelected(): boolean;
31
+ set allItemsSelected(value: boolean);
32
+ get selectedItemsOrAllItems(): IPlayQueueItemStore[];
33
+ setItems(value: IPlayQueueItemStore[]): void;
34
+ interact(): void;
35
+ clear(): void;
36
+ unselectAll(): void;
37
+ setCurrentItem(item: IPlayQueueItemStore | undefined): void;
38
+ setNextItems(items: IPlayQueueItemStore[]): void;
39
+ clearAndSetItems(items: IPlayQueueItemStore[]): void;
40
+ playNext(items: IPlayQueueItemStore[]): Promise<void>;
41
+ playSelectedItemsNext(): Promise<void>;
42
+ addItems(items: IPlayQueueItemStore[]): Promise<void>;
43
+ addSelectedItems(): Promise<void>;
44
+ playFirst(items: IPlayQueueItemStore[]): Promise<void>;
45
+ moveItem(item: IPlayQueueItemStore, index: number): void;
46
+ removeItems(items: IPlayQueueItemStore[]): Promise<void>;
47
+ removeSelectedItems(): Promise<void>;
48
+ removeOtherItems(item: IPlayQueueItemStore): Promise<void>;
49
+ removeItemsAbove(item: IPlayQueueItemStore): Promise<void>;
50
+ toggleRepeat(): void;
51
+ toggleShuffle(): void;
52
+ previous(): Promise<void>;
53
+ next(): Promise<void>;
54
+ goToFirst(): Promise<void>;
55
+ }
@@ -0,0 +1,15 @@
1
+ import { TimeEvent } from '@aigamo/nostalgic-diva';
2
+ import { IObservableStateProvider } from './IObservableStateProvider';
3
+ export declare class PlayerStore {
4
+ playing: boolean;
5
+ percent: number;
6
+ seeking: boolean;
7
+ constructor(observableStateProvider: IObservableStateProvider);
8
+ setPlaying(value: boolean): void;
9
+ setPercent(value: number): void;
10
+ setSeeking(value: boolean): void;
11
+ onPlay(): void;
12
+ onPause(): void;
13
+ onEnded(): void;
14
+ onTimeUpdate({ percent }: TimeEvent): void;
15
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum RepeatMode {
2
+ Off = "Off",
3
+ All = "All",
4
+ One = "One"
5
+ }
@@ -0,0 +1,2 @@
1
+ import { JSONSchemaType, ValidateFunction } from 'ajv';
2
+ export declare function getOrAddSchema<T>(schema: JSONSchemaType<T>, keyRef: string): ValidateFunction<T>;
@@ -0,0 +1,6 @@
1
+ export * from './IObservableStateProvider';
2
+ export * from './IPlayQueueItemStore';
3
+ export * from './IPlayQueueStore';
4
+ export * from './MobXObservableStateProvider';
5
+ export * from './ObservableStateProvider';
6
+ export * from './RepeatMode';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";var S=Object.defineProperty;var w=(n,e,i)=>e in n?S(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var p=(n,e,i)=>w(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@aigamo/nostalgic-diva"),a=require("@elastic/eui"),c=require("@fluentui/react-icons"),h=require("mobx-react-lite"),t=require("react"),O=require("react-sortablejs"),s=require("mobx"),T=require("lodash-es"),F=require("ajv");var u=(n=>(n.Off="Off",n.All="All",n.One="One",n))(u||{});const x=80,M=h.observer(({playerStore:n})=>{const e=g.useNostalgicDiva(),i=t.useCallback(l=>{const m=Number(l.currentTarget.value)/100;n.setPercent(m)},[n]),o=t.useCallback(l=>{l.button===0&&n.setSeeking(!0)},[n]),r=t.useCallback(async l=>{if(l.button===0){const m=Number(l.currentTarget.value)/100;n.setSeeking(!1);const d=await e.getDuration();d!==void 0&&await e.setCurrentTime(d*m)}},[n,e]);return t.createElement(a.EuiRange,{min:0,max:100,step:1e-7,value:n.percent*100,onChange:i,onMouseDown:o,onMouseUp:r,fullWidth:!0,showRange:!0,css:{blockSize:32}})}),A=t.memo(({button:n,isOpen:e,closePopover:i})=>{const[o,r]=t.useState("0"),l=g.useNostalgicDiva();t.useLayoutEffect(()=>{e&&l.getVolume().then(d=>{d!==void 0&&r(Math.floor(d*100).toString())})},[e,l]);const m=t.useCallback(async d=>{r(d.currentTarget.value),await l.setVolume(Number(d.currentTarget.value)/100)},[l]);return t.createElement(a.EuiPopover,{button:n,isOpen:e,closePopover:i,anchorPosition:"upRight"},t.createElement(a.EuiFormRow,null,t.createElement(a.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"center",alignItems:"center"},t.createElement(a.EuiButtonIcon,{title:"Mute","aria-label":"Mute",iconType:c.Speaker2Regular,size:"s",iconSize:"l"}),t.createElement(a.EuiRange,{min:0,max:100,step:1,value:o,onChange:m,css:{blockSize:32}}))))}),z=t.memo(({playQueueStore:n,closePopover:e})=>{const i=g.useNostalgicDiva(),o=t.useCallback(async()=>{const E=await i.getCurrentTime();E!==void 0&&await i.setCurrentTime(E-10),e()},[i,e]),r=t.useCallback(async()=>{const E=await i.getCurrentTime();E!==void 0&&await i.setCurrentTime(E+30),e()},[i,e]),l=t.useCallback(async E=>{await i.setPlaybackRate(E),e()},[i,e]),m=t.useCallback(async()=>{n.currentItem!==void 0&&await n.removeItems([n.currentItem]),e()},[n,e]),[d]=t.useState(),v=t.useMemo(()=>[{id:0,items:[{name:"Speed",icon:t.createElement(a.EuiIcon,{type:c.TopSpeedRegular,size:"m"}),panel:1},{name:"Skip back 10 seconds",icon:t.createElement(a.EuiIcon,{type:c.SkipBack10Regular,size:"m"}),onClick:o,disabled:n.isEmpty},{name:"Skip forward 30 seconds",icon:t.createElement(a.EuiIcon,{type:c.SkipForward30Regular,size:"m"}),onClick:r,disabled:n.isEmpty},{isSeparator:!0},{name:"Remove from play queue",icon:t.createElement(a.EuiIcon,{type:c.DismissRegular,size:"m"}),onClick:m,disabled:n.isEmpty}]},{id:1,title:"Speed",items:[.25,.5,.75,1,1.25,1.5,1.75,2].map(E=>({name:E.toString(),onClick:()=>l(E),icon:E===d?"check":"empty"}))}],[n,o,r,m,l,d]);return t.createElement(a.EuiContextMenu,{initialPanelId:0,panels:v})}),B=t.memo(({playQueueStore:n,button:e,isOpen:i,closePopover:o})=>t.createElement(a.EuiPopover,{button:e,isOpen:i,closePopover:o,panelPaddingSize:"none",anchorPosition:"upRight"},t.createElement(z,{playQueueStore:n,closePopover:o}))),N={[u.Off]:c.ArrowRepeatAllOffFilled,[u.All]:c.ArrowRepeatAllFilled,[u.One]:c.ArrowRepeat1Filled},D=h.observer(({playerStore:n,playQueueStore:e})=>{const i=g.useNostalgicDiva(),o=t.useCallback(async()=>{if(e.hasPreviousItem){const r=await i.getCurrentTime();r===void 0||r<5?await e.previous():await i.setCurrentTime(0)}else await i.setCurrentTime(0)},[e,i]);return t.createElement(a.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"center",alignItems:"center"},t.createElement(a.EuiButtonIcon,{title:`Shuffle: ${e.shuffle?"On":"Off"}`,"aria-label":`Shuffle: ${e.shuffle?"On":"Off"}`,iconType:e.shuffle?c.ArrowShuffleFilled:c.ArrowShuffleOffFilled,size:"s",iconSize:"l",onClick:e.toggleShuffle,disabled:!0}),t.createElement(a.EuiButtonIcon,{title:"Previous","aria-label":"Previous",iconType:c.PreviousFilled,size:"s",iconSize:"l",onClick:o,disabled:e.isEmpty}),n.playing?t.createElement(a.EuiButtonIcon,{title:"Pause","aria-label":"Pause",iconType:c.PauseFilled,size:"s",iconSize:"l",onClick:()=>i.pause(),disabled:!e.canPlay}):t.createElement(a.EuiButtonIcon,{title:"Play","aria-label":"Play",iconType:c.PlayFilled,size:"s",iconSize:"l",onClick:()=>i.play(),disabled:!e.canPlay}),t.createElement(a.EuiButtonIcon,{title:"Next","aria-label":"Next",iconType:c.NextFilled,size:"s",iconSize:"l",onClick:e.next,disabled:!e.hasNextItem}),t.createElement(a.EuiButtonIcon,{title:`Repeat: ${e.repeat===u.All?"All":e.repeat===u.One?"One":"Off"}`,"aria-label":`Repeat: ${e.repeat===u.All?"All":e.repeat===u.One?"One":"Off"}`,iconType:N[e.repeat],size:"s",iconSize:"l",onClick:e.toggleRepeat}))}),L=t.memo(()=>{const[n,e]=t.useState(!1),i=()=>e(!n);return t.createElement(A,{button:t.createElement(a.EuiButtonIcon,{title:"Volume","aria-label":"Volume",iconType:c.Speaker2Regular,size:"s",iconSize:"l",onClick:i}),isOpen:n,closePopover:()=>e(!1)})}),V=t.memo(({playQueueStore:n})=>{const[e,i]=t.useState(!1),o=()=>i(!e);return t.createElement(B,{playQueueStore:n,button:t.createElement(a.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:c.MoreHorizontalFilled,size:"s",iconSize:"l",onClick:o}),isOpen:e,closePopover:()=>i(!1)})}),H=t.memo(({playQueueStore:n})=>t.createElement(a.EuiFlexGroup,{responsive:!1,gutterSize:"s",justifyContent:"flexEnd",alignItems:"center"},t.createElement(L,null),t.createElement(V,{playQueueStore:n}))),j=h.observer(({playerStore:n,playQueueStore:e})=>t.createElement(a.EuiBottomBar,{paddingSize:"s"},t.createElement(a.EuiFlexGroup,{direction:"column",gutterSize:"none"},t.createElement(a.EuiFlexItem,null,t.createElement(M,{playerStore:n})),t.createElement(a.EuiFlexItem,null,t.createElement(a.EuiFlexGroup,{responsive:!1},t.createElement(a.EuiFlexItem,{css:{width:"calc(100% / 3)"}}),t.createElement(a.EuiFlexItem,{css:{width:"calc(100% / 3)"}},t.createElement(D,{playerStore:n,playQueueStore:e})),t.createElement(a.EuiFlexItem,{css:{width:"calc(100% / 3)"}},t.createElement(H,{playQueueStore:e}))))))),q=({onCancel:n,onSave:e})=>{const[i,o]=t.useState(""),[r,l]=t.useState(""),[m,d]=t.useState(!1);return React.createElement(a.EuiModal,{onClose:n,initialFocus:"[name=url]"},React.createElement(a.EuiModalHeader,null,React.createElement(a.EuiModalHeaderTitle,null,"Add video")),React.createElement(a.EuiModalBody,null,React.createElement(a.EuiForm,{component:"form"},React.createElement(a.EuiFormRow,{label:"URL"},React.createElement(a.EuiFieldText,{name:"url",value:i,onChange:v=>o(v.target.value)})),React.createElement(a.EuiFormRow,{label:"Title"},React.createElement(a.EuiFieldText,{name:"title",value:r,onChange:v=>l(v.target.value)})))),React.createElement(a.EuiModalFooter,null,React.createElement(a.EuiButtonEmpty,{onClick:n},"Cancel"),React.createElement(a.EuiButton,{type:"submit",onClick:async()=>{try{d(!0),await e({url:i,title:r})}finally{d(!1)}},fill:!0,disabled:i.trim().length===0,isLoading:m},"Save")))};function U(n){return n!==null&&typeof n=="object"&&"title"in n&&typeof n.title=="string"}const $=t.memo(({playQueueStore:n})=>{const[e,i]=t.useState(!1),o=t.useCallback(async r=>{const l=g.findVideoService(r.url);if(l!==void 0){const m=l.extractVideoId(r.url);if(m!==void 0){const v=await(await fetch(`https://noembed.com/embed?url=${encodeURIComponent(r.url)}`)).json();await n.addItems([n.createItem({url:r.url,type:l.type,videoId:m,title:r.title||(U(v)?v.title:m)})])}}i(!1)},[n]);return React.createElement(React.Fragment,null,React.createElement(a.EuiButton,{onClick:()=>i(!0),iconType:c.AddRegular,color:"primary"},"Add video"),e&&React.createElement(q,{onCancel:()=>i(!1),onSave:o}))}),G=h.observer(({playQueueStore:n})=>{const{euiTheme:e}=a.useEuiTheme();return t.createElement(a.EuiTableHeader,{style:{position:"sticky",top:112,zIndex:998,background:e.colors.backgroundBasePlain}},t.createElement(a.EuiTableHeaderCellCheckbox,null,t.createElement(a.EuiCheckbox,{id:"",checked:n.allItemsSelected,onChange:i=>{n.allItemsSelected=i.target.checked}})),t.createElement(a.EuiTableHeaderCell,{width:24}),t.createElement(a.EuiTableHeaderCell,null,"Title"),t.createElement(a.EuiTableHeaderCell,null))}),J=t.memo(({item:n,closePopover:e})=>{const i=t.memo(({onClick:o,...r})=>{const l=t.useCallback(m=>{e(),o==null||o(m)},[o]);return t.createElement(a.EuiContextMenuItem,{...r,onClick:l})});return t.createElement(a.EuiContextMenuPanel,null,t.createElement(i,{icon:t.createElement(a.EuiIcon,{type:""}),onClick:n.playFirst},"Play first"),t.createElement(i,{icon:t.createElement(a.EuiIcon,{type:""}),onClick:n.playNext},"Play next"),t.createElement(i,{icon:t.createElement(a.EuiIcon,{type:c.AddRegular}),onClick:n.addToPlayQueue},"Add to play queue"),t.createElement(a.EuiHorizontalRule,{margin:"none"}),t.createElement(i,{icon:t.createElement(a.EuiIcon,{type:c.ArrowUploadRegular}),onClick:n.moveToTop,disabled:!n.canMoveToTop},"Move to the top"),t.createElement(i,{icon:t.createElement(a.EuiIcon,{type:c.ArrowDownloadRegular}),onClick:n.moveToBottom,disabled:!n.canMoveToBottom},"Move to the bottom"),t.createElement(a.EuiHorizontalRule,{margin:"none"}),t.createElement(i,{icon:t.createElement(a.EuiIcon,{type:""}),onClick:n.removeToTop,disabled:!n.canRemoveToTop},"Remove to the top"),t.createElement(i,{icon:t.createElement(a.EuiIcon,{type:""}),onClick:n.removeOthers,disabled:!n.canRemoveOthers},"Remove others"))}),X=t.memo(({item:n})=>{const[e,i]=t.useState(!1),o=t.useCallback(()=>i(!e),[e]),r=t.useCallback(()=>i(!1),[]);return t.createElement(a.EuiPopover,{button:t.createElement(a.EuiButtonIcon,{title:"More options","aria-label":"More options",iconType:c.MoreHorizontalFilled,size:"s",color:"text",onClick:o}),isOpen:e,closePopover:r,panelPaddingSize:"none",anchorPosition:"leftCenter"},t.createElement(J,{item:n,closePopover:r}))}),W=h.observer(({item:n})=>{const e=g.useNostalgicDiva();return t.createElement(a.EuiTableRowCell,{textOnly:!1,hasActions:!0,align:"right"},t.createElement(a.EuiButton,{iconType:c.PlayRegular,size:"s",onClick:async()=>{n.isCurrent?await e.setCurrentTime(0):n.play()}},"Play"),t.createElement(a.EuiButton,{iconType:c.DismissRegular,size:"s",onClick:n.remove},"Remove"),t.createElement(X,{item:n}))}),Y={Audio:"",Dailymotion:"https://www.dailymotion.com/favicon.ico",Niconico:"https://www.nicovideo.jp/favicon.ico",SoundCloud:"https://soundcloud.com/favicon.ico",Twitch:"https://www.twitch.tv/favicon.ico",Vimeo:"https://vimeo.com/favicon.ico",YouTube:"https://www.youtube.com/favicon.ico"},K=h.observer(({item:n})=>{const e=g.useNostalgicDiva();return t.createElement(a.EuiTableRow,{key:n.id,isSelected:n.isCurrent},t.createElement(a.EuiTableRowCellCheckbox,null,t.createElement(a.EuiCheckbox,{id:n.id.toString(),checked:n.isSelected,onChange:n.toggleSelected})),t.createElement(a.EuiTableRowCell,{textOnly:!1},t.createElement("img",{src:Y[n.type],width:16,height:16,alt:n.type})),t.createElement(a.EuiTableRowCell,null,t.createElement(a.EuiLink,{href:n.url,target:"_blank",external:!0,onClick:()=>e.pause()},n.title)),t.createElement(W,{item:n}))}),Z=h.observer(({playQueueStore:n})=>t.createElement(O.ReactSortable,{tag:"tbody",list:n.items,setList:e=>n.setItems(e)},n.items.map(e=>t.createElement(K,{key:e.id,item:e})))),_=h.observer(({playQueueStore:n})=>t.createElement(a.EuiTable,null,t.createElement(G,{playQueueStore:n}),t.createElement(Z,{playQueueStore:n}))),Q=h.observer(({playQueueStore:n})=>{const[e,i]=t.useState(!1);return React.createElement(React.Fragment,null,e&&React.createElement(a.EuiFlyout,{type:"push",size:"s",onClose:()=>i(!1)},React.createElement("div",{style:{blockSize:"100%"}},React.createElement(a.EuiCodeBlock,{language:"json",overflowHeight:"100%",isCopyable:!0,isVirtualized:!0},JSON.stringify(n.localStorageState,void 0,2)))),React.createElement($,{playQueueStore:n}))}),ee=h.observer(({playerStore:n,playQueueStore:e})=>{const{euiTheme:i}=a.useEuiTheme();return React.createElement(React.Fragment,null,React.createElement(a.EuiFlexGroup,{alignItems:"center",gutterSize:"m",style:{position:"sticky",top:48,zIndex:998,background:i.colors.backgroundBasePlain}},React.createElement(a.EuiFlexItem,{grow:!1},React.createElement(a.EuiButton,{disabled:e.isEmpty||e.selectedItems.length===0,onClick:e.playSelectedItemsNext},"Play next")),React.createElement(a.EuiFlexItem,{grow:!1},React.createElement(a.EuiButton,{iconType:c.AddRegular,onClick:e.addSelectedItems,disabled:e.isEmpty||e.selectedItems.length===0},"Add to play queue")),React.createElement(a.EuiFlexItem,{grow:!1},React.createElement(a.EuiButton,{iconType:c.DismissRegular,onClick:e.removeSelectedItems,disabled:e.isEmpty||e.selectedItems.length===0},"Remove")),React.createElement(a.EuiFlexItem,{grow:!1},React.createElement(a.EuiButton,{iconType:c.DeleteRegular,onClick:e.clear,disabled:e.isEmpty},"Clear")),React.createElement(a.EuiFlexItem,{grow:!0}),React.createElement(a.EuiFlexItem,{grow:!1},React.createElement(Q,{playQueueStore:e}))),!e.isEmpty&&React.createElement(React.Fragment,null,React.createElement(a.EuiSpacer,{size:"l",style:{position:"sticky",top:88,zIndex:998,background:i.colors.backgroundBasePlain}}),React.createElement(_,{playQueueStore:e})))}),te=h.observer(({playerStore:n,playQueueStore:e})=>React.createElement(React.Fragment,null,React.createElement(a.EuiPageTemplate.Header,{pageTitle:"Play queue",rightSideItems:[]}),React.createElement(a.EuiPageTemplate.Section,null,React.createElement(ee,{playerStore:n,playQueueStore:e})))),I={width:16*25,height:9*25},ne=h.observer(({playerStore:n,playQueueStore:e})=>{const i=g.useNostalgicDiva(),o=t.useCallback(async()=>{e.interacted&&await i.play()},[e,i]),r=t.useCallback(async()=>{switch(e.repeat){case u.One:await i.setCurrentTime(0);break;case u.Off:case u.All:if(e.isLastItem)switch(e.repeat){case u.Off:n.onEnded();break;case u.All:e.hasMultipleItems?await e.goToFirst():await i.setCurrentTime(0);break}else await e.next();break}},[e,n,i]),l=t.useMemo(()=>({onLoaded:o,onPlay:n.onPlay,onPause:n.onPause,onEnded:r,onTimeUpdate:n.onTimeUpdate}),[n,o,r]);return React.createElement("div",{css:{position:"fixed",right:0,bottom:x,width:I.width,height:I.height,zIndex:998,backgroundColor:"rgb(39, 39, 39)",display:"flex",flexDirection:"column"}},React.createElement("div",{css:{flexGrow:1,backgroundColor:"black"}},e.currentItem&&React.createElement(g.NostalgicDiva,{src:e.currentItem.url,options:l})))});class C{makeObservable(e,i){return s.makeObservable(e,i)}}const b=class b{constructor(e,i,o){p(this,"id");p(this,"isSelected",!1);this.observableStateProvider=e,this.playQueueStore=i,this.dto=o,this.id=b.nextId++,e.makeObservable(this,{isSelected:s.observable,isCurrent:s.computed,index:s.computed,isFirst:s.computed,isLast:s.computed,canMoveToTop:s.computed,canMoveToBottom:s.computed,canRemoveToTop:s.computed,canRemoveOthers:s.computed,unselect:s.action,toggleSelected:s.action.bound,play:s.action,remove:s.action.bound,playFirst:s.action.bound,playNext:s.action.bound,addToPlayQueue:s.action.bound,moveToTop:s.action.bound,moveToBottom:s.action.bound,removeToTop:s.action.bound,removeOthers:s.action.bound})}static fromDto(e,i,o){return new b(e,i,o)}get url(){return this.dto.url}get type(){return this.dto.type}get videoId(){return this.dto.videoId}get title(){return this.dto.title}get isCurrent(){return this.playQueueStore.currentItem===this}get index(){return this.playQueueStore.items.indexOf(this)}get isFirst(){return this.index===0}get isLast(){return this.index===this.playQueueStore.items.length-1}get canMoveToTop(){return!this.isFirst}get canMoveToBottom(){return!this.isLast}get canRemoveToTop(){return!this.isFirst}get canRemoveOthers(){return this.playQueueStore.hasMultipleItems}clone(){return this.playQueueStore.createItem(this.dto)}unselect(){this.isSelected=!1}toggleSelected(){this.isSelected=!this.isSelected}play(){this.playQueueStore.setCurrentItem(this)}remove(){return this.playQueueStore.removeItems([this])}async playFirst(){await this.playQueueStore.playFirst([this.clone()])}async playNext(){await this.playQueueStore.playNext([this.clone()])}async addToPlayQueue(){await this.playQueueStore.addItems([this.clone()])}moveToTop(){this.playQueueStore.moveItem(this,0)}moveToBottom(){this.playQueueStore.moveItem(this,this.playQueueStore.items.length-1)}removeToTop(){return this.playQueueStore.removeItemsAbove(this)}removeOthers(){return this.playQueueStore.removeOtherItems(this)}};p(b,"nextId",1);let y=b;const f=new F({coerceTypes:!0});function ie(n,e){let i;if(i=f.getSchema(e),i===void 0&&(f.addSchema(n,e),i=f.getSchema(e)),i===void 0||i.schema!==n)throw new Error(`Invalid schema. Expected: '${JSON.stringify(n)}', but got '${JSON.stringify(i==null?void 0:i.schema)}'.`);return i}const ae={type:"object",properties:{version:{type:"string",nullable:!0},repeat:{type:"string",enum:Object.values(u),nullable:!0},shuffle:{type:"boolean",nullable:!0},items:{type:"array",nullable:!0,items:{type:"object",properties:{url:{type:"string"},type:{type:"string"},videoId:{type:"string"},title:{type:"string"}},required:["url","type","videoId","title"]}},currentIndex:{type:"integer",nullable:!0}}},se=ie(ae,"PlayQueueStore");class oe{constructor(e){p(this,"interacted",!1);p(this,"items",[]);p(this,"currentId");p(this,"repeat",u.Off);p(this,"shuffle",!1);this.observableStateProvider=e,e.makeObservable(this,{interacted:s.observable,items:s.observable,currentId:s.observable,repeat:s.observable,shuffle:s.observable,localStorageState:s.computed.struct,isEmpty:s.computed,currentItem:s.computed,canPlay:s.computed,canPause:s.computed,hasMultipleItems:s.computed,currentIndex:s.computed,hasPreviousItem:s.computed,hasNextItem:s.computed,isLastItem:s.computed,selectedItems:s.computed,allItemsSelected:s.computed,selectedItemsOrAllItems:s.computed,setItems:s.action,interact:s.action,clear:s.action.bound,unselectAll:s.action,setCurrentItem:s.action,setNextItems:s.action,clearAndSetItems:s.action,playNext:s.action,playSelectedItemsNext:s.action.bound,addItems:s.action,addSelectedItems:s.action.bound,playFirst:s.action,moveItem:s.action,removeItems:s.action,removeSelectedItems:s.action.bound,removeOtherItems:s.action,removeItemsAbove:s.action,toggleRepeat:s.action.bound,toggleShuffle:s.action.bound,previous:s.action,next:s.action.bound,goToFirst:s.action})}createItem(e){return y.fromDto(this.observableStateProvider,this,e)}get localStorageState(){return{version:"1.0",repeat:this.repeat,shuffle:this.shuffle,items:this.items.map(e=>e.dto),currentIndex:this.currentIndex}}set localStorageState(e){var i;this.repeat=e.repeat??u.Off,this.shuffle=e.shuffle??!1,this.items=((i=e.items)==null?void 0:i.map(o=>this.createItem(o)))??[],this.currentIndex=e.currentIndex}validateLocalStorageState(e){return se(e)}get isEmpty(){return this.items.length===0}get currentItem(){return this.items.find(e=>e.id===this.currentId)}get canPlay(){return this.currentItem!==void 0}get canPause(){return this.currentItem!==void 0}get hasMultipleItems(){return this.items.length>1}get currentIndex(){return this.currentId!==void 0?this.items.findIndex(e=>e.id===this.currentId):void 0}set currentIndex(e){var i;this.currentId=e!==void 0?(i=this.items.at(e))==null?void 0:i.id:void 0}get hasPreviousItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex>0}get hasNextItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex<this.items.length-1}get isLastItem(){return this.currentIndex!==void 0&&this.currentIndex===this.items.length-1}get selectedItems(){return this.items.filter(e=>e.isSelected)}get allItemsSelected(){return this.selectedItems.length===this.items.length}set allItemsSelected(e){for(const i of this.items)i.isSelected=e}get selectedItemsOrAllItems(){return this.selectedItems.length>0?this.selectedItems:this.items}setItems(e){this.items=e}interact(){this.interacted=!0}clear(){this.interact(),this.currentIndex=void 0,this.items=[]}unselectAll(){for(const e of this.items)e.unselect()}setCurrentItem(e){this.interact(),this.currentId=e==null?void 0:e.id}setNextItems(e){this.currentIndex!==void 0&&this.items.splice(this.currentIndex+1,0,...e)}clearAndSetItems(e){this.clear(),this.setCurrentItem(e[0]),this.setNextItems(e)}async playNext(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.setNextItems(e)}async playSelectedItemsNext(){await this.playNext(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async addItems(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.items.push(...e)}async addSelectedItems(){await this.addItems(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async playFirst(e){if(this.isEmpty){this.clearAndSetItems(e);return}const{currentIndex:i}=this;i!==void 0&&(this.interact(),this.items.splice(i,0,...e),this.currentIndex=i)}moveItem(e,i){const o=this.items.splice(this.items.indexOf(e),1)[0];this.items.splice(i,0,o)}async removeItems(e){const{currentItem:i}=this;T.pull(this.items,...e.filter(l=>l!==i));const{currentIndex:o,isLastItem:r}=this;T.pull(this.items,e.find(l=>l===i)),this.currentItem!==i&&(this.interact(),r?await this.goToFirst():this.currentIndex=o)}async removeSelectedItems(){await this.removeItems(this.selectedItemsOrAllItems),this.unselectAll()}async removeOtherItems(e){const i=e.id;return this.removeItems(this.items.filter(o=>o.id!==i))}async removeItemsAbove(e){const i=this.items.indexOf(e);return this.removeItems(this.items.filter((o,r)=>r<i))}toggleRepeat(){switch(this.repeat){case u.Off:this.repeat=u.All;break;case u.All:this.repeat=u.One;break;case u.One:this.repeat=u.Off;break}}toggleShuffle(){this.shuffle=!this.shuffle}async previous(){this.currentIndex!==void 0&&this.hasPreviousItem&&(this.interact(),this.currentIndex--)}async next(){this.currentIndex!==void 0&&this.hasNextItem&&(this.interact(),this.currentIndex++)}async goToFirst(){this.currentIndex!==void 0&&(this.currentIndex=0)}}const R=t.createContext(void 0),re=({children:n})=>{const[e]=t.useState(()=>new oe(new C)),i=g.useNostalgicDiva();return t.useEffect(()=>s.reaction(()=>e.currentItem,async(o,r)=>{o===void 0||r===void 0||o.type===r.type&&o.videoId===r.videoId&&await i.setCurrentTime(0)}),[e,i]),React.createElement(R.Provider,{value:e},n)},k=()=>t.useContext(R),le=h.observer(({children:n})=>{const e=k();return React.createElement(a.EuiPageTemplate,{panelled:!0,style:{minBlockSize:`max(460px, 100vh - ${x}px)`}},n,!e.isEmpty&&React.createElement(a.EuiSpacer,{style:{blockSize:I.height}}))});class ce{constructor(e){p(this,"playing",!1);p(this,"percent",0);p(this,"seeking",!1);e.makeObservable(this,{playing:s.observable,percent:s.observable,seeking:s.observable,setPlaying:s.action,setPercent:s.action,setSeeking:s.action,onPlay:s.action.bound,onPause:s.action.bound,onEnded:s.action.bound,onTimeUpdate:s.action.bound})}setPlaying(e){this.playing=e}setPercent(e){this.percent=e}setSeeking(e){this.seeking=e}onPlay(){this.playing=!0}onPause(){this.playing=!1}onEnded(){this.playing=!1}onTimeUpdate({percent:e}){e!==void 0&&(this.seeking||(this.percent=e))}}const P=t.createContext(void 0),ue=({children:n})=>{const[e]=t.useState(()=>new ce(new C));return React.createElement(P.Provider,{value:e},n)},me=()=>t.useContext(P);class de{makeObservable(e,i){return e}}exports.BottomBar=j;exports.HydrangeanDiva=te;exports.MediaPlayerLayout=le;exports.MiniPlayer=ne;exports.MobXObservableStateProvider=C;exports.ObservableStateProvider=de;exports.PlayQueueStoreProvider=re;exports.PlayerStoreProvider=ue;exports.RepeatMode=u;exports.bottomBarHeight=x;exports.miniPlayerSize=I;exports.usePlayQueueStore=k;exports.usePlayerStore=me;
2
+ //# sourceMappingURL=index.cjs.js.map