diff --git a/Cargo.lock b/Cargo.lock index 66f7cfc..c7cd133 100644 --- a/Cargo.lock +++ b/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.22.0" @@ -102,7 +108,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -290,9 +296,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -556,6 +562,7 @@ dependencies = [ "serde", "serde_json", "sha1", + "specta", "test-case", "tokio", "tracing", @@ -688,7 +695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -698,7 +705,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -722,7 +729,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -733,7 +740,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -760,7 +767,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -781,7 +788,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -791,7 +798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -804,7 +811,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -868,13 +875,13 @@ checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -906,7 +913,7 @@ checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1069,7 +1076,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1153,7 +1160,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1413,7 +1420,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1447,8 +1454,10 @@ dependencies = [ "rusqlite_migration", "serde", "serde_json", + "specta", "tauri", "tauri-build", + "tauri-specta", "tokio", "tokio-rusqlite", ] @@ -1513,7 +1522,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1803,124 +1812,6 @@ dependencies = [ "png", ] -[[package]] -name = "icu_collections" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - -[[package]] -name = "icu_normalizer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" - -[[package]] -name = "icu_properties" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" - -[[package]] -name = "icu_provider" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -1929,14 +1820,12 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "1.0.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "icu_normalizer", - "icu_properties", - "smallvec", - "utf8_iter", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -1974,6 +1863,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "infer" version = "0.15.0" @@ -2238,12 +2133,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd1bc4d24ad230d21fb898d1116b1801d7adfc449d42026475862ab48b11e70e" -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - [[package]] name = "lock_api" version = "0.4.12" @@ -2739,6 +2628,12 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pathdiff" version = "0.2.1" @@ -2865,7 +2760,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2912,7 +2807,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3036,9 +2931,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -3528,7 +3423,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3599,7 +3494,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3610,7 +3505,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3642,7 +3537,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3693,7 +3588,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3855,6 +3750,32 @@ dependencies = [ "system-deps", ] +[[package]] +name = "specta" +version = "2.0.0-rc.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3624a07cbde326fdf1ec37cbd39d06a224660fa0199b7db7316f2349583df981" +dependencies = [ + "once_cell", + "paste", + "serde", + "serde_json", + "specta-macros", + "thiserror", +] + +[[package]] +name = "specta-macros" +version = "2.0.0-rc.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef33e9678ae36993fcbfc46aa29568ef10d32fd54428808759c6a450998c43ec" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "spin" version = "0.9.8" @@ -3910,9 +3831,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "swift-rs" @@ -3938,9 +3859,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" dependencies = [ "proc-macro2", "quote", @@ -3959,17 +3880,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "system-configuration" version = "0.5.1" @@ -4091,6 +4001,7 @@ dependencies = [ "serde_json", "serde_repr", "serialize-to-javascript", + "specta", "state", "swift-rs", "tauri-build", @@ -4149,7 +4060,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "syn 2.0.66", + "syn 2.0.67", "tauri-utils", "thiserror", "time", @@ -4167,7 +4078,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "tauri-codegen", "tauri-utils", ] @@ -4215,6 +4126,34 @@ dependencies = [ "wry", ] +[[package]] +name = "tauri-specta" +version = "2.0.0-rc.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85f26e4ded13fbeab2216dcb5a59b5cf8b475740afea932918888402bcc62a02" +dependencies = [ + "heck 0.5.0", + "indoc", + "serde", + "serde_json", + "specta", + "tauri", + "tauri-specta-macros", + "thiserror", +] + +[[package]] +name = "tauri-specta-macros" +version = "2.0.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f9e90bf2012877e2c4029a1bf756277183e9c7c77b850ef965711553998012" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.67", +] + [[package]] name = "tauri-utils" version = "2.0.0-beta.17" @@ -4288,7 +4227,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4299,7 +4238,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "test-case-core", ] @@ -4326,7 +4265,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4370,16 +4309,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -4421,7 +4350,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4576,7 +4505,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4701,12 +4630,27 @@ dependencies = [ "unic-common", ] +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -4727,9 +4671,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -4756,18 +4700,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "uuid" version = "1.8.0" @@ -4807,7 +4739,7 @@ checksum = "cff2381c6b31ab2555441e382d699a56c3551d0cfdf0c4df5617bf271c1dd102" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4894,7 +4826,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "wasm-bindgen-shared", ] @@ -4928,7 +4860,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5054,7 +4986,7 @@ checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5182,7 +5114,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5193,7 +5125,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5204,7 +5136,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5215,7 +5147,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5476,18 +5408,6 @@ version = "0.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a40369220be405a294b88b13ccc3d916fac12423250b30092c8c4ea19001f7f1" -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "wry" version = "0.40.1" @@ -5551,30 +5471,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - [[package]] name = "zerocopy" version = "0.7.34" @@ -5592,28 +5488,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", + "syn 2.0.67", ] [[package]] @@ -5633,29 +5508,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "zerovec" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3cca434..d4f0eb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,8 @@ resolver = "2" [workspace.dependencies] serde_json = "1.0.114" serde = { version = "1.0.197", features = ["derive"] } +oauth2 = "4.4.2" +specta = "=2.0.0-rc.12" reqwest = { version = "0.12.4", default-features = false, features = [ "rustls-tls", @@ -15,7 +17,5 @@ reqwest = { version = "0.12.4", default-features = false, features = [ error-stack = { version = "0.4.1", features = ["spantrace", "serde"] } -oauth2 = "4.4.2" - [profile.release] lto = true diff --git a/apps/glowsquid-frontend/src/lib/bindings.ts b/apps/glowsquid-frontend/src/lib/bindings.ts new file mode 100644 index 0000000..f0bbf7c --- /dev/null +++ b/apps/glowsquid-frontend/src/lib/bindings.ts @@ -0,0 +1,101 @@ + + // This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. + + /** user-defined commands **/ + + export const commands = { +async greet(name: string) : Promise { +return await TAURI_INVOKE("greet", { name }); +}, +async addAccount() : Promise>> { +try { + return { status: "ok", data: await TAURI_INVOKE("add_account") }; +} catch (e) { + if(e instanceof Error) throw e; + else return { status: "error", error: e as any }; +} +} +} + + /** user-defined events **/ + + + + /** user-defined statics **/ + + + +/** user-defined types **/ + +export type AuthError = "MsToken" | "MinecraftToken" | "MinecraftProfile" +export type Cape = { id: string; state: UsageState; url: string; alias: string } +/** + * A custom error type that wraps around a error-stack error, converting it from Report to Error + * + * Also known as the most unholy error type known to crabkind + */ +export type Error = { error: T; report: JsonValue } +export type JsonValue = null | boolean | number | string | JsonValue[] | { [key in string]: JsonValue } +export type MinecraftProfile = { id: string; name: string; skins: Skin[]; capes: Cape[] } +export type Skin = { id: string; state: UsageState; url: string; variant: SkinVariant } +export type SkinVariant = "CLASSIC" | "SLIM" +export type UsageState = "ACTIVE" | "INACTIVE" + +/** tauri-specta globals **/ + + import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core"; +import * as TAURI_API_EVENT from "@tauri-apps/api/event"; +import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; + +type __EventObj__ = { + listen: ( + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType>; + once: ( + cb: TAURI_API_EVENT.EventCallback + ) => ReturnType>; + emit: T extends null + ? (payload?: T) => ReturnType + : (payload: T) => ReturnType; +}; + +export type Result = + | { status: "ok"; data: T } + | { status: "error"; error: E }; + +function __makeEvents__>( + mappings: Record +) { + return new Proxy( + {} as unknown as { + [K in keyof T]: __EventObj__ & { + (handle: __WebviewWindow__): __EventObj__; + }; + }, + { + get: (_, event) => { + const name = mappings[event as keyof T]; + + return new Proxy((() => {}) as any, { + apply: (_, __, [window]: [__WebviewWindow__]) => ({ + listen: (arg: any) => window.listen(name, arg), + once: (arg: any) => window.once(name, arg), + emit: (arg: any) => window.emit(name, arg), + }), + get: (_, command: keyof __EventObj__) => { + switch (command) { + case "listen": + return (arg: any) => TAURI_API_EVENT.listen(name, arg); + case "once": + return (arg: any) => TAURI_API_EVENT.once(name, arg); + case "emit": + return (arg: any) => TAURI_API_EVENT.emit(name, arg); + } + }, + }); + }, + } + ); +} + + \ No newline at end of file diff --git a/apps/glowsquid-frontend/src/routes/+page.svelte b/apps/glowsquid-frontend/src/routes/+page.svelte index b8f368b..5f04253 100644 --- a/apps/glowsquid-frontend/src/routes/+page.svelte +++ b/apps/glowsquid-frontend/src/routes/+page.svelte @@ -1,5 +1,6 @@ diff --git a/apps/glowsquid-frontend/src/routes/accountDropdown.svelte b/apps/glowsquid-frontend/src/routes/accountDropdown.svelte index 4600c5d..745d181 100644 --- a/apps/glowsquid-frontend/src/routes/accountDropdown.svelte +++ b/apps/glowsquid-frontend/src/routes/accountDropdown.svelte @@ -5,17 +5,18 @@ import DownArrow from '~icons/material-symbols/keyboard-arrow-down' import Settings from '~icons/material-symbols/settings-outline' import Plus from '~icons/material-symbols/add' - import { invoke } from '@tauri-apps/api/core' + import { commands } from '$lib/bindings' const addAccount = (e: Event) => { console.log('Add account') - invoke('add_account') + commands.addAccount() .then((response) => { - console.log(`Success`, response) - }) - .catch((error) => { - console.error(`Error`, error) + if (response.status === 'ok') { + console.log('Account added', response.data) + } else { + console.error('Failed to add account', response.error.error, response.error.report) + } }) } diff --git a/apps/glowsquid/Cargo.toml b/apps/glowsquid/Cargo.toml index 823d19a..823f935 100644 --- a/apps/glowsquid/Cargo.toml +++ b/apps/glowsquid/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" tauri-build = { version = "2.0.0-beta", features = [] } [dependencies] -tauri = { version = "2.0.0-beta", features = [] } +tauri = { version = "=2.0.0-beta.22", features = [] } copper = { path = "../../libs/copper" } serde.workspace = true @@ -30,6 +30,9 @@ once_cell = "1.19.0" axum = "0.7.5" tokio = "1.38.0" open = "5.1.4" +specta = { version = "=2.0.0-rc.12", features = ["serde", "serde_json", "typescript"] } +tauri-specta = { version = "=2.0.0-rc.11", features = ["javascript", "typescript"] } + [features] # This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!! diff --git a/apps/glowsquid/src/auth.rs b/apps/glowsquid/src/auth.rs index 2b6f971..153bf94 100644 --- a/apps/glowsquid/src/auth.rs +++ b/apps/glowsquid/src/auth.rs @@ -1,20 +1,16 @@ -use std::{ - error::Error, - fmt, - future::IntoFuture, - net::{IpAddr, Ipv4Addr, SocketAddr}, - sync::Arc, -}; +use std::{error::Error, fmt, future::IntoFuture, sync::Arc}; use axum::{extract, response::IntoResponse, routing, Router}; use copper::client::auth::{MicrosoftAuthenticator, MinecraftProfile, MinecraftToken, OauthCode}; use oauth2::{CsrfToken, PkceCodeVerifier}; use once_cell::sync::OnceCell; +use serde::Serialize; +use specta::Type; use tauri::{async_runtime, AppHandle, Manager, State}; use tokio::net::TcpListener; use tokio_rusqlite::Connection; -use error_stack::{Result, ResultExt}; +use error_stack::ResultExt; // Glowsquids details. If you're making your own app, please do not use these. // These are just for ease of use/packaging. @@ -47,19 +43,14 @@ impl AuthState { } } -// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] +#[specta::specta] pub async fn add_account( state: State<'_, AuthState>, app: AppHandle, -) -> Result { +) -> Result> { // setup the server - let listener = TcpListener::bind(( - "127.0.0.1", - get_available_port().expect("Failed to get available port"), - )) - .await - .unwrap(); + let listener = TcpListener::bind(("127.0.0.1", 0)).await.unwrap(); let port = listener.local_addr().unwrap().port(); let redirect_uri = format!("http://localhost:{}/code", port); @@ -102,9 +93,10 @@ pub async fn add_account( .get_minecraft_profile(&minecraft_token) .await .change_context(AuthError::MinecraftProfile) + .map_err(Into::into) } -#[derive(Debug)] +#[derive(Debug, Clone, Copy, Type, Serialize)] pub enum AuthError { MsToken, MinecraftToken, @@ -128,13 +120,13 @@ struct AuthServerState { oauth: MicrosoftAuthenticator, csrf_token: CsrfToken, pkce_verifier: Arc, - send_token: async_runtime::Sender>, + send_token: async_runtime::Sender>, } async fn get_code( extract::Query(code): extract::Query, extract::State(state): extract::State, -) -> std::result::Result<&'static str, impl IntoResponse> { +) -> Result<&'static str, impl IntoResponse> { let ms_token = match state .oauth .get_ms_access_token(code, state.csrf_token, &state.pkce_verifier) @@ -171,11 +163,3 @@ async fn get_code( Ok("Authenticated! You can now close this window and go back to Glowsquid.") } - -fn get_available_port() -> Option { - (8000..9000).find(|port| port_is_available(*port)) -} - -fn port_is_available(port: u16) -> bool { - std::net::TcpListener::bind(("127.0.0.1", port)).is_ok() -} diff --git a/apps/glowsquid/src/error.rs b/apps/glowsquid/src/error.rs new file mode 100644 index 0000000..2d9b09e --- /dev/null +++ b/apps/glowsquid/src/error.rs @@ -0,0 +1,40 @@ +use std::{ + error, + fmt::{self, Debug}, +}; + +use serde::Serialize; +use serde_json::Value; +use specta::Type; + +/// A custom error type that wraps around a error-stack error, converting it from Report to Error +/// +/// Also known as the most unholy error type known to crabkind +#[derive(Debug, Serialize, Type)] +pub struct Error { + error: T, + report: Value, + #[serde(skip)] + error_stack: error_stack::Report, +} + +impl error::Error for Error {} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + std::fmt::Display::fmt(&self.error_stack, f) + } +} + +// copy instead of clone to enforce cheapness +impl From> for Error { + fn from(error_stack: error_stack::Report) -> Self { + let error = *error_stack.current_context(); + Self { + error, + // cursed way to do this without cloning + report: serde_json::from_str(&serde_json::to_string(&error_stack).unwrap()).unwrap(), + error_stack, + } + } +} diff --git a/apps/glowsquid/src/main.rs b/apps/glowsquid/src/main.rs index e24e75e..9babe24 100644 --- a/apps/glowsquid/src/main.rs +++ b/apps/glowsquid/src/main.rs @@ -2,24 +2,36 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] mod auth; +mod error; use auth::*; use tauri::{async_runtime::block_on, Manager}; // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] +#[specta::specta] fn greet(name: &str) -> String { format!("Hello, {}! You've been greeted from Rust!", name) } fn main() { + let invoke_handler = { + let builder = tauri_specta::ts::builder() + .commands(tauri_specta::collect_commands![greet, add_account]); + + #[cfg(debug_assertions)] // <- Only export on non-release builds + let builder = builder.path("../glowsquid-frontend/src/lib/bindings.ts"); + + builder.build().unwrap() + }; + tauri::Builder::default() .setup(|app| { app.manage(block_on(AuthState::new(app.app_handle()))); Ok(()) }) - .invoke_handler(tauri::generate_handler![greet, add_account]) + .invoke_handler(invoke_handler) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/libs/copper/Cargo.toml b/libs/copper/Cargo.toml index 85efba0..bcce6e4 100644 --- a/libs/copper/Cargo.toml +++ b/libs/copper/Cargo.toml @@ -19,6 +19,7 @@ serde_json.workspace = true error-stack.workspace = true oauth2.workspace = true reqwest.workspace = true +specta.workspace = true chrono = { version = "0.4.35", default-features = false, features = ["std"] } derive_builder = { version = "0.20.0", features = ["clippy"] } diff --git a/libs/copper/src/auth/structs.rs b/libs/copper/src/auth/structs.rs deleted file mode 100644 index d669020..0000000 --- a/libs/copper/src/auth/structs.rs +++ /dev/null @@ -1,12 +0,0 @@ -use std::{error::Error, fmt::Display}; - -use chrono::{DateTime, Utc}; -use error_stack::{Result, ResultExt}; -use oauth2::{ - basic::BasicTokenType, AuthorizationCode, CsrfToken, EmptyExtraTokenFields, - StandardTokenResponse, -}; -use serde::Deserialize; -use veil::Redact; - -use super::MicrosoftAuthenticator; diff --git a/libs/copper/src/client/auth.rs b/libs/copper/src/client/auth.rs index 5133c0e..3f612b1 100644 --- a/libs/copper/src/client/auth.rs +++ b/libs/copper/src/client/auth.rs @@ -10,6 +10,7 @@ use oauth2::{ }; use serde::{Deserialize, Serialize}; use serde_json::json; +use specta::Type; use std::{error::Error, fmt::Display}; use tracing::{debug, trace}; use veil::Redact; @@ -450,7 +451,7 @@ impl MinecraftToken { } } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Type)] pub struct MinecraftProfile { id: String, name: String, @@ -463,14 +464,14 @@ impl MinecraftProfile { pub fn current_skin(&self) -> Option<&Skin> { self.skins .iter() - .find(|skin| skin.state == UsageState::ACTIVE) + .find(|skin| skin.state == UsageState::Active) } #[must_use] pub fn current_cape(&self) -> Option<&Cape> { self.capes .iter() - .find(|cape| cape.state == UsageState::ACTIVE) + .find(|cape| cape.state == UsageState::Active) } #[must_use] @@ -484,7 +485,8 @@ impl MinecraftProfile { } } -#[derive(Serialize, Deserialize, Debug)] +// todo: add more Type implementations other than what is needed for the auth code +#[derive(Serialize, Deserialize, Debug, Type)] pub struct Skin { id: String, state: UsageState, @@ -509,14 +511,14 @@ impl Skin { } } -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy, Type)] #[serde(rename_all = "UPPERCASE")] pub enum SkinVariant { Classic, Slim, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Type)] pub struct Cape { id: String, state: UsageState, @@ -524,9 +526,9 @@ pub struct Cape { alias: String, } -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy, Type)] #[serde(rename_all = "UPPERCASE")] pub enum UsageState { - ACTIVE, - INACTIVE, + Active, + Inactive, }