File tree 4 files changed +28
-3
lines changed
4 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * This module gets ran on the initialization on Electron
2
+ * This module gets ran on the initialization of Electron
3
3
* @module
4
4
*/
5
- /* eslint-disable no-var */
6
5
7
6
declare global {
7
+ // eslint-disable-next-line no-var
8
8
var __IS_ELECTRON__ : boolean ;
9
9
10
10
interface $ElectronMusicPlayer {
@@ -26,11 +26,14 @@ declare global {
26
26
readFile : ( path : string ) => Promise < Uint8Array > ;
27
27
traverseDirectory : ( path : string ) => Promise < string [ ] > ;
28
28
}
29
+
30
+ // eslint-disable-next-line no-var
29
31
var $ElectronMusicPlayer : $ElectronMusicPlayer | undefined ;
30
32
31
33
interface ElectronMusicPlayer extends $ElectronMusicPlayer {
32
34
fetchShim : typeof globalThis . fetch ;
33
35
}
36
+ // eslint-disable-next-line no-var
34
37
var ElectronMusicPlayer : ElectronMusicPlayer | undefined ;
35
38
}
36
39
Original file line number Diff line number Diff line change @@ -36,12 +36,15 @@ import "@ionic/vue/css/palettes/dark.system.css";
36
36
37
37
/* Theme variables */
38
38
import "./theme/variables.css" ;
39
+ import { isMobilePlatform } from "./utils/os" ;
39
40
40
41
/* Vue store */
41
42
const pinia = createPinia ( ) ;
42
43
43
44
if ( __IS_ELECTRON__ ) {
44
45
await import ( "./electron" ) ;
46
+ } else if ( isMobilePlatform ( ) ) {
47
+ void import ( "./mobile" ) ;
45
48
}
46
49
47
50
const app = createApp ( App ) . use ( IonicVue ) . use ( pinia ) . use ( router ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * This module gets ran on the initialization of Mobile devices
3
+ * @module
4
+ */
5
+
6
+ declare global {
7
+ // eslint-disable-next-line no-var
8
+ var capacitorFetch : typeof window . fetch ;
9
+ }
10
+
11
+ const capacitorPatchedFetch = window . fetch ;
12
+ const webFetch = "CapacitorWebFetch" in window && ( window . CapacitorWebFetch as typeof window . fetch ) ;
13
+
14
+ if ( webFetch ) {
15
+ window . fetch = webFetch ;
16
+ window . capacitorFetch = capacitorPatchedFetch ;
17
+ }
18
+
19
+ export { } ;
Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ export class YouTubeMusicPlayerService extends MusicPlayerService<YouTubeSong> {
158
158
// youtube.js seems to be destructurizing fetch somewhere, which causes
159
159
// "Illegal Invocation error", so we just provide our own
160
160
// TODO: Proxy for web support
161
- const fetch = isElectron ( ) ? ElectronMusicPlayer ! . fetchShim : window . fetch . bind ( window ) ;
161
+ const fetch = isElectron ( ) ? ElectronMusicPlayer ! . fetchShim : window . capacitorFetch ;
162
162
163
163
const tmp = await Innertube . create ( {
164
164
generate_session_locally : false ,
You can’t perform that action at this time.
0 commit comments