diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/.gitignore b/tooling/cli/templates/plugin/with-api/examples/svelte-app/.gitignore deleted file mode 100644 index 072f27e9df58..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -public/build/ -public/index.tauri.html diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/package.json b/tooling/cli/templates/plugin/with-api/examples/svelte-app/package.json deleted file mode 100644 index 3c83f9ff8072..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "svelte-app", - "version": "1.0.0", - "scripts": { - "build": "rollup -c", - "dev": "rollup -c -w", - "start": "sirv public", - "validate": "svelte-check", - "tauri": "tauri" - }, - "devDependencies": { - "@rollup/plugin-commonjs": "22.0.0", - "@rollup/plugin-node-resolve": "13.3.0", - "@rollup/plugin-typescript": "8.3.3", - "@tauri-apps/cli": "^1.0.0", - "@tsconfig/svelte": "3.0.0", - "rollup": "2.75.6", - "rollup-plugin-css-only": "3.1.0", - "rollup-plugin-livereload": "2.0.5", - "rollup-plugin-svelte": "7.1.0", - "rollup-plugin-terser": "7.0.2", - "svelte": "3.48.0", - "svelte-check": "2.7.2", - "svelte-preprocess": "4.10.7", - "tslib": "2.4.0", - "typescript": "4.7.3" - }, - "dependencies": { - "sirv-cli": "2.0.2", - "tauri-plugin-{{ plugin_name }}-api": "link:../../" - } -} diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/favicon.png b/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/favicon.png deleted file mode 100644 index 7e6f5eb5a2f1..000000000000 Binary files a/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/favicon.png and /dev/null differ diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/global.css b/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/global.css deleted file mode 100644 index 619a92f33190..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/global.css +++ /dev/null @@ -1,68 +0,0 @@ -html, -body { - position: relative; - width: 100%; - height: 100%; -} - -body { - color: #333; - margin: 0; - padding: 8px; - box-sizing: border-box; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; -} - -a { - color: rgb(0, 100, 200); - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -a:visited { - color: rgb(0, 80, 160); -} - -label { - display: block; -} - -input, -button, -select, -textarea { - font-family: inherit; - font-size: inherit; - -webkit-padding: 0.4em 0; - padding: 0.4em; - margin: 0 0 0.5em 0; - box-sizing: border-box; - border: 1px solid #ccc; - border-radius: 2px; -} - -input:disabled { - color: #ccc; -} - -button { - color: #333; - background-color: #f4f4f4; - outline: none; -} - -button:disabled { - color: #999; -} - -button:not(:disabled):active { - background-color: #ddd; -} - -button:focus { - border-color: #666; -} diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/index.html b/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/index.html deleted file mode 100644 index 1e84363f6b27..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/public/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - Svelte app - - - - - - - - - - diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/rollup.config.js b/tooling/cli/templates/plugin/with-api/examples/svelte-app/rollup.config.js deleted file mode 100644 index e546b7180702..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/rollup.config.js +++ /dev/null @@ -1,87 +0,0 @@ -import svelte from 'rollup-plugin-svelte' -import commonjs from '@rollup/plugin-commonjs' -import resolve from '@rollup/plugin-node-resolve' -import livereload from 'rollup-plugin-livereload' -import { terser } from 'rollup-plugin-terser' -import sveltePreprocess from 'svelte-preprocess' -import typescript from '@rollup/plugin-typescript' -import css from 'rollup-plugin-css-only' - -const production = !process.env.ROLLUP_WATCH - -function serve() { - let server - - function toExit() { - if (server) server.kill(0) - } - - return { - writeBundle() { - if (server) return - server = require('child_process').spawn( - 'npm', - ['run', 'start', '--', '--dev'], - { - stdio: ['ignore', 'inherit', 'inherit'], - shell: true - } - ) - - process.on('SIGTERM', toExit) - process.on('exit', toExit) - } - } -} - -export default { - input: 'src/main.ts', - output: { - sourcemap: true, - format: 'iife', - name: 'app', - file: 'public/build/bundle.js' - }, - plugins: [ - svelte({ - preprocess: sveltePreprocess(), - compilerOptions: { - // enable run-time checks when not in production - dev: !production - } - }), - // we'll extract any component CSS out into - // a separate file - better for performance - css({ output: 'bundle.css' }), - - // If you have external dependencies installed from - // npm, you'll most likely need these plugins. In - // some cases you'll need additional configuration - - // consult the documentation for details: - // https://github.com/rollup/plugins/tree/master/packages/commonjs - resolve({ - browser: true, - dedupe: ['svelte'] - }), - commonjs(), - typescript({ - sourceMap: !production, - inlineSources: !production - }), - - // In dev mode, call `npm run start` once - // the bundle has been generated - !production && serve(), - - // Watch the `public` directory and refresh the - // browser on changes when not in production - !production && livereload('public'), - - // If we're building for production (npm run build - // instead of npm run dev), minify - production && terser() - ], - watch: { - clearScreen: false - } -} diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/Cargo.crate-manifest b/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/Cargo.crate-manifest deleted file mode 100644 index 74a685bdfd71..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/Cargo.crate-manifest +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "app" -version = "0.1.0" -description = "A Tauri App" -authors = [ "{{ author }}" ] -repository = "" -edition = "2021" -rust-version = "1.59" - -[dependencies] -serde_json = "1.0" -serde = { version = "1.0", features = [ "derive" ] } -tauri = {{{ tauri_example_dep }}} -tauri-plugin-{{ plugin_name }} = { path = "../../../" } - -[build-dependencies] -tauri-build = {{{ tauri_build_dep }}} - -[features] -default = [ "custom-protocol" ] -custom-protocol = [ "tauri/custom-protocol" ] diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/rustfmt.toml b/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/rustfmt.toml deleted file mode 100644 index d962cdac2267..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/rustfmt.toml +++ /dev/null @@ -1,13 +0,0 @@ -max_width = 100 -hard_tabs = false -tab_spaces = 2 -newline_style = "Auto" -use_small_heuristics = "Default" -reorder_imports = true -reorder_modules = true -remove_nested_parens = true -edition = "2021" -merge_derives = true -use_try_shorthand = false -use_field_init_shorthand = false -force_explicit_abi = true diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/src/main.rs b/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/src/main.rs deleted file mode 100644 index cafd857d94fa..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/src/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" -)] - -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_{{ plugin_name_snake_case }}::init()) - .run(tauri::generate_context!()) - .expect("failed to run app"); -} diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src/App.svelte b/tooling/cli/templates/plugin/with-api/examples/svelte-app/src/App.svelte deleted file mode 100644 index 24e618e8d82a..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src/App.svelte +++ /dev/null @@ -1,18 +0,0 @@ - - -
- -
{@html response}
-
diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src/main.ts b/tooling/cli/templates/plugin/with-api/examples/svelte-app/src/main.ts deleted file mode 100644 index 0651393408ff..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -import App from './App.svelte' - -const app = new App({ - target: document.body, - props: {} -}) - -export default app diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/tsconfig.json b/tooling/cli/templates/plugin/with-api/examples/svelte-app/tsconfig.json deleted file mode 100644 index 543124837b37..000000000000 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "@tsconfig/svelte/tsconfig.json", - - "include": ["src/**/*"], - "exclude": ["node_modules/*", "__sapper__/*", "public/*"] -} diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/.gitignore b/tooling/cli/templates/plugin/with-api/examples/tauri-app/.gitignore new file mode 100644 index 000000000000..a547bf36d8d1 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/.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/tooling/cli/templates/plugin/with-api/examples/tauri-app/.vscode/extensions.json b/tooling/cli/templates/plugin/with-api/examples/tauri-app/.vscode/extensions.json new file mode 100644 index 000000000000..61343e9b89ef --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "svelte.svelte-vscode", + "tauri-apps.tauri-vscode", + "rust-lang.rust-analyzer" + ] +} diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/README.md b/tooling/cli/templates/plugin/with-api/examples/tauri-app/README.md new file mode 100644 index 000000000000..72726a1fa45d --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/README.md @@ -0,0 +1,8 @@ +# Svelte + Vite + +This template should help get you started developing with Tauri and Svelte 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/tooling/cli/templates/plugin/with-api/examples/tauri-app/index.html b/tooling/cli/templates/plugin/with-api/examples/tauri-app/index.html new file mode 100644 index 000000000000..fad1c5d9c250 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/index.html @@ -0,0 +1,14 @@ + + + + + + + Tauri + Svelte + + + +
+ + + diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/jsconfig.json b/tooling/cli/templates/plugin/with-api/examples/tauri-app/jsconfig.json new file mode 100644 index 000000000000..ee5e92f298e4 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/jsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "moduleResolution": "Node", + "target": "ESNext", + "module": "ESNext", + /** + * svelte-preprocess cannot figure out whether you have + * a value or a type, so tell TypeScript to enforce using + * `import type` instead of `import` for Types. + */ + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "resolveJsonModule": true, + /** + * To have warnings / errors of the Svelte compiler at the + * correct position, enable source maps by default. + */ + "sourceMap": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "baseUrl": ".", + /** + * Typecheck JS in `.svelte` and `.js` files by default. + * Disable this if you'd like to use dynamic types. + */ + "checkJs": true + }, + /** + * Use global.d.ts instead of compilerOptions.types + * to avoid limiting type declarations. + */ + "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] +} diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/package.json b/tooling/cli/templates/plugin/with-api/examples/tauri-app/package.json new file mode 100644 index 000000000000..88a2e8cf93d3 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/package.json @@ -0,0 +1,22 @@ +{ + "name": "tauri-app", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "tauri": "tauri" + }, + "dependencies": { + "@tauri-apps/api": "^1.1.0", + "tauri-plugin-{{ plugin_name }}-api": "link:../../" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^1.0.1", + "svelte": "^3.49.0", + "vite": "^3.0.2", + "@tauri-apps/cli": "^1.1.0" + } +} diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/svelte.svg b/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/svelte.svg new file mode 100644 index 000000000000..c5e08481f8ae --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/svelte.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/tauri.svg b/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/tauri.svg new file mode 100644 index 000000000000..31b62c92804b --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/vite.svg b/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/vite.svg new file mode 100644 index 000000000000..e7b8dfb1b2a6 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/.gitignore b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/.gitignore similarity index 98% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/.gitignore rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/.gitignore index aba21e242c95..f4dfb82b2cf3 100644 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/.gitignore +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/.gitignore @@ -1,3 +1,4 @@ # Generated by Cargo # will have compiled files and executables /target/ + diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/Cargo.toml b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/Cargo.toml new file mode 100644 index 000000000000..df85cfb55e3c --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "tauri-app" +version = "0.0.0" +description = "A Tauri App" +authors = ["you"] +license = "" +repository = "" +edition = "2021" +rust-version = "1.59" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = {{{ tauri_build_dep }}} + +[dependencies] +serde_json = "1.0" +serde = { version = "1.0", features = ["derive"] } +tauri = {{{ tauri_example_dep }}} +tauri-plugin-{{ plugin_name }} = { path = "../../../" } + +[features] +# by default Tauri runs in production mode +# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL +default = [ "custom-protocol" ] +# this feature is used used for production builds where `devPath` points to the filesystem +# DO NOT remove this +custom-protocol = [ "tauri/custom-protocol" ] diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/build.rs b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/build.rs similarity index 100% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/build.rs rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/build.rs diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/128x128.png b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/128x128.png similarity index 100% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/128x128.png rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/128x128.png diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/128x128@2x.png b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/128x128@2x.png similarity index 100% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/128x128@2x.png rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/128x128@2x.png diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/32x32.png b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/32x32.png similarity index 100% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/32x32.png rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/32x32.png diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/icon.icns b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/icon.icns similarity index 100% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/icon.icns rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/icon.icns diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/icon.ico b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/icon.ico similarity index 100% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/icon.ico rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/icon.ico diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/icon.png b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/icon.png similarity index 100% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/icons/icon.png rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/icons/icon.png diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/src/main.rs b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/src/main.rs new file mode 100644 index 000000000000..92691036fd6e --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/src/main.rs @@ -0,0 +1,18 @@ +#![cfg_attr( + all(not(debug_assertions), target_os = "windows"), + windows_subsystem = "windows" +)] + +// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +fn main() { + tauri::Builder::default() + .invoke_handler(tauri::generate_handler![greet]) + .plugin(tauri_plugin_{{ plugin_name_snake_case }}::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/tauri.conf.json b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/tauri.conf.json similarity index 50% rename from tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/tauri.conf.json rename to tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/tauri.conf.json index 18abc738da88..85db6a8f92e9 100644 --- a/tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/tauri.conf.json +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/tauri.conf.json @@ -1,15 +1,27 @@ { "build": { - "distDir": "../public", - "devPath": "http://localhost:8080", "beforeDevCommand": "yarn dev", - "beforeBuildCommand": "yarn build" + "beforeBuildCommand": "yarn build", + "devPath": "http://localhost:1420", + "distDir": "../dist", + "withGlobalTauri": false + }, + "package": { + "productName": "tauri-app", + "version": "0.0.0" }, "tauri": { + "allowlist": { + "all": true + }, "bundle": { "active": true, - "targets": "all", - "identifier": "com.tauri.{{ plugin_name }}", + "category": "DeveloperTool", + "copyright": "", + "deb": { + "depends": [] + }, + "externalBin": [], "icon": [ "icons/32x32.png", "icons/128x128.png", @@ -17,34 +29,38 @@ "icons/icon.icns", "icons/icon.ico" ], - "resources": [], - "externalBin": [], - "copyright": "", - "category": "DeveloperTool", - "shortDescription": "", + "identifier": "com.tauri.dev", "longDescription": "", - "deb": { - "depends": [] - }, "macOS": { + "entitlements": null, + "exceptionDomain": "", "frameworks": [], - "exceptionDomain": "" + "providerShortName": null, + "signingIdentity": null + }, + "resources": [], + "shortDescription": "", + "targets": "all", + "windows": { + "certificateThumbprint": null, + "digestAlgorithm": "sha256", + "timestampUrl": "" } }, - "allowlist": { - "all": false + "security": { + "csp": null + }, + "updater": { + "active": false }, "windows": [ { - "title": "Tauri App", - "width": 800, + "fullscreen": false, "height": 600, "resizable": true, - "fullscreen": false + "title": "tauri-app", + "width": 800 } - ], - "security": { - "csp": "default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'" - } + ] } } diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/App.svelte b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/App.svelte new file mode 100644 index 000000000000..7c05b27167b8 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/App.svelte @@ -0,0 +1,54 @@ + + +
+

