mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-22 15:40:07 -04:00
* custom updater with toasts * new state management + updated router route * tauri-specific update route * ref * update in prod only * change 'Install' to 'Update' * fix tsconfig * desktop tauri * remove tauri patch * tauri 1.5 * tauri 1.5 * use tauri script * native-deps * Rework preprep and tauri script to better support tauri 1.5 * Update to tauri 1.5.1 - Update workspace and apps/desktop dependencies - Fix mustache import, @types/mustache is not compatible with ES imports - Replace arm64 with aarch64 in machineID, they should be treated the same and this simplyfies the code * Fix tauri updater not building due to missing key - Fix dmg background not being found - Generate an adhoc key for tauri updater with it is enabled and the user is doing a prod build * Fix ctrl+c/ctrl+v typo * Normalie @tanstack/react-query version through workspace - Use undici in scripts instead of global fetch - Fix typecheck * Fix linux prod and dev builds - Improve error handling in tauri.mjs * Normalize dev deps in workspace - Improve linux shared libs setup * Fix CI and server docker * Fix windows - Remove superfluous envvar * Attempt to fix server, mobile, deb and release updater * Attempt to fix deb and mobile again - Fix type on deb dependency - Enable release deb for aarch64-unknown-linux-gnu * Github doesn't have arm runners - Fix typo in server Dockerfile * Publish deb and updater artifacts * remove version from asset name * update commands * log release * Some logs on updater errors * show updater errors on frontend * fix desktop ui caching --------- Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Co-authored-by: Ericson Fogo Soares <ericson.ds999@gmail.com>
79 lines
2.9 KiB
TypeScript
79 lines
2.9 KiB
TypeScript
import { createContext, useContext, type PropsWithChildren } from 'react';
|
|
import { auth } from '@sd/client';
|
|
|
|
export type OperatingSystem = 'browser' | 'linux' | 'macOS' | 'windows' | 'unknown';
|
|
|
|
// Platform represents the underlying native layer the app is running on.
|
|
// This could be Tauri or web.
|
|
export type Platform = {
|
|
platform: 'web' | 'tauri'; // This represents the specific platform implementation
|
|
getThumbnailUrlByThumbKey: (thumbKey: string[]) => string;
|
|
getFileUrl: (libraryId: string, locationLocalId: number, filePathId: number) => string;
|
|
getFileUrlByPath: (path: string) => string;
|
|
openLink: (url: string) => void;
|
|
// Tauri patches `window.confirm` to return `Promise` not `bool`
|
|
confirm(msg: string, cb: (result: boolean) => void): void;
|
|
getOs?(): Promise<OperatingSystem>;
|
|
openDirectoryPickerDialog?(): Promise<null | string | string[]>;
|
|
openFilePickerDialog?(): Promise<null | string | string[]>;
|
|
saveFilePickerDialog?(opts?: { title?: string; defaultPath?: string }): Promise<string | null>;
|
|
showDevtools?(): void;
|
|
openPath?(path: string): void;
|
|
openLogsDir?(): void;
|
|
userHomeDir?(): Promise<string>;
|
|
// Opens a file path with a given ID
|
|
openFilePaths?(library: string, ids: number[]): any;
|
|
openEphemeralFiles?(paths: string[]): any;
|
|
revealItems?(
|
|
library: string,
|
|
items: (
|
|
| { Location: { id: number } }
|
|
| { FilePath: { id: number } }
|
|
| { Ephemeral: { path: string } }
|
|
)[]
|
|
): Promise<unknown>;
|
|
getFilePathOpenWithApps?(library: string, ids: number[]): Promise<unknown>;
|
|
getEphemeralFilesOpenWithApps?(paths: string[]): Promise<unknown>;
|
|
openFilePathWith?(library: string, fileIdsAndAppUrls: [number, string][]): Promise<unknown>;
|
|
openEphemeralFileWith?(pathsAndUrls: [string, string][]): Promise<unknown>;
|
|
lockAppTheme?(themeType: 'Auto' | 'Light' | 'Dark'): any;
|
|
updater?: {
|
|
useSnapshot: () => UpdateStore;
|
|
checkForUpdate(): Promise<Update | null>;
|
|
installUpdate(): Promise<any>;
|
|
};
|
|
auth: auth.ProviderConfig;
|
|
};
|
|
|
|
export type Update = { version: string; body: string | null };
|
|
export type UpdateStore =
|
|
| { status: 'idle' }
|
|
| { status: 'loading' }
|
|
| { status: 'error' }
|
|
| { status: 'updateAvailable'; update: Update }
|
|
| { status: 'noUpdateAvailable' }
|
|
| { status: 'installing' };
|
|
|
|
// Keep this private and use through helpers below
|
|
const context = createContext<Platform>(undefined!);
|
|
|
|
// is a hook which allows you to fetch information about the current platform from the React context.
|
|
export function usePlatform(): Platform {
|
|
const ctx = useContext(context);
|
|
if (!ctx)
|
|
throw new Error(
|
|
"The 'PlatformProvider' has not been mounted above the current 'usePlatform' call."
|
|
);
|
|
|
|
return ctx;
|
|
}
|
|
|
|
// provides the platform context to the rest of the app through React context.
|
|
// Mount it near the top of your component tree.
|
|
export function PlatformProvider({
|
|
platform,
|
|
children
|
|
}: PropsWithChildren<{ platform: Platform }>) {
|
|
return <context.Provider value={platform}>{children}</context.Provider>;
|
|
}
|