diff --git a/package.json b/package.json index 7641524..d6bf455 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "google-task", "private": true, - "version": "0.0.6", + "version": "0.0.7", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ce84b26..4005012 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + [[package]] name = "addr2line" version = "0.20.0" @@ -52,6 +58,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +dependencies = [ + "getrandom 0.2.10", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.5" @@ -110,6 +127,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "ascii" version = "1.1.0" @@ -218,7 +241,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -235,7 +258,7 @@ checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -438,7 +461,7 @@ dependencies = [ "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", "syn_derive", ] @@ -469,7 +492,7 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58da0ae1e701ea752cc46c1bb9f39d5ecefc7395c3ecd526261a566d4f16e0c2" dependencies = [ - "ahash", + "ahash 0.8.5", "base64 0.13.1", "bitvec", "hex", @@ -508,14 +531,37 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byte-unit" -version = "4.0.19" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c" +checksum = "d405b41420a161b4e1dd5a52e3349f41b4dae9a39be02aff1d67fe53256430ac" dependencies = [ + "rust_decimal", "serde", "utf8-width", ] +[[package]] +name = "bytecheck" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bytemuck" version = "1.13.1" @@ -1006,7 +1052,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -1049,7 +1095,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -1060,7 +1106,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -1151,6 +1197,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" +[[package]] +name = "document-features" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e493c573fce17f00dcab13b6ac057994f3ce17d1af4dc39bfd482b83c6eb6157" +dependencies = [ + "litrs", +] + [[package]] name = "dotenv" version = "0.15.0" @@ -1236,7 +1291,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -1554,7 +1609,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -1900,11 +1955,15 @@ dependencies = [ "oauth2", "serde", "serde_json", + "specta", + "strum", "tauri", "tauri-build", "tauri-plugin-context-menu", "tauri-plugin-log", "tauri-plugin-oauth", + "tauri-plugin-single-instance", + "tauri-specta", ] [[package]] @@ -2033,6 +2092,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.7", +] [[package]] name = "hashbrown" @@ -2382,6 +2444,18 @@ dependencies = [ "serde", ] +[[package]] +name = "indoc" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" + +[[package]] +name = "indoc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" + [[package]] name = "infer" version = "0.12.0" @@ -2637,6 +2711,12 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +[[package]] +name = "litrs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9275e0933cf8bb20f008924c0cb07a0692fe54d8064996520bf998de9eb79aa" + [[package]] name = "lock_api" version = "0.3.4" @@ -3156,7 +3236,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -3270,9 +3350,15 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec 1.11.0", - "windows-targets", + "windows-targets 0.48.1", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pathdiff" version = "0.2.1" @@ -3557,13 +3643,33 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "publicsuffix" version = "1.5.4" @@ -3606,9 +3712,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -3920,6 +4026,15 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +[[package]] +name = "rend" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" +dependencies = [ + "bytecheck", +] + [[package]] name = "reqwest" version = "0.9.24" @@ -4032,6 +4147,50 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rkyv" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +dependencies = [ + "bitvec", + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid 1.4.1", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.33.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4" +dependencies = [ + "arrayvec", + "borsh", + "bytes 1.4.0", + "num-traits", + "rand 0.8.5", + "rkyv", + "serde", + "serde_json", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -4249,9 +4408,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.183" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -4267,20 +4426,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "indexmap 2.0.0", "itoa 1.0.9", @@ -4296,7 +4455,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -4374,7 +4533,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -4386,7 +4545,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -4502,6 +4661,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "siphasher" version = "0.3.10" @@ -4580,6 +4745,37 @@ dependencies = [ "system-deps 5.0.0", ] +[[package]] +name = "specta" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2240c3aa020aa61d2c569087d213baafbb212f4ceb9de9dd162376ea6aa0fe3" +dependencies = [ + "document-features", + "indoc 1.0.9", + "once_cell", + "paste", + "serde", + "serde_json", + "specta-macros", + "tauri", + "thiserror", +] + +[[package]] +name = "specta-macros" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4605306321c356e03873b8ee71d7592a5e7c508add325c3ed0677c16fdf1bcfb" +dependencies = [ + "Inflector", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", + "termcolor", +] + [[package]] name = "spin" version = "0.5.2" @@ -4657,6 +4853,28 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.41", +] + [[package]] name = "subtle" version = "2.4.1" @@ -4676,9 +4894,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" dependencies = [ "proc-macro2", "quote", @@ -4694,7 +4912,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -4934,11 +5152,15 @@ dependencies = [ [[package]] name = "tauri-plugin-context-menu" -version = "0.5.0" -source = "git+https://github.com/c2r0b/tauri-plugin-context-menu?branch=main#41d5cec126b03e9f997f12ac950a2c3621d8a8ba" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26a464805da19d73ab964d719aae2f11e4df2555276bcc49ecc2161dbdbd1110" dependencies = [ "cocoa", "dispatch", + "gdk", + "glib", + "gtk", "image", "lazy_static", "libc", @@ -4951,7 +5173,7 @@ dependencies = [ [[package]] name = "tauri-plugin-log" version = "0.0.0" -source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#bd4bf06e6cf591e47da5ff97d3cb6830f9728343" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#4aa61dcc9e9abcfba5709cca9770f08aa578a3e3" dependencies = [ "byte-unit", "fern", @@ -4975,6 +5197,20 @@ dependencies = [ "url 2.3.0", ] +[[package]] +name = "tauri-plugin-single-instance" +version = "0.0.0" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#4aa61dcc9e9abcfba5709cca9770f08aa578a3e3" +dependencies = [ + "log", + "serde", + "serde_json", + "tauri", + "thiserror", + "windows-sys 0.52.0", + "zbus", +] + [[package]] name = "tauri-runtime" version = "0.14.1" @@ -5016,6 +5252,21 @@ dependencies = [ "wry", ] +[[package]] +name = "tauri-specta" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa034c38b7bdfeccc606eca0b030a1e67a20b78e7642edef09816b7e1ff9a9de" +dependencies = [ + "heck 0.4.1", + "indoc 2.0.4", + "serde", + "serde_json", + "specta", + "tauri", + "thiserror", +] + [[package]] name = "tauri-utils" version = "1.5.0" @@ -5090,6 +5341,15 @@ dependencies = [ "utf-8", ] +[[package]] +name = "termcolor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +dependencies = [ + "winapi-util", +] + [[package]] name = "thin-slice" version = "0.1.1" @@ -5098,22 +5358,22 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -5178,6 +5438,21 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "0.1.22" @@ -5264,7 +5539,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -5454,7 +5729,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] @@ -5779,7 +6054,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", "wasm-bindgen-shared", ] @@ -5813,7 +6088,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6024,7 +6299,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.1", ] [[package]] @@ -6074,7 +6349,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.1", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -6092,6 +6376,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.0", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows-tokens" version = "0.39.0" @@ -6110,6 +6409,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.37.0" @@ -6134,6 +6439,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.37.0" @@ -6158,6 +6469,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.37.0" @@ -6182,6 +6499,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.37.0" @@ -6206,6 +6529,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -6218,6 +6547,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.37.0" @@ -6242,6 +6577,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" version = "0.5.4" @@ -6487,7 +6828,7 @@ checksum = "9731702e2f0617ad526794ae28fbc6f6ca8849b5ba729666c2a5bc4b6ddee2cd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.41", ] [[package]] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index cbea852..29a6aec 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -22,9 +22,13 @@ borsh = { version = "1.2.0", features = ["std", "borsh-derive", "derive", "bson" cocoon = "0.4.1" tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "main" } tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } -tauri-plugin-context-menu = { version = "0.6.1" } +tauri-plugin-context-menu = "0.6.1" +tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } dotenv = "0.15.0" lazy_static = "1.4.0" +strum = { version = "0.25.0", features = ["strum_macros"] } +specta = "1.0.5" +tauri-specta = { version = "1.0.2", features = ["javascript", "typescript"] } [features] # this feature is used for production builds or when `devPath` points to the filesystem diff --git a/src-tauri/src/libs.rs b/src-tauri/src/libs.rs index 5357d52..ce1880c 100644 --- a/src-tauri/src/libs.rs +++ b/src-tauri/src/libs.rs @@ -1,4 +1,5 @@ pub mod response; pub mod auth; pub mod filehelper; -pub mod tauri_actions; \ No newline at end of file +pub mod tauri_actions; +pub mod argument; \ No newline at end of file diff --git a/src-tauri/src/libs/argument.rs b/src-tauri/src/libs/argument.rs new file mode 100644 index 0000000..e3a2541 --- /dev/null +++ b/src-tauri/src/libs/argument.rs @@ -0,0 +1,9 @@ +use specta::Type; +use serde::{Deserialize, Serialize}; + + +#[derive(Deserialize, Type)] +pub struct MyCustomArgumentType { + pub foo: String, + pub bar: i32, +} \ No newline at end of file diff --git a/src-tauri/src/libs/auth.rs b/src-tauri/src/libs/auth.rs index fa27156..6904fc5 100644 --- a/src-tauri/src/libs/auth.rs +++ b/src-tauri/src/libs/auth.rs @@ -10,7 +10,7 @@ use borsh::{BorshDeserialize, to_vec}; -#[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, serde::Serialize, serde::Deserialize, Clone)] +#[derive(borsh::BorshDeserialize, borsh::BorshSerialize, Debug, serde::Serialize, serde::Deserialize, Clone, specta::Type)] pub struct AccessToken { access_token: String, expires_in: i32, @@ -64,7 +64,7 @@ impl AccessToken { pub struct Auth; impl Auth { - pub fn save_auth_code(code: String) -> String { + pub fn save_auth_code(code: String) -> SaveTokenResponse { let encoded = to_vec(&code).unwrap(); let password: String = env::var("DB_PASSWORD").unwrap(); let mut cocoon = Cocoon::new(password.as_bytes()); @@ -79,7 +79,7 @@ impl Auth { success: true, token: code, }; - serde_json::to_string(&response).expect("JSON serialization error") + return response; } pub fn load_auth_code() -> String { @@ -95,18 +95,15 @@ impl Auth { }; } - pub fn save_access_token(token: String) -> String { + pub fn save_access_token(token: String) -> SaveAccessTokenResponse { let content : AccessToken = serde_json::from_str(&token).unwrap(); let response : SaveAccessTokenResponse = content.save(); - // Serialize the response object to JSON and return as a string - serde_json::to_string(&response).expect("JSON serialization error") + return response; } - pub fn load_access_token() -> String { + pub fn load_access_token() -> AccessToken { let response : AccessToken = AccessToken::load(); - println!("response: {:?}", response); - // Serialize the response object to JSON and return as a string - serde_json::to_string(&response).expect("JSON serialization error") + return response; } } diff --git a/src-tauri/src/libs/filehelper.rs b/src-tauri/src/libs/filehelper.rs index 146464d..278a1aa 100644 --- a/src-tauri/src/libs/filehelper.rs +++ b/src-tauri/src/libs/filehelper.rs @@ -6,9 +6,8 @@ use tauri::Env; pub const ENV_FILE: &str = "../.env.local"; -pub const USERS_FILES: [&str; 4] = ["access_token.db", "auth_code.db", "tasks.json", "user_profile.json"]; - +pub const USERS_FILES: [&str; 4] = ["access_token.db", "auth_code.db", "tasks.json", "user_profile.json"]; pub fn initialize_user_files() { @@ -32,7 +31,7 @@ pub fn get_app_local_data_dir(file_name: &str) -> String { let path = path.to_str().unwrap().to_string(); println!("path: {} \n file name: {} \n", path, file_name); // check if file exists - if !std::path::Path::new(file_name).exists() { + if !std::path::Path::new(&path).exists() { println!("File does not exist, creating file {} for {}", file_name, path); // create file let mut file = std::fs::File::create(&path).unwrap(); diff --git a/src-tauri/src/libs/response.rs b/src-tauri/src/libs/response.rs index 786e088..8bda805 100644 --- a/src-tauri/src/libs/response.rs +++ b/src-tauri/src/libs/response.rs @@ -1,6 +1,8 @@ +use specta::Type; +use serde::{Deserialize, Serialize}; use super::auth::AccessToken; // save token response -#[derive(serde::Serialize)] +#[derive(Serialize, Type)] pub struct SaveTokenResponse { pub message: String, pub token: String, @@ -8,9 +10,15 @@ pub struct SaveTokenResponse { } -#[derive(serde::Serialize, serde::Deserialize)] +#[derive(Serialize, Type)] pub struct SaveAccessTokenResponse { pub message: String, pub success: bool, pub token: AccessToken, } + + +#[derive(Serialize, Type)] +pub struct GreetResponse { + pub message: String, +} \ No newline at end of file diff --git a/src-tauri/src/libs/tauri_actions.rs b/src-tauri/src/libs/tauri_actions.rs index cef92f9..50bc531 100644 --- a/src-tauri/src/libs/tauri_actions.rs +++ b/src-tauri/src/libs/tauri_actions.rs @@ -1,56 +1,56 @@ +use std::env; + use tauri; // super mod imports; use super::auth::{AccessToken, Auth}; use super::filehelper::{ENV_FILE, ACCESS_TOKEN_FILE}; +use super::response::{SaveAccessTokenResponse, SaveTokenResponse, GreetResponse}; -#[derive(serde::Serialize)] // Add this derive to enable JSON serialization -struct GreetResponse { - message: String, -} - #[tauri::command] +#[specta::specta] pub fn test_command() -> String { println!("access token path: {}", &*ACCESS_TOKEN_FILE); println!("ENV_FILE: {}", ENV_FILE); - return "ACCESS_TOKEN_FILE".to_string() + return env::var("DB_PASSWORD").unwrap(); } -// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] -pub fn greet(name: String) -> String { - let response = GreetResponse { +#[specta::specta] +pub fn greet(name: String) -> GreetResponse { + return GreetResponse { message: format!("Hello, {}! You've been greeted from Rust!", name), }; - - // Serialize the response object to JSON and return as a string - serde_json::to_string(&response).expect("JSON serialization error") } // remember to call `.manage(MyState::default())` #[tauri::command] -pub fn save_access_token(token: String) -> String { +#[specta::specta] +pub fn save_access_token(token: String) -> SaveAccessTokenResponse { dotenv::from_filename(ENV_FILE).ok(); return Auth::save_access_token(token); } // a command to load the access token from the file #[tauri::command] -pub fn load_access_token() -> String { +#[specta::specta] +pub fn load_access_token() -> AccessToken { dotenv::from_filename(ENV_FILE).ok(); return Auth::load_access_token(); } #[tauri::command] -pub fn save_code(code: String) -> String { +#[specta::specta] +pub fn save_code(code: String) -> SaveTokenResponse { dotenv::from_filename(ENV_FILE).ok(); return Auth::save_auth_code(code); } #[tauri::command] +#[specta::specta] pub fn load_code() -> String { dotenv::from_filename(ENV_FILE).ok(); return Auth::load_auth_code(); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c6eaa72..d8f473f 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -4,29 +4,55 @@ mod libs; use tauri_plugin_log::{LogTarget}; +use specta::collect_types; +use tauri_specta::{ts, js}; + + use libs::tauri_actions::{save_access_token,load_access_token, greet, test_command, save_code, load_code}; use libs::filehelper::{ENV_FILE, initialize_user_files}; -fn main() { - dotenv::from_filename(ENV_FILE).ok(); - initialize_user_files(); - tauri::Builder::default() - .plugin(tauri_plugin_context_menu::init()) - .plugin(tauri_plugin_oauth::init()) - .plugin(tauri_plugin_log::Builder::default().targets([ - LogTarget::LogDir, - LogTarget::Stdout, - LogTarget::Webview, - ]).build()) - .invoke_handler(tauri::generate_handler![ +fn run_specta() { + + println!("Running specta to generate typescript bindings"); + + #[cfg(debug_assertions)] + ts::export(collect_types![ save_access_token, load_access_token, greet, test_command, save_code, load_code, - ]) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); + ], "../src/helpers/commands.ts").unwrap(); +} + +fn main() { + dotenv::from_filename(ENV_FILE).ok(); + initialize_user_files(); + run_specta(); + + tauri::Builder::default() + .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { + println!("{}, {argv:?}, {cwd}", app.package_info().name); + // app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap(); + })) + .plugin(tauri_plugin_context_menu::init()) + .plugin(tauri_plugin_oauth::init()) + .plugin(tauri_plugin_log::Builder::default().targets([ + LogTarget::LogDir, + LogTarget::Stdout, + LogTarget::Webview, + ]) + .build()) + .invoke_handler(tauri::generate_handler![ + save_access_token, + load_access_token, + greet, + test_command, + save_code, + load_code, + ]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } diff --git a/src/App.tsx b/src/App.tsx index 515a267..10e125d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,7 @@ import { useState , useEffect} from "react"; import { Box, Button, Spinner, useToast } from '@chakra-ui/react' import { fetchUserProfile,getUserProfileFromStorage, getAccessToken, openAuthWindow, saveAccessToken, saveAuthCode, saveUserProfile, getAccessTokenFromStorage, deleteAccessToken } from "./helpers/auth"; -import { AccessToken, UserProfile } from "./types/googleapis"; +import { UserProfile } from "./types/googleapis"; import { loadContextmenu , pushNotification } from "./helpers/windowhelper"; import TaskPage from "./components/TaskPage"; import { useRecoilState, useRecoilValue, useSetRecoilState } from "recoil"; @@ -9,10 +9,15 @@ import { accessTokenState, activeCategoryTasksState, activeTaskCategoryState, at import Header from "./components/ui/Header"; import { task } from "./types/taskapi"; import { listen_for_auth_code } from "./helpers/eventlistner"; +import { test_command } from "./helpers/invoker"; +import { AccessToken } from "./helpers/commands"; // disable default context menu on build loadContextmenu(); +// to check / test db password +test_command().then(d => pushNotification(d)); + function App() { const [loading, setLoading] = useState(false); const loggedIn = useRecoilValue(loggedInSelector); @@ -110,7 +115,7 @@ function App() { if (!accessToken) throw new Error("Signin required"); pushNotification("Login Successful") const profile = navigator.onLine ? await fetchUserProfile(accessToken.access_token) : await getUserProfileFromStorage(); - if(!profile) throw new Error("Something went wrong, please try again"); + if(!profile || !profile?.email) throw new Error("Something went wrong, please try again"); setProfile(profile); setAccessToken(accessToken.access_token); pushNotification(`welcome back ${profile.name}`) diff --git a/src/helpers/auth.ts b/src/helpers/auth.ts index 2775772..303b6ac 100644 --- a/src/helpers/auth.ts +++ b/src/helpers/auth.ts @@ -1,10 +1,11 @@ import { shell } from "@tauri-apps/api"; import axios from "axios"; -import { AccessToken, UserProfile } from "../types/googleapis"; +import { UserProfile } from "../types/googleapis"; import { readTextFile, removeFile, writeTextFile, exists } from "@tauri-apps/api/fs"; import { CLIENT_ID, CLIENT_SECRET } from "../config/credentials"; import settings from "../config/settings"; import { generate_oauth_port, get_access_token, get_auth_code, save_access_token, save_auth_code } from "./invoker"; +import { AccessToken } from "./commands"; const DEFAULT_DIRECTORY = settings.fs.DEFAULT_DIRECTORY; @@ -159,13 +160,12 @@ export async function getAccessTokenFromStorage() { try { // if file does not exist, return null if(! await exists(STORAGE_PATHS.access_token, { dir: DEFAULT_DIRECTORY })) throw new Error("File does not exist"); - const accessTokenText: string = (await get_access_token()) as string; + let accessToken = await get_access_token(); console.log('new access token found') - let accessToken = JSON.parse(accessTokenText) as AccessToken; // check if the access token is expired console.log(accessToken, "accessToken"); const lastLogin = parseInt(localStorage.getItem("lastLogin") || "0"); - if ((accessToken.expiry_in < Date.now() || Date.now() - lastLogin > 3620) && navigator.onLine){ + if ((accessToken.expires_in < Date.now() || Date.now() - lastLogin > 3620) && navigator.onLine){ console.log("Access token expired"); accessToken = await refreshAndSaveAccessToken(accessToken.refresh_token); } diff --git a/src/helpers/commands.ts b/src/helpers/commands.ts new file mode 100644 index 0000000..c77c376 --- /dev/null +++ b/src/helpers/commands.ts @@ -0,0 +1,40 @@ +/* eslint-disable */ +// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. + +declare global { + interface Window { + __TAURI_INVOKE__(cmd: string, args?: Record): Promise; + } +} + +// Function avoids 'window not defined' in SSR +const invoke = () => window.__TAURI_INVOKE__; + +export function saveAccessToken(token: string) { + return invoke()("save_access_token", { token }) +} + +export function loadAccessToken() { + return invoke()("load_access_token") +} + +export function greet(name: string) { + return invoke()("greet", { name }) +} + +export function testCommand() { + return invoke()("test_command") +} + +export function saveCode(code: string) { + return invoke()("save_code", { code }) +} + +export function loadCode() { + return invoke()("load_code") +} + +export type GreetResponse = { message: string } +export type SaveTokenResponse = { message: string; token: string; success: boolean } +export type SaveAccessTokenResponse = { message: string; success: boolean; token: AccessToken } +export type AccessToken = { access_token: string; expires_in: number; refresh_token: string; scope: string; token_type: string; id_token: string } diff --git a/src/helpers/googleapihelper.ts b/src/helpers/googleapihelper.ts index 9a25419..e598fb7 100644 --- a/src/helpers/googleapihelper.ts +++ b/src/helpers/googleapihelper.ts @@ -1,7 +1,8 @@ import { readTextFile } from "@tauri-apps/api/fs"; import settings from "../config/settings"; -import { AccessToken, GoogleServices } from "../types/googleapis"; +import {GoogleServices } from "../types/googleapis"; import axios, { AxiosInstance } from "axios"; +import { AccessToken } from "./commands"; const STORAGE_PATHS = settings.storage.paths; diff --git a/src/helpers/invoker.ts b/src/helpers/invoker.ts index 1155361..e0bfb39 100644 --- a/src/helpers/invoker.ts +++ b/src/helpers/invoker.ts @@ -1,29 +1,30 @@ -import {invoke} from '@tauri-apps/api/tauri'; -import { AccessToken } from '../types/googleapis'; +import { invoke } from '@tauri-apps/api/tauri'; +import * as commands from './commands'; +import { AccessToken } from './commands'; export async function save_auth_code(code: string) { - return await invoke('save_code', {code}); + return await commands.saveCode(code); } export async function get_auth_code() { - return await invoke('load_code'); + return await commands.loadCode(); } export async function save_access_token(token: string|AccessToken) { const accessTokenText: string = typeof token === "string" ? token : JSON.stringify(token, null, 2); - return await invoke('save_access_token', {token : accessTokenText}); + return await commands.saveAccessToken(accessTokenText); } export async function get_access_token() { - return await invoke('load_access_token'); + return await commands.loadAccessToken(); } export async function test_command() { - return await invoke('test_command'); + return await commands.testCommand(); } export async function greet(name: string) { - return await invoke('greet', {name}); + return await commands.greet(name); } export async function generate_oauth_port() { diff --git a/src/helpers/windowhelper.ts b/src/helpers/windowhelper.ts index 8059a37..fae04c2 100644 --- a/src/helpers/windowhelper.ts +++ b/src/helpers/windowhelper.ts @@ -1,5 +1,5 @@ import { Options, isPermissionGranted, requestPermission, sendNotification } from "@tauri-apps/api/notification"; -import {showMenu} from "tauri-plugin-context-menu"; +import { showMenu } from "tauri-plugin-context-menu"; // Disable the right-click menu and text selection. export function loadContextmenu() { @@ -8,7 +8,6 @@ export function loadContextmenu() { } window.addEventListener("contextmenu", (e) => { e.preventDefault() - pushNotification("Click Context") showMenu({ items: [ { @@ -38,3 +37,4 @@ export function pushNotification(options: string | Options) { }); } + diff --git a/src/types/googleapis.ts b/src/types/googleapis.ts index a235d4f..8db7871 100644 --- a/src/types/googleapis.ts +++ b/src/types/googleapis.ts @@ -4,14 +4,6 @@ export interface UserProfile { name: string | null; // User's name } -export interface AccessToken { - access_token: string; - refresh_token: string; - scope: string; - token_type: string; - expiry_in: number; - id_token: string; -} export type GoogleServices = 'tasks' | 'oauth2'