diff --git a/src-plugin/Cargo.toml b/src-plugin/Cargo.toml index d0db066..11c8d34 100644 --- a/src-plugin/Cargo.toml +++ b/src-plugin/Cargo.toml @@ -9,10 +9,12 @@ exclude = ["/examples", "/webview-dist", "/webview-src", "/node_modules"] links = "tauri-plugin-ahqstore" [dependencies] -tauri = { version = "2.0.0-beta.22" } +tauri = { git = "https://github.com/tauri-apps/tauri", version = "2.0.0-beta.22" } serde = "1.0" thiserror = "1.0" [build-dependencies] -tauri-plugin = { version = "2.0.0-beta.17", features = ["build"] } -tauri-build = "2.0.0-beta.17" +tauri-plugin = { git = "https://github.com/tauri-apps/tauri", features = [ + "build", +] } +tauri-build = { git = "https://github.com/tauri-apps/tauri" } diff --git a/src-plugin/android/build.gradle.kts b/src-plugin/android/build.gradle.kts index d6b688f..534b688 100644 --- a/src-plugin/android/build.gradle.kts +++ b/src-plugin/android/build.gradle.kts @@ -30,13 +30,16 @@ android { kotlinOptions { jvmTarget = "1.8" } + buildFeatures { + buildConfig = true + } } dependencies { - implementation("androidx.core:core-ktx:1.9.0") - implementation("androidx.appcompat:appcompat:1.6.0") - implementation("com.google.android.material:material:1.7.0") + implementation("androidx.core:core-ktx:1.13.1") + implementation("androidx.appcompat:appcompat:1.7.0") + implementation("com.google.android.material:material:1.12.0") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/src-plugin/android/src/main/java/ExamplePlugin.kt b/src-plugin/android/src/main/java/ExamplePlugin.kt index b13752f..7fc4d94 100644 --- a/src-plugin/android/src/main/java/ExamplePlugin.kt +++ b/src-plugin/android/src/main/java/ExamplePlugin.kt @@ -1,5 +1,7 @@ package com.plugin.ahqstore +import android.webkit.WebView + import android.app.Activity import app.tauri.annotation.Command import app.tauri.annotation.InvokeArg @@ -15,12 +17,17 @@ class PingArgs { @TauriPlugin class ExamplePlugin(private val activity: Activity): Plugin(activity) { + @Command + override fun load(webkit: WebView) { + + } + - @Command - fun ping(invoke: Invoke) { - val args = invoke.parseArgs(PingArgs::class.java) + @Command + fun ping(invoke: Invoke) { + val args = invoke.parseArgs(PingArgs::class.java) - val ret = JSObject() - invoke.resolve(ret) - } + val ret = JSObject() + invoke.resolve(ret) + } } diff --git a/src-plugin/examples/tauri-app/src-tauri/Cargo.toml b/src-plugin/examples/tauri-app/src-tauri/Cargo.toml index e576be4..10a6f67 100644 --- a/src-plugin/examples/tauri-app/src-tauri/Cargo.toml +++ b/src-plugin/examples/tauri-app/src-tauri/Cargo.toml @@ -15,8 +15,8 @@ crate-type = ["staticlib", "cdylib", "rlib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = { version = "2.0.0-beta.17", default-features = false } +tauri-build = { version = "2.0.0-beta.17", default-features = false , features = [] } [dependencies] -tauri = { version = "2.0.0-beta.22" } +tauri = { version = "2.0.0-beta.22", features = [] } tauri-plugin-store-plugin = { path = "../../../" } diff --git a/src-plugin/permissions/schemas/schema.json b/src-plugin/permissions/schemas/schema.json index ac32f0a..67dbb6b 100644 --- a/src-plugin/permissions/schemas/schema.json +++ b/src-plugin/permissions/schemas/schema.json @@ -172,7 +172,7 @@ } }, "Scopes": { - "description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.", + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", "type": "object", "properties": { "allow": { @@ -186,7 +186,7 @@ } }, "deny": { - "description": "Data that defines what is denied by the scope.", + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", "type": [ "array", "null" diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 7e703ac..7ff88d7 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -30,12 +30,24 @@ dependencies = [ name = "ahqstore-android" version = "0.0.1" dependencies = [ + "ahqstore-types", + "lazy_static", + "reqwest", "serde", "serde_json", "tauri", "tauri-build", "tauri-plugin-ahqstore", - "tauri-plugin-http", +] + +[[package]] +name = "ahqstore-types" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5ddd606e84adeaab1b98f45f526e9e9b90caf0344d19ba2d4afbedfea204465" +dependencies = [ + "serde", + "serde_json", ] [[package]] @@ -97,12 +109,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - [[package]] name = "autocfg" version = "1.3.0" @@ -204,9 +210,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" @@ -394,34 +400,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "cookie" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" -dependencies = [ - "percent-encoding", - "time", - "version_check", -] - -[[package]] -name = "cookie_store" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387461abbc748185c3a6e1673d826918b450b87ff22639429c694619a83b6cf6" -dependencies = [ - "cookie", - "idna 0.3.0", - "log", - "publicsuffix", - "serde", - "serde_derive", - "serde_json", - "time", - "url", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -577,12 +555,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "data-url" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" - [[package]] name = "deranged" version = "0.3.11" @@ -625,16 +597,6 @@ dependencies = [ "dirs-sys", ] -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - [[package]] name = "dirs-sys" version = "0.4.1" @@ -647,34 +609,12 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dispatch" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "dlib" version = "0.5.2" @@ -763,15 +703,6 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1238,25 +1169,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "h2" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http", - "indexmap 2.2.6", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -1343,9 +1255,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "hyper" @@ -1356,7 +1268,6 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2", "http", "http-body", "httparse", @@ -1369,9 +1280,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http", @@ -1382,6 +1293,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", + "webpki-roots", ] [[package]] @@ -1437,124 +1349,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" @@ -1563,26 +1357,14 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] -[[package]] -name = "idna" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" -dependencies = [ - "icu_normalizer", - "icu_properties", - "smallvec", - "utf8_iter", -] - [[package]] name = "indexmap" version = "1.9.3" @@ -1802,12 +1584,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" @@ -1906,9 +1682,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", "simd-adler32", @@ -2527,28 +2303,59 @@ dependencies = [ ] [[package]] -name = "psl-types" -version = "2.0.11" +name = "quick-xml" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", +] [[package]] -name = "publicsuffix" -version = "2.2.3" +name = "quinn" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a8c1bda5ae1af7f99a2962e49df150414a43d62404644d98dd5c3a93d07457" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" dependencies = [ - "idna 0.3.0", - "psl-types", + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "thiserror", + "tokio", + "tracing", ] [[package]] -name = "quick-xml" -version = "0.31.0" +name = "quinn-proto" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" dependencies = [ - "memchr", + "bytes", + "rand 0.8.5", + "ring", + "rustc-hash", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -2719,18 +2526,14 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64 0.22.1", "bytes", - "cookie", - "cookie_store", - "encoding_rs", "futures-core", "futures-util", - "h2", "http", "http-body", "http-body-util", @@ -2744,6 +2547,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", "rustls", "rustls-pemfile", "rustls-pki-types", @@ -2751,7 +2555,6 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", "tokio-rustls", "tokio-util", @@ -2786,6 +2589,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.4.0" @@ -2797,11 +2606,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.4" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ - "log", + "once_cell", "ring", "rustls-pki-types", "rustls-webpki", @@ -3261,41 +3070,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "system-deps" @@ -3369,13 +3146,12 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tauri" version = "2.0.0-beta.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a258ecc5ac7ddade525f512c4962fd01cd0f5265e917b4572579c32c027bb31" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "anyhow", "bytes", "cocoa", - "dirs-next", + "dirs", "dunce", "embed_plist", "futures-util", @@ -3418,12 +3194,11 @@ dependencies = [ [[package]] name = "tauri-build" version = "2.0.0-beta.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b964bb6d03d97e24e12f896aab463b02a3c2ff76a60f728cc37b5548eb470e" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "anyhow", "cargo_toml", - "dirs-next", + "dirs", "glob", "heck 0.5.0", "json-patch", @@ -3440,8 +3215,7 @@ dependencies = [ [[package]] name = "tauri-codegen" version = "2.0.0-beta.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3529cfa977ed7c097f2a5e8da19ecffbe61982450a6c819e6165b6d0cfd3dd3a" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "base64 0.22.1", "brotli", @@ -3467,8 +3241,7 @@ dependencies = [ [[package]] name = "tauri-macros" version = "2.0.0-beta.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f97dd80334f29314aa5f40b5fad10cb9feffd08e5a5324fd728613841e5d33" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3481,8 +3254,7 @@ dependencies = [ [[package]] name = "tauri-plugin" version = "2.0.0-beta.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c8385fd0a4f661f5652b0d9e2d7256187d553bb174f88564d10ebcfa6a3af53" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "anyhow", "glob", @@ -3506,51 +3278,10 @@ dependencies = [ "thiserror", ] -[[package]] -name = "tauri-plugin-fs" -version = "2.0.0-beta.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3aa91955751f329e0aa431b87c199b7378b6f91ec0765d2ad9d4c64e017c3cda" -dependencies = [ - "anyhow", - "glob", - "schemars", - "serde", - "serde_json", - "serde_repr", - "tauri", - "tauri-plugin", - "thiserror", - "url", - "uuid", -] - -[[package]] -name = "tauri-plugin-http" -version = "2.0.0-beta.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf3c02f09bb81c8c4bec73991148aebaab099f6d00c04486ad8fc2c92384f22" -dependencies = [ - "data-url", - "http", - "regex", - "reqwest", - "schemars", - "serde", - "serde_json", - "tauri", - "tauri-plugin", - "tauri-plugin-fs", - "thiserror", - "url", - "urlpattern", -] - [[package]] name = "tauri-runtime" version = "2.0.0-beta.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7dc96172a43536236ab55b7da7b8461bf75810985e668589e2395cb476937cb" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "dpi", "gtk", @@ -3568,8 +3299,7 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" version = "2.0.0-beta.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4fd913b1f14a9b618c7f3ae35656d3aa759767fcb95b72006357c12b9d0b09" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "cocoa", "gtk", @@ -3592,8 +3322,7 @@ dependencies = [ [[package]] name = "tauri-utils" version = "2.0.0-beta.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f24a9c20d676a3f025331cc1c3841256ba88c9f25fb7fae709d2b3089c50d90" +source = "git+https://github.com/tauri-apps/tauri#3bbfac8f3ba9363fb267bf353687f01884d48924" dependencies = [ "brotli", "cargo_metadata", @@ -3711,16 +3440,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" @@ -3754,9 +3473,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", "rustls-pki-types", @@ -4031,12 +3750,12 @@ 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 1.0.0", + "idna", "percent-encoding", "serde", ] @@ -4060,18 +3779,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" @@ -4296,9 +4003,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c452ad30530b54a4d8e71952716a212b08efd0f3562baa66c29a618b07da7c3" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] @@ -4731,18 +4438,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[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" @@ -4806,75 +4501,8 @@ 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 = "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", -] - [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" - -[[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", -] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6081a98..6bcf536 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -12,11 +12,18 @@ name = "ahqstore_android_lib" crate-type = ["lib", "cdylib", "staticlib"] [build-dependencies] -tauri-build = { version = "2.0.0-beta", features = [] } +tauri-build = { git = "https://github.com/tauri-apps/tauri", features = [] } [dependencies] -tauri = { version = "2.0.0-beta", features = ["rustls-tls"] } +tauri = { git = "https://github.com/tauri-apps/tauri", features = [ + "rustls-tls", +] } serde = { version = "1", features = ["derive"] } -serde_json = "1" +serde_json = { version = "1", default-features = false, features = ["alloc"] } tauri-plugin-ahqstore = { path = "../src-plugin" } -tauri-plugin-http = "2.0.0-beta.10" +ahqstore-types = { version = "2.1.1", default-features = false } +reqwest = { version = "0.12.5", default-features = false, features = [ + "json", + "rustls-tls", +] } +lazy_static = "1.4.0" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 4375d7d..d9c434e 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -3,34 +3,5 @@ "identifier": "default", "description": "Capability for the main window", "windows": ["main"], - "permissions": [ - "path:default", - "event:default", - "window:default", - "app:default", - "image:default", - "resources:default", - "menu:default", - "tray:default", - { - "identifier": "http:default", - "allow": [ - { - "url": "https://github.com/ahqsoftwares/ahq-store-data/*" - }, - { - "url": "https://github.com/ahqsoftwares/tauri-ahq-store/releases/*" - }, - { - "url": "https://api.github.com/*" - }, - { - "url": "https://rawcdn.githack.com/*" - }, - { - "url": "https://github.com/login/*" - } - ] - } - ] + "permissions": [] } diff --git a/src-tauri/gen/android/app/build.gradle.kts b/src-tauri/gen/android/app/build.gradle.kts index e5bb70a..f4ebd77 100644 --- a/src-tauri/gen/android/app/build.gradle.kts +++ b/src-tauri/gen/android/app/build.gradle.kts @@ -49,6 +49,9 @@ android { kotlinOptions { jvmTarget = "1.8" } + buildFeatures { + buildConfig = true + } } rust { @@ -56,12 +59,12 @@ rust { } dependencies { - implementation("androidx.webkit:webkit:1.6.1") - implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.webkit:webkit:1.9.0") + implementation("androidx.appcompat:appcompat:1.7.0") implementation("com.google.android.material:material:1.8.0") testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.4") - androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") } apply(from = "tauri.build.gradle.kts") \ No newline at end of file diff --git a/src-tauri/gen/android/app/src/main/AndroidManifest.xml b/src-tauri/gen/android/app/src/main/AndroidManifest.xml index 93c2df4..530ef99 100644 --- a/src-tauri/gen/android/app/src/main/AndroidManifest.xml +++ b/src-tauri/gen/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,10 @@ + + = None; + +macro_rules! from_str { + ($($x:tt)*) => { + from_str($($x)*).ok()? + }; +} + +pub fn init_cache(app: &App) { + let s = app.path().app_cache_dir().unwrap(); + + let s = s.to_str().unwrap(); + let s=s.to_string(); + + unsafe { + let _ = fs::create_dir_all(&s); + CACHE_DIR = Some(s); + } +} + +pub fn commit() -> String { + let cache = unsafe { + CACHE_DIR.as_ref().unwrap() + }; + + fs::read_to_string(format!("{cache}/commit")).unwrap_or("def".into()) +} + +pub fn clear_cache() { + let cache = unsafe { + CACHE_DIR.as_ref().unwrap() + }; + + let _ = fs::remove_dir_all(&cache); + let _ = fs::create_dir_all(&cache); +} + +pub fn set_cache(key: &str, pre: u8, data: Vec) -> Option<()> { + let cache = unsafe { + CACHE_DIR.as_ref().unwrap() + }; + + let _ = fs::remove_file(format!("{cache}/{key}")); + + let mut f = File::create(format!("{cache}/{key}")).ok()?; + let _ = f.write(&[pre]); + let _ = f.write_all(&data); + + let _ = f.flush(); + + drop(f); + + Some(()) +} + +pub fn get_cache() -> Option> { + let mut h = HashMap::new(); + + for k in fs::read_dir(unsafe { CACHE_DIR.as_ref().unwrap() }).ok()? { + let k = k.unwrap(); + + let key = k.file_name(); + let key = key.to_string_lossy().to_string(); + + let data = fs::read(&key).ok()?; + let mut data = VecDeque::from(data); + + let r#type = data.pop_front()?; + + let data = Vec::from(data); + let data = String::from_utf8(data).ok()?; + match r#type { + 0 => {} + 1 => { + h.insert(key, Val::App(from_str!(&data))); + } + 2 => { + h.insert(key, Val::Home(from_str!(&data))); + } + 3 => { + h.insert(key, Val::Map(from_str!(&data))); + } + 4 => { + h.insert(key, Val::User(data)); + } + 5 => { + h.insert(key, Val::Search(from_str!(&data))); + } + _ => return None + } + } + + Some(h) +} \ No newline at end of file diff --git a/src-tauri/src/api/db.rs b/src-tauri/src/api/db.rs new file mode 100644 index 0000000..1ec9182 --- /dev/null +++ b/src-tauri/src/api/db.rs @@ -0,0 +1,14 @@ +use tauri::{App, Manager}; + +static mut APP_DB: Option = None; + +pub fn init_db(app: &App) { + let s = app.path().app_data_dir().unwrap(); + + let s = s.to_str().unwrap(); + let s=s.to_string(); + + unsafe { + APP_DB = Some(s); + } +} \ No newline at end of file diff --git a/src-tauri/src/api/mod.rs b/src-tauri/src/api/mod.rs new file mode 100644 index 0000000..0d31dc8 --- /dev/null +++ b/src-tauri/src/api/mod.rs @@ -0,0 +1,149 @@ +use std::collections::HashMap; + +use lazy_static::lazy_static; +use ahqstore_types::{AHQStoreApplication, Commit}; +use reqwest::{Client, ClientBuilder}; +use runtime_cache::Val; + +pub mod cache; +pub mod db; +mod runtime_cache; + +static mut COMMIT: Option = None; + +pub static TOTAL_URL: &'static str = "https://rawcdn.githack.com/ahqstore/data/{sha}/db/total"; +pub static HOME_URL: &'static str = "https://rawcdn.githack.com/ahqstore/data/{sha}/db/home.json"; +pub static APP_URL: &'static str = + "https://rawcdn.githack.com/ahqstore/data/{sha}/db/apps/{app}.json"; +pub static MAP_URL: &'static str = + "https://rawcdn.githack.com/ahqstore/data/{sha}/db/map/{id}.json"; +pub static SEARCH_URL: &'static str = + "https://rawcdn.githack.com/ahqstore/data/{sha}/db/search/{id}.json"; +pub static DEV_USER_URL: &'static str = + "https://rawcdn.githack.com/ahqstore/data/{sha}/db/info/{dev}.json"; + +lazy_static! { + static ref CLIENT: Client = ClientBuilder::new() + .user_agent("AHQ Store Android") + .build() + .unwrap(); +} + +macro_rules! cache { + ($($x:tt)*) => { + runtime_cache::get($($x)*) + }; +} + +pub async fn init() { + let mut c: Vec = CLIENT.get("https://api.github.com/repos/ahqstore/data/commits") + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + + let sha = c.remove(0).sha; + + let cache = cache::commit(); + + let cac = || { + cache::clear_cache(); + runtime_cache::init_cache(HashMap::new()); + }; + + if &sha == &cache { + if let Some(x) = cache::get_cache() { + runtime_cache::init_cache(x); + } else { + cac(); + } + } else { + cac(); + } + + println!("Got Commit: {}", &sha); + unsafe { COMMIT = Some(sha); } +} + +#[tauri::command] +pub async fn get_commit() -> &'static str { + unsafe { &COMMIT.as_ref().unwrap() } +} + +#[tauri::command(async)] +pub async fn get_total() -> Option { + let sha = get_commit().await; + + CLIENT.get(TOTAL_URL.replace("{sha}", sha)) + .send() + .await + .ok()? + .json() + .await + .ok() +} + +#[tauri::command(async)] +pub fn get_app(app_id: &str) -> Option<&'static AHQStoreApplication> { + let cache_id = format!("APP_{app_id}"); + let c = cache!(&cache_id); + + if let Some(Val::App(x)) = c { + return Some(x); + } + + let app: AHQStoreApplication = tauri::async_runtime::block_on(async { + CLIENT.get(APP_URL + .replace("{sha}", get_commit().await) + .replace("{app}", &app_id) + ).send() + .await + .ok()? + .json() + .await + .ok() + })?; + + runtime_cache::set(cache_id, Val::App(app)); + + let cache_id = format!("APP_{app_id}"); + let c = cache!(&cache_id); + + if let Some(Val::App(x)) = c { + return Some(x); + } + + None +} + +#[tauri::command] +pub async fn get_home() -> Option<&'static Vec<(String, Vec)>> { + let home = "HOME_DATA"; + let c = cache!(&home); + + if let Some(Val::Home(x)) = c { + return Some(x); + } + + let app = + CLIENT.get(HOME_URL + .replace("{sha}", get_commit().await) + ).send() + .await + .ok()? + .json() + .await + .ok()?; + + runtime_cache::set(home.into(), Val::Home(app)); + + let c = cache!(&home); + + if let Some(Val::Home(x)) = c { + return Some(x); + } + + None +} \ No newline at end of file diff --git a/src-tauri/src/api/runtime_cache.rs b/src-tauri/src/api/runtime_cache.rs new file mode 100644 index 0000000..018d620 --- /dev/null +++ b/src-tauri/src/api/runtime_cache.rs @@ -0,0 +1,57 @@ +use std::collections::HashMap; +use ahqstore_types::AHQStoreApplication; +use serde_json::to_string; +use serde::{Serialize, Deserialize}; + +use crate::cache::set_cache; + +pub type Map = HashMap; + +#[derive(Serialize, Deserialize)] +pub struct SearchS { + pub app: String, + pub title: String, + pub id: String, +} +pub type Search = Vec; + +pub enum Val { + App(AHQStoreApplication), + Home(Vec<(String, Vec)>), + Map(Map), + User(String), + Search(Search) +} + +macro_rules! str { + ($($x:tt)*) => { + to_string($($x)*).unwrap() + }; +} + +static mut CACHE_DIR: Option> = None; + +pub fn init_cache(cache: HashMap) { + unsafe { CACHE_DIR = Some(cache) }; +} + +pub fn get(key: &str) -> Option<&'static Val> { + unsafe { + CACHE_DIR.as_ref().unwrap().get(key) + } +} + +pub fn set(key: String, val: Val) { + unsafe { + let (pre, data) = match &val { + Val::App(a) => (1, str!(a)), + Val::Home(a) => (2, str!(a)), + Val::Map(a) => (3, str!(a)), + Val::User(a) => (4, a.clone()), + Val::Search(a) => (5, str!(a)) + }; + set_cache(&key, pre, data.as_bytes().to_vec()); + + CACHE_DIR.as_mut().unwrap().insert(key, val); + } +} \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 3591ba3..ec92e2f 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,24 +1,22 @@ -// 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) -} +#[macro_use] +mod api; + +use api::*; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_ahqstore::init()) - .plugin(tauri_plugin_http::init()) .setup(|app| { - use tauri::Manager; - #[cfg(debug_assertions)] // only include this code on debug builds - { - let window = app.get_webview_window("main").unwrap(); - window.open_devtools(); - } + api::cache::init_cache(app); + api::db::init_db(app); + + tauri::async_runtime::block_on(async { + api::init().await; + }); Ok(()) }) - .invoke_handler(tauri::generate_handler![greet]) + .invoke_handler(tauri::generate_handler![get_total, get_commit, get_app, get_home]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/src/app/data/http.ts b/src/app/data/http.ts index 302ef27..e0e42ae 100644 --- a/src/app/data/http.ts +++ b/src/app/data/http.ts @@ -1,13 +1,12 @@ -import { ClientOptions, fetch as tauriFetch } from "@tauri-apps/plugin-http"; +import { ClientOptions } from "@tauri-apps/plugin-http"; export default async function fetch( url: string, config: (RequestInit & ClientOptions) | undefined, ) { - return await tauriFetch(url, { + return await window.fetch(url, { ...(config || {}), method: config?.method || "GET", - connectTimeout: 100_000, headers: { "User-Agent": "AHQ Store", ...(config?.headers || {}), diff --git a/src/app/data/index.ts b/src/app/data/index.ts index a865a7f..cd1bd4f 100644 --- a/src/app/data/index.ts +++ b/src/app/data/index.ts @@ -1,3 +1,4 @@ +import { invoke } from "@tauri-apps/api/core"; import { ApplicationData } from "./fetchApps"; import fetch from "./http"; @@ -15,44 +16,15 @@ const devUserUrl = "https://rawcdn.githack.com/ahqstore/data/{sha}/db/info/{dev}.json"; export async function getSha() { - const { ok, data } = await fetch("https://api.github.com/repos/ahqstore/data/commits", { - method: "GET" - }); - - console.log(ok, JSON.stringify(data)); - if (!ok) { - throw new Error(""); - } - - sha = data[0].sha; + sha = await invoke("get_commit"); } export async function get_total() { - if (sha == "") { - get_sha(); - } - - const { data } = await fetch(totalUrl.replace("{sha}", sha), { - method: "GET" - }); - - return Number(data); + return await invoke("get_total"); } export async function get_home() { - if (sha == "") { - get_sha(); - } - - const url = homeUrl.replace("{sha}", sha); - - const { data } = await fetch(url, { - method: "GET", - headers: { - "ngrok-skip-browser-warning": "true" - } - }); - + const data = await invoke<[string, string[]][]>("get_home"); return data; } @@ -92,11 +64,11 @@ export async function get_map(): Promise { for (let i = 1; i <= total; i++) { const url = mapUrl.replace("{sha}", sha).replace("{id}", i.toString()); - const val = await fetch(url, { + const { data } = await fetch(url, { method: "GET" }); - map = { ...map, ...val }; + map = { ...map, ...data }; } return map as unknown as any as T; @@ -107,15 +79,9 @@ export function get_sha() { } export async function get_app(app: string): Promise { - const { data } = await fetch( - appUrl.replace("{sha}", sha).replace("{app}", app), - { - method: "GET", - headers: { - "ngrok-skip-browser-warning": "true" - } - }, - ); + const data = await invoke("get_app", { + app_id: app + }); const appData: ApplicationData = { ...data, diff --git a/src/app/index.tsx b/src/app/index.tsx index 8702698..9fa19aa 100644 --- a/src/app/index.tsx +++ b/src/app/index.tsx @@ -33,6 +33,7 @@ export default function App() { setApps(await get_home()); setMap(await get_map<{ [key: string]: Object }>()); + console.log("Load"); await delay(500); setLoad(true); })()