diff --git a/package.json b/package.json index 4e70471..452da82 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build:node": "MOKU_TARGET=node vite build", "build:tauri": "MOKU_TARGET=static vite build", "build:android": "MOKU_TARGET=static vite build", - "tauri:dev": "tauri dev", + "tauri:dev": "tauri dev --config src-tauri/tauri.dev.conf.json", "tauri:build": "tauri build" }, "devDependencies": { @@ -21,18 +21,25 @@ "@sveltejs/adapter-static": "^3.0.10", "@sveltejs/kit": "^2.57.0", "@sveltejs/vite-plugin-svelte": "^7.0.0", - "@tauri-apps/cli": "^2.0.0", + "@tauri-apps/cli": "^2.1.0", "svelte": "^5.55.2", "svelte-check": "^4.4.6", "typescript": "^6.0.2", "vite": "^8.0.7" }, "dependencies": { + "@capacitor/browser": "^8.0.3", + "@capacitor/core": "^8.3.4", + "@capacitor/filesystem": "^8.1.2", "@tauri-apps/api": "^2.0.0", + "@tauri-apps/plugin-dialog": "^2.7.1", + "@tauri-apps/plugin-fs": "^2.5.1", "@tauri-apps/plugin-http": "^2.5.9", "@tauri-apps/plugin-os": "^2.3.2", + "@tauri-apps/plugin-process": "^2.3.1", "@tauri-apps/plugin-shell": "^2.3.5", "@tauri-apps/plugin-store": "^2.4.3", + "capacitor-native-biometric": "^4.2.2", "phosphor-svelte": "^3.1.0" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 56df0dd..52b1b83 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,21 +8,42 @@ importers: .: dependencies: + '@capacitor/browser': + specifier: ^8.0.3 + version: 8.0.3(@capacitor/core@8.3.4) + '@capacitor/core': + specifier: ^8.3.4 + version: 8.3.4 + '@capacitor/filesystem': + specifier: ^8.1.2 + version: 8.1.2(@capacitor/core@8.3.4) '@tauri-apps/api': specifier: ^2.0.0 version: 2.11.0 + '@tauri-apps/plugin-dialog': + specifier: ^2.7.1 + version: 2.7.1 + '@tauri-apps/plugin-fs': + specifier: ^2.5.1 + version: 2.5.1 '@tauri-apps/plugin-http': specifier: ^2.5.9 version: 2.5.9 '@tauri-apps/plugin-os': specifier: ^2.3.2 version: 2.3.2 + '@tauri-apps/plugin-process': + specifier: ^2.3.1 + version: 2.3.1 '@tauri-apps/plugin-shell': specifier: ^2.3.5 version: 2.3.5 '@tauri-apps/plugin-store': specifier: ^2.4.3 version: 2.4.3 + capacitor-native-biometric: + specifier: ^4.2.2 + version: 4.2.2 phosphor-svelte: specifier: ^3.1.0 version: 3.1.0(svelte@5.55.5(@typescript-eslint/types@8.57.1))(vite@8.0.10) @@ -40,8 +61,8 @@ importers: specifier: ^7.0.0 version: 7.0.0(svelte@5.55.5(@typescript-eslint/types@8.57.1))(vite@8.0.10) '@tauri-apps/cli': - specifier: ^2.0.0 - version: 2.11.2 + specifier: ^2.1.0 + version: 2.1.0 svelte: specifier: ^5.55.2 version: 5.55.5(@typescript-eslint/types@8.57.1) @@ -57,6 +78,25 @@ importers: packages: + '@capacitor/browser@8.0.3': + resolution: {integrity: sha512-WJWPHEPbweiFoHYmVlCbZf5yrqJ2Rchx2Xvbmd+3Lf+Zkpq3nXBThThY2CF69lYEg1NINGF9BcHThIOEU1gZlQ==} + peerDependencies: + '@capacitor/core': '>=8.0.0' + + '@capacitor/core@3.9.0': + resolution: {integrity: sha512-j1lL0+/7stY8YhIq1Lm6xixvUqIn89vtyH5ZpJNNmcZ0kwz6K9eLkcG6fvq1UWMDgSVZg9JrRGSFhb4LLoYOsw==} + + '@capacitor/core@8.3.4': + resolution: {integrity: sha512-CqRQCkb6HXxcx/N7s+hHTN6ef2CmamFiRMITwm4qB840ph56mS42bzUgn6tKCP+RZjdDweiRHj9ytDDeN6jFag==} + + '@capacitor/filesystem@8.1.2': + resolution: {integrity: sha512-doaaMfGoFR2hWU6aV6u83I+5ZsGyJVq+Gz4r9lMpJzUKMm1eMu0hLnFdV1aXZlU9FlK/RndFrVD8oRZfNOqWgQ==} + peerDependencies: + '@capacitor/core': '>=8.0.0' + + '@capacitor/synapse@1.0.4': + resolution: {integrity: sha512-/C1FUo8/OkKuAT4nCIu/34ny9siNHr9qtFezu4kxm6GY1wNFxrCFWjfYx5C1tUhVGz3fxBABegupkpjXvjCHrw==} + '@emnapi/core@1.10.0': resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==} @@ -410,88 +450,90 @@ packages: '@tauri-apps/api@2.11.0': resolution: {integrity: sha512-7CinYODhky9lmO23xHnUFv0Xt43fbtWMyxZcLcRBlFkcgXKuEirBvHpmtJ89YMhyeGcq20Wuc47Fa4XjyniywA==} - '@tauri-apps/cli-darwin-arm64@2.11.2': - resolution: {integrity: sha512-+4UZzLt+eOAEQCwgd+TqKgyUJMrvx+BgdXLLaqJYmPqzP+nE6YZr/hY6CWLYGQb8jFn99jEkmC6uA3tNvamA1w==} + '@tauri-apps/cli-darwin-arm64@2.1.0': + resolution: {integrity: sha512-ESc6J6CE8hl1yKH2vJ+ALF+thq4Be+DM1mvmTyUCQObvezNCNhzfS6abIUd3ou4x5RGH51ouiANeT3wekU6dCw==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@tauri-apps/cli-darwin-x64@2.11.2': - resolution: {integrity: sha512-VjYYtZUPqDMLutSfJEyxFE3Bz+DPi7c8wC3imckgvciLDZLq4qwKJxBicg0BXGhXjJsl8vKWgWRFNMPELQ+Xyg==} + '@tauri-apps/cli-darwin-x64@2.1.0': + resolution: {integrity: sha512-TasHS442DFs8cSH2eUQzuDBXUST4ECjCd0yyP+zZzvAruiB0Bg+c8A+I/EnqCvBQ2G2yvWLYG8q/LI7c87A5UA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@tauri-apps/cli-linux-arm-gnueabihf@2.11.2': - resolution: {integrity: sha512-yMemD6f4i95AQriS8EazyOFzbE34yjnP16i3IOzpHGQvBoy2DjypFMFBq0NtPuITURv/cOGguRtHR5d79/9CSA==} + '@tauri-apps/cli-linux-arm-gnueabihf@2.1.0': + resolution: {integrity: sha512-aP7ZBGNL4ny07Cbb6kKpUOSrmhcIK2KhjviTzYlh+pPhAptxnC78xQGD3zKQkTi2WliJLPmBYbOHWWQa57lQ9w==} engines: {node: '>= 10'} cpu: [arm] os: [linux] - '@tauri-apps/cli-linux-arm64-gnu@2.11.2': - resolution: {integrity: sha512-cgI91D2wL8GSgoWwZXDqt+DwnuZCP2/bz03QAE4TrhgAKIsrB4hX26W/H1EONPUUNkqrsgeCD0wU6pcNjV/5kw==} + '@tauri-apps/cli-linux-arm64-gnu@2.1.0': + resolution: {integrity: sha512-ZTdgD5gLeMCzndMT2f358EkoYkZ5T+Qy6zPzU+l5vv5M7dHVN9ZmblNAYYXmoOuw7y+BY4X/rZvHV9pcGrcanQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [glibc] - '@tauri-apps/cli-linux-arm64-musl@2.11.2': - resolution: {integrity: sha512-X1rm0BERqAAggtYTESSgXrS3sz4Sb/OiPiz54UqISlXW+GkR3vNIGnsy/lejNmoXGVqri3Q53BCfQiclOIyRPw==} + '@tauri-apps/cli-linux-arm64-musl@2.1.0': + resolution: {integrity: sha512-NzwqjUCilhnhJzusz3d/0i0F1GFrwCQbkwR6yAHUxItESbsGYkZRJk0yMEWkg3PzFnyK4cWTlQJMEU52TjhEzA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [musl] - '@tauri-apps/cli-linux-riscv64-gnu@2.11.2': - resolution: {integrity: sha512-usbMLJbT3KtkOrBMDVeGYNM35aTHXx38SJSzTMSqqjeUIOQ+iVPjb2yAGNAE+KqmBbAx4FOFIyMeKXx2M/JKGQ==} - engines: {node: '>= 10'} - cpu: [riscv64] - os: [linux] - libc: [glibc] - - '@tauri-apps/cli-linux-x64-gnu@2.11.2': - resolution: {integrity: sha512-Ru4gwJKPG0ctVGchRGpRup4Y4lW2SSfFnrbQcyHhCliKy4g8Qz97TrUgCur4CbWyAgKxvGh3SjrkA0LDYzDGiw==} + '@tauri-apps/cli-linux-x64-gnu@2.1.0': + resolution: {integrity: sha512-TyiIpMEtZxNOQmuFyfJwaaYbg3movSthpBJLIdPlKxSAB2BW0VWLY3/ZfIxm/G2YGHyREkjJvimzYE0i37PnMA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [glibc] - '@tauri-apps/cli-linux-x64-musl@2.11.2': - resolution: {integrity: sha512-eUm7T6clN1MMmNSRQ9gaWsQdyehQx2Gmn5hht/QUlqZQI/qcP2OJK5dnaxqwFzCr2HdsEo9ydxaqcS1oJzMvUw==} + '@tauri-apps/cli-linux-x64-musl@2.1.0': + resolution: {integrity: sha512-/dQd0TlaxBdJACrR72DhynWftzHDaX32eBtS5WBrNJ+nnNb+znM3gON6nJ9tSE9jgDa6n1v2BkI/oIDtypfUXw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [musl] - '@tauri-apps/cli-win32-arm64-msvc@2.11.2': - resolution: {integrity: sha512-HeeZW80jU+gVTOEX4X/hC6NVSAdDVXajwP5fxIZ/3z9WvUC7qrudX2GMTilYq6Dg0e0sk0XgsAJD1hZ5wPBXUA==} + '@tauri-apps/cli-win32-arm64-msvc@2.1.0': + resolution: {integrity: sha512-NdQJO7SmdYqOcE+JPU7bwg7+odfZMWO6g8xF9SXYCMdUzvM2Gv/AQfikNXz5yS7ralRhNFuW32i5dcHlxh4pDg==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@tauri-apps/cli-win32-ia32-msvc@2.11.2': - resolution: {integrity: sha512-YhjQNZcXfbkCLyazSv1nPnJ9iRFE1wm6kc51FDbU10/Dk09io+6PAGMLjkxnX2GdM0qMnDmTjstY8mTDVvtKeA==} + '@tauri-apps/cli-win32-ia32-msvc@2.1.0': + resolution: {integrity: sha512-f5h8gKT/cB8s1ticFRUpNmHqkmaLutT62oFDB7N//2YTXnxst7EpMIn1w+QimxTvTk2gcx6EcW6bEk/y2hZGzg==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@tauri-apps/cli-win32-x64-msvc@2.11.2': - resolution: {integrity: sha512-d2JchlFIpZevZVReyqhQOekJmb1UH3rhZ5VX6sH3ty9ETE0TKQavpihvoScUXfKKpW6HZC0MrFGRU0ZtD+w3gA==} + '@tauri-apps/cli-win32-x64-msvc@2.1.0': + resolution: {integrity: sha512-P/+LrdSSb5Xbho1LRP4haBjFHdyPdjWvGgeopL96OVtrFpYnfC+RctB45z2V2XxqFk3HweDDxk266btjttfjGw==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - '@tauri-apps/cli@2.11.2': - resolution: {integrity: sha512-bk3HemqvGRoy+5D/dVMUQHKMYLglD0jVnMm/0iGMH6ufZ+p8r14m6BpIixwij3PBvZdvORUp1YifTD8QxVZ1Nw==} + '@tauri-apps/cli@2.1.0': + resolution: {integrity: sha512-K2VhcKqBhAeS5pNOVdnR/xQRU6jwpgmkSL2ejHXcl0m+kaTggT0WRDQnFtPq6NljA7aE03cvwsbCAoFG7vtkJw==} engines: {node: '>= 10'} hasBin: true + '@tauri-apps/plugin-dialog@2.7.1': + resolution: {integrity: sha512-OK1UBXYt+ojcmxMktzzuyonYIFta8CmAASpX+CA+DTGK24KlHjhYI6x2iOJ/TjZF4N7/ACK1oFmEOjIY9IhzOQ==} + + '@tauri-apps/plugin-fs@2.5.1': + resolution: {integrity: sha512-9Lz+Jopp6QyeEWhlpkMx4R/+P9HgR+AVAI4vOZhlT8Xaymtz8iVI/Ov984/XTqgJz/5gz5NretqPB/XEMS3NhQ==} + '@tauri-apps/plugin-http@2.5.9': resolution: {integrity: sha512-lCiY0+vs4HvIUSvZrBs8TC3TiCB0MOPRmiUjTq4prW7SlcJE2jdLeT6KBsJrT9Tlplufl7W1pY6SFAO3gCWxDA==} '@tauri-apps/plugin-os@2.3.2': resolution: {integrity: sha512-n+nXWeuSeF9wcEsSPmRnBEGrRgOy6jjkSU+UVCOV8YUGKb2erhDOxis7IqRXiRVHhY8XMKks00BJ0OAdkpf6+A==} + '@tauri-apps/plugin-process@2.3.1': + resolution: {integrity: sha512-nCa4fGVaDL/B9ai03VyPOjfAHRHSBz5v6F/ObsB73r/dA3MHHhZtldaDMIc0V/pnUw9ehzr2iEG+XkSEyC0JJA==} + '@tauri-apps/plugin-shell@2.3.5': resolution: {integrity: sha512-jewtULhiQ7lI7+owCKAjc8tYLJr92U16bPOeAa472LHJdgaibLP83NcfAF2e+wkEcA53FxKQAZ7byDzs2eeizg==} @@ -530,6 +572,9 @@ packages: resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==} engines: {node: '>= 0.4'} + capacitor-native-biometric@4.2.2: + resolution: {integrity: sha512-stg0h48UxgkNuNcCAgCXLp2DUspRQs79bCBPntpCBhsDxk2bhDRUu+J/QpFtDQHG4M4DioSUcYaAsVw2N6N7wA==} + chokidar@4.0.3: resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} engines: {node: '>= 14.16.0'} @@ -859,6 +904,25 @@ packages: snapshots: + '@capacitor/browser@8.0.3(@capacitor/core@8.3.4)': + dependencies: + '@capacitor/core': 8.3.4 + + '@capacitor/core@3.9.0': + dependencies: + tslib: 2.8.1 + + '@capacitor/core@8.3.4': + dependencies: + tslib: 2.8.1 + + '@capacitor/filesystem@8.1.2(@capacitor/core@8.3.4)': + dependencies: + '@capacitor/core': 8.3.4 + '@capacitor/synapse': 1.0.4 + + '@capacitor/synapse@1.0.4': {} + '@emnapi/core@1.10.0': dependencies: '@emnapi/wasi-threads': 1.2.1 @@ -1116,52 +1180,56 @@ snapshots: '@tauri-apps/api@2.11.0': {} - '@tauri-apps/cli-darwin-arm64@2.11.2': + '@tauri-apps/cli-darwin-arm64@2.1.0': optional: true - '@tauri-apps/cli-darwin-x64@2.11.2': + '@tauri-apps/cli-darwin-x64@2.1.0': optional: true - '@tauri-apps/cli-linux-arm-gnueabihf@2.11.2': + '@tauri-apps/cli-linux-arm-gnueabihf@2.1.0': optional: true - '@tauri-apps/cli-linux-arm64-gnu@2.11.2': + '@tauri-apps/cli-linux-arm64-gnu@2.1.0': optional: true - '@tauri-apps/cli-linux-arm64-musl@2.11.2': + '@tauri-apps/cli-linux-arm64-musl@2.1.0': optional: true - '@tauri-apps/cli-linux-riscv64-gnu@2.11.2': + '@tauri-apps/cli-linux-x64-gnu@2.1.0': optional: true - '@tauri-apps/cli-linux-x64-gnu@2.11.2': + '@tauri-apps/cli-linux-x64-musl@2.1.0': optional: true - '@tauri-apps/cli-linux-x64-musl@2.11.2': + '@tauri-apps/cli-win32-arm64-msvc@2.1.0': optional: true - '@tauri-apps/cli-win32-arm64-msvc@2.11.2': + '@tauri-apps/cli-win32-ia32-msvc@2.1.0': optional: true - '@tauri-apps/cli-win32-ia32-msvc@2.11.2': + '@tauri-apps/cli-win32-x64-msvc@2.1.0': optional: true - '@tauri-apps/cli-win32-x64-msvc@2.11.2': - optional: true - - '@tauri-apps/cli@2.11.2': + '@tauri-apps/cli@2.1.0': optionalDependencies: - '@tauri-apps/cli-darwin-arm64': 2.11.2 - '@tauri-apps/cli-darwin-x64': 2.11.2 - '@tauri-apps/cli-linux-arm-gnueabihf': 2.11.2 - '@tauri-apps/cli-linux-arm64-gnu': 2.11.2 - '@tauri-apps/cli-linux-arm64-musl': 2.11.2 - '@tauri-apps/cli-linux-riscv64-gnu': 2.11.2 - '@tauri-apps/cli-linux-x64-gnu': 2.11.2 - '@tauri-apps/cli-linux-x64-musl': 2.11.2 - '@tauri-apps/cli-win32-arm64-msvc': 2.11.2 - '@tauri-apps/cli-win32-ia32-msvc': 2.11.2 - '@tauri-apps/cli-win32-x64-msvc': 2.11.2 + '@tauri-apps/cli-darwin-arm64': 2.1.0 + '@tauri-apps/cli-darwin-x64': 2.1.0 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.1.0 + '@tauri-apps/cli-linux-arm64-gnu': 2.1.0 + '@tauri-apps/cli-linux-arm64-musl': 2.1.0 + '@tauri-apps/cli-linux-x64-gnu': 2.1.0 + '@tauri-apps/cli-linux-x64-musl': 2.1.0 + '@tauri-apps/cli-win32-arm64-msvc': 2.1.0 + '@tauri-apps/cli-win32-ia32-msvc': 2.1.0 + '@tauri-apps/cli-win32-x64-msvc': 2.1.0 + + '@tauri-apps/plugin-dialog@2.7.1': + dependencies: + '@tauri-apps/api': 2.11.0 + + '@tauri-apps/plugin-fs@2.5.1': + dependencies: + '@tauri-apps/api': 2.11.0 '@tauri-apps/plugin-http@2.5.9': dependencies: @@ -1171,6 +1239,10 @@ snapshots: dependencies: '@tauri-apps/api': 2.11.0 + '@tauri-apps/plugin-process@2.3.1': + dependencies: + '@tauri-apps/api': 2.11.0 + '@tauri-apps/plugin-shell@2.3.5': dependencies: '@tauri-apps/api': 2.11.0 @@ -1201,6 +1273,10 @@ snapshots: axobject-query@4.1.0: {} + capacitor-native-biometric@4.2.2: + dependencies: + '@capacitor/core': 3.9.0 + chokidar@4.0.3: dependencies: readdirp: 4.1.2 @@ -1464,8 +1540,7 @@ snapshots: totalist@3.0.1: {} - tslib@2.8.1: - optional: true + tslib@2.8.1: {} typescript@6.0.3: {} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 18a2d48..5008c40 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -4,6 +4,7 @@ "version": "0.9.4", "identifier": "io.github.MokuProject.Moku", "build": { + "devUrl": "http://localhost:1420", "frontendDist": "../dist", "beforeBuildCommand": "pnpm build" }, diff --git a/src-tauri/tauri.dev.conf.json b/src-tauri/tauri.dev.conf.json index b245eb4..d6c2f88 100644 --- a/src-tauri/tauri.dev.conf.json +++ b/src-tauri/tauri.dev.conf.json @@ -1,6 +1,5 @@ { "build": { - "devUrl": "http://localhost:1420", "beforeDevCommand": "pnpm dev" }, "app": { @@ -13,4 +12,4 @@ "bundle": { "externalBin": [] } -} +} \ No newline at end of file diff --git a/src/lib/platform-adapters/tauri/index.ts b/src/lib/platform-adapters/tauri/index.ts index 6389734..02d187a 100644 --- a/src/lib/platform-adapters/tauri/index.ts +++ b/src/lib/platform-adapters/tauri/index.ts @@ -4,8 +4,6 @@ import { open } from '@tauri-apps/plugin-dialog' import { readFile, writeFile } from '@tauri-apps/plugin-fs' import { open as openUrl } from '@tauri-apps/plugin-shell' import { getVersion } from '@tauri-apps/api/app' -import { check } from '@tauri-apps/plugin-updater' -import { relaunch } from '@tauri-apps/plugin-process' import type { PlatformAdapter, PlatformFeature, @@ -69,19 +67,20 @@ export class TauriAdapter implements PlatformAdapter { } async setTitle(title: string) { - await invoke('set_window_title', { title }) + await getCurrentWindow().setTitle(title) } async minimize() { - await invoke('minimize_window') + await getCurrentWindow().minimize() } async maximize() { - await invoke('maximize_window') + const win = getCurrentWindow() + await (await win.isMaximized() ? win.unmaximize() : win.maximize()) } async close() { - await invoke('close_window') + await getCurrentWindow().close() } async toggleFullscreen() { @@ -106,20 +105,23 @@ export class TauriAdapter implements PlatformAdapter { } async checkForAppUpdate(): Promise { - const update = await check() - if (!update?.available) return null - return { - version: update.version, - url: update.body ?? '', - notes: update.body, - } + const releases = await invoke>('list_releases') + const current = await getVersion() + const valid = releases.filter(r => r.tag_name?.trim()) + if (!valid.length) return null + const parse = (v: string) => v.replace(/^v/, '').split('.').map(Number) + const latest = valid.map(r => r.tag_name).sort((a, b) => { + const pa = parse(a), pb = parse(b) + for (let i = 0; i < 3; i++) if ((pb[i] ?? 0) !== (pa[i] ?? 0)) return (pb[i] ?? 0) - (pa[i] ?? 0) + return 0 + })[0] + const pa = parse(latest), pb = parse(current) + if (!pa.some((n, i) => n > (pb[i] ?? 0))) return null + const rel = valid.find(r => r.tag_name === latest)! + return { version: latest.replace(/^v/, ''), url: rel.html_url, notes: rel.body } } - async installAppUpdate() { - const update = await check() - if (update?.available) { - await update.downloadAndInstall() - await relaunch() - } + async installAppUpdate(tag: string) { + await invoke('download_and_install_update', { tag }) } } \ No newline at end of file diff --git a/src/lib/server-adapters/suwayomi/index.ts b/src/lib/server-adapters/suwayomi/index.ts index 4e7b630..9d11359 100644 --- a/src/lib/server-adapters/suwayomi/index.ts +++ b/src/lib/server-adapters/suwayomi/index.ts @@ -86,7 +86,7 @@ import { mapDownloadItem, mapCategory, } from './types' -import { clearPageCache as _clearPageCache } from './pageCache' +import { initPageCache, clearPageCache as _clearPageCache } from './pageCache' const SET_SOCKS_PROXY = ` mutation SetSocksProxy( @@ -142,6 +142,7 @@ export class SuwayomiAdapter implements ServerAdapter { const { username, password } = config.credentials this.authHeader = 'Basic ' + btoa(`${username}:${password}`) } + initPageCache(this.gql.bind(this), this.getServerUrl.bind(this)) } getServerUrl(): string { diff --git a/src/lib/server-adapters/suwayomi/pageCache.ts b/src/lib/server-adapters/suwayomi/pageCache.ts index 50564a4..023c2c9 100644 --- a/src/lib/server-adapters/suwayomi/pageCache.ts +++ b/src/lib/server-adapters/suwayomi/pageCache.ts @@ -1,7 +1,16 @@ -import { gql, getServerUrl } from "$lib/server-adapters/suwayomi"; -import { getBlobUrl, preloadBlobUrls } from "$lib/core/cache/imageCache"; -import { dedupeRequest } from "$lib/core/async/batchRequests"; -import { FETCH_CHAPTER_PAGES } from "$lib/server-adapters/suwayomi/chapters"; +import { getBlobUrl, preloadBlobUrls } from "$lib/core/cache/imageCache"; +import { dedupeRequest } from "$lib/core/async/batchRequests"; +import { FETCH_CHAPTER_PAGES } from "$lib/server-adapters/suwayomi/chapters"; + +type GqlFn = (query: string, vars?: Record, signal?: AbortSignal) => Promise; + +let _gql: GqlFn; +let _getServerUrl: () => string; + +export function initPageCache(gql: GqlFn, getServerUrl: () => string): void { + _gql = gql; + _getServerUrl = getServerUrl; +} const pageCache = new Map(); const inflight = new Map>(); @@ -32,9 +41,9 @@ export function fetchPages( if (!inflight.has(chapterId)) { const p = dedupeRequest(`chapter-pages:${chapterId}`, () => - gql<{ fetchChapterPages: { pages: string[] } }>(FETCH_CHAPTER_PAGES, { chapterId }) + _gql<{ fetchChapterPages: { pages: string[] } }>(FETCH_CHAPTER_PAGES, { chapterId }) .then(d => { - const urls = d.fetchChapterPages.pages.map(p => p.startsWith("http") ? p : `${getServerUrl()}${p}`); + const urls = d.fetchChapterPages.pages.map(p => p.startsWith("http") ? p : `${_getServerUrl()}${p}`); if (useBlob && urls[priorityPage]) getBlobUrl(urls[priorityPage], 999); pageCache.set(chapterId, urls); return urls; diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 784e857..2422f15 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1,2 +1,2 @@ export const ssr = false -export const prerender = true +export const prerender = false \ No newline at end of file diff --git a/static/favicon.svg b/static/favicon.svg new file mode 100644 index 0000000..f522609 --- /dev/null +++ b/static/favicon.svg @@ -0,0 +1,22 @@ + + + + + + diff --git a/vite.config.ts b/vite.config.ts index ebcb9c2..7fc9bec 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,5 +19,13 @@ export default defineConfig({ target: ['es2021', 'chrome100', 'safari13'], minify: !process.env.TAURI_DEBUG ? 'oxc' : false, sourcemap: !!process.env.TAURI_DEBUG, + rollupOptions: { + external: [ + '@capacitor/filesystem', + '@capacitor/app', + '@capacitor/browser', + 'capacitor-native-biometric', + ], + }, }, }) \ No newline at end of file