diff --git a/.changeset/sixty-mice-double.md b/.changeset/sixty-mice-double.md new file mode 100644 index 000000000..27943e21e --- /dev/null +++ b/.changeset/sixty-mice-double.md @@ -0,0 +1,5 @@ +--- +"create-farm": patch +--- + +Add support for tauri v2 diff --git a/crates/create-farm-rs/src/lib.rs b/crates/create-farm-rs/src/lib.rs index 6a21aa707..582b4d392 100644 --- a/crates/create-farm-rs/src/lib.rs +++ b/crates/create-farm-rs/src/lib.rs @@ -124,6 +124,21 @@ where Template::Tauri(Some(*sub_template)) } + Template::Tauri2(None) => { + let sub_templates = vec![ + TauriSubTemplate::React, + TauriSubTemplate::Vue, + TauriSubTemplate::Svelte, + TauriSubTemplate::Vanilla, + TauriSubTemplate::Solid, + TauriSubTemplate::Preact, + ]; + + let sub_template = + prompts::select("Select a Tauri2 template:", &sub_templates, Some(0))?.unwrap(); + + Template::Tauri2(Some(*sub_template)) + } Template::Electron(None) => { let sub_templates = vec![ ElectronSubTemplate::React, @@ -162,7 +177,7 @@ where } clean_dir(&target_dir)?; } else { - let _ = fs::create_dir_all(&target_dir); + fs::create_dir_all(&target_dir)?; } // Render the template diff --git a/crates/create-farm-rs/src/package_manager.rs b/crates/create-farm-rs/src/package_manager.rs index 7ce509950..9700fc264 100644 --- a/crates/create-farm-rs/src/package_manager.rs +++ b/crates/create-farm-rs/src/package_manager.rs @@ -71,6 +71,7 @@ impl PackageManager { Template::Lit, Template::Preact, Template::Nestjs, + Template::Tauri2(None), Template::Tauri(None), Template::Electron(None) ], diff --git a/crates/create-farm-rs/src/template.rs b/crates/create-farm-rs/src/template.rs index d1b17856b..1b5c6af6b 100644 --- a/crates/create-farm-rs/src/template.rs +++ b/crates/create-farm-rs/src/template.rs @@ -153,6 +153,7 @@ pub enum Template { Solid, Preact, Nestjs, + Tauri2(Option), Tauri(Option), Electron(Option), } @@ -175,6 +176,8 @@ impl Display for Template { Template::Solid => write!(f, "solid"), Template::Preact => write!(f, "preact"), Template::Nestjs => write!(f, "nestjs"), + Template::Tauri2(None) => write!(f, "tauri2"), + Template::Tauri2(Some(sub_template)) => write!(f, "tauri2-{sub_template}"), Template::Tauri(None) => write!(f, "tauri"), Template::Tauri(Some(sub_template)) => write!(f, "tauri-{sub_template}"), Template::Electron(None) => write!(f, "electron"), @@ -197,6 +200,7 @@ impl FromStr for Template { "solid" => Ok(Template::Solid), "preact" => Ok(Template::Preact), "nestjs" => Ok(Template::Nestjs), + "tauri2" => Ok(Template::Tauri2(None)), "tauri" => Ok(Template::Tauri(None)), "electron" => Ok(Template::Electron(None)), _ => Err(format!( @@ -222,7 +226,16 @@ impl Displayable for Template { Template::Svelte => "\x1b[38;2;255;137;54mSvelte - (https://svelte.dev/)\x1b[0m", Template::Lit => "\x1b[33mLit - (https://lit.dev/)\x1b[0m", Template::Preact => "\x1b[36mPreact - (https://preactjs.com/)\x1b[0m", + Template::Tauri2(None) => "\x1b[38;2;255;137;54mTauri2 - (https://tauri.app/)\x1b[0m", Template::Tauri(None) => "\x1b[38;2;255;137;54mTauri - (https://tauri.app/)\x1b[0m", + Template::Tauri2(Some(sub_template)) => match sub_template { + TauriSubTemplate::React => "\x1b[38;2;255;215;0mTauri2 with React\x1b[0m", + TauriSubTemplate::Vue => "\x1b[38;2;255;215;0mTauri2 with Vue\x1b[0m", + TauriSubTemplate::Vanilla => "\x1b[38;2;255;215;0mTauri2 with Vanilla\x1b[0m", + TauriSubTemplate::Svelte => "\x1b[38;2;255;215;0mTauri2 with Svelte\x1b[0m", + TauriSubTemplate::Solid => "\x1b[38;2;255;215;0mTauri2 with Solid\x1b[0m", + TauriSubTemplate::Preact => "\x1b[38;2;255;215;0mTauri2 with Preact\x1b[0m", + }, Template::Tauri(Some(sub_template)) => match sub_template { TauriSubTemplate::React => "\x1b[38;2;255;215;0mTauri with React\x1b[0m", TauriSubTemplate::Vue => "\x1b[38;2;255;215;0mTauri with Vue\x1b[0m", @@ -258,6 +271,7 @@ impl<'a> Template { Template::Solid, Template::Preact, Template::Nestjs, + Template::Tauri2(None), Template::Tauri(None), Template::Electron(None), ]; @@ -357,6 +371,8 @@ impl<'a> Template { }; let current_template_name = match self { + Template::Tauri2(None) => "tauri2".to_string(), + Template::Tauri2(Some(sub_template)) => format!("tauri2/{}", sub_template.to_simple_string()), Template::Tauri(None) => "tauri".to_string(), Template::Tauri(Some(sub_template)) => format!("tauri/{}", sub_template.to_simple_string()), Template::Electron(None) => "electron".to_string(), diff --git a/crates/create-farm-rs/templates/tauri2/preact/.vscode/extensions.json b/crates/create-farm-rs/templates/tauri2/preact/.vscode/extensions.json new file mode 100644 index 000000000..24d7cc6de --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/README.md b/crates/create-farm-rs/templates/tauri2/preact/README.md new file mode 100644 index 000000000..90f8c56a8 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/README.md @@ -0,0 +1,7 @@ +# Tauri + Preact + Typescript + +This template should help get you started developing with Tauri, Preact and Typescript in Vite. + +## Recommended IDE Setup + +- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/crates/create-farm-rs/templates/tauri2/preact/farm.config.ts b/crates/create-farm-rs/templates/tauri2/preact/farm.config.ts new file mode 100644 index 000000000..49101096d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/farm.config.ts @@ -0,0 +1,27 @@ +import { defineConfig } from "@farmfe/core"; +import preact from '@preact/preset-vite'; + +// @ts-ignore process is a nodejs global +const host = process.env.TAURI_DEV_HOST; + +// https://www.farmfe.org/docs/config/configuring-farm +export default defineConfig({ + plugins: [preact()], + + clearScreen: false, + server: { + port: 1420, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421, + watchOptions: { + ignored: ["**/node_modules/**"], + } + } + : undefined, + }, +}); diff --git a/crates/create-farm-rs/templates/tauri2/preact/gitignore b/crates/create-farm-rs/templates/tauri2/preact/gitignore new file mode 100644 index 000000000..a547bf36d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/crates/create-farm-rs/templates/tauri2/preact/index.html b/crates/create-farm-rs/templates/tauri2/preact/index.html new file mode 100644 index 000000000..753595a61 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/index.html @@ -0,0 +1,14 @@ + + + + + + + Tauri + Preact + Typescript + + + +
+ + + diff --git a/crates/create-farm-rs/templates/tauri2/preact/package.json b/crates/create-farm-rs/templates/tauri2/preact/package.json new file mode 100644 index 000000000..72703f404 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/package.json @@ -0,0 +1,25 @@ +{ + "name": "", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "farm", + "build": "tsc && farm build", + "preview": "farm preview", + "tauri": "tauri" + }, + "dependencies": { + "preact": "^10.25.1", + "@tauri-apps/api": "^2", + "@tauri-apps/plugin-opener": "^2" + }, + "devDependencies": { + "@farmfe/cli": "^1.0.4", + "@farmfe/core": "^1.6.3", + "@preact/preset-vite": "^2.9.3", + "core-js": "^3.39.0", + "typescript": "^5.6.2", + "@tauri-apps/cli": "^2" + } +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/public/farm.png b/crates/create-farm-rs/templates/tauri2/preact/public/farm.png new file mode 100644 index 000000000..0caeb4381 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/public/farm.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/public/favicon.ico b/crates/create-farm-rs/templates/tauri2/preact/public/favicon.ico new file mode 100644 index 000000000..80465dedc Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/public/favicon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/public/tauri.svg b/crates/create-farm-rs/templates/tauri2/preact/public/tauri.svg new file mode 100644 index 000000000..31b62c928 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/public/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/Cargo.toml b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/Cargo.toml new file mode 100644 index 000000000..39f75dd71 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-opener = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/build.rs b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/build.rs new file mode 100644 index 000000000..d860e1e6a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/capabilities/default.json b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/capabilities/default.json new file mode 100644 index 000000000..4cdbf49a7 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "opener:default" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/gitignore b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/gitignore new file mode 100644 index 000000000..b21bd681d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/128x128.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/128x128.png new file mode 100644 index 000000000..6be5e50e9 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/128x128.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/128x128@2x.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/128x128@2x.png new file mode 100644 index 000000000..e81becee5 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/128x128@2x.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/32x32.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/32x32.png new file mode 100644 index 000000000..a437dd517 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/32x32.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square107x107Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 000000000..0ca4f2719 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square107x107Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square142x142Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 000000000..b81f82039 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square142x142Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square150x150Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 000000000..624c7bfba Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square150x150Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square284x284Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 000000000..c021d2ba7 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square284x284Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square30x30Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 000000000..621970023 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square30x30Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square310x310Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 000000000..f9bc04839 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square310x310Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square44x44Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 000000000..d5fbfb2ab Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square44x44Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square71x71Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 000000000..63440d798 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square71x71Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square89x89Logo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 000000000..f3f705af2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/Square89x89Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/StoreLogo.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/StoreLogo.png new file mode 100644 index 000000000..455638826 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/StoreLogo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.icns b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.icns new file mode 100644 index 000000000..12a5bcee2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.icns differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.ico b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.ico new file mode 100644 index 000000000..b3636e4b2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.png b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.png new file mode 100644 index 000000000..e1cd2619e Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/icons/icon.png differ diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/src/lib.rs b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/src/lib.rs new file mode 100644 index 000000000..4a277ef35 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/src/main.rs b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/src/main.rs new file mode 100644 index 000000000..9259f6c80 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + preact_lib::run() +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/src-tauri/tauri.conf.json b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/tauri.conf.json new file mode 100644 index 000000000..307bb5e56 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src-tauri/tauri.conf.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "", + "version": "0.1.0", + "identifier": "com.tauri.dev", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/src/App.css b/crates/create-farm-rs/templates/tauri2/preact/src/App.css new file mode 100644 index 000000000..e04987e17 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src/App.css @@ -0,0 +1,117 @@ +.logo.farm:hover { + filter: drop-shadow(0 0 2em #ff7474); +} + +.logo.preact:hover { + filter: drop-shadow(0 0 2em #673ab8); +} + +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/src/App.tsx b/crates/create-farm-rs/templates/tauri2/preact/src/App.tsx new file mode 100644 index 000000000..3bb931635 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src/App.tsx @@ -0,0 +1,51 @@ +import { useState } from "preact/hooks"; +import preactLogo from "./assets/preact.svg"; +import { invoke } from "@tauri-apps/api/core"; +import "./App.css"; + +function App() { + const [greetMsg, setGreetMsg] = useState(""); + const [name, setName] = useState(""); + + async function greet() { + // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ + setGreetMsg(await invoke("greet", { name })); + } + + return ( +
+

Welcome to Tauri + Preact

+ + +

Click on the Tauri, Farm, and Preact logos to learn more.

+ +
{ + e.preventDefault(); + greet(); + }} + > + setName(e.currentTarget.value)} + placeholder="Enter a name..." + /> + +
+

