-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathstore.ts
98 lines (95 loc) · 2.25 KB
/
store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
export const params = (new URL(location.href)).searchParams;
export const getSaved = localStorage.getItem.bind(localStorage);
export const store: {
player: {
playbackState: 'none' | 'playing' | 'paused',
hls: {
on: boolean,
src: (arg0: string) => void,
api: string[],
manifests: string[]
}
hq: boolean,
codec: 'opus' | 'aac' | 'any'
supportsOpus: Promise<boolean>,
data: Piped | undefined,
legacy: boolean,
fallback: string,
usePiped: boolean
},
lrcSync: (arg0: number) => {} | void,
queue: string[],
stream: CollectionItem,
streamHistory: string[]
api: {
piped: string[],
invidious: string[],
hyperpipe: string,
index: number
},
loadImage: boolean,
linkHost: string,
searchQuery: string,
superCollectionType: 'featured' | 'collections' | 'channels' | 'feed' | 'playlists',
actionsMenu: CollectionItem,
list: List & Record<'url' | 'type' | 'uploader', string>,
downloadFormat: 'opus' | 'wav' | 'mp3' | 'ogg'
} = {
player: {
playbackState: 'none',
hls: {
on: Boolean(getSaved('HLS')),
src: () => '',
manifests: [],
api: ['https://pipedapi.kavin.rocks']
},
hq: Boolean(getSaved('hq')),
codec: 'opus',
supportsOpus: navigator.mediaCapabilities.decodingInfo({
type: 'file',
audio: {
contentType: 'audio/webm;codecs=opus'
}
}).then(res => res.supported),
data: undefined,
legacy: !('OffscreenCanvas' in window),
fallback: '',
usePiped: true
},
lrcSync: () => '',
queue: [],
stream: {
id: params.get('s') || '',
title: '',
author: '',
duration: '',
channelUrl: ''
},
streamHistory: [],
api: {
piped: ['https://pipedapi.kavin.rocks'],
invidious: ['https://iv.ggtyler.dev'],
hyperpipe: 'https://hyperpipeapi.onrender.com',
index: 0
},
loadImage: getSaved('imgLoad') !== 'off',
linkHost: getSaved('linkHost') || location.origin,
searchQuery: '',
superCollectionType: 'featured',
actionsMenu: {
id: '',
title: '',
author: '',
duration: '',
channelUrl: ''
},
list: {
name: '',
url: '',
type: '',
id: '',
uploader: '',
thumbnail: ''
},
downloadFormat: getSaved('dlFormat') as 'opus' || 'opus'
}