Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/desktop/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import { createFileRoute } from '@tanstack/react-router'

import { Route as rootRouteImport } from './routes/__root'
import { Route as NotificationRouteImport } from './routes/notification'
import { Route as AppRouteRouteImport } from './routes/app/route'
import { Route as AppDevtoolRouteImport } from './routes/app/devtool'
import { Route as AppOnboardingIndexRouteImport } from './routes/app/onboarding/index'
Expand All @@ -22,6 +23,11 @@ import { Route as AppMainLayoutIndexRouteImport } from './routes/app/main/_layou
const AppSettingsRouteImport = createFileRoute('/app/settings')()
const AppMainRouteImport = createFileRoute('/app/main')()

const NotificationRoute = NotificationRouteImport.update({
id: '/notification',
path: '/notification',
getParentRoute: () => rootRouteImport,
} as any)
const AppRouteRoute = AppRouteRouteImport.update({
id: '/app',
path: '/app',
Expand Down Expand Up @@ -68,6 +74,7 @@ const AppMainLayoutIndexRoute = AppMainLayoutIndexRouteImport.update({

export interface FileRoutesByFullPath {
'/app': typeof AppRouteRouteWithChildren
'/notification': typeof NotificationRoute
'/app/devtool': typeof AppDevtoolRoute
'/app/main': typeof AppMainLayoutRouteWithChildren
'/app/settings': typeof AppSettingsLayoutRouteWithChildren
Expand All @@ -77,6 +84,7 @@ export interface FileRoutesByFullPath {
}
export interface FileRoutesByTo {
'/app': typeof AppRouteRouteWithChildren
'/notification': typeof NotificationRoute
'/app/devtool': typeof AppDevtoolRoute
'/app/main': typeof AppMainLayoutIndexRoute
'/app/settings': typeof AppSettingsLayoutIndexRoute
Expand All @@ -85,6 +93,7 @@ export interface FileRoutesByTo {
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/app': typeof AppRouteRouteWithChildren
'/notification': typeof NotificationRoute
'/app/devtool': typeof AppDevtoolRoute
'/app/main': typeof AppMainRouteWithChildren
'/app/main/_layout': typeof AppMainLayoutRouteWithChildren
Expand All @@ -98,6 +107,7 @@ export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths:
| '/app'
| '/notification'
| '/app/devtool'
| '/app/main'
| '/app/settings'
Expand All @@ -107,13 +117,15 @@ export interface FileRouteTypes {
fileRoutesByTo: FileRoutesByTo
to:
| '/app'
| '/notification'
| '/app/devtool'
| '/app/main'
| '/app/settings'
| '/app/onboarding'
id:
| '__root__'
| '/app'
| '/notification'
| '/app/devtool'
| '/app/main'
| '/app/main/_layout'
Expand All @@ -126,10 +138,18 @@ export interface FileRouteTypes {
}
export interface RootRouteChildren {
AppRouteRoute: typeof AppRouteRouteWithChildren
NotificationRoute: typeof NotificationRoute
}

declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/notification': {
id: '/notification'
path: '/notification'
fullPath: '/notification'
preLoaderRoute: typeof NotificationRouteImport
parentRoute: typeof rootRouteImport
}
'/app': {
id: '/app'
path: '/app'
Expand Down Expand Up @@ -262,6 +282,7 @@ const AppRouteRouteWithChildren = AppRouteRoute._addFileChildren(

const rootRouteChildren: RootRouteChildren = {
AppRouteRoute: AppRouteRouteWithChildren,
NotificationRoute: NotificationRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import {
createRootRouteWithContext,
type LinkProps,
Outlet,
useNavigate,
} from "@tanstack/react-router";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { lazy, useEffect } from "react";

import type { DeepLink } from "@hypr/plugin-deeplink2";
import { events as windowsEvents } from "@hypr/plugin-windows";

import { AuthProvider } from "../auth";
import { BillingProvider } from "../billing";
import { ErrorComponent, NotFoundComponent } from "../components/control";
import type { Context } from "../types";

0 as DeepLink["to"] extends NonNullable<LinkProps["to"]>
? 0
: "DeepLink['to'] must match a valid route";

export const Route = createRootRouteWithContext<Partial<Context>>()({
component: Component,
errorComponent: ErrorComponent,
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop/src/routes/notification.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createFileRoute, redirect } from "@tanstack/react-router";

export const Route = createFileRoute("/notification")({
beforeLoad: async () => {
throw redirect({ to: "/app/main" });
},
});
2 changes: 1 addition & 1 deletion plugins/deeplink2/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const COMMANDS: &[&str] = &["ping", "get_available_deep_links"];
const COMMANDS: &[&str] = &[];

fn main() {
tauri_plugin::Builder::new(COMMANDS).build();
Expand Down
23 changes: 4 additions & 19 deletions plugins/deeplink2/js/bindings.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,7 @@


export const commands = {
async ping() : Promise<Result<string, string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("plugin:deeplink2|ping") };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
},
async getAvailableDeepLinks() : Promise<Result<DeepLinkInfo[], string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("plugin:deeplink2|get_available_deep_links") };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
}

}

/** user-defined events **/
Expand All @@ -40,10 +25,10 @@ deepLinkEvent: "plugin:deeplink2:deep-link-event"

/** user-defined types **/

export type AuthDeepLink = { action: "Callback"; access_token: string; refresh_token: string }
export type DeepLink = { type: "Auth"; data: AuthDeepLink } | { type: "Unknown"; data: { url: string } }
export type DeepLink = { to: "/app/onboarding"; search: OnboardingSearch }
export type DeepLinkEvent = DeepLink
export type DeepLinkInfo = { name: string; description: string; example: string }
export type OnboardingSearch = { step: OnboardingStep; local?: boolean }
export type OnboardingStep = "welcome" | "permissions"

/** tauri-specta globals **/

Expand Down
15 changes: 0 additions & 15 deletions plugins/deeplink2/src/commands.rs

This file was deleted.

2 changes: 2 additions & 0 deletions plugins/deeplink2/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub enum Error {
UnknownPath(String),
#[error("url parse error: {0}")]
UrlParse(#[from] url::ParseError),
#[error("missing query parameter: {0}")]
MissingQueryParam(String),
}

impl Serialize for Error {
Expand Down
16 changes: 0 additions & 16 deletions plugins/deeplink2/src/ext.rs

This file was deleted.

17 changes: 3 additions & 14 deletions plugins/deeplink2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
mod commands;
mod error;
mod ext;
mod types;

pub use error::{Error, Result};
pub use ext::*;
pub use types::*;

const PLUGIN_NAME: &str = "deeplink2";

fn make_specta_builder<R: tauri::Runtime>() -> tauri_specta::Builder<R> {
tauri_specta::Builder::<R>::new()
.plugin_name(PLUGIN_NAME)
.commands(tauri_specta::collect_commands![
commands::ping::<tauri::Wry>,
commands::get_available_deep_links::<tauri::Wry>,
])
.events(tauri_specta::collect_events![events::DeepLinkEvent])
.commands(tauri_specta::collect_commands![])
.events(tauri_specta::collect_events![types::DeepLinkEvent])
.typ::<types::DeepLink>()
.error_handling(tauri_specta::ErrorHandlingMode::Result)
}

Expand All @@ -29,11 +23,6 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
.build()
}

pub mod events {
#[derive(Debug, Clone, serde::Serialize, specta::Type, tauri_specta::Event)]
pub struct DeepLinkEvent(pub crate::DeepLink);
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
107 changes: 0 additions & 107 deletions plugins/deeplink2/src/types.rs

This file was deleted.

Loading
Loading