{greetMsg}

+
+ ); +} + +export default App; diff --git a/crates/create-farm-rs/templates/tauri2/preact/src/assets/preact.svg b/crates/create-farm-rs/templates/tauri2/preact/src/assets/preact.svg new file mode 100644 index 000000000..2d23db7ee --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src/assets/preact.svg @@ -0,0 +1 @@ + diff --git a/crates/create-farm-rs/templates/tauri2/preact/src/main.tsx b/crates/create-farm-rs/templates/tauri2/preact/src/main.tsx new file mode 100644 index 000000000..a4eaf2a26 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/src/main.tsx @@ -0,0 +1,4 @@ +import { render } from "preact"; +import App from "./App"; + +render(, document.getElementById("root")!); diff --git a/crates/create-farm-rs/templates/tauri2/preact/tsconfig.json b/crates/create-farm-rs/templates/tauri2/preact/tsconfig.json new file mode 100644 index 000000000..21abced1d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "jsxImportSource": "preact", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/crates/create-farm-rs/templates/tauri2/preact/tsconfig.node.json b/crates/create-farm-rs/templates/tauri2/preact/tsconfig.node.json new file mode 100644 index 000000000..54e79e3d0 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/preact/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["farm.config.ts"] +} diff --git a/crates/create-farm-rs/templates/tauri2/react/.gitignore b/crates/create-farm-rs/templates/tauri2/react/.gitignore new file mode 100644 index 000000000..a547bf36d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/crates/create-farm-rs/templates/tauri2/react/.vscode/extensions.json b/crates/create-farm-rs/templates/tauri2/react/.vscode/extensions.json new file mode 100644 index 000000000..24d7cc6de --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] +} diff --git a/crates/create-farm-rs/templates/tauri2/react/README.md b/crates/create-farm-rs/templates/tauri2/react/README.md new file mode 100644 index 000000000..102e36689 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/README.md @@ -0,0 +1,7 @@ +# Tauri + React + Typescript + +This template should help get you started developing with Tauri, React and Typescript in Vite. + +## Recommended IDE Setup + +- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/crates/create-farm-rs/templates/tauri2/react/farm.config.ts b/crates/create-farm-rs/templates/tauri2/react/farm.config.ts new file mode 100644 index 000000000..dafd47175 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/farm.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from "@farmfe/core"; + +// @ts-ignore process is a nodejs global +const host = process.env.TAURI_DEV_HOST; + +// https://www.farmfe.org/docs/config/configuring-farm +export default defineConfig({ + plugins: ['@farmfe/plugin-react'], + + clearScreen: false, + server: { + port: 1420, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421, + watchOptions: { + ignored: ["**/node_modules/**"], + } + } + : undefined, + }, +}); diff --git a/crates/create-farm-rs/templates/tauri2/react/index.html b/crates/create-farm-rs/templates/tauri2/react/index.html new file mode 100644 index 000000000..aedcd3c09 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/index.html @@ -0,0 +1,14 @@ + + + + + + + Tauri + React + Typescript + + + +
+ + + diff --git a/crates/create-farm-rs/templates/tauri2/react/package.json b/crates/create-farm-rs/templates/tauri2/react/package.json new file mode 100644 index 000000000..f39a1b82b --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/package.json @@ -0,0 +1,28 @@ +{ + "name": "", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "farm", + "build": "tsc && farm build", + "preview": "farm preview", + "tauri": "tauri" + }, + "dependencies": { + "@tauri-apps/api": "^2.1.1", + "@tauri-apps/plugin-shell": "^2.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1" + }, + "devDependencies": { + "@farmfe/cli": "^1.0.4", + "@farmfe/core": "^1.6.2", + "@farmfe/plugin-react": "^1.2.6", + "@tauri-apps/cli": "^2.1.0", + "@types/react": "^18.3.18", + "@types/react-dom": "^18.3.5", + "core-js": "^3.39.0", + "typescript": "^5.7.2" + } +} diff --git a/crates/create-farm-rs/templates/tauri2/react/public/farm.png b/crates/create-farm-rs/templates/tauri2/react/public/farm.png new file mode 100644 index 000000000..0caeb4381 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/public/farm.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/public/favicon.ico b/crates/create-farm-rs/templates/tauri2/react/public/favicon.ico new file mode 100644 index 000000000..80465dedc Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/public/favicon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/react/public/tauri.svg b/crates/create-farm-rs/templates/tauri2/react/public/tauri.svg new file mode 100644 index 000000000..31b62c928 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/public/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/Cargo.toml b/crates/create-farm-rs/templates/tauri2/react/src-tauri/Cargo.toml new file mode 100644 index 000000000..eae9d26ce --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src-tauri/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-shell = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/build.rs b/crates/create-farm-rs/templates/tauri2/react/src-tauri/build.rs new file mode 100644 index 000000000..d860e1e6a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/capabilities/default.json b/crates/create-farm-rs/templates/tauri2/react/src-tauri/capabilities/default.json new file mode 100644 index 000000000..3bb4cc497 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "shell:allow-open" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/gitignore b/crates/create-farm-rs/templates/tauri2/react/src-tauri/gitignore new file mode 100644 index 000000000..b21bd681d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src-tauri/gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/128x128.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/128x128.png new file mode 100644 index 000000000..6be5e50e9 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/128x128.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/128x128@2x.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/128x128@2x.png new file mode 100644 index 000000000..e81becee5 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/128x128@2x.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/32x32.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/32x32.png new file mode 100644 index 000000000..a437dd517 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/32x32.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square107x107Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 000000000..0ca4f2719 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square107x107Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square142x142Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 000000000..b81f82039 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square142x142Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square150x150Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 000000000..624c7bfba Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square150x150Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square284x284Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 000000000..c021d2ba7 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square284x284Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square30x30Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 000000000..621970023 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square30x30Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square310x310Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 000000000..f9bc04839 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square310x310Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square44x44Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 000000000..d5fbfb2ab Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square44x44Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square71x71Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 000000000..63440d798 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square71x71Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square89x89Logo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 000000000..f3f705af2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/Square89x89Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/StoreLogo.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/StoreLogo.png new file mode 100644 index 000000000..455638826 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/StoreLogo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.icns b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.icns new file mode 100644 index 000000000..12a5bcee2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.icns differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.ico b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.ico new file mode 100644 index 000000000..b3636e4b2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.png b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.png new file mode 100644 index 000000000..e1cd2619e Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/react/src-tauri/icons/icon.png differ diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/src/lib.rs b/crates/create-farm-rs/templates/tauri2/react/src-tauri/src/lib.rs new file mode 100644 index 000000000..f91b35e43 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_shell::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/src/main.rs b/crates/create-farm-rs/templates/tauri2/react/src-tauri/src/main.rs new file mode 100644 index 000000000..ddf7fdcc0 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + react_lib::run() +} diff --git a/crates/create-farm-rs/templates/tauri2/react/src-tauri/tauri.conf.json b/crates/create-farm-rs/templates/tauri2/react/src-tauri/tauri.conf.json new file mode 100644 index 000000000..307bb5e56 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src-tauri/tauri.conf.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "", + "version": "0.1.0", + "identifier": "com.tauri.dev", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/crates/create-farm-rs/templates/tauri2/react/src/App.css b/crates/create-farm-rs/templates/tauri2/react/src/App.css new file mode 100644 index 000000000..716df1ce3 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src/App.css @@ -0,0 +1,117 @@ +.logo.farm:hover { + filter: drop-shadow(0 0 2em #ff7474); +} + +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafb); +} + +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +} diff --git a/crates/create-farm-rs/templates/tauri2/react/src/App.tsx b/crates/create-farm-rs/templates/tauri2/react/src/App.tsx new file mode 100644 index 000000000..98f82086c --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src/App.tsx @@ -0,0 +1,51 @@ +import { useState } from "react"; +import reactLogo from "./assets/react.svg"; +import { invoke } from "@tauri-apps/api/core"; +import "./App.css"; + +function App() { + const [greetMsg, setGreetMsg] = useState(""); + const [name, setName] = useState(""); + + async function greet() { + // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ + setGreetMsg(await invoke("greet", { name })); + } + + return ( +
+

Welcome to Farm + Tauri + React

+ + +

Click on the Tauri, Farm, and React logos to learn more.

+ +
{ + e.preventDefault(); + greet(); + }} + > + setName(e.currentTarget.value)} + placeholder="Enter a name..." + /> + +
+

