diff --git a/package.json b/package.json index c5439d0..74895e1 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@tanstack/react-query-devtools": "^4.35.3", "@tauri-apps/api": "^1.4.0", "axios": "^1.5.0", + "axios-tauri-api-adapter": "^0.2.0", "blurhash": "^2.0.5", "events": "^3.3.0", "framer-motion": "^10.16.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 42ffbba..9df37f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ dependencies: axios: specifier: ^1.5.0 version: 1.5.0 + axios-tauri-api-adapter: + specifier: ^0.2.0 + version: 0.2.0 blurhash: specifier: ^2.0.5 version: 2.0.5 @@ -1285,6 +1288,20 @@ packages: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} dev: false + /axios-tauri-api-adapter@0.2.0: + resolution: {integrity: sha512-+iSmMbdobsRS3bV1urGq/a6cMMsI4VbZsWQGIJMb28R0ZEpzYDqGxhDA4OYQiC5m1ywVtlpgGbxE/cqDZldjQA==} + engines: {node: '>=16', pnpm: '>=7'} + requiresBuild: true + dependencies: + '@tauri-apps/api': 1.4.0 + axios: 1.5.0 + build-url-ts: 6.1.5 + http-status-codes: 2.3.0 + url-parse: 1.5.10 + transitivePeerDependencies: + - debug + dev: false + /axios@1.5.0: resolution: {integrity: sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==} dependencies: @@ -1328,6 +1345,10 @@ packages: node-releases: 2.0.13 update-browserslist-db: 1.0.11(browserslist@4.21.10) + /build-url-ts@6.1.5: + resolution: {integrity: sha512-kjauShWoKG69xYwoJ4OTbHSliwhWHXa3wFJSamAva9SyK7OoihxdBfamaBjWhZPJvy0MP0cioXsZZhKKfFFCsg==} + dev: false + /callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -1629,6 +1650,10 @@ packages: react-is: 16.13.1 dev: false + /http-status-codes@2.3.0: + resolution: {integrity: sha512-RJ8XvFvpPM/Dmc5SV+dC4y5PCeOhT3x1Hq0NU3rjGeg5a/CqlhZ7uudknPwZFz4aeAXDcbAyaeP7GAo9lvngtA==} + dev: false + /immutable@4.3.4: resolution: {integrity: sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==} @@ -1833,6 +1858,10 @@ packages: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} dev: false + /querystringify@2.2.0: + resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} + dev: false + /react-blurhash@0.3.0(blurhash@2.0.5)(react@18.2.0): resolution: {integrity: sha512-XlKr4Ns1iYFRnk6DkAblNbAwN/bTJvxTVoxMvmTcURdc5oLoXZwqAF9N3LZUh/HT+QFlq5n6IS6VsDGsviYAiQ==} peerDependencies: @@ -1984,6 +2013,10 @@ packages: resolution: {integrity: sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==} dev: false + /requires-port@1.0.0: + resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} + dev: false + /resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} @@ -2090,6 +2123,13 @@ packages: escalade: 3.1.1 picocolors: 1.0.0 + /url-parse@1.5.10: + resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==} + dependencies: + querystringify: 2.2.0 + requires-port: 1.0.0 + dev: false + /use-sync-external-store@1.2.0(react@18.2.0): resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==} peerDependencies: diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 9faac62..f6721cc 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -18,7 +18,7 @@ tauri-build = { version = "1.4.0", features = [] } log = "^0.4.20" serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.4.1", features = ["devtools", "process-exit", "process-relaunch", "shell-all", "window-set-fullscreen"] } +tauri = { version = "1.4.1", features = [ "http-all", "devtools", "process-exit", "process-relaunch", "shell-all", "window-set-fullscreen", "http-all"] } tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" } tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev", features = ["colored"] } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index bbcff75..c1f191b 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -23,6 +23,16 @@ }, "shell": { "all": true + }, + "http": { + "all": true, + "request": true, + "scope": [ + "http://**", + "http://*", + "https://**", + "https://*" + ] } }, "bundle": { diff --git a/src/App.jsx b/src/App.jsx index 4fc09f3..57e209f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -70,7 +70,6 @@ import { v4 as uuidv4 } from "uuid"; import { delServer, getServer } from "./utils/storage/servers.js"; import { delUser, getUser } from "./utils/storage/user.js"; -import axios from "axios"; import { useBackdropStore } from "./utils/store/backdrop.js"; import { usePlaybackDataLoadStore, @@ -85,6 +84,11 @@ import ArtistTitlePage from "./routes/artist/index.jsx"; import EpisodeTitlePage from "./routes/episode/index.jsx"; import PlaylistTitlePage from "./routes/playlist/index.jsx"; +// Initial custom axios client to use tauri's http module +import axios from "axios"; +import axiosTauriApiAdapter from "axios-tauri-api-adapter"; +const axiosClient = axios.create({ adapter: axiosTauriApiAdapter }); + const jellyfin = new Jellyfin({ clientInfo: { name: "JellyPlayer", @@ -97,13 +101,14 @@ const jellyfin = new Jellyfin({ }); event.on("create-jellyfin-api", (serverAddress) => { - window.api = jellyfin.createApi(serverAddress); + window.api = jellyfin.createApi(serverAddress, null, axiosClient); // window.api = jellyfin.createApi(serverAddress); }); event.on("set-api-accessToken", (serverAddress) => { window.api = jellyfin.createApi( serverAddress, sessionStorage.getItem("accessToken"), + axiosClient, ); }); @@ -190,6 +195,7 @@ function App() { const result = await axios.get( new URL(`${server.Ip}/System/Ping`).href, ); + if (result.data == "Jellyfin Server") { event.emit("create-jellyfin-api", server.Ip); setServerReachable(true);