Welcome to Tauri!

+ +
+ + + + + + + + + +
+ +

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

+ +
+ +
+ +
+ +
{@html response}
+
+ +
+ + diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/lib/Greet.svelte b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/lib/Greet.svelte new file mode 100644 index 000000000000..d8a1bd7d6465 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/lib/Greet.svelte @@ -0,0 +1,22 @@ + + +
+
+ + +
+

{greetMsg}

+
+ diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/main.js b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/main.js new file mode 100644 index 000000000000..6b4e1a969ec1 --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/main.js @@ -0,0 +1,8 @@ +import "./style.css"; +import App from "./App.svelte"; + +const app = new App({ + target: document.getElementById("app"), +}); + +export default app; diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/style.css b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/style.css new file mode 100644 index 000000000000..c0f9e3bc8e2f --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/style.css @@ -0,0 +1,102 @@ +: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; +} + +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; + } +} diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/vite-env.d.ts b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/vite-env.d.ts new file mode 100644 index 000000000000..4078e7476a2e --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/tooling/cli/templates/plugin/with-api/examples/tauri-app/vite.config.js b/tooling/cli/templates/plugin/with-api/examples/tauri-app/vite.config.js new file mode 100644 index 000000000000..714f46d724da --- /dev/null +++ b/tooling/cli/templates/plugin/with-api/examples/tauri-app/vite.config.js @@ -0,0 +1,27 @@ +import { defineConfig } from "vite"; +import { svelte } from "@sveltejs/vite-plugin-svelte"; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [svelte()], + + // Vite optons tailored for Tauri development and only applied in `tauri dev` or `tauri build` + // prevent vite from obscuring rust errors + clearScreen: false, + // tauri expects a fixed port, fail if that port is not available + server: { + port: 1420, + strictPort: true, + }, + // to make use of `TAURI_DEBUG` and other env variables + // https://tauri.studio/v1/api/config#buildconfig.beforedevcommand + envPrefix: ["VITE_", "TAURI_"], + build: { + // Tauri supports es2021 + target: ["es2021", "chrome100", "safari13"], + // don't minify for debug builds + minify: !process.env.TAURI_DEBUG ? "esbuild" : false, + // produce sourcemaps for debug builds + sourcemap: !!process.env.TAURI_DEBUG, + }, +});