Skip to content

Commit

Permalink
add right identifier back
Browse files Browse the repository at this point in the history
  • Loading branch information
atilafassina committed Jun 4, 2024
1 parent 399e791 commit 398762a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
16 changes: 12 additions & 4 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use error::Error;
use futures::future::try_join_all;
use specta;
use std::path::Path;
use tauri_plugin_devtools;
use util::FolderStat;

#[cfg(debug_assertions)]
use tauri_plugin_devtools;

#[tauri::command]
#[specta::specta]
async fn get_dir_data(pattern: &str) -> Result<Vec<FolderStat>, Error> {
Expand All @@ -24,18 +26,24 @@ async fn get_dir_data(pattern: &str) -> Result<Vec<FolderStat>, Error> {
}

pub fn run() {
#[cfg(debug_assertions)]
let mut builder = tauri::Builder::default()
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init());

#[cfg(not(debug_assertions))]
let mut builder = tauri::Builder::default()
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init());

let invoke_handler = {
let builder =
let tauri_specta_builder =
tauri_specta::ts::builder().commands(tauri_specta::collect_commands![get_dir_data]);

#[cfg(debug_assertions)]
let builder = builder.path("../src/commands.ts");
let tauri_specta_builder = builder.path("../src/commands.ts");

builder.build().unwrap()
tauri_specta_builder.build().unwrap()
};

#[cfg(debug_assertions)]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"productName": "pulsar",
"version": "0.1.0",
"identifier": "com.tauri.dev",
"identifier": "pulsar.atila.io",
"build": {
"beforeDevCommand": "pnpm dev",
"beforeBuildCommand": "pnpm build",
Expand Down
44 changes: 24 additions & 20 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.

/** user-defined commands **/
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.

export const commands = {
async getDirData(pattern: string): Promise<Result<FolderStat[], Error>> {
try {
return {
status: "ok",
data: await TAURI_INVOKE("get_dir_data", { pattern }),
};
} catch (e) {
if (e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
},
};
/** user-defined commands **/

/** user-defined events **/
export const commands = {
async getDirData(pattern: string) : Promise<Result<FolderStat[], Error>> {
try {
return { status: "ok", data: await TAURI_INVOKE("get_dir_data", { pattern }) };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
}
}

/** user-defined statics **/
/** user-defined events **/



/** user-defined statics **/



/** user-defined types **/

export type Error = { type: "TooLarge" };
export type FolderStat = { path: string; size: number };
export type Error = { type: "TooLarge" }
export type FolderStat = { path: string; size: number }

/** tauri-specta globals **/

import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core";
import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core";
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";

Expand Down Expand Up @@ -81,3 +83,5 @@ function __makeEvents__<T extends Record<string, any>>(
}
);
}


0 comments on commit 398762a

Please sign in to comment.