From 0d5835d133943583e2d46a6bb14fb151e2998530 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 27 Dec 2022 19:32:29 +0200 Subject: [PATCH] chore: update plugin example based on CTA (#5213) Co-authored-by: Lucas Nogueira --- .../with-api/examples/svelte-app/.gitignore | 3 - .../with-api/examples/svelte-app/package.json | 32 ------ .../examples/svelte-app/public/favicon.png | Bin 3127 -> 0 bytes .../examples/svelte-app/public/global.css | 68 ------------ .../examples/svelte-app/public/index.html | 17 --- .../examples/svelte-app/rollup.config.js | 87 --------------- .../svelte-app/src-tauri/Cargo.crate-manifest | 21 ---- .../svelte-app/src-tauri/rustfmt.toml | 13 --- .../examples/svelte-app/src-tauri/src/main.rs | 11 -- .../examples/svelte-app/src/App.svelte | 18 ---- .../with-api/examples/svelte-app/src/main.ts | 8 -- .../examples/svelte-app/tsconfig.json | 6 -- .../with-api/examples/tauri-app/.gitignore | 24 +++++ .../tauri-app/.vscode/extensions.json | 7 ++ .../with-api/examples/tauri-app/README.md | 8 ++ .../with-api/examples/tauri-app/index.html | 14 +++ .../with-api/examples/tauri-app/jsconfig.json | 34 ++++++ .../with-api/examples/tauri-app/package.json | 22 ++++ .../examples/tauri-app/public/svelte.svg | 1 + .../examples/tauri-app/public/tauri.svg | 6 ++ .../examples/tauri-app/public/vite.svg | 1 + .../src-tauri/.gitignore | 1 + .../examples/tauri-app/src-tauri/Cargo.toml | 28 +++++ .../src-tauri/build.rs | 0 .../src-tauri/icons/128x128.png | Bin .../src-tauri/icons/128x128@2x.png | Bin .../src-tauri/icons/32x32.png | Bin .../src-tauri/icons/icon.icns | Bin .../src-tauri/icons/icon.ico | Bin .../src-tauri/icons/icon.png | Bin .../examples/tauri-app/src-tauri/src/main.rs | 18 ++++ .../src-tauri/tauri.conf.json | 62 +++++++---- .../examples/tauri-app/src/App.svelte | 54 ++++++++++ .../examples/tauri-app/src/lib/Greet.svelte | 22 ++++ .../with-api/examples/tauri-app/src/main.js | 8 ++ .../with-api/examples/tauri-app/src/style.css | 102 ++++++++++++++++++ .../examples/tauri-app/src/vite-env.d.ts | 2 + .../examples/tauri-app/vite.config.js | 27 +++++ 38 files changed, 418 insertions(+), 307 deletions(-) delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/.gitignore delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/package.json delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/public/favicon.png delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/public/global.css delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/public/index.html delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/rollup.config.js delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/Cargo.crate-manifest delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/rustfmt.toml delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/src/main.rs delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/src/App.svelte delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/src/main.ts delete mode 100644 tooling/cli/templates/plugin/with-api/examples/svelte-app/tsconfig.json create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/.gitignore create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/.vscode/extensions.json create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/README.md create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/index.html create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/jsconfig.json create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/package.json create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/public/svelte.svg create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/public/tauri.svg create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/public/vite.svg rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/.gitignore (98%) create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/Cargo.toml rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/build.rs (100%) rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/icons/128x128.png (100%) rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/icons/128x128@2x.png (100%) rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/icons/32x32.png (100%) rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/icons/icon.icns (100%) rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/icons/icon.ico (100%) rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/icons/icon.png (100%) create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/src-tauri/src/main.rs rename tooling/cli/templates/plugin/with-api/examples/{svelte-app => tauri-app}/src-tauri/tauri.conf.json (50%) create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/src/App.svelte create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/src/lib/Greet.svelte create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/src/main.js create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/src/style.css create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/src/vite-env.d.ts create mode 100644 tooling/cli/templates/plugin/with-api/examples/tauri-app/vite.config.js 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 7e6f5eb5a2f1f1c882d265cf479de25caa925645..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3127 zcmV-749N3|P)i z7)}s4L53SJCkR}iVi00SFk;`MXX*#X*kkwKs@nFGS}c;=?XFjU|G$3t^5sjIVS2G+ zw)WGF83CpoGXhLGW(1gW%uV|X7>1P6VhCX=Ux)Lb!*DZ%@I3!{Gsf7d?gtIQ%nQiK z3%(LUSkBji;C5Rfgd6$VsF@H`Pk@xtY6t<>FNR-pD}=C~$?)9pdm3XZ36N5PNWYjb z$xd$yNQR9N!dfj-Vd@BwQo^FIIWPPmT&sZyQ$v81(sCBV=PGy{0wltEjB%~h157*t zvbe_!{=I_783x!0t1-r#-d{Y?ae$Q4N_Nd^Ui^@y(%)Gjou6y<3^XJdu{rmUf-Me?)zZ>9OR&6U5H*cK; z$gUlB{g0O4gN0sLSO|Of?hU(l?;h(jA3uH!Z{EBKuV23ouU@^Y6#%v+QG;>e*E}%?wlu-NT4DG zs)z)7WbLr)vGAu(ohrKc^em@OpO&f~6_>E61n_e0_V3@{U3^O;j{`^mNCJUj_>;7v zsMs6Hu3g7+@v+lSo;=yTYFqq}jZmQ-BK8K{C4kqi_i*jBaQE(Au0607V-zKeT;EPg zX(`vrn=L+e74+-Tqeok@_`tDa$G9I|$nTU5H*2V8@y()n*zqM?J1G!-1aX;CfDC9B zTnJ#j_%*n8Qb1)re*Bno7g0RG{Eb;IK14irJYJp$5Z6ac9~b_P?+5t~95~SRG$g?1 znFJ7p$xV&GZ18m~79TGRdfsc-BcX$9yXTR*n)mPD@1~O(_?cT$ZvFPucRmGlq&se0 zKrcUf^k}4hM*biEJOWKzz!qQe;CB_ZtSOO9Owg#lZAc=s65^rb{fZe(TYu_rk!wKkEf}RIt=#Om( zR8mN`DM<^xj~59euMMspBolVN zAPTr8sSDI104orIAdmL$uOXn*6hga1G+0WD0E?UtabxC#VC~vf3|10|phW;yQ3CY8 z2CM=)ErF;xq-YJ5G|um}>*1#E+O_Mu|Nr#qQ&G1P-NMq@f?@*XUcSbV?tX=)ilM-Q zBZP|!Bpv0V;#ojKcpc7$=eqO;#Uy~#?^kNI{vSZfLx&DEt~LTmaKWXcx=joubklI<*Aw z>LtMaQ7DR<1I2LkWvwyu#Rwn~;ezT}_g(@5l3h?W%-a86Y-t#O1PubP+z<%?V5D(U zy57A6{h+{?kOZp7&WKZR+=sznMJ}+Dnpo=C_0%R_x_t~J5T?E_{+))l5v1%52>)d-`iiZyx|5!%M2Fb2dU zW3~MwwpEH9Rhue+k$UIOoo($Ds!NbOyMR36fRHu;*15(YcA7siIZk#%JWz>P!qX1?IUojG&nKR>^gArBt2 zit(ETyZ=@V&7mv_Fi4bABcnwP+jzQuHcfU&BrAV91u-rFvEi7y-KnWsvHH=d2 zgAk(GKm_S8RcTJ>2N3~&Hbwp{Z3NF_Xeh}g4Eke)V&dY{W(3&b1j9t4yK_aYJisZZ{1rcU5- z;eD>K;ndPq&B-8yA_S0F!4ThA&{1{x)H<#?k9a#6Pc6L?V^s0``ynL&D;p(!Nmx`Y zFkHex{4p!Ggm^@DlehW}iHHVi}~u=$&N? z(NEBLQ#UxxAkdW>X9LnqUr#t4Lu0=9L8&o>JsqTtT5|%gb3QA~hr0pED71+iFFr)dZ=Q=E6ng{NE{Z~0)C?deO#?Aj zSDQ$z#TeC2T^|=}6GBo-&$;E{HL3!q3Z-szuf)O=G#zDjin4SSP%o%6+2IT#sLjQa ziyxFFz~LMjWY+_a5H!U6%a<=b7QVP^ z*90a62;bVq{?@)P6^DWd^Yilq4|YTV2Nw!Yu;a1lPI-sxR)rf@Fe5DhDP7FH zZZ%4S*1C30P;|O+jB!1;m|rXT90Sm5*RBbQN`PKu+hDD*S^yE(CdtSfg=z>u$cIj> z - - - - - - 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, + }, +});