{greetMsg}

+
+ ); +} + +export default App; diff --git a/crates/create-farm-rs/templates/tauri2/react/src/assets/react.svg b/crates/create-farm-rs/templates/tauri2/react/src/assets/react.svg new file mode 100644 index 000000000..6c87de9bb --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/crates/create-farm-rs/templates/tauri2/react/src/env.d.ts b/crates/create-farm-rs/templates/tauri2/react/src/env.d.ts new file mode 100644 index 000000000..11f02fe2a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/crates/create-farm-rs/templates/tauri2/react/src/main.tsx b/crates/create-farm-rs/templates/tauri2/react/src/main.tsx new file mode 100644 index 000000000..2be325ed2 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/src/main.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import ReactDOM from "react-dom/client"; +import App from "./App"; + +ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( + + + , +); diff --git a/crates/create-farm-rs/templates/tauri2/react/tsconfig.json b/crates/create-farm-rs/templates/tauri2/react/tsconfig.json new file mode 100644 index 000000000..a7fc6fbf2 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/crates/create-farm-rs/templates/tauri2/react/tsconfig.node.json b/crates/create-farm-rs/templates/tauri2/react/tsconfig.node.json new file mode 100644 index 000000000..54e79e3d0 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/react/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["farm.config.ts"] +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/.vscode/extensions.json b/crates/create-farm-rs/templates/tauri2/solid/.vscode/extensions.json new file mode 100644 index 000000000..24d7cc6de --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/README.md b/crates/create-farm-rs/templates/tauri2/solid/README.md new file mode 100644 index 000000000..648e2c163 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/README.md @@ -0,0 +1,7 @@ +# Tauri + Solid + Typescript + +This template should help get you started developing with Tauri, Solid and Typescript in Vite. + +## Recommended IDE Setup + +- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/crates/create-farm-rs/templates/tauri2/solid/farm.config.ts b/crates/create-farm-rs/templates/tauri2/solid/farm.config.ts new file mode 100644 index 000000000..17395d849 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/farm.config.ts @@ -0,0 +1,27 @@ +import { defineConfig } from "@farmfe/core"; +import solid from "vite-plugin-solid"; + +// @ts-ignore process is a nodejs global +const host = process.env.TAURI_DEV_HOST; + +// https://www.farmfe.org/docs/config/configuring-farm +export default defineConfig({ + vitePlugins: [solid()], + + clearScreen: false, + server: { + port: 1420, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421, + watchOptions: { + ignored: ["**/node_modules/**"], + } + } + : undefined, + }, +}); diff --git a/crates/create-farm-rs/templates/tauri2/solid/gitignore b/crates/create-farm-rs/templates/tauri2/solid/gitignore new file mode 100644 index 000000000..76add878f --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/crates/create-farm-rs/templates/tauri2/solid/index.html b/crates/create-farm-rs/templates/tauri2/solid/index.html new file mode 100644 index 000000000..9c2276adb --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/index.html @@ -0,0 +1,17 @@ + + + + + + + + Tauri + Solid + Typescript App + + + + +
+ + + + diff --git a/crates/create-farm-rs/templates/tauri2/solid/package.json b/crates/create-farm-rs/templates/tauri2/solid/package.json new file mode 100644 index 000000000..dfa6b1ba3 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/package.json @@ -0,0 +1,27 @@ +{ + "name": "", + "version": "0.1.0", + "description": "", + "type": "module", + "scripts": { + "start": "farm", + "dev": "farm", + "build": "farm build", + "serve": "farm preview", + "tauri": "tauri" + }, + "license": "MIT", + "dependencies": { + "solid-js": "^1.9.3", + "@tauri-apps/api": "^2", + "@tauri-apps/plugin-opener": "^2" + }, + "devDependencies": { + "@farmfe/cli": "^1.0.4", + "@farmfe/core": "^1.6.3", + "core-js": "^3.39.0", + "typescript": "~5.6.2", + "vite-plugin-solid": "^2.11.0", + "@tauri-apps/cli": "^2" + } +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/public/farm.png b/crates/create-farm-rs/templates/tauri2/solid/public/farm.png new file mode 100644 index 000000000..0caeb4381 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/public/farm.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/public/tauri.svg b/crates/create-farm-rs/templates/tauri2/solid/public/tauri.svg new file mode 100644 index 000000000..31b62c928 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/public/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/Cargo.toml b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/Cargo.toml new file mode 100644 index 000000000..39f75dd71 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-opener = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/build.rs b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/build.rs new file mode 100644 index 000000000..d860e1e6a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/capabilities/default.json b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/capabilities/default.json new file mode 100644 index 000000000..4cdbf49a7 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "opener:default" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/gitignore b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/gitignore new file mode 100644 index 000000000..b21bd681d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/128x128.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/128x128.png new file mode 100644 index 000000000..6be5e50e9 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/128x128.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/128x128@2x.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/128x128@2x.png new file mode 100644 index 000000000..e81becee5 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/128x128@2x.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/32x32.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/32x32.png new file mode 100644 index 000000000..a437dd517 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/32x32.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square107x107Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 000000000..0ca4f2719 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square107x107Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square142x142Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 000000000..b81f82039 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square142x142Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square150x150Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 000000000..624c7bfba Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square150x150Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square284x284Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 000000000..c021d2ba7 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square284x284Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square30x30Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 000000000..621970023 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square30x30Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square310x310Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 000000000..f9bc04839 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square310x310Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square44x44Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 000000000..d5fbfb2ab Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square44x44Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square71x71Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 000000000..63440d798 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square71x71Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square89x89Logo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 000000000..f3f705af2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/Square89x89Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/StoreLogo.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/StoreLogo.png new file mode 100644 index 000000000..455638826 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/StoreLogo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.icns b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.icns new file mode 100644 index 000000000..12a5bcee2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.icns differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.ico b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.ico new file mode 100644 index 000000000..b3636e4b2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.png b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.png new file mode 100644 index 000000000..e1cd2619e Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/icons/icon.png differ diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/src/lib.rs b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/src/lib.rs new file mode 100644 index 000000000..4a277ef35 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/src/main.rs b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/src/main.rs new file mode 100644 index 000000000..01a809cba --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + solid_lib::run() +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/src-tauri/tauri.conf.json b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/tauri.conf.json new file mode 100644 index 000000000..4c7e9cb59 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src-tauri/tauri.conf.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "", + "version": "0.1.0", + "identifier": "com.tauri.app", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/src/App.css b/crates/create-farm-rs/templates/tauri2/solid/src/App.css new file mode 100644 index 000000000..daa3e843e --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src/App.css @@ -0,0 +1,117 @@ +.logo.farm:hover { + filter: drop-shadow(0 0 2em #ff7474); +} + +.logo.solid:hover { + filter: drop-shadow(0 0 2em #2f5d90); +} + +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/src/App.tsx b/crates/create-farm-rs/templates/tauri2/solid/src/App.tsx new file mode 100644 index 000000000..7597e835d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src/App.tsx @@ -0,0 +1,51 @@ +import { createSignal } from "solid-js"; +import logo from "./assets/logo.svg"; +import { invoke } from "@tauri-apps/api/core"; +import "./App.css"; + +function App() { + const [greetMsg, setGreetMsg] = createSignal(""); + const [name, setName] = createSignal(""); + + async function greet() { + // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ + setGreetMsg(await invoke("greet", { name: name() })); + } + + return ( +
+

Welcome to Tauri + Solid

+ + +

Click on the Tauri, Vite, and Solid logos to learn more.

+ +
{ + e.preventDefault(); + greet(); + }} + > + setName(e.currentTarget.value)} + placeholder="Enter a name..." + /> + +
+

{greetMsg()}

+
+ ); +} + +export default App; diff --git a/crates/create-farm-rs/templates/tauri2/solid/src/assets/logo.svg b/crates/create-farm-rs/templates/tauri2/solid/src/assets/logo.svg new file mode 100644 index 000000000..025aa303c --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/crates/create-farm-rs/templates/tauri2/solid/src/index.tsx b/crates/create-farm-rs/templates/tauri2/solid/src/index.tsx new file mode 100644 index 000000000..26b551742 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/src/index.tsx @@ -0,0 +1,5 @@ +/* @refresh reload */ +import { render } from "solid-js/web"; +import App from "./App"; + +render(() => , document.getElementById("root") as HTMLElement); diff --git a/crates/create-farm-rs/templates/tauri2/solid/tsconfig.json b/crates/create-farm-rs/templates/tauri2/solid/tsconfig.json new file mode 100644 index 000000000..399995840 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve", + "jsxImportSource": "solid-js", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/crates/create-farm-rs/templates/tauri2/solid/tsconfig.node.json b/crates/create-farm-rs/templates/tauri2/solid/tsconfig.node.json new file mode 100644 index 000000000..54e79e3d0 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/solid/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["farm.config.ts"] +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/.vscode/extensions.json b/crates/create-farm-rs/templates/tauri2/svelte/.vscode/extensions.json new file mode 100644 index 000000000..61343e9b8 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "svelte.svelte-vscode", + "tauri-apps.tauri-vscode", + "rust-lang.rust-analyzer" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/.vscode/settings.json b/crates/create-farm-rs/templates/tauri2/svelte/.vscode/settings.json new file mode 100644 index 000000000..2f86c5011 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "svelte.enable-ts-plugin": true +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/README.md b/crates/create-farm-rs/templates/tauri2/svelte/README.md new file mode 100644 index 000000000..858d17956 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/README.md @@ -0,0 +1,7 @@ +# Tauri + SvelteKit + TypeScript + +This template should help get you started developing with Tauri, SvelteKit and TypeScript in Vite. + +## Recommended IDE Setup + +[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). diff --git a/crates/create-farm-rs/templates/tauri2/svelte/farm.config.ts b/crates/create-farm-rs/templates/tauri2/svelte/farm.config.ts new file mode 100644 index 000000000..c0d8c66ce --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/farm.config.ts @@ -0,0 +1,27 @@ +import { defineConfig } from "@farmfe/core"; +import { sveltekit } from "@sveltejs/kit/vite"; + +// @ts-ignore process is a nodejs global +const host = process.env.TAURI_DEV_HOST; + +// https://www.farmfe.org/docs/config/configuring-farm +export default defineConfig({ + vitePlugins: [sveltekit()], + + clearScreen: false, + server: { + port: 1420, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421, + watchOptions: { + ignored: ["**/node_modules/**"], + } + } + : undefined, + }, +}); diff --git a/crates/create-farm-rs/templates/tauri2/svelte/gitignore b/crates/create-farm-rs/templates/tauri2/svelte/gitignore new file mode 100644 index 000000000..6635cf554 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/gitignore @@ -0,0 +1,10 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/crates/create-farm-rs/templates/tauri2/svelte/package.json b/crates/create-farm-rs/templates/tauri2/svelte/package.json new file mode 100644 index 000000000..57f05b3d7 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/package.json @@ -0,0 +1,31 @@ +{ + "name": "", + "version": "0.1.0", + "description": "", + "type": "module", + "scripts": { + "dev": "farm", + "build": "farm build", + "preview": "farm preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "tauri": "tauri" + }, + "license": "MIT", + "dependencies": { + "@tauri-apps/api": "^2", + "@tauri-apps/plugin-opener": "^2" + }, + "devDependencies": { + "@farmfe/cli": "^1.0.4", + "@farmfe/core": "^1.6.3", + "@sveltejs/adapter-static": "^3.0.6", + "@sveltejs/kit": "^2.9.0", + "@sveltejs/vite-plugin-svelte": "^5.0.0", + "svelte": "^5.0.0", + "svelte-check": "^4.0.0", + "core-js": "^3.39.0", + "typescript": "~5.6.2", + "@tauri-apps/cli": "^2" + } +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/Cargo.toml b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/Cargo.toml new file mode 100644 index 000000000..39f75dd71 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-opener = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/build.rs b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/build.rs new file mode 100644 index 000000000..d860e1e6a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/capabilities/default.json b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/capabilities/default.json new file mode 100644 index 000000000..4cdbf49a7 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "opener:default" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/gitignore b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/gitignore new file mode 100644 index 000000000..b21bd681d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/128x128.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/128x128.png new file mode 100644 index 000000000..6be5e50e9 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/128x128.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/128x128@2x.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/128x128@2x.png new file mode 100644 index 000000000..e81becee5 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/128x128@2x.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/32x32.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/32x32.png new file mode 100644 index 000000000..a437dd517 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/32x32.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square107x107Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 000000000..0ca4f2719 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square107x107Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square142x142Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 000000000..b81f82039 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square142x142Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square150x150Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 000000000..624c7bfba Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square150x150Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square284x284Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 000000000..c021d2ba7 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square284x284Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square30x30Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 000000000..621970023 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square30x30Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square310x310Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 000000000..f9bc04839 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square310x310Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square44x44Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 000000000..d5fbfb2ab Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square44x44Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square71x71Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 000000000..63440d798 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square71x71Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square89x89Logo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 000000000..f3f705af2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/Square89x89Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/StoreLogo.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/StoreLogo.png new file mode 100644 index 000000000..455638826 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/StoreLogo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.icns b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.icns new file mode 100644 index 000000000..12a5bcee2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.icns differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.ico b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.ico new file mode 100644 index 000000000..b3636e4b2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.png b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.png new file mode 100644 index 000000000..e1cd2619e Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/icons/icon.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/src/lib.rs b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/src/lib.rs new file mode 100644 index 000000000..4a277ef35 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/src/main.rs b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/src/main.rs new file mode 100644 index 000000000..d85d44ddd --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + svelte_lib::run() +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/tauri.conf.json b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/tauri.conf.json new file mode 100644 index 000000000..42e12943a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src-tauri/tauri.conf.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "", + "version": "0.1.0", + "identifier": "com.tauri.dev", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../build" + }, + "app": { + "windows": [ + { + "title": "", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src/app.html b/crates/create-farm-rs/templates/tauri2/svelte/src/app.html new file mode 100644 index 000000000..92e7e3338 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src/app.html @@ -0,0 +1,13 @@ + + + + + + + Tauri + SvelteKit + Typescript App + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src/routes/+layout.ts b/crates/create-farm-rs/templates/tauri2/svelte/src/routes/+layout.ts new file mode 100644 index 000000000..f4fb6898e --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src/routes/+layout.ts @@ -0,0 +1,5 @@ +// Tauri doesn't have a Node.js server to do proper SSR +// so we will use adapter-static to prerender the app (SSG) +// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info +export const prerender = true; +export const ssr = false; diff --git a/crates/create-farm-rs/templates/tauri2/svelte/src/routes/+page.svelte b/crates/create-farm-rs/templates/tauri2/svelte/src/routes/+page.svelte new file mode 100644 index 000000000..d538b29bf --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/src/routes/+page.svelte @@ -0,0 +1,156 @@ + + +
+

Welcome to Tauri + Svelte

+ + +

Click on the Tauri, Vite, and SvelteKit logos to learn more.

+ +
+ + +
+

{greetMsg}

+
+ + diff --git a/crates/create-farm-rs/templates/tauri2/svelte/static/farm.png b/crates/create-farm-rs/templates/tauri2/svelte/static/farm.png new file mode 100644 index 000000000..0caeb4381 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/static/farm.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/static/favicon.png b/crates/create-farm-rs/templates/tauri2/svelte/static/favicon.png new file mode 100644 index 000000000..825b9e65a Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/svelte/static/favicon.png differ diff --git a/crates/create-farm-rs/templates/tauri2/svelte/static/svelte.svg b/crates/create-farm-rs/templates/tauri2/svelte/static/svelte.svg new file mode 100644 index 000000000..c5e08481f --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/static/svelte.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/crates/create-farm-rs/templates/tauri2/svelte/static/tauri.svg b/crates/create-farm-rs/templates/tauri2/svelte/static/tauri.svg new file mode 100644 index 000000000..31b62c928 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/static/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/crates/create-farm-rs/templates/tauri2/svelte/svelte.config.js b/crates/create-farm-rs/templates/tauri2/svelte/svelte.config.js new file mode 100644 index 000000000..2d45f91c5 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/svelte.config.js @@ -0,0 +1,15 @@ +// Tauri doesn't have a Node.js server to do proper SSR +// so we will use adapter-static to prerender the app (SSG) +// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info +import adapter from "@sveltejs/adapter-static"; +import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + preprocess: vitePreprocess(), + kit: { + adapter: adapter(), + }, +}; + +export default config; diff --git a/crates/create-farm-rs/templates/tauri2/svelte/tsconfig.json b/crates/create-farm-rs/templates/tauri2/svelte/tsconfig.json new file mode 100644 index 000000000..593dc1963 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/svelte/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + } + // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias + // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/.vscode/extensions.json b/crates/create-farm-rs/templates/tauri2/vanilla/.vscode/extensions.json new file mode 100644 index 000000000..24d7cc6de --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/README.md b/crates/create-farm-rs/templates/tauri2/vanilla/README.md new file mode 100644 index 000000000..b381dcf5b --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/README.md @@ -0,0 +1,7 @@ +# Tauri + Vanilla TS + +This template should help get you started developing with Tauri in vanilla HTML, CSS and Typescript. + +## Recommended IDE Setup + +- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/farm.config.ts b/crates/create-farm-rs/templates/tauri2/vanilla/farm.config.ts new file mode 100644 index 000000000..609dac203 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/farm.config.ts @@ -0,0 +1,27 @@ +import { defineConfig } from "@farmfe/core"; + +// @ts-ignore process is a nodejs global +const host = process.env.TAURI_DEV_HOST; + +// https://www.farmfe.org/docs/config/configuring-farm +export default defineConfig({ + compilation: { + presetEnv: false + }, + clearScreen: false, + server: { + port: 1420, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421, + watchOptions: { + ignored: ["**/node_modules/**"], + } + } + : undefined, + }, +}); diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/gitignore b/crates/create-farm-rs/templates/tauri2/vanilla/gitignore new file mode 100644 index 000000000..a547bf36d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/index.html b/crates/create-farm-rs/templates/tauri2/vanilla/index.html new file mode 100644 index 000000000..34be9b9e0 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/index.html @@ -0,0 +1,43 @@ + + + + + + + Tauri App + + + + +
+

Welcome to Farm + Tauri

+ + +

Click on the Tauri logo to learn more about the framework

+ +
+ + +
+

+
+ + diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/package.json b/crates/create-farm-rs/templates/tauri2/vanilla/package.json new file mode 100644 index 000000000..c525745d7 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/package.json @@ -0,0 +1,23 @@ +{ + "name": "", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "farm", + "build": "tsc && farm build", + "preview": "farm preview", + "tauri": "tauri" + }, + "dependencies": { + "@tauri-apps/api": "^2", + "@tauri-apps/plugin-opener": "^2" + }, + "devDependencies": { + "@farmfe/cli": "^1.0.4", + "@farmfe/core": "^1.6.3", + "@tauri-apps/cli": "^2", + "core-js": "^3.40.0", + "typescript": "^5.7.2" + } +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/public/farm.png b/crates/create-farm-rs/templates/tauri2/vanilla/public/farm.png new file mode 100644 index 000000000..0caeb4381 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/public/farm.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/Cargo.toml b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/Cargo.toml new file mode 100644 index 000000000..39f75dd71 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-opener = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/build.rs b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/build.rs new file mode 100644 index 000000000..d860e1e6a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/capabilities/default.json b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/capabilities/default.json new file mode 100644 index 000000000..4cdbf49a7 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "opener:default" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/gitignore b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/gitignore new file mode 100644 index 000000000..b21bd681d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/128x128.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/128x128.png new file mode 100644 index 000000000..6be5e50e9 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/128x128.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/128x128@2x.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/128x128@2x.png new file mode 100644 index 000000000..e81becee5 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/128x128@2x.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/32x32.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/32x32.png new file mode 100644 index 000000000..a437dd517 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/32x32.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square107x107Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 000000000..0ca4f2719 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square107x107Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square142x142Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 000000000..b81f82039 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square142x142Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square150x150Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 000000000..624c7bfba Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square150x150Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square284x284Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 000000000..c021d2ba7 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square284x284Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square30x30Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 000000000..621970023 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square30x30Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square310x310Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 000000000..f9bc04839 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square310x310Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square44x44Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 000000000..d5fbfb2ab Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square44x44Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square71x71Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 000000000..63440d798 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square71x71Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square89x89Logo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 000000000..f3f705af2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/Square89x89Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/StoreLogo.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/StoreLogo.png new file mode 100644 index 000000000..455638826 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/StoreLogo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.icns b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.icns new file mode 100644 index 000000000..12a5bcee2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.icns differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.ico b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.ico new file mode 100644 index 000000000..b3636e4b2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.png b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.png new file mode 100644 index 000000000..e1cd2619e Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/icons/icon.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/src/lib.rs b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/src/lib.rs new file mode 100644 index 000000000..4a277ef35 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/src/main.rs b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/src/main.rs new file mode 100644 index 000000000..62e0da38a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + vanilla_lib::run() +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/tauri.conf.json b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/tauri.conf.json new file mode 100644 index 000000000..91b9d5e13 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src-tauri/tauri.conf.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "", + "version": "0.1.0", + "identifier": "com.tauri.dev", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "withGlobalTauri": true, + "windows": [ + { + "title": "", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src/assets/tauri.svg b/crates/create-farm-rs/templates/tauri2/vanilla/src/assets/tauri.svg new file mode 100644 index 000000000..31b62c928 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src/assets/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src/assets/typescript.svg b/crates/create-farm-rs/templates/tauri2/vanilla/src/assets/typescript.svg new file mode 100644 index 000000000..30a5edd33 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src/assets/typescript.svg @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src/main.ts b/crates/create-farm-rs/templates/tauri2/vanilla/src/main.ts new file mode 100644 index 000000000..478334127 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src/main.ts @@ -0,0 +1,22 @@ +import { invoke } from "@tauri-apps/api/core"; + +let greetInputEl: HTMLInputElement | null; +let greetMsgEl: HTMLElement | null; + +async function greet() { + if (greetMsgEl && greetInputEl) { + // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ + greetMsgEl.textContent = await invoke("greet", { + name: greetInputEl.value, + }); + } +} + +window.addEventListener("DOMContentLoaded", () => { + greetInputEl = document.querySelector("#greet-input"); + greetMsgEl = document.querySelector("#greet-msg"); + document.querySelector("#greet-form")?.addEventListener("submit", (e) => { + e.preventDefault(); + greet(); + }); +}); diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/src/styles.css b/crates/create-farm-rs/templates/tauri2/vanilla/src/styles.css new file mode 100644 index 000000000..adc8c4c4a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/src/styles.css @@ -0,0 +1,117 @@ +.logo.farm:hover { + filter: drop-shadow(0 0 2em #ff7474); +} + +.logo.typescript:hover { + filter: drop-shadow(0 0 2em #2d79c7); +} + +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +} diff --git a/crates/create-farm-rs/templates/tauri2/vanilla/tsconfig.json b/crates/create-farm-rs/templates/tauri2/vanilla/tsconfig.json new file mode 100644 index 000000000..75abdef26 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vanilla/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/.vscode/extensions.json b/crates/create-farm-rs/templates/tauri2/vue/.vscode/extensions.json new file mode 100644 index 000000000..cf4385bdd --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "Vue.volar", + "tauri-apps.tauri-vscode", + "rust-lang.rust-analyzer" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/README.md b/crates/create-farm-rs/templates/tauri2/vue/README.md new file mode 100644 index 000000000..5047afc64 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/README.md @@ -0,0 +1,16 @@ +# Tauri + Vue + TypeScript + +This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` + + diff --git a/crates/create-farm-rs/templates/tauri2/vue/package.json b/crates/create-farm-rs/templates/tauri2/vue/package.json new file mode 100644 index 000000000..ca6329663 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/package.json @@ -0,0 +1,26 @@ +{ + "name": "", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "farm", + "build": "vue-tsc --noEmit && farm build", + "preview": "farm preview", + "tauri": "tauri" + }, + "dependencies": { + "@tauri-apps/api": "^2.1.1", + "@tauri-apps/plugin-shell": "^2.2.0", + "vue": "^3.5.13" + }, + "devDependencies": { + "@farmfe/cli": "^1.0.4", + "@farmfe/core": "^1.6.3", + "@tauri-apps/cli": "^2.1.0", + "@vitejs/plugin-vue": "^5.2.1", + "core-js": "^3.39.0", + "typescript": "^5.7.2", + "vue-tsc": "^2.2.0" + } +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/public/farm.png b/crates/create-farm-rs/templates/tauri2/vue/public/farm.png new file mode 100644 index 000000000..0caeb4381 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/public/farm.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/public/favicon.ico b/crates/create-farm-rs/templates/tauri2/vue/public/favicon.ico new file mode 100644 index 000000000..80465dedc Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/public/favicon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/public/tauri.svg b/crates/create-farm-rs/templates/tauri2/vue/public/tauri.svg new file mode 100644 index 000000000..31b62c928 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/public/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/Cargo.toml b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/Cargo.toml new file mode 100644 index 000000000..eae9d26ce --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-shell = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/build.rs b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/build.rs new file mode 100644 index 000000000..d860e1e6a --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/capabilities/default.json b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/capabilities/default.json new file mode 100644 index 000000000..3bb4cc497 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "shell:allow-open" + ] +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/gitignore b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/gitignore new file mode 100644 index 000000000..b21bd681d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/128x128.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/128x128.png new file mode 100644 index 000000000..6be5e50e9 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/128x128.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/128x128@2x.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/128x128@2x.png new file mode 100644 index 000000000..e81becee5 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/128x128@2x.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/32x32.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/32x32.png new file mode 100644 index 000000000..a437dd517 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/32x32.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square107x107Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 000000000..0ca4f2719 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square107x107Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square142x142Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 000000000..b81f82039 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square142x142Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square150x150Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 000000000..624c7bfba Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square150x150Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square284x284Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 000000000..c021d2ba7 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square284x284Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square30x30Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 000000000..621970023 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square30x30Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square310x310Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 000000000..f9bc04839 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square310x310Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square44x44Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 000000000..d5fbfb2ab Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square44x44Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square71x71Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 000000000..63440d798 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square71x71Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square89x89Logo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 000000000..f3f705af2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/Square89x89Logo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/StoreLogo.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/StoreLogo.png new file mode 100644 index 000000000..455638826 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/StoreLogo.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.icns b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.icns new file mode 100644 index 000000000..12a5bcee2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.icns differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.ico b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.ico new file mode 100644 index 000000000..b3636e4b2 Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.ico differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.png b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.png new file mode 100644 index 000000000..e1cd2619e Binary files /dev/null and b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/icons/icon.png differ diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/src/lib.rs b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/src/lib.rs new file mode 100644 index 000000000..f91b35e43 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_shell::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/src/main.rs b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/src/main.rs new file mode 100644 index 000000000..7c2381247 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + vue_lib::run() +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/src-tauri/tauri.conf.json b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/tauri.conf.json new file mode 100644 index 000000000..307bb5e56 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src-tauri/tauri.conf.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "", + "version": "0.1.0", + "identifier": "com.tauri.dev", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/src/App.vue b/crates/create-farm-rs/templates/tauri2/vue/src/App.vue new file mode 100644 index 000000000..668feba27 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src/App.vue @@ -0,0 +1,160 @@ + + + + + + \ No newline at end of file diff --git a/crates/create-farm-rs/templates/tauri2/vue/src/assets/vue.svg b/crates/create-farm-rs/templates/tauri2/vue/src/assets/vue.svg new file mode 100644 index 000000000..770e9d333 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src/assets/vue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/crates/create-farm-rs/templates/tauri2/vue/src/env.d.ts b/crates/create-farm-rs/templates/tauri2/vue/src/env.d.ts new file mode 100644 index 000000000..fc812394b --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src/env.d.ts @@ -0,0 +1,7 @@ +/// + +declare module "*.vue" { + import type { DefineComponent } from "vue"; + const component: DefineComponent<{}, {}, any>; + export default component; +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/src/main.ts b/crates/create-farm-rs/templates/tauri2/vue/src/main.ts new file mode 100644 index 000000000..b670de8b8 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/src/main.ts @@ -0,0 +1,4 @@ +import { createApp } from "vue"; +import App from "./App.vue"; + +createApp(App).mount("#app"); diff --git a/crates/create-farm-rs/templates/tauri2/vue/tsconfig.json b/crates/create-farm-rs/templates/tauri2/vue/tsconfig.json new file mode 100644 index 000000000..f82888f3d --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/crates/create-farm-rs/templates/tauri2/vue/tsconfig.node.json b/crates/create-farm-rs/templates/tauri2/vue/tsconfig.node.json new file mode 100644 index 000000000..54e79e3d0 --- /dev/null +++ b/crates/create-farm-rs/templates/tauri2/vue/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["farm.config.ts"